Skip to content

Commit fd266f0

Browse files
committed
CU DP Design
1 parent 4bf7169 commit fd266f0

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

lab_08/lab_8_2.vhd

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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;

0 commit comments

Comments
 (0)