VHDL Lecture
VHDL Lecture
component RAM
port (
Reset : in std_logic;
clk : in std_logic; component scheduler
Address : in std_logic_vector(7 downto 0); port (
Data : out std_logic_vector(7 downto 0)); Reset : in std_logic;
END component; Clk : in std_logic;
Grant : out std_logic_vector(3 downto 0);
component buffer_control Newpacket : in std_logic_vector(3 downto 0);
port ( lengthin : in std_logic_vector(3 downto 0));
Reset : in std_logic; END component;
clk : in std_logic;
MemAddr : out std_logic_vector(7 downto 0); component change_header
port (
MemData : in std_logic_vector(7 downto Reset : in std_logic;
0); clk : in std_logic;
Queue : in std_logic_vector(3 downto 0); datain : in std_logic_vector(7 downto 0);
Newpck : out std_logic_vector(3 downto 0); dataout : out std_logic_vector(7 downto 0);
Datain : in std_logic_vector(7 downto 0); length : out std_logic_vector(3 downto 0));
Dataout : out std_logic_vector(7 downto 0)); END component;
END component;
ENTITY and2 IS
port (
a : in std_logic;
b : in std_logic;
c : out std_logic);
END and2;
ENTITY and2 IS
port (
a : in std_logic;
b : in std_logic;
c : out std_logic);
END and2;
process(a,b)
begin
c <= a and b;
end process;
END procbased;
process(clk,data_ready,cpu_req,done_trans)
begin
if (cpu_req='1' and cpu_req'event and clk'event and clk='1') then
...
end if;
if (data_ready and clk'event and clk='0') then
...
end if;
if (done_trans='1' and clk'event and clk='0') then
...
end if;
if (cpu_req'event and clk='1' and clk'event and cpu_req='0') then
...
end if;
end process;
process(reset,clk)
begin • Still using both rising and falling clock edges.
if reset = '0' then • Well defined clock
dummy1 <= '0'; • 30-40% faster
dummy2 <= '0';
elsif rising_edge(clk) then
if cpu_req = '1' then
dummy1 <= '1';
else
dummy1 <= '0';
end if;
elsif falling_edge(clk) then
if done_trans='1' then
dummy2 <='1';
else
dummy2 <= '0';
end if;
end if;
end process;
END PROCESS ;
..
a <= x"00" + 17; --set a to integer value 17, (a <= 17 not allowed)
b <= std_logic_vector(to_unsigned(58,8)); -- set b to integer value 58
..
count1: process(clk,reset)
begin
if (reset = '1') then
count_int <= "0000";
elsif rising_edge(clk) then
if (en = '1') then
if (up_down = '1') then
count_int <= count_int + '1' after 1 ns;
else
count_int <= unsigned(count_int) - '1' after 1 ns;
end if;
end if;
end if;
end process count1;
• Moore
– Output depending only
on state
– Easy to control
– Often recommended
• Mealy
– Output also dependent
on asynchronous input
– Hard to control delay
hec_ok
Hunt
Ok = 0
hec_error
Presync
a_hec_error Ok = 0
Sync
Ok = 1
b_hec_ok
Register
Datain Dataout
Combinational
Register logic Register
Clock
Do expression: Y=A+B-C+D
process(clk)
begin
if rising_edge(clk) then
if (CTRL = '1') then
D <= A+B after 1 ns;
else
D <= B+C after 1 ns;
end if;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
if (CTRL = '1') then
D <= D1 after 1 ns;
else
D <= D2 after 1 ns;
end if;
D1 <= A+B after 1 ns;
D2 <= B+C after 1 ns;
end if;
end process;
32 DTU Fotonik, Technical University of Denmark
Simulation and Testbench
TestBench
Stimuli / Verification