summaryrefslogtreecommitdiff
path: root/rtl/core/fetch/fetch.sv
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-10-15 19:31:55 -0600
committerAlejandro Soto <alejandro@34project.org>2022-10-15 19:31:55 -0600
commitec152d814af82524cf68df95d7f06b9b70c0d0d0 (patch)
tree417ad3c693f0618dd9609ffef6028fa0a955fee2 /rtl/core/fetch/fetch.sv
parent7d95ff01bcd8c42efe118fd1bddaabfca0e937eb (diff)
Rework bus architecture
Diffstat (limited to '')
-rw-r--r--rtl/core/fetch/fetch.sv16
1 files changed, 10 insertions, 6 deletions
diff --git a/rtl/core/fetch/fetch.sv b/rtl/core/fetch/fetch.sv
index a57c679..e8c6a9b 100644
--- a/rtl/core/fetch/fetch.sv
+++ b/rtl/core/fetch/fetch.sv
@@ -17,7 +17,7 @@ module core_fetch
addr
);
- ptr next_pc, head;
+ ptr next_pc, head, hold_addr;
logic fetched_valid, do_flush, discard;
assign do_flush = branch | flush;
@@ -30,7 +30,7 @@ module core_fetch
.*
);
- always_comb
+ always_comb begin
if(branch)
head = target;
else if(flush)
@@ -38,17 +38,21 @@ module core_fetch
else
head = {30{1'bx}};
- always_ff @(posedge clk) begin
if(do_flush)
- addr <= head;
+ addr = head;
else if(fetched_valid)
- addr <= addr + 1;
+ addr = hold_addr + 1;
+ else
+ addr = hold_addr;
+ end
+ always_ff @(posedge clk) begin
discard <= discard ? ~fetched : do_flush & fetch;
+ hold_addr <= addr;
end
initial begin
- addr = 0;
+ hold_addr = 0;
discard = 0;
end