-
Notifications
You must be signed in to change notification settings - Fork 0
/
DATAPATH.vhdl
174 lines (157 loc) · 5.09 KB
/
DATAPATH.vhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity DATAPATH is
port (
CLK : in std_logic;
RW : std_logic;
DA : in std_logic_vector(2 downto 0);
AA : in std_logic_vector(2 downto 0);
BA : in std_logic_vector(2 downto 0);
F_SEL : in std_logic_vector(3 downto 0);
MD : std_logic;
MB : std_logic;
CONST : in std_logic_vector(7 downto 0);
DATA_IP : in std_logic_vector(7 downto 0);
ADDR_OP : out std_logic_vector(7 downto 0);
DATA_OP : out std_logic_vector(7 downto 0);
V, N, C, Z : out std_logic
);
end DATAPATH;
architecture structure of DATAPATH is
component REGISTER_FILE is
port (
CLK : std_logic;
DATA : in std_logic_vector(7 downto 0);
RW : in std_logic;
DA : in std_logic_vector(2 downto 0);
AA : in std_logic_vector(2 downto 0);
BA : in std_logic_vector(2 downto 0);
A, B : out std_logic_vector(7 downto 0)
);
end component;
component FUNCTION_UNIT is
port (
CLK : in std_logic;
IP_0, IP_1 : in std_logic_vector(7 downto 0);
F_SEL : in std_logic_vector(3 downto 0);
OP : out std_logic_vector(7 downto 0);
V, C, N, Z : out std_logic
);
end component;
-- signal REG_0 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_1 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_2 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_3 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_4 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_5 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_6 : std_logic_vector(7 downto 0) := "11111111";
-- signal REG_7 : std_logic_vector(7 downto 0) := "11111111";
-- signal RW : std_logic;
-- signal DA : std_logic_vector(2 downto 0);
-- signal AA : std_logic_vector(2 downto 0);
-- signal BA : std_logic_vector(2 downto 0);
-- signal MD : std_logic;
signal REG_IP : std_logic_vector(7 downto 0);
signal REG_A, REG_B : std_logic_vector(7 downto 0);
signal FUN_IP_B : std_logic_vector(7 downto 0);
signal FUNC_OP : std_logic_vector(7 downto 0);
begin
reg_comp : REGISTER_FILE port map(CLK => CLK, DATA => REG_IP, RW => RW, DA => DA, AA => AA, BA => BA, A => REG_A, B => REG_B);
fun_comp : FUNCTION_UNIT port map(CLK => CLK, IP_0 => REG_A, IP_1 => FUN_IP_B, F_SEL => F_SEL, OP => FUNC_OP, V => V, N => N, C => C, Z => Z);
with MB select
FUN_IP_B <= REG_B when '0',
CONST when others;
with MD select
REG_IP <= FUNC_OP when '0',
DATA_IP when others;
ADDR_OP <= REG_A;
DATA_OP <= FUN_IP_B;
-- process (CLK)
-- begin
-- if rising_edge(CLK) then
-- if CONTROL_WORD(0) = '1' then
-- case CONTROL_WORD(15 downto 13) is
-- when "000" =>
-- REG_0 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "001" =>
-- REG_1 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "010" =>
-- REG_2 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "011" =>
-- REG_3 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "100" =>
-- REG_4 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "101" =>
-- REG_5 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "110" =>
-- REG_6 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when "111" =>
-- REG_7 <= FUNC_OP when CONTROL_WORD(1) = '0' else DATA_IP;
-- when others =>
-- null;
-- end case;
-- end if;
-- end if;
-- end process;
-- process (CLK)
-- begin
-- if rising_edge(CLK) then
-- case CONTROL_WORD(12 downto 10) is
-- when "000" =>
-- REG_A <= REG_0;
-- when "001" =>
-- REG_A <= REG_1;
-- when "010" =>
-- REG_A <= REG_2;
-- when "011" =>
-- REG_A <= REG_3;
-- when "100" =>
-- REG_A <= REG_4;
-- when "101" =>
-- REG_A <= REG_5;
-- when "110" =>
-- REG_A <= REG_6;
-- when "111" =>
-- REG_A <= REG_7;
-- when others =>
-- null;
-- end case;
-- end if;
-- end process;
-- process (CLK)
-- begin
-- if rising_edge(CLK) then
-- case CONTROL_WORD(9 downto 7) is
-- when "000" =>
-- REG_B <= REG_0;
-- when "001" =>
-- REG_B <= REG_1;
-- when "010" =>
-- REG_B <= REG_2;
-- when "011" =>
-- REG_B <= REG_3;
-- when "100" =>
-- REG_B <= REG_4;
-- when "101" =>
-- REG_B <= REG_5;
-- when "110" =>
-- REG_B <= REG_6;
-- when "111" =>
-- REG_B <= REG_7;
-- when others =>
-- null;
-- end case;
-- end if;
-- end process;
-- process (CLK)
-- begin
-- if rising_edge(CLK) then
-- if CONTROL_WORD(6) = '0' then
-- FUN_IP_B <= REG_B;
-- else
-- FUN_IP_B <= CONST;
-- end if;
-- end if;
-- end process;
end architecture structure;