-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdecode_temp.vhd
109 lines (94 loc) · 3.5 KB
/
decode_temp.vhd
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
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
ENTITY decode_stage_temp IS
GENERIC (
REGISTER_SIZE : INTEGER := 16;
REGISTER_NUMBER : INTEGER := 8
);
PORT (
clk : IN STD_LOGIC;
reset : IN STD_LOGIC;
fetched_instruction : IN STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
reg_write : IN STD_LOGIC;
write_back_address : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
write_back_data : IN STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
input_port_data : IN STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
-- input signals from control unit
IN_PORT_IN : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
-- TODO: integrate JMP and CALL instructions
-- JMP_IN : IN STD_LOGIC;
-- CALL_IN : IN STD_LOGIC;
-- Outputs
read_data_1 : OUT STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
read_data_2 : OUT STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0)
);
END ENTITY decode_stage;
ARCHITECTURE decode_stage_architecture OF decode_stage IS
COMPONENT general_register_file IS
GENERIC (
REGISTER_SIZE : INTEGER := REGISTER_SIZE;
REGISTER_NUMBER : INTEGER := REGISTER_NUMBER
);
PORT (
write_enable, clk, reset : IN STD_LOGIC;
read_address1, read_address2, write_address : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
write_data : IN STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
read_data1, read_data2 : OUT STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0)
);
END COMPONENT;
COMPONENT input_port IS
GENERIC (
DATA_SIZE : INTEGER := 16
);
PORT (
clk : IN STD_LOGIC; -- Clock signal
reset : IN STD_LOGIC; -- Reset signal
data_in : IN STD_LOGIC_VECTOR(DATA_SIZE - 1 DOWNTO 0);
data_out : OUT STD_LOGIC_VECTOR(DATA_SIZE - 1 DOWNTO 0)
);
END COMPONENT;
COMPONENT generic_mux IS
GENERIC (
M : INTEGER := REGISTER_SIZE;
N : INTEGER := 2;
K : INTEGER := 1
);
PORT (
inputs : IN STD_LOGIC_VECTOR(M * N - 1 DOWNTO 0);
sel : IN STD_LOGIC_VECTOR(K - 1 DOWNTO 0);
outputs : OUT STD_LOGIC_VECTOR(M - 1 DOWNTO 0)
);
END COMPONENT;
SIGNAL temp_data_1 : STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
SIGNAL input_mux : STD_LOGIC_VECTOR(2 * REGISTER_SIZE - 1 DOWNTO 0);
SIGNAL temp_input_port_output : STD_LOGIC_VECTOR(REGISTER_SIZE - 1 DOWNTO 0);
BEGIN
-- Component instantiations with proper signal assignments
register_file_instance : general_register_file
PORT MAP(
write_enable => reg_write,
clk => clk,
reset => reset,
read_address1 => fetched_instruction(2 DOWNTO 0), -- Use direct input instead of temp signal
read_address2 => fetched_instruction(5 DOWNTO 3), -- Use direct input instead of temp signal
write_address => write_back_address,
write_data => write_back_data,
read_data1 => temp_data_1,
read_data2 => read_data_2
);
input_port_instance : input_port
PORT MAP(
clk => clk,
reset => reset,
data_in => input_port_data,
data_out => temp_input_port_output
);
input_mux <= temp_input_port_output & temp_data_1;
input_port_mux_instance : generic_mux
PORT MAP(
inputs => input_mux,
sel => IN_PORT_IN,
outputs => read_data_1
);
END ARCHITECTURE decode_stage_architecture;