- output reg [31:0] pc = 0);
-
- reg [31:0] prevpc;
- reg [31:0] nextpc;
- initial
- prevpc = 32'hFFFFFFFC; /* ugh... the first pc we request will be this +4 */
- always @(negedge Nrst)
- prevpc <= 32'hFFFFFFFC;
-
- always @(*)
- if (!Nrst)
- nextpc = 32'hFFFFFFFC;
- else if (stall) /* don't change any internal state */
- nextpc = prevpc;
+ output reg [31:0] pc = 32'hFFFFFFFC);
+
+ reg qjmp = 0; /* A jump has been queued up while we were stalled. */
+ reg [31:0] qjmppc;
+ always @(posedge clk)
+ if (stall && jmp && !qjmp)
+ {qjmp,qjmppc} <= {jmp, jmppc};
+ else if (!stall && qjmp) /* It has already been handled. */
+ {qjmp,qjmppc} <= {1'b0, 32'hxxxxxxxx};
+
+ reg [31:0] reqpc;
+ always @(*)
+ if (stall)
+ reqpc = pc;
+ else if (qjmp)
+ reqpc = qjmppc;