86. 86
reset => ,
count => );
TiÕp tôc, thùc hiÖn t−¬ng tù trong cöa sæ Sources in Project
chän file stat_mac.vhd, trong cöa sæ Source nh¸y ®óp vµo View
VHDL Instantiation Template. Copy phÇn khai b¸o Component
vµ phÇn Instantiation d¸n vµo file top.vhd. Khai b¸o mét Signal
timer : std_logic_vector (3 downto 0) ë d−íi khai b¸o cÊu tróc . Sau
khi thùc hiÖn c¸c b−íc ta sÏ cã ch−¬ng tr×nh cña líp top nh− sau.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity top is
Port ( clock : in std_logic;
reset : in std_logic;
red_light : out std_logic;
amber_light : out std_logic;
green_light : out std_logic);
end top;
architecture Behavioral of top is
signal timer : std_logic_vector (3 downto 0);
COMPONENT counter
PORT ( clock : IN std_logic;
reset : IN std_logic;
87. 87
count : INOUT std_logic_vector(3 downto 0));
END COMPONENT;
COMPONENT stat_mac
PORT (TIMER : IN std_logic_vector(3 downto 0);
CLK : IN std_logic;
RESET : IN std_logic;
AMB : OUT std_logic;
GRN : OUT std_logic;
RD : OUT std_logic);
END COMPONENT;
begin
Inst_counter: counter PORT MAP (
clock => clock,
reset => reset,
count => timer);
Inst_stat_mac: stat_mac PORT MAP (
TIMER => timer,
CLK => clock,
RESET => reset,
AMB => amber_light,
GRN => green_light,
RD => red_light);
end Behavioral;
Sau khi cã ®−îc ch−¬ng tr×nh nh− trªn b¹n nhÊp nót Save, lóc