From 66b017c15adcfabe590dbd101d4c73c22aa73307 Mon Sep 17 00:00:00 2001 From: Kai Berszin Date: Fri, 5 Dec 2025 14:11:50 +0100 Subject: [PATCH] sw: Enable cluster IRQ for clint --- .../spatz_cluster/src/generated/bootrom.sv | 49 +++++++++-- .../src/generated/spatz_cluster_wrapper.sv | 81 +++++++++--------- hw/system/spatz_cluster/test/bootrom.S | 5 ++ hw/system/spatz_cluster/test/bootrom.bin | Bin 276 -> 292 bytes hw/system/spatz_cluster/test/bootrom.dump | 67 +++++++++------ hw/system/spatz_cluster/test/bootrom.elf | Bin 5320 -> 5336 bytes 6 files changed, 127 insertions(+), 75 deletions(-) diff --git a/hw/system/spatz_cluster/src/generated/bootrom.sv b/hw/system/spatz_cluster/src/generated/bootrom.sv index e1bbfa02..ff24a453 100644 --- a/hw/system/spatz_cluster/src/generated/bootrom.sv +++ b/hw/system/spatz_cluster/src/generated/bootrom.sv @@ -8,29 +8,62 @@ module bootrom #( /* Automatically generated. DO NOT CHANGE! */ - parameter int unsigned DataWidth = 512, - parameter int unsigned AddrWidth = 32 + parameter int unsigned DataWidth = 64, + parameter int unsigned AddrWidth = 48 ) ( input logic clk_i, input logic req_i, input logic [AddrWidth-1:0] addr_i, output logic [DataWidth-1:0] rdata_o ); - localparam int RomSize = 4; + localparam int RomSize = 37; localparam int AddrBits = RomSize > 1 ? $clog2(RomSize) : 1; const logic [RomSize-1:0][DataWidth-1:0] mem = { - 512'h000000000000000000000000000200000000000000100000000000000000000000000000000000020000000000001000ffdff06f10500073000380670003a383, - 512'h000383930583839301c383b30205ae030185a3831050007330461073008666133040267330431073800303130000133704858593000005973053107304c30313, - 512'h0000031700000f9300000f1300000e9300000e1300000d9300000d1300000c9300000c1300000b9300000b1300000a9300000a13000009930000091300000893, - 512'h00000813000007930000071300000693000006130000059300000513000004930000041300000393000003130000029300000213000001930000011300000093 + 64'h00000000000010d8, + 64'h0000000080000000, + 64'h0000000070000000, + 64'h0000000000000000, + 64'h0000000000020000, + 64'h0000000020000000, + 64'h0000000000000001, + 64'h0000000000000002, + 64'h0000000000001000, + 64'hffdff06f10500073, + 64'h000380670003a383, + 64'h0003839305838393, + 64'h01c383b30205ae03, + 64'h0185a38310500073, + 64'h3046107300666633, + 64'h0008033730402673, + 64'h3046107300866613, + 64'h3040267330431073, + 64'h8003031300001337, + 64'h0585859300000597, + 64'h3053107305c30313, + 64'h0000031700000f93, + 64'h00000f1300000e93, + 64'h00000e1300000d93, + 64'h00000d1300000c93, + 64'h00000c1300000b93, + 64'h00000b1300000a93, + 64'h00000a1300000993, + 64'h0000091300000893, + 64'h0000081300000793, + 64'h0000071300000693, + 64'h0000061300000593, + 64'h0000051300000493, + 64'h0000041300000393, + 64'h0000031300000293, + 64'h0000021300000193, + 64'h0000011300000093 }; logic [AddrBits-1:0] addr_q; always_ff @(posedge clk_i) begin if (req_i) begin - addr_q <= addr_i[AddrBits-1+6:6]; + addr_q <= addr_i[AddrBits-1+3:3]; end end diff --git a/hw/system/spatz_cluster/src/generated/spatz_cluster_wrapper.sv b/hw/system/spatz_cluster/src/generated/spatz_cluster_wrapper.sv index 772a21d3..6c44ff0b 100644 --- a/hw/system/spatz_cluster/src/generated/spatz_cluster_wrapper.sv +++ b/hw/system/spatz_cluster/src/generated/spatz_cluster_wrapper.sv @@ -18,16 +18,16 @@ package spatz_cluster_pkg; /////////// // AXI Data Width - localparam int unsigned SpatzAxiDataWidth = 512; + localparam int unsigned SpatzAxiDataWidth = 64; localparam int unsigned SpatzAxiStrbWidth = SpatzAxiDataWidth / 8; // AXI Address Width - localparam int unsigned SpatzAxiAddrWidth = 32; + localparam int unsigned SpatzAxiAddrWidth = 48; // AXI ID Width - localparam int unsigned SpatzAxiIdInWidth = 2; - localparam int unsigned SpatzAxiIdOutWidth = 4; + localparam int unsigned SpatzAxiIdInWidth = 6; + localparam int unsigned SpatzAxiIdOutWidth = 2; // AXI User Width - localparam int unsigned SpatzAxiUserWidth = 2; + localparam int unsigned SpatzAxiUserWidth = 10; typedef logic [SpatzAxiDataWidth-1:0] axi_data_t; typedef logic [SpatzAxiStrbWidth-1:0] axi_strb_t; @@ -50,21 +50,21 @@ package spatz_cluster_pkg; localparam int unsigned BeWidth = DataWidth / 8; localparam int unsigned ByteOffset = $clog2(BeWidth); - localparam int unsigned ICacheLineWidth = 256; - localparam int unsigned ICacheLineCount = 64; + localparam int unsigned ICacheLineWidth = 128; + localparam int unsigned ICacheLineCount = 128; localparam int unsigned ICacheWays = 2; - localparam int unsigned TCDMStartAddr = 32'h100000; - localparam int unsigned TCDMSize = 32'h20000; + localparam int unsigned TCDMStartAddr = 48'h20000000; + localparam int unsigned TCDMSize = 48'h20000; localparam int unsigned PeriStartAddr = TCDMStartAddr + TCDMSize; - localparam int unsigned BootAddr = 32'h1000; + localparam int unsigned BootAddr = 48'h1000; function automatic snitch_pma_pkg::rule_t [snitch_pma_pkg::NrMaxRules-1:0] get_cached_regions(); automatic snitch_pma_pkg::rule_t [snitch_pma_pkg::NrMaxRules-1:0] cached_regions; cached_regions = '{default: '0}; - cached_regions[0] = '{base: 32'h80000000, mask: 32'h80000000}; + cached_regions[0] = '{base: 48'h70000000, mask: 48'hfffff0000000}; return cached_regions; endfunction @@ -78,11 +78,11 @@ package spatz_cluster_pkg; '{ PipeRegs: // FMA Block '{ - '{ 1, // FP32 - 2, // FP64 - 0, // FP16 + '{ 2, // FP32 + 4, // FP64 + 1, // FP16 0, // FP8 - 0, // FP16alt + 1, // FP16alt 0 // FP8alt }, '{1, 1, 1, 1, 1, 1}, // DIVSQRT @@ -98,12 +98,12 @@ package spatz_cluster_pkg; 2, 2, 2}, // CONV - '{2, - 2, - 2, - 2, - 2, - 2} // DOTP + '{4, + 4, + 4, + 4, + 4, + 4} // DOTP }, UnitTypes: '{'{fpnew_pkg::MERGED, fpnew_pkg::MERGED, @@ -140,11 +140,11 @@ package spatz_cluster_pkg; '{ PipeRegs: // FMA Block '{ - '{ 1, // FP32 - 2, // FP64 - 0, // FP16 + '{ 2, // FP32 + 4, // FP64 + 1, // FP16 0, // FP8 - 0, // FP16alt + 1, // FP16alt 0 // FP8alt }, '{1, 1, 1, 1, 1, 1}, // DIVSQRT @@ -160,12 +160,12 @@ package spatz_cluster_pkg; 2, 2, 2}, // CONV - '{2, - 2, - 2, - 2, - 2, - 2} // DOTP + '{4, + 4, + 4, + 4, + 4, + 4} // DOTP }, UnitTypes: '{'{fpnew_pkg::MERGED, fpnew_pkg::MERGED, @@ -229,6 +229,9 @@ module spatz_cluster_wrapper input logic [NumCores-1:0] meip_i, input logic [NumCores-1:0] mtip_i, input logic [NumCores-1:0] msip_i, + input logic [9:0] hart_base_id_i, + input logic [AxiAddrWidth-1:0] cluster_base_addr_i, + input logic [AxiUserWidth-1:0] axi_core_default_user_i, output logic cluster_probe_o, input axi_in_req_t axi_in_req_i, output axi_in_resp_t axi_in_resp_o, @@ -286,8 +289,8 @@ module spatz_cluster_wrapper .BootAddr (32'h1000), .ClusterPeriphSize (64), .NrCores (2), - .TCDMDepth (1024), - .NrBanks (16), + .TCDMDepth (512), + .NrBanks (32), .ICacheLineWidth (spatz_cluster_pkg::ICacheLineWidth), .ICacheLineCount (spatz_cluster_pkg::ICacheLineCount), .ICacheWays (spatz_cluster_pkg::ICacheWays), @@ -303,12 +306,12 @@ module spatz_cluster_wrapper .axi_out_req_t (spatz_axi_iwc_out_req_t), .axi_out_resp_t (spatz_axi_iwc_out_resp_t), .Xdma (2'b01), - .DMAAxiReqFifoDepth (3), - .DMAReqFifoDepth (3), + .DMAAxiReqFifoDepth (24), + .DMAReqFifoDepth (8), .RegisterOffloadRsp (1), .RegisterCoreReq (1), .RegisterCoreRsp (1), - .RegisterTCDMCuts (0), + .RegisterTCDMCuts (1), .RegisterExt (0), .XbarLatency (axi_pkg::CUT_ALL_PORTS), .MaxMstTrans (4), @@ -320,9 +323,9 @@ module spatz_cluster_wrapper .meip_i, .mtip_i, .msip_i, - .hart_base_id_i (10'h0), - .cluster_base_addr_i (32'h100000), - .axi_core_default_user_i (2'h1), + .hart_base_id_i, + .cluster_base_addr_i, + .axi_core_default_user_i, .cluster_probe_o, .axi_in_req_i, .axi_in_resp_o, diff --git a/hw/system/spatz_cluster/test/bootrom.S b/hw/system/spatz_cluster/test/bootrom.S index 1ec3ded1..a1618ec9 100644 --- a/hw/system/spatz_cluster/test/bootrom.S +++ b/hw/system/spatz_cluster/test/bootrom.S @@ -53,6 +53,11 @@ _start: csrr a2, mie ori a2, a2, 0x8 csrw mie, a2 + // Activate MCIP + csrr a2, mie + li t1, 0x80000 + or a2, a2, t1 + csrw mie, a2 // Wait for the wakeup interrupt wfi diff --git a/hw/system/spatz_cluster/test/bootrom.bin b/hw/system/spatz_cluster/test/bootrom.bin index b81b5f92db61a87d5cf0d5d4f16cb344bafdb77c..d9b3d8f3c176803b030fc45298d331462c6bb6cd 100755 GIT binary patch delta 90 zcmbQjw1jCwGcRkgK(N7dRtAR2t*xvRCrEOsIT)BTb1)dErA=IHYr@C?2MQ1t6I=kw OD1g!pAo_*?0|Nj6X$)Zi delta 79 zcmZ3&G=*tGGcQZAK(N7dRtAR2t*tB*CrD1*X>P&*2LezQ6I=w!Xn+YY0vRWO$^btI B3H|^8 diff --git a/hw/system/spatz_cluster/test/bootrom.dump b/hw/system/spatz_cluster/test/bootrom.dump index 0a6e98b1..6c7823a8 100644 --- a/hw/system/spatz_cluster/test/bootrom.dump +++ b/hw/system/spatz_cluster/test/bootrom.dump @@ -37,54 +37,65 @@ Disassembly of section .text: 1074: 00000f13 li t5,0 1078: 00000f93 li t6,0 107c: 00000317 auipc t1,0x0 - 1080: 04c30313 addi t1,t1,76 # 10c8 + 1080: 05c30313 addi t1,t1,92 # 10d8 1084: 30531073 csrw mtvec,t1 1088: 00000597 auipc a1,0x0 - 108c: 04858593 addi a1,a1,72 # 10d0 + 108c: 05858593 addi a1,a1,88 # 10e0 1090: 00001337 lui t1,0x1 1094: 80030313 addi t1,t1,-2048 # 800 <_start-0x800> 1098: 30431073 csrw 0x304,t1 109c: 30402673 csrr a2,0x304 10a0: 00866613 ori a2,a2,8 10a4: 30461073 csrw 0x304,a2 - 10a8: 10500073 wfi - 10ac: 0185a383 lw t2,24(a1) - 10b0: 0205ae03 lw t3,32(a1) - 10b4: 01c383b3 add t2,t2,t3 - 10b8: 05838393 addi t2,t2,88 - 10bc: 00038393 mv t2,t2 - 10c0: 0003a383 lw t2,0(t2) - 10c4: 00038067 jr t2 + 10a8: 30402673 csrr a2,0x304 + 10ac: 00080337 lui t1,0x80 + 10b0: 00666633 or a2,a2,t1 + 10b4: 30461073 csrw 0x304,a2 + 10b8: 10500073 wfi + 10bc: 0185a383 lw t2,24(a1) + 10c0: 0205ae03 lw t3,32(a1) + 10c4: 01c383b3 add t2,t2,t3 + 10c8: 05838393 addi t2,t2,88 + 10cc: 00038393 mv t2,t2 + 10d0: 0003a383 lw t2,0(t2) + 10d4: 00038067 jr t2 -000010c8 : - 10c8: 10500073 wfi - 10cc: ffdff06f j 10c8 +000010d8 : + 10d8: 10500073 wfi + 10dc: ffdff06f j 10d8 Disassembly of section .rodata: -000010d0 : - 10d0: 1000 addi s0,sp,32 - 10d2: 0000 unimp - 10d4: 0000 unimp - 10d6: 0000 unimp - 10d8: 0002 0x2 - ... - 10ea: 0010 addi a2,sp,0 +000010e0 : + 10e0: 1000 addi s0,sp,32 + 10e2: 0000 unimp + 10e4: 0000 unimp + 10e6: 0000 unimp + 10e8: 0002 0x2 + 10ea: 0000 unimp 10ec: 0000 unimp 10ee: 0000 unimp - 10f0: 0000 unimp - 10f2: 0002 0x2 + 10f0: 0001 nop ... + 10fa: 2000 fld fs0,0(s0) + 10fc: 0000 unimp + 10fe: 0000 unimp 1100: 0000 unimp - 1102: 8000 0x8000 + 1102: 0002 0x2 ... - 110c: 0001 nop + 1110: 0000 unimp + 1112: 7000 flw fs0,32(s0) + 1114: 0000 unimp + 1116: 0000 unimp + 1118: 0000 unimp + 111a: 8000 0x8000 + 111c: 0000 unimp ... Disassembly of section .boot_section: -00001110 : - 1110: 10c8 addi a0,sp,100 +00001120 : + 1120: 10d8 addi a4,sp,100 ... Disassembly of section .Pulp_Chip.Info: @@ -101,7 +112,7 @@ Disassembly of section .Pulp_Chip.Info: 10: 495f 666e 006f 0x6f666e495f 16: 70696863 bltu s2,t1,726 <_start-0x8da> 1a: 6e3d lui t3,0xf - 1c: 20656e6f jal t3,56222 + 1c: 20656e6f jal t3,56222 20: 3d757063 bleu s7,a0,3e0 <_start-0xc20> 24: 6f6e flw ft10,216(sp) 26: 656e flw fa0,216(sp) diff --git a/hw/system/spatz_cluster/test/bootrom.elf b/hw/system/spatz_cluster/test/bootrom.elf index 221918581a230b75be0611e500dc8cb6f2c90674..17348b033c4dc62eb7316df76f700b14a3aca7d2 100755 GIT binary patch delta 226 zcmX@1c|&u80%O5MMP*hMMg|6zjh)e4h03fc?afQm9OFfu3t z6(~$*6v}6OFu71jna$rnHJ~te^DH4IMxe-CVR=@N84o5O6jo+c5Co}xDXh+@GFebW aov~=LC6MfyoCqZ6Ozs4dvXeK8hyws?gewOC delta 202 zcmcbic|vo70%O8NMP*hIMg|6vjh4Jg^ z3``7YpaI4Q>Sj1GSy8ZG@PYtDj2Wt0VDdphd%+V>Q3eJ^21TF(fyshG`HUAPHwr1U zIahjwXH;xnCB(!C6j>`Q&k8c*!sLs>%B%u{Ahkb*)fq)5D~hNyCQbGPk~NbHfn?9* MnLv_v@<9=C09<`3i2wiq