Skip to content

Commit

Permalink
[Insitu-Cache] Connect Snitch to use L1D$ when accessing L2. Change t…
Browse files Browse the repository at this point in the history
…he common.ld.in to only puts data section to L2.
  • Loading branch information
DiyouS committed Jan 13, 2025
1 parent bd80b30 commit 7b07fb2
Show file tree
Hide file tree
Showing 15 changed files with 4,926 additions and 146 deletions.
35 changes: 22 additions & 13 deletions hw/ip/spatz_cc/src/spatz_cc.sv
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ module spatz_cc
parameter fpu_implementation_t FPUImplementation = fpu_implementation_t'(0),

Check warning on line 53 in hw/ip/spatz_cc/src/spatz_cc.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/ip/spatz_cc/src/spatz_cc.sv#L53

Line length exceeds max: 100; is: 111 [Style: line-length] [line-length]
Raw output
message:"Line length exceeds max: 100; is: 111 [Style: line-length] [line-length]"  location:{path:"hw/ip/spatz_cc/src/spatz_cc.sv"  range:{start:{line:53  column:101}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}
/// Boot address of core.
parameter logic [31:0] BootAddr = 32'h0000_1000,

/// Address to indicate start of L2
parameter logic [AddrWidth-1:0] L2Addr = 48'h0000_5180_0000,

Check warning on line 58 in hw/ip/spatz_cc/src/spatz_cc.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/ip/spatz_cc/src/spatz_cc.sv#L58

Line length exceeds max: 100; is: 103 [Style: line-length] [line-length]
Raw output
message:"Line length exceeds max: 100; is: 103 [Style: line-length] [line-length]"  location:{path:"hw/ip/spatz_cc/src/spatz_cc.sv"  range:{start:{line:58  column:101}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}
parameter logic [AddrWidth-1:0] L2Size = 48'h0000_0080_0000,

Check warning on line 59 in hw/ip/spatz_cc/src/spatz_cc.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/ip/spatz_cc/src/spatz_cc.sv#L59

Line length exceeds max: 100; is: 103 [Style: line-length] [line-length]
Raw output
message:"Line length exceeds max: 100; is: 103 [Style: line-length] [line-length]"  location:{path:"hw/ip/spatz_cc/src/spatz_cc.sv"  range:{start:{line:59  column:101}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}
/// Reduced-register extension
parameter bit RVE = 0,
/// Enable F and D Extension
Expand Down Expand Up @@ -420,19 +424,18 @@ module spatz_cc
// Decide whether to go to SoC or TCDM
dreq_t data_tcdm_req;
drsp_t data_tcdm_rsp;
dreq_t data_spm_req;
drsp_t data_spm_rsp;
dreq_t data_soc_req;
drsp_t data_soc_rsp;
dreq_t data_l1_req;
drsp_t data_l1_rsp;
logic [3:0] data_soc_req_id, data_soc_rsp_id;
logic data_soc_push, data_soc_pop;
logic data_soc_full, data_soc_empty;

localparam int unsigned SelectWidth = cf_math_pkg::idx_width(2);
localparam int unsigned SelectWidth = cf_math_pkg::idx_width(3);
typedef logic [SelectWidth-1:0] select_t;
select_t slave_select;
// Combine if the a request is targetting at SPM or L2
logic cache_select;
assign cache_select = (slave_select == 0) ? 0 : 1;

// Since we are now using cache, the fpu_sequencer should not
// bypass the L1D cache.
Expand All @@ -445,7 +448,7 @@ module spatz_cc
) i_reqrsp_demux (
.clk_i (clk_i ),
.rst_ni (rst_ni ),
.slv_select_i (slave_select ),
.slv_select_i (cache_select ),
.slv_req_i (snitch_dreq_q ),
.slv_rsp_o (snitch_drsp_q ),
.mst_req_o ({data_tcdm_req, data_soc_req}),
Expand Down Expand Up @@ -519,19 +522,25 @@ module spatz_cc
logic [AddrWidth-1:0] mask;
} reqrsp_rule_t;

reqrsp_rule_t addr_map;
logic [AddrWidth-1:0] l2_addr_start, l2_addr_end;
assign l2_addr_start = 48'h0000_8000_0000;
assign l2_addr_end = 48'h0000_1000_0000;
assign addr_map = '{
reqrsp_rule_t [1:0] addr_map;
logic [AddrWidth-1:0] l2_addr_start, l2_addr_mask;
assign l2_addr_start = L2Addr;
assign l2_addr_mask = ~(L2Size-1);
assign addr_map[0] = '{
idx : 1,
base: tcdm_addr_base_i,
mask: ({AddrWidth{1'b1}} << TCDMAddrWidth)
};

assign addr_map[1] = '{
idx : 2,
base: l2_addr_start,
mask: l2_addr_mask
};

addr_decode_napot #(
.NoIndices (2 ),
.NoRules (1 ),
.NoIndices (3 ),
.NoRules (2 ),
.addr_t (logic [AddrWidth-1:0]),
.rule_t (reqrsp_rule_t )
) i_addr_decode_napot (
Expand Down
2 changes: 2 additions & 0 deletions hw/system/spatz_cluster/src/spatz_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,8 @@ module spatz_cluster

spatz_cc #(
.BootAddr (BootAddr ),
.L2Addr (L2Addr ),
.L2Size (L2Size ),
.RVE (1'b0 ),
.RVF (RVF ),
.RVD (RVD ),
Expand Down
8 changes: 4 additions & 4 deletions sw/snRuntime/link/common.ld.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ENTRY(_start)

MEMORY
{
/* DRAM (rwxa) : ORIGIN = @MEM_DRAM_ORIGIN@, LENGTH = @MEM_DRAM_SIZE@ */
DRAM (rwxa) : ORIGIN = @L2_ORIGIN@, LENGTH = @L2_SIZE@
DRAM (rwxa) : ORIGIN = @MEM_DRAM_ORIGIN@, LENGTH = @MEM_DRAM_SIZE@
L2 (rwxa) : ORIGIN = @L2_ORIGIN@, LENGTH = @L2_SIZE@
}

SECTIONS
Expand Down Expand Up @@ -67,14 +67,14 @@ SECTIONS
*(.sdata .sdata.* .gnu.linkonce.s.*)
} >DRAM

/* Initialized data sections goes into DRAM */
/* Initialized data sections goes into L2 */
.data :
{
. = ALIGN(1024);
__DATA_BEGIN__ = .;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
} >DRAM
} >L2
_edata = .; PROVIDE (edata = .);

/* small bss section */
Expand Down
4 changes: 4 additions & 0 deletions sw/snRuntime/src/platforms/standalone/putchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ void snrt_putchar(char character) {
buf->hdr.syscall_mem[2] = (uintptr_t)&buf->data; // buffer
buf->hdr.syscall_mem[3] = buf->hdr.size; // length

volatile uint32_t *busy = 1000;
while (*busy){};

tohost = (uintptr_t)buf->hdr.syscall_mem;
while (fromhost == 0)
;
fromhost = 0;

buf->hdr.size = 0;
}

}
1 change: 1 addition & 0 deletions sw/snRuntime/src/platforms/standalone/start_snitch.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ _snrt_exit:
la t1, tohost
sw t0, 0(t1)
call l1d_flush
call set_eoc
1: ret

# HTIF sections
Expand Down
3 changes: 2 additions & 1 deletion sw/spatzBenchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ add_spatz_test_twoParam(sp-fft sp-fft/main.c 512 2)

add_spatz_test_threeParam(dp-mxfmatmul dp-mxfmatmul/main.c 64 64 64)

add_spatz_test_oneParam(linked-list linked-list/main.c 64)
add_spatz_test_twoParam(linked-list linked-list/main.c 64 8)
add_spatz_test_twoParam(linked-list linked-list/main.c 256 16)

# Tests for DATE
# Vanilla fmatmul
Expand Down
Loading

0 comments on commit 7b07fb2

Please sign in to comment.