Browse Source

Improved interrupt timing/alignment, fixing bug where interrupts are not allowed during the UART bootloader.

bart 1 year ago
parent
commit
2fe0518bb3
3 changed files with 10 additions and 4 deletions
  1. 5 2
      Quartus/modules/CPU/CPU.v
  2. BIN
      Quartus/output_files/output_file.jic
  3. 5 2
      Verilog/modules/CPU/CPU.v

+ 5 - 2
Quartus/modules/CPU/CPU.v

@@ -174,12 +174,15 @@ assign PC = pc_FE;
 wire [31:0] PC_backup_current;
 wire [31:0] PC_backup_current;
 assign PC_backup_current = pc4_EX - PCincrease;
 assign PC_backup_current = pc4_EX - PCincrease;
 
 
-// branch_MEM (for some reason) aligns interrupt with pipeline, removing all instability since the addition of caching
+// branch/jump/halt properly aligns interrupt with pipeline, as if it was a normal jump
+//  this fixed all instability since the addition of caching (because this decreased the time to obtain instructions)
 assign interruptValid = (
 assign interruptValid = (
     intCPU && 
     intCPU && 
     !intDisabled && 
     !intDisabled && 
     PC_backup_current < PCstart && 
     PC_backup_current < PCstart && 
-    branch_MEM
+    (
+        branch_MEM || jumpr_MEM || jumpc_MEM || halt_MEM
+    )
 );
 );
 
 
 always @(posedge clk) 
 always @(posedge clk) 

BIN
Quartus/output_files/output_file.jic


+ 5 - 2
Verilog/modules/CPU/CPU.v

@@ -174,12 +174,15 @@ assign PC = pc_FE;
 wire [31:0] PC_backup_current;
 wire [31:0] PC_backup_current;
 assign PC_backup_current = pc4_EX - PCincrease;
 assign PC_backup_current = pc4_EX - PCincrease;
 
 
-// branch_MEM (for some reason) aligns interrupt with pipeline, removing all instability since the addition of caching
+// branch/jump/halt properly aligns interrupt with pipeline, as if it was a normal jump
+//  this fixed all instability since the addition of caching (because this decreased the time to obtain instructions)
 assign interruptValid = (
 assign interruptValid = (
     intCPU && 
     intCPU && 
     !intDisabled && 
     !intDisabled && 
     PC_backup_current < PCstart && 
     PC_backup_current < PCstart && 
-    branch_MEM
+    (
+        branch_MEM || jumpr_MEM || jumpc_MEM || halt_MEM
+    )
 );
 );
 
 
 always @(posedge clk) 
 always @(posedge clk)