modelsim 2 pontos de paragem ( breakpoints )
Post on 04-Jan-2016
45 Views
Preview:
DESCRIPTION
TRANSCRIPT
1LDH Aula3
LDH Aula3 2
a0 a1
a2
a4 a3
y0,y1 y1,y2
y3,y4,y5
y4
y1,y5
1
x0not x0
x0not x0 and
not x1not x0 and x1not x3
x3 and not x0 x3 a
nd x
0
not
x1
x1
A = {a0,a1,a2,a3,a4}; - conjunto de estados – MOSTRAR NOS DISPLAYSY = {y0,y1,y2,y3,y4,y5} - conjunto de saídas – MOSTRAR NOS LEDSX = {x0,x1,x2,x3,x4} - conjunto de entradas – ENTRAR A PARTIR DOS INTERRUPTORES
LDH Aula3 3
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity FSM_code is Port ( reset : std_logic;
X : in STD_LOGIC_VECTOR (3 downto 0); Y : out STD_LOGIC_VECTOR (5 downto 0);
state : out integer range 0 to 4; Clock : in STD_LOGIC);end FSM_code;
architecture Behavioral of FSM_code is
type estado is (a0,a1,a2,a3,a4);signal c_s, n_s : estado;signal Y_c : std_logic_vector(5 downto 0);signal Y_n : std_logic_vector(5 downto 0);
LDH Aula3 4
beginprocess(Clock,reset)begin
if reset = '1' thenc_s <= a0;Y_c <= (others => '0');
elsif rising_edge(Clock) thenc_s <= n_s;Y_c <= Y_n;
end if;end process;
process(c_s)begin
n_s <= c_s; Y_n <= Y_c;case c_s is
when a0 => Y_n <= "000011";n_s <= a1;
when a1 => Y_n <= "000110";if X(0) = '1' then n_s <= a2;
else n_s <= a4;end if;
LDH Aula3 5
when a2 => Y_n <= "111000";if X(0) = '1' then n_s <= a2;elsif X(1) = '1' then n_s <= a3;
else n_s <= a0;end if;
when a3 => Y_n <= "010000";if X(3) = '0' then n_s <= a4;elsif X(0) = '1' then n_s <= a1;
else n_s <= a0;end if;
when a4 => Y_n <= "100010";if X(1) = '1' then n_s <= a3;
else n_s <= a0;end if;
when others => null; end case;
end process;state <= 0 when c_s = a0 else 1 when c_s = a1 else 2 when c_s = a2
else 3 when c_s = a3 else 4 when c_s = a4 else 0;Y <= Y_n;
end Behavioral;
LDH Aula3 6
LDH Aula3 7
Pontos de paragem só podem ser activados em linhas de cor vermelha
1. Abrir ficheiro FSM_VHDL.2. Inserir um ponto de paragem em linha 43 (when a1 => Y_n <= "000110";).
3. Click ícone “Restart”
4. A simulação vai ser executada até ao ponto de paragem.5. Pode verificar valores:
• na janela “Objects”;• utilizando rato;• seleccionando examine (ver próximo slide).
LDH Aula3 8
LDH Aula3 9
Depois pode utilizar o botão “step”
ou “step over”
ou “Continue Run”, etc
terminar simulação
LDH Aula310
Exemplos VHDL: Full Adder
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity adder1 is port ( A: in STD_LOGIC; B: in STD_LOGIC; SUM: out STD_LOGIC; CARRY: out STD_LOGIC );end adder1;
architecture adder1_arch of adder1 isbegin SUM <= A xor B; CARRY <= A and B;end adder1_arch;
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ORGATE is port ( A: in STD_LOGIC; B: in STD_LOGIC; Z: out STD_LOGIC );end ORGATE;
architecture ORGATE_arch of ORGATE isbegin Z <= A or B;end ORGATE_arch;
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
LDH Aula3 11
entity FULLADD isport (A, B, CIN : in std_logic; SUM, CARRY : out std_logic);end FULLADD;
architecture STRUCT of FULLADD is signal I1, I2, I3 : std_logic; component adder1 port(A,B : in std_logic; SUM, CARRY : out std_logic); end component; component ORGATE port(A,B : in std_logic; Z : out std_logic); end component;begin u1:adder1 port map(A,B,I1,I2); u2:adder1 port map(I1,CIN,SUM,I3); u3:ORGATE port map(I2,I3,CARRY);end STRUCT;
LDH Aula3 12
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity var_sig isport (clk : in std_logic; output : out std_logic);end entity var_sig;
architecture behav of var_sig isbegin
process (clk) variable temp_var : std_logic; begin temp_var := '1'; if (temp_var = '1') then output <= temp_var; else output <= '0'; end if; temp_var := '0';end process;end behav;
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity sig_var isport (clk : in std_logic; output : out std_logic);end entity sig_var;
architecture behav of sig_var is signal temp_sig : std_logic;begin
test: process (clk) begin temp_sig <= '1'; if (temp_sig = '1') then output <= temp_sig; else output <= '0'; end if; temp_sig <= '0';end process test;end behav;
Exemplos VHDL: Sinais e variáveis
LDH Aula3 13
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity test_bench_SigVar is port ( outputSig : buffer std_logic; outputVar : buffer std_logic );end;
architecture test_adder of test_bench_SigVar is
signal clk : std_logic := '0';
component var_sig isport (clk : in std_logic; output : out std_logic);end component;
component sig_var isport (clk : in std_logic; output : out std_logic);end component;
begin var_sig_instance : var_sig port map (clk, outputVar);
sig_var_instance : sig_var port map (clk, outputSig);
process begin wait for 50 ps; clk <= not clk;end process; end architecture test_adder;
LDH Aula3 14
Acabar exemplos da aula anterior
Organização: 1. Cada grupo vai receber tarefas 1, 2, 3, etc. Quando um grupo concluir uma tarefa deverá mostrar os resultados. A nota da avaliação será calculada com base no número de tarefas implementadas e número de erros.
2. O tempo de trabalho é 2.5 horas. Os primeiros 20 minutos da aula vão ser usados para explicar o trabalho. Os seguintes 5 minutos - para distribuir a primeira tarefa. O tempo de trabalho é 13h25m-15h55m. Depois das 15h55m não será aceite nenhuma tarefa.
LDH Aula3 15
Pode encontrar o código aqui ou utilizarcódigos dos meus exemplos (por exemplo, para máquina de estados finitos)
Deve mostrar os resultados da simulação
Durante avaliação não pode fazer perguntas
top related