-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDECSTAGE_TB.vhd
More file actions
123 lines (107 loc) · 3.56 KB
/
Copy pathDECSTAGE_TB.vhd
File metadata and controls
123 lines (107 loc) · 3.56 KB
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
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY DECSTAGE_TB IS
END DECSTAGE_TB;
ARCHITECTURE behavior OF DECSTAGE_TB IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT DECSTAGE
PORT(
Instr : IN std_logic_vector(31 downto 0);
RF_WrEn : IN std_logic;
ALU_out : IN std_logic_vector(31 downto 0);
MEM_out : IN std_logic_vector(31 downto 0);
RF_WrData_sel : IN std_logic;
RF_B_sel : IN std_logic;
RST : IN std_logic;
ImmExt : IN std_logic_vector(1 downto 0);
Clk : IN std_logic;
Immed : OUT std_logic_vector(31 downto 0);
RF_A : OUT std_logic_vector(31 downto 0);
RF_B : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
--Inputs
signal Instr : std_logic_vector(31 downto 0) := (others => '0');
signal RF_WrEn : std_logic := '0';
signal ALU_out : std_logic_vector(31 downto 0) := (others => '0');
signal MEM_out : std_logic_vector(31 downto 0) := (others => '0');
signal RF_WrData_sel : std_logic := '0';
signal RF_B_sel : std_logic := '0';
signal RST : std_logic := '0';
signal ImmExt : std_logic_vector(1 downto 0) := (others => '0');
signal Clk : std_logic := '0';
--Outputs
signal Immed : std_logic_vector(31 downto 0);
signal RF_A : std_logic_vector(31 downto 0);
signal RF_B : std_logic_vector(31 downto 0);
-- Clock period definitions
constant Clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: DECSTAGE PORT MAP (
Instr => Instr,
RF_WrEn => RF_WrEn,
ALU_out => ALU_out,
MEM_out => MEM_out,
RF_WrData_sel => RF_WrData_sel,
RF_B_sel => RF_B_sel,
RST => RST,
ImmExt => ImmExt,
Clk => Clk,
Immed => Immed,
RF_A => RF_A,
RF_B => RF_B
);
-- Clock process definitions
Clk_process :process
begin
Clk <= '0';
wait for Clk_period/2;
Clk <= '1';
wait for Clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
RST <='1';
ImmExt<= "00" ; --signExtension
wait for Clk_period;
-- addi r5,r0,8
--RF[rd] = RF[rs] + SignExtend(Imm)
Instr <= "11000000000001010000000000001000";
RF_WrEn <='1';
ALU_out <="00000000000000000000000000001000";
MEM_out <="00000000000000000000000000010010";
RF_WrData_sel <= '0';
RF_B_sel <= '1'; --0 gia immediate
RST <= '0';
ImmExt <="00";
wait for Clk_period;
-- ori r3,r0,ABCD
-- RF[rd] = RF[rs] | ZeroFill(Imm)
Instr <= "11001100000000111010101111001101";
RF_WrEn <='1';
ALU_out <="00000000000000001010101111001101";
MEM_out <="00000000000000000000000000010011";
RF_WrData_sel <= '0';
RF_B_sel <= '1';
RST <= '0';
ImmExt <="10";
wait for Clk_period;
-- sw r3 4(r0)
--MEM[RF[rs] + SignExtend(Imm)] <- RF[rd]
Instr <= "01111100000000110000000000000100";
RF_WrEn <='1';
ALU_out <="00000000000000000000000000110001";
MEM_out <="00000000000000000000000000000100";
RF_WrData_sel <= '1';
RF_B_sel <= '1';
RST <= '0';
ImmExt <="00";
wait for Clk_period;
wait;
end process;
END;