fixed instruction word input on stall, fixed uninitialized instruction word after reset by stalling 1 cycle
Stefan Schuermans

Stefan Schuermans commited on 2012-02-16 20:09:51
Showing 1 changed files, with 10 additions and 4 deletions.

... ...
@@ -20,11 +20,12 @@ END ENTITY e_mips_core;
20 20
 ARCHITECTURE a_mips_core OF e_mips_core IS
21 21
 
22 22
     SIGNAL s_stall:         std_logic;
23
+    SIGNAL r_stall_reset:   std_logic := '1';
23 24
     SIGNAL s_stall_data_rd: std_logic;
24 25
 
25 26
     SIGNAL r_pc:         std_logic_vector(31 DOWNTO 0) := X"FFFFFFFC";
26 27
     SIGNAL n_pc:         std_logic_vector(31 DOWNTO 0);
27
-
28
+    SIGNAL r_instr_data: std_logic_vector(31 DOWNTO 0) := X"00000000";
28 29
     SIGNAL s_instr:      std_logic_vector(31 DOWNTO 0);
29 30
 
30 31
     SIGNAL n_reg_s:  std_logic_vector( 4 DOWNTO 0);
... ...
@@ -184,7 +185,7 @@ ARCHITECTURE a_mips_core OF e_mips_core IS
184 185
 
185 186
 BEGIN
186 187
 
187
-    s_stall <= i_stall OR s_stall_data_rd OR s_mul_busy OR s_div_busy;
188
+    s_stall <= i_stall OR r_stall_reset OR s_stall_data_rd OR s_mul_busy OR s_div_busy;
188 189
 
189 190
     decoder: e_mips_decoder
190 191
         PORT MAP (
... ...
@@ -259,22 +260,27 @@ BEGIN
259 260
     p_sync_pc: PROCESS(rst, clk)
260 261
     BEGIN
261 262
         IF rst = '1' THEN
263
+            r_stall_reset <= '1';
262 264
             r_pc          <= X"FFFFFFFC";
265
+            r_instr_data  <= X"00000000";
263 266
         ELSIF rising_edge(clk) THEN
267
+            r_stall_reset <= '0';
264 268
             IF s_stall = '0' THEN
265 269
                 r_pc         <= n_pc;
270
+                r_instr_data <= i_instr_data;
266 271
             END IF;
267 272
         END IF;
268 273
     END PROCESS p_sync_pc;
269 274
 
270
-    p_fetch: PROCESS(s_stall, r_pc, n_pc, i_instr_data)
275
+    p_fetch: PROCESS(s_stall, r_pc, n_pc, r_instr_data, i_instr_data)
271 276
     BEGIN
272 277
         IF s_stall = '1' THEN
273 278
             o_instr_addr <= r_pc;
279
+            s_instr      <= r_instr_data;
274 280
         ELSE
275 281
             o_instr_addr <= n_pc;
276
-        END IF;
277 282
             s_instr      <= i_instr_data;
283
+        END IF;
278 284
     END PROCESS p_fetch;
279 285
 
280 286
     p_sync_dec2ex: PROCESS(rst, clk)
281 287