Skip to content

Commit 8efa413

Browse files
committed
rtl bugs squashed
1 parent 54094a1 commit 8efa413

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-29
lines changed

Project_2_RISC_Pipelined/EX_stage.vhd

+8-3
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ signal se6_ex_op: std_logic_vector(15 downto 0);
228228
signal alu_flagz_sig, alu_flagc_sig: std_logic;
229229
signal PE1_addr_sig: std_logic_vector(2 downto 0);
230230
signal EX_reg_op_sig: std_logic_vector(93 downto 0);
231+
signal dummy_ip61, dummy_ip55, dummy_ip54: std_logic;
231232
begin
232233

233234
a: ALU_2 port map(alu_op=>OR_reg_op(17 downto 16),alu_a=>alu_a_ip,alu_b=>OR_reg_op(51 downto 36),alu_c=>alu_flagc_sig,alu_z=>alu_flagz_sig,alu_out=>alu2_out_sig );
@@ -236,6 +237,10 @@ b: priority_encoder1 port map (ip=>OR_reg_op(7 downto 0),op_addr=>PE1_addr_sig,u
236237

237238
c: SE6_ex port map (ip=>OR_reg_op(73 downto 68),op=>se6_ex_op);
238239

240+
dummy_ip61 <=(RF_write_out and not(nullify_control_ex));
241+
dummy_ip55 <= (flagc_write_out and not(nullify_control_ex));
242+
dummy_ip54 <= (flagz_write_out and not(nullify_control_ex));
243+
239244
d: EX_interface_reg port map(
240245
EN=>'1',
241246
CLK=>clock,
@@ -249,11 +254,11 @@ d: EX_interface_reg port map(
249254
ip(2)=>alu_flagc_sig,
250255
ip(1)=>alu_flagz_sig,
251256
ip(0)=>nullify_control_ex,
252-
ip(61)=>(RF_write_out and not(nullify_control_ex)),
257+
ip(61)=>dummy_ip61,
253258
ip(60)=>OR_reg_op(18),
254259
ip(59 downto 56)=>OR_reg_op(14 downto 11),
255-
ip(55)=>(flagc_write_out and not(nullify_control_ex)),
256-
ip(54)=>(flagz_write_out and not(nullify_control_ex)),
260+
ip(55)=>dummy_ip55,
261+
ip(54)=>dummy_ip54,
257262
op=>EX_reg_op_sig);
258263

259264
PCtoR7 <= EX_reg_op_sig(93 downto 78);

Project_2_RISC_Pipelined/ID_stage.vhd

+16-8
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,33 @@ end component;
5151
signal RF_enable, mem_write, ALU2_a_mux,flagc_en,flagz_en: std_logic;
5252
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);
54-
54+
signal dummy_ip8, dummy_ip19, dummy_ip18, dummy_ip10, dummy_ip9: std_logic;
5555
begin
56+
57+
dummy_ip8 <= (nullify_ID_control or not(IF_reg_op(0)));
58+
dummy_ip19 <=(RF_enable and not(nullify_ID_control));
59+
dummy_ip18 <= (mem_write and not(nullify_ID_control));
60+
dummy_ip10 <= (flagc_en and not(nullify_ID_control));
61+
dummy_ip9 <= (flagz_en and not(nullify_ID_control));
62+
5663
a: ID_interface_reg port map(
5764
EN=>EN_id_control,
5865
EN_8bits=>EN_8bits_control,
5966
reset=>reset,
6067
CLK=>clock,
6168
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)),
69+
ip(19)=>dummy_ip19,
70+
ip(18)=>dummy_ip18,
6671
ip(17 downto 16)=>ALU2_op,
6772
ip(15)=>ALU2_a_mux,
6873
ip(14 downto 13)=>RF_a3_mux,
6974
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)));
75+
ip(10)=>dummy_ip10,
76+
ip(9)=>dummy_ip9,
77+
ip(8)=>dummy_ip8,
78+
ip(7 downto 0)=>PE2_mux_op,
79+
op=>ID_reg_op);
80+
7381

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

Project_2_RISC_Pipelined/Mem_stage.vhd

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end entity;
1212

1313
architecture mem of memory_data is
1414
type RAM_array is array (0 to 2**4-1) of std_logic_vector (15 downto 0);
15-
signal RAM : RAM_array:= (X"3115",X"32C7",X"0050",X"039A",others=>X"0000");
15+
signal RAM : RAM_array:= (X"3001",X"3203",X"3605",X"700A",X"6014",X"C283",others=>X"0000");
1616
begin
1717
process(clk, mem_write, data_in, address, RAM)
1818
begin
@@ -89,9 +89,11 @@ end component;
8989

9090
signal memd_z_flag,memd_muxz_output: std_logic;
9191
signal mem_muxaddr_op ,mem_data_out_sig,mem_mux_datain_op: std_logic_vector(15 downto 0);
92+
signal dummy_mem_write: std_logic;
9293
begin
94+
dummy_mem_write<=(EX_reg_op(60) and not(EX_reg_op(0)));
9395

94-
a: memory_data port map(clk=>clock,mem_write=>(EX_reg_op(60) and not(EX_reg_op(0))),address=>mem_muxaddr_op,data_in=>mem_mux_datain_op,data_out=>mem_data_out_sig);
96+
a: memory_data port map(clk=>clock,mem_write=>dummy_mem_write,address=>mem_muxaddr_op,data_in=>mem_mux_datain_op,data_out=>mem_data_out_sig);
9597

9698
b:mem_interface_reg port map(EN=>'1',CLK=>clock,reset=>reset,ip(76 downto 61)=>EX_reg_op(93 downto 78),ip(60 downto 45)=>EX_reg_op(77 downto 62),ip(44 downto 29)=>mem_data_out_sig,ip(28 downto 13)=>EX_reg_op(53 downto 38),ip(5 downto 3)=>EX_reg_op(5 downto 3),ip(2)=>EX_reg_op(2),ip(1)=>memd_muxz_output,ip(0)=>nullify_control_mem,ip(12)=>EX_reg_op(61),ip(11 downto 6)=>EX_reg_op(59 downto 54),op=>Mem_reg_op);
9799

Project_2_RISC_Pipelined/OR_stage.vhd

+15-8
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ entity OR_stage is
312312
);
313313
end entity;
314314

315-
architecture Behave of OR_stage is
315+
architecture ors of OR_stage is
316316

317317
component R7 is
318318
Generic (NUM_BITS : INTEGER := 16);
@@ -374,14 +374,21 @@ end component;
374374
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);
375375
signal RF_a3_sig,RF_a2_sig,op_PE2: std_logic_vector (2 downto 0);
376376
signal PE1_mux_op: std_logic_vector(7 downto 0);
377-
377+
signal not_nullify_ex: std_logic;
378+
signal dummy_ip19,dummy_ip18, dummy_ip10, dummy_ip9: std_logic;
378379
begin
379380

381+
not_nullify_ex <= not(nullify_ex);
382+
dummy_ip19 <= (ID_reg_op(19) and not(nullify_control_OR));
383+
dummy_ip18 <= (ID_reg_op(18) and not(nullify_control_OR));
384+
dummy_ip10 <= (ID_reg_op(10) and not(nullify_control_OR));
385+
dummy_ip9 <= (ID_reg_op(9) and not(nullify_control_OR));
386+
380387
a: SE6 port map (ip=>ID_reg_op(25 downto 20),op=>SE6_op);
381388
b: SE9 port map (ip=>ID_reg_op(28 downto 20),op=>SE9_op);
382389
c: ALU_3 port map (alu_a=>SE_mux_op,alu_b=>ID_reg_op(51 downto 36),alu_out=>alu3_op_sig);
383390
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 );
384-
e: R7 port map(EN=>not(nullify_ex),ip=>PC_ex,op=>R7_op,reset=>reset,clk=>clock);
391+
e: R7 port map(EN=>not_nullify_ex,ip=>PC_ex,op=>R7_op,reset=>reset,clk=>clock);
385392
f: priority_encoder2 port map(ip=>ID_reg_op(7 downto 0), op_addr=>op_PE2, update=> PE2_op);
386393
g: OR_interface_reg port map(
387394
EN=>'1',
@@ -392,11 +399,11 @@ g: OR_interface_reg port map(
392399
ip(67 downto 52)=>rf_d1_mux_sig,
393400
ip(51 downto 36)=>rf_d2_mux_sig,
394401
ip(35 downto 20)=>alu3_op_sig,
395-
ip(19)=>(ID_reg_op(19) and not(nullify_control_OR)),
396-
ip(18)=>(ID_reg_op(18) and not(nullify_control_OR)),
402+
ip(19)=>dummy_ip19,
403+
ip(18)=>dummy_ip18,
397404
ip(17 downto 11)=>ID_reg_op(17 downto 11),
398-
ip(10)=>(ID_reg_op(10) and not(nullify_control_OR)),
399-
ip(9)=>(ID_reg_op(9) and not(nullify_control_OR)),
405+
ip(10)=>dummy_ip10,
406+
ip(9)=>dummy_ip9,
400407
ip(8)=>nullify_control_OR,
401408
ip(7 downto 0)=>PE1_mux_op,
402409
op=>OR_reg_op);
@@ -512,4 +519,4 @@ else
512519
end if;
513520
end process;
514521

515-
end Behave;
522+
end architecture ors;

Project_2_RISC_Pipelined/WB_stage.vhd

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use ieee.numeric_std.all;
55
entity user_flagz is
66
Generic (NUM_BITS : INTEGER :=1);
77
port (EN, reset, CLK: in std_logic;
8-
ip: in std_logic_vector(NUM_BITS-1 downto 0);
9-
op: out std_logic_vector(NUM_BITS-1 downto 0)
10-
);
8+
ip: in std_logic;
9+
op: out std_logic);
1110
end entity;
1211

1312
architecture reg_arch of user_flagz is
@@ -16,7 +15,7 @@ reg1 : process(CLK, EN, ip)
1615
begin
1716
if CLK'event and CLK = '1' then
1817
if reset = '1' then
19-
op(NUM_BITS-1 downto 0) <= (others=>'0');
18+
op <= '0';
2019
elsif EN = '1' then
2120
op <= ip;
2221
end if;
@@ -34,9 +33,8 @@ use ieee.numeric_std.all;
3433
entity user_flagc is
3534
Generic (NUM_BITS : INTEGER :=1);
3635
port (EN, reset, CLK: in std_logic;
37-
ip: in std_logic_vector(NUM_BITS-1 downto 0);
38-
op: out std_logic_vector(NUM_BITS-1 downto 0)
39-
);
36+
ip: in std_logic;
37+
op: out std_logic);
4038
end entity;
4139

4240
architecture reg_arch of user_flagc is
@@ -45,7 +43,7 @@ reg1 : process(CLK, EN, ip)
4543
begin
4644
if CLK'event and CLK = '1' then
4745
if reset = '1' then
48-
op(NUM_BITS-1 downto 0) <= (others=>'0');
46+
op<= '0';
4947
elsif EN = '1' then
5048
op <= ip;
5149
end if;

0 commit comments

Comments
 (0)