File tree Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ LIBRARY IEEE;
2+ USE IEEE.STD_LOGIC_1164.ALL ;
3+ USE IEEE.STD_LOGIC_ARITH.ALL ;
4+ use IEEE.STD_LOGIC_UNSIGNED.ALL ;
5+
6+ Entity lab_8_2 is
7+
8+ port (
9+ clk : IN STD_LOGIC ;
10+ load : IN STD_LOGIC ;
11+ clear : IN STD_LOGIC ;
12+ out_sel : IN std_logic ;
13+
14+ iNOT10 : out std_logic ; --status signal
15+ dp_out : out std_logic_vector (3 downto 0 )--display out
16+
17+ );
18+
19+ END lab_8_2;
20+
21+ Architecture dataflow of lab_8_2 is
22+ signal iNOT10S: std_logic := '1' ;
23+ signal data : std_logic_vector (3 downto 0 ) := "0000" ;
24+ TYPE state_type IS (S0,S1,S2,S3);
25+ SIGNAL state:state_type;
26+
27+ begin
28+
29+ process (clear, clk) is
30+ begin
31+ if (clear = '1' ) then
32+ data <= "0000" ;
33+ state<= S0;
34+
35+ elsif (clk'EVENT AND clk = '1' ) then
36+ CASE state IS
37+ WHEN S0=>
38+ if (load = '1' ) then
39+ data <= data + '1' ;
40+ state<= S1;
41+ end if ;
42+
43+ WHEN S1=>
44+ IF (load= '1' and out_sel= '1' ) then
45+ data <= data + '1' ;
46+ dp_out<= data;
47+ state<= S2;
48+ elsif out_sel= '0' then
49+ dp_out <= "ZZZZ" ;
50+ end if ;
51+
52+ WHEN S2=>
53+ if (load= '1' and out_sel= '1' and iNOT10S/= '0' ) then
54+ data <= data + '1' ;
55+ dp_out<= data;
56+ end if ;
57+
58+ if data= "1010" then
59+ state<= S3;
60+ iNOT10S<= '0' ;
61+ else
62+ iNOT10S<= '1' ;
63+ end if ;
64+
65+ WHEN S3=>
66+ if (out_sel= '0' ) then
67+ dp_out<= "ZZZZ" ;
68+ end if ;
69+ end case ;
70+ end if ;
71+ end process ;
72+ dp_out<= "ZZZZ" WHEN out_sel= '0' ;
73+ iNOT10<= iNOT10S;
74+ end dataflow;
You can’t perform that action at this time.
0 commit comments