Skip to content

Commit

Permalink
added sketch of line refilling fsm
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjessee committed Apr 7, 2024
1 parent fbd27cb commit 0175beb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
48 changes: 42 additions & 6 deletions rtl/letc/core/letc_core_cache.sv
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ end
//The refilling FSM is the only thing that needs to write to the SRAM, and
//the stage using the cache only needs to read it! (with tag comparison also being snooped by the
//refilling FSM)
//TODO need to expose byte enables to make things simpler for us
logic cache_line_wen;
index_t cache_write_index;
cache_line_s cache_line_to_write, cache_line_to_read;
logic cache_line_wen;
index_t cache_write_index;
logic [WORD_WIDTH:0] cache_line_wben;
cache_line_s cache_line_to_write, cache_line_to_read;
amd_lutram #(
.DEPTH (CACHE_DEPTH),
.BWIDTH(WORD_WIDTH),
Expand All @@ -99,7 +99,7 @@ amd_lutram #(
.i_wclk(i_clk),
.i_wen(cache_line_wen),
.i_waddr(cache_write_index),
.i_wben('1),//TODO
.i_wben(cache_line_wben),
.i_wdata(cache_line_to_write),

.i_raddr(stage_index),
Expand All @@ -119,6 +119,8 @@ always_ff @(posedge i_clk) begin
//for cache coherency for example, the only time a cache line can
//become valid is when we write to it; and then it can never become invalid
//again until the cache is flushed!
//when a line is evicted, the line that took its place is also
//valid.
cache_line_valid[cache_write_index] <= 1'b1;
end
end
Expand Down Expand Up @@ -159,7 +161,41 @@ end
* Line Refilling FSM and Write Logic
* --------------------------------------------------------------------------------------------- */

//TODO
//TODO implement this
//------fsm pseudocode--------//
//state 1: idle.
// if request:
// next_state = compare tag
// else:
// next_state = idle
//state 2: compare tag.
// (address splitting exposes correct cache line)
// (hit logic compares tag)
// if hit:
// stage_limp.ready = 1
// next_state = idle
// else:
// axi_fsm_limp.addr = stage_limp.addr //does this need to be flopped?
// axi_fsm_limp.valid = 1
// cache_line_wben = 1
// next_state = refill
//state 3: refill 1
// if axi_fsm_limp.ready:
// cache_line_wen = 1
// next_state = refill 2
// else:
// next_state = refill 1
//state 4: refill 2
// cache_line_wen = 0
// cache_line_wben <<= 1 //how to ensure a shift register is inferred?
// axi_fsm_limp.addr += 4
// next_state = refill 3
//state 5: refill 3
// if cache_line_wben == (1<<WORD_WIDTH): //should be a constant compare
// stage_limp.ready = 1
// next_state = idle
// else
// next_state = refill 1

always_comb begin
cache_line_to_write.tag = stage_tag_compare_value;
Expand Down
2 changes: 1 addition & 1 deletion rtl/letc/core/letc_core_limp_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ paddr_t addr;
word_t rdata;
word_t wdata;
//TODO fault signal if unaligned, AXI errors, etc

//TODO bypass signal for direct memory access from stage
/* ------------------------------------------------------------------------------------------------
* Modports
* --------------------------------------------------------------------------------------------- */
Expand Down

0 comments on commit 0175beb

Please sign in to comment.