summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--control_unit.v14
-rw-r--r--nqcpu.v2
2 files changed, 9 insertions, 7 deletions
diff --git a/control_unit.v b/control_unit.v
index 00ebd4f..fa652e0 100644
--- a/control_unit.v
+++ b/control_unit.v
@@ -1,7 +1,7 @@
module control_unit (
input clk,
- input fetch_ready,
+ input needWait,
output fetch_en,
output decode_en,
@@ -25,11 +25,13 @@ module control_unit (
assign incr_pc = current_state[1];
always @(posedge clk) begin
- case(current_state)
- 10'b1: if(fetch_ready) current_state <= 10'b10;
- 10'b10: current_state <= 10'b100;
- 10'b100: current_state <= 10'b1;
- endcase
+ if(!needWait) begin
+ case(current_state)
+ 10'b1: current_state <= 10'b10;
+ 10'b10: current_state <= 10'b100;
+ 10'b100: current_state <= 10'b1;
+ endcase
+ end
end
assign dbg_state = current_state;
diff --git a/nqcpu.v b/nqcpu.v
index a818587..ffb5f31 100644
--- a/nqcpu.v
+++ b/nqcpu.v
@@ -150,7 +150,7 @@ module nqcpu (
control_unit control_unit_inst (
.clk(clk),
- .fetch_ready(fetch_ready),
+ .needWait(fetch_en & !fetch_ready),
.fetch_en(fetch_en),
.decode_en(decode_en),