diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-11-10 18:00:43 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-11-10 18:00:43 -0600 |
| commit | 028ab74e28a08982d0ef5fea9cdf0225c7daeac3 (patch) | |
| tree | 8658fe516c51234797796f56da1ae6682b3107fc /rtl/core/fetch | |
| parent | ba5557c0b9096716bf6b1e3d102979ebec82b51a (diff) | |
Fix fetch discard glitches on flush
Diffstat (limited to 'rtl/core/fetch')
| -rw-r--r-- | rtl/core/fetch/fetch.sv | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/rtl/core/fetch/fetch.sv b/rtl/core/fetch/fetch.sv index 1853ee0..63cb936 100644 --- a/rtl/core/fetch/fetch.sv +++ b/rtl/core/fetch/fetch.sv @@ -23,16 +23,19 @@ module core_fetch ); ptr next_pc, hold_addr, target; - logic fetched_valid, discard; + logic prefetch_ready, fetched_valid, discard, pending, next_pending; + assign fetch = prefetch_ready && !discard; assign flush = branch || prefetch_flush; assign target = wr_pc ? wr_current[31:2] : branch_target; //TODO: alignment exception + assign next_pending = fetch || (pending && !fetched); assign fetched_valid = fetched && !discard; core_prefetch #(.ORDER(PREFETCH_ORDER)) prefetch ( .head(fetch_head), .fetched(fetched_valid), + .fetch(prefetch_ready), .* ); @@ -54,10 +57,12 @@ module core_fetch always_ff @(posedge clk or negedge rst_n) if(!rst_n) begin + pending <= 0; discard <= 0; hold_addr <= 0; end else begin - discard <= discard ? !fetched : flush && fetch; + pending <= next_pending; + discard <= next_pending && (discard || flush); hold_addr <= addr; end |
