Skip to content

Commit 2c7ef64

Browse files
committed
squashed some more bugs
1 parent ab89509 commit 2c7ef64

10 files changed

+43
-19
lines changed

Project_2_RISC_Pipelined/EX_stage.vhd

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ end if;
156156
end process;
157157
end SignedExtender;
158158
---------------------------------------------------------------
159+
library ieee;
160+
use ieee.std_logic_1164.all;
161+
use ieee.numeric_std.all;
162+
159163
entity EX_stage is
160164
port (OR_reg_op: in std_logic_vector(99 downto 0);
161165
RF_write_out,flagc_write_out,flagz_write_out: in std_logic;

Project_2_RISC_Pipelined/ID_stage.vhd

+19-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ library ieee;
3131
use ieee.std_logic_1164.all;
3232
use ieee.numeric_std.all;
3333
entity ID_stage is
34-
port(reset,clock,nullify_ID_control,PE2_mux_control: in std_logic;
34+
port(reset,clock,nullify_ID_control,PE2_mux_control,EN_id_control,EN_8bits_control: in std_logic;
3535
PE2_ip: std_logic_vector (7 downto 0);
3636
IF_reg_op :in std_logic_vector(32 downto 0);
3737
ID_reg_op : out std_logic_vector (51 downto 0);
@@ -42,7 +42,7 @@ architecture Behave of ID_stage is
4242

4343
component ID_interface_reg is
4444
Generic (NUM_BITS : INTEGER := 52);
45-
port (EN, reset, CLK,EN_id_control,EN_8bits_control: in std_logic;
45+
port (EN, reset, CLK, EN_8bits: in std_logic;
4646
ip: in std_logic_vector(NUM_BITS-1 downto 0);
4747
op: out std_logic_vector(NUM_BITS-1 downto 0)
4848
);
@@ -53,7 +53,23 @@ signal ALU2_op,RF_D3_mux,RF_a3_mux: std_logic_vector(1 downto 0);
5353
signal PE2_mux_op: std_logic_vector(7 downto 0);
5454

5555
begin
56-
a: ID_interface_reg(EN=>EN_id_control,EN_8bits=>EN_8bits_control,reset=>reset,CLK=>clock,ip(51 downto 20)=>IF_reg_op(32 downto 1),ip(8)=>(nullify_ID_control or not(IF_reg_op(0))),ip(7 downto 0)=>PE2_mux_op,ip(19)=>(RF_enable and not(nullify_ID_control)),ip(18)=>(mem_write and not(nullify_ID_control)),ip(17 downto 16)=>ALU2_op,ip(15)=>ALU2_a_mux,ip(14 downto 13)=>RF_a3_mux,ip(12 downto 11)=>RF_D3_mux,op=>ID_reg_op,ip(10)=>(flagc_en and not(nullify_ID_control)),ip(9)=>(flagz_en and not(nullify_ID_control)));
56+
a: ID_interface_reg port map(
57+
EN=>EN_id_control,
58+
EN_8bits=>EN_8bits_control,
59+
reset=>reset,
60+
CLK=>clock,
61+
ip(51 downto 20)=>IF_reg_op(32 downto 1),
62+
ip(8)=>(nullify_ID_control or not(IF_reg_op(0))),
63+
ip(7 downto 0)=>PE2_mux_op,
64+
ip(19)=>(RF_enable and not(nullify_ID_control)),
65+
ip(18)=>(mem_write and not(nullify_ID_control)),
66+
ip(17 downto 16)=>ALU2_op,
67+
ip(15)=>ALU2_a_mux,
68+
ip(14 downto 13)=>RF_a3_mux,
69+
ip(12 downto 11)=>RF_D3_mux,
70+
op=>ID_reg_op,
71+
ip(10)=>(flagc_en and not(nullify_ID_control)),
72+
ip(9)=>(flagz_en and not(nullify_ID_control)));
5773

5874
mem_id_08(15 downto 7)<=IF_reg_op(9 downto 1);
5975
mem_id_08(6 downto 0)<="0000000";

Project_2_RISC_Pipelined/IF_stage.vhd

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ architecture mem of memory_instruction is
1212
type RAM_array is array (0 to 2**4-1) of std_logic_vector (15 downto 0);
1313
signal RAM : RAM_array:= (X"3115",X"32C7",X"0050",X"039A",others=>X"0000");
1414
begin
15-
process(clk,data_in, address, RAM)
15+
process(clk, address, RAM)
1616
begin
1717
if rising_edge(clk) then
1818
data_out <= RAM(to_integer(unsigned(address)));
@@ -134,7 +134,7 @@ signal PC_out,PC_in: std_logic_vector(15 downto 0);
134134
signal ALU1_out,mem_instr_out: std_logic_vector(15 downto 0);
135135
begin
136136
a: PC port map(EN => PC_en_control,CLK=>clock,reset=>reset,ip=>PC_in,op=>PC_out);
137-
b: memory_instruction port map(clock=>clock,address=>PC_out,data_out=>mem_instr_out);
137+
b: memory_instruction port map(clk=>clock,address=>PC_out,data_out=>mem_instr_out);
138138
c: ALU_1 port map(alu_in=>PC_out,alu_out=>ALU1_out);
139139
d: IF_interface_reg port map(EN=>'1',reset=>reset,CLk=>clock,ip(32 downto 17)=>PC_out,ip(16 downto 1)=>mem_instr_out,ip(0)=>validate_control,op=>IF_reg_op);
140140
process(PC_control,ALU1_out)

Project_2_RISC_Pipelined/Mem_stage.vhd

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ end process;
5555
end reg_arch;
5656

5757
-------------------------------------------------------------------
58+
library ieee;
59+
use ieee.std_logic_1164.all;
60+
use ieee.numeric_std.all;
5861

5962
entity Mem_stage is
6063
port(

Project_2_RISC_Pipelined/OR_stage.vhd

+8-7
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,22 @@ component ALU_3 is
343343
alu_out: out std_logic_vector(15 downto 0));
344344
end component;
345345

346-
signal SE6_op,SE9_op,SE_mux_op,RF_D3_sig,alu3_op,R7_op,rf_d1_sig,rf_d2_sig,rf_d1_mux_sig,rf_d2_mux_sig: std_logic_vector (15 downto 0);
346+
signal SE6_op,SE9_op,SE_mux_op,RF_D3_sig,alu3_op_sig,R7_op,rf_d1_sig,rf_d2_sig,rf_d1_mux_sig,rf_d2_mux_sig: std_logic_vector (15 downto 0);
347347
signal RF_a3_sig,RF_a2_sig,op_PE2: std_logic_vector (2 downto 0);
348348
signal PE1_mux_op: std_logic_vector(7 downto 0);
349349

350350
begin
351351

352352
a: SE6 port map (ip=>ID_reg_op(25 downto 20),op=>SE6_op);
353353
b: SE9 port map (ip=>ID_reg_op(28 downto 20),op=>SE9_op);
354-
c: ALU_3 port map (alu_a=>SE_mux_op,alu_b=>ID_reg_op(51 downto 36),alu_out=>alu3_op);
354+
c: ALU_3 port map (alu_a=>SE_mux_op,alu_b=>ID_reg_op(51 downto 36),alu_out=>alu3_op_sig);
355355
d: RegFile port map(CLK => clock, reset=>reset,rf_a1=>ID_reg_op(31 downto 29),rf_a2 => RF_a2_sig, rf_a3 =>RF_a3_sig,rf_d3=>RF_d3_sig,rf_d1=>rf_d1_sig,rf_d2=>rf_d2_sig,rf_wr =>mem_rf_en );
356-
e: R7 port map(EN=>not(nullify_ex),ip=>PC_ex,op=>R7_op);
356+
e: R7 port map(EN=>not(nullify_ex),ip=>PC_ex,op=>R7_op,reset=>reset,clk=>clock);
357357
f: priority_encoder2 port map(ip=>ID_reg_op(7 downto 0), op_addr=>op_PE2, update=> PE2_op);
358-
g: OR_interface_reg port map(EN=>'1',reset=>reset,CLK=>clock,ip(99 downto 84)=>ID_reg_op(51 downto 36),ip(83 downto 68)=>ID_reg_op(35 downto 20),ip(67 downto 52)=>rf_d1_mux_sig,ip(51 downto 34)=>rf_d2_mux_sig,ip(35 downto 20)=>alu3_op,ip(19)=>(ID_reg_op(19) and not(nullify_control_OR)),ip(18)=>(ID_reg_op(18) and not(nullify_control_OR)),ip(17 downto 11)=>ID_reg_op(17 downto 11),ip(10)=>(ID_reg_op(10) and not(nullify_control_OR)),ip(9)=>(ID_reg_op(9) and not(nullify_control_OR)),ip(8)=>nullify_control_OR,ip(7 downto 0)=>PE1_mux_op);
358+
g: OR_interface_reg port map(EN=>'1',reset=>reset,CLK=>clock,ip(99 downto 84)=>ID_reg_op(51 downto 36),ip(83 downto 68)=>ID_reg_op(35 downto 20),ip(67 downto 52)=>rf_d1_mux_sig,ip(51 downto 34)=>rf_d2_mux_sig,ip(35 downto 20)=>alu3_op_sig,ip(19)=>(ID_reg_op(19) and not(nullify_control_OR)),ip(18)=>(ID_reg_op(18) and not(nullify_control_OR)),ip(17 downto 11)=>ID_reg_op(17 downto 11),ip(10)=>(ID_reg_op(10) and not(nullify_control_OR)),ip(9)=>(ID_reg_op(9) and not(nullify_control_OR)),ip(8)=>nullify_control_OR,ip(7 downto 0)=>PE1_mux_op);
359359

360360
RF_d2_or<=rf_d2_sig;
361+
ALU3_op<=alu3_op_sig;
361362
process(ID_reg_op)
362363
begin
363364
if (ID_reg_op(35 downto 32) ="1000") then
@@ -371,10 +372,10 @@ end process;
371372

372373
process(ID_reg_op,op_PE2)
373374
begin
374-
if (ID_reg_op(35 downto 32) = "0111" and not(ID_reg_op(8))) then
375-
rf_a2 <= op_PE2;
375+
if (ID_reg_op(35 downto 32) = "0111" and ID_reg_op(8)='0' ) then
376+
rf_a2_sig <= op_PE2;
376377
else
377-
rf_a2 <= ID_reg_op(28 downto 26);
378+
rf_a2_sig <= ID_reg_op(28 downto 26);
378379
end if;
379380
end process;
380381

Project_2_RISC_Pipelined/PE1_mux_control.vhd

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ architecture Behave of PE1_mux_control is
1414
begin
1515
process(OR_reg_opcode,nullified_or)
1616
begin
17-
if(OR_reg_opcode = "0110" and not(nullified_or)) then
18-
PE1_mux_control<='1';
17+
if(OR_reg_opcode = "0110" and nullified_or='0') then
18+
PE1_mux_controller<='1';
1919
else
20-
PE1_mux_control<='0';
20+
PE1_mux_controller<='0';
2121
end if;
2222
end process;
2323
end Behave;

Project_2_RISC_Pipelined/PE2_mux_control.vhd

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ architecture Behave of PE2_mux_control is
1414
begin
1515
process(ID_reg_opcode,nullified_id)
1616
begin
17-
if(ID_reg_opcode = "0111" and not(nullified_id)) then
17+
if(ID_reg_opcode = "0111" and nullified_id='0') then
1818
PE2_mux_controller<='1';
1919
else
2020
PE2_mux_controller<='0';

Project_2_RISC_Pipelined/RF_d1_control.vhd

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end entity;
1616

1717
architecture Behave of RF_d1_control is
1818
begin
19-
process(RS_id1,RD_or,RD_ex,RD_mem,ID_opcode,EX_opcode,OR_opcode,mem_opcode,cflag_ex,cflag_mem,zflag_ex,zflag_mem,nullify_or,nullify_id,nullify_ex,nullify_mem)
19+
process(RS_id1,RD_or,RD_ex,RD_mem,ID_opcode,EX_opcode,OR_opcode,mem_opcode,cflag_ex,cflag_mem,zflag_ex,zflag_mem,nullify_or,nullify_id,nullify_ex,nullify_mem,PE1_op,PE2_stored,user_cflag,user_zflag)
2020
begin
2121
if((OR_opcode(5 downto 2) = "0110" and nullify_or ='0' and PE1_op /= "00000000") or (OR_opcode(5 downto 2) = "0111" and nullify_or ='0' and PE2_stored /= "00000000")) then
2222
RF_d1_mux_control<="0001";

Project_2_RISC_Pipelined/RF_d2_control.vhd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end entity;
1515

1616
architecture Behave of RF_d2_control is
1717
begin
18-
process(RS_id2,RD_or,RD_ex,RD_mem,ID_opcode,EX_opcode,OR_opcode,mem_opcode,cflag_ex,cflag_mem,zflag_ex,zflag_mem,nullify_or,nullify_id,nullify_ex,nullify_mem)
18+
process(RS_id2,RD_or,RD_ex,RD_mem,ID_opcode,EX_opcode,OR_opcode,mem_opcode,cflag_ex,cflag_mem,zflag_ex,zflag_mem,nullify_or,nullify_id,nullify_ex,nullify_mem,user_zflag,user_cflag)
1919
begin
2020
if(((ID_opcode = "0000") or (ID_opcode = "0001") or
2121
(ID_opcode = "0010") or (ID_opcode = "0101") or

Project_2_RISC_Pipelined/write_control.vhd

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ begin
3333
end if;
3434
end process;
3535

36-
process(authentic_c,authentic_z,opcode_EX,opcode_OR,load_flag_z,nullify_ex)
36+
process(authentic_c,authentic_z,opcode_EX,opcode_OR,load_flag_z,nullify_ex,rf_write_or,flagc_write_or,flagz_write_or)
3737
begin
3838
if((((opcode_OR = "000001") or (opcode_OR = "001001")) and (authentic_z = '0')) or (((opcode_OR = "000010") or (opcode_OR = "001010")) and (authentic_c = '0')) or ((opcode_EX(5 downto 2) = "0100") and ((opcode_OR = "000001") or (opcode_OR = "001001")) and (load_flag_z = '0') and (nullify_ex = '0'))) then
3939
RF_write_out<='0';

0 commit comments

Comments
 (0)