Skip to content

Commit a67eac7

Browse files
committed
2 parents 6be0177 + a46ec48 commit a67eac7

10 files changed

Lines changed: 297 additions & 156 deletions

File tree

src/main/resources/csrc/Cyclotron.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@ void cyclotron_init(const char* elfname) {
3636
cyclotron_init_rs(elfname);
3737
}
3838

39+
void cyclotron_fetch_rs(
40+
uint8_t req_valid,
41+
uint64_t req_bits_tag,
42+
uint32_t req_bits_pc,
43+
uint8_t* resp_valid_ptr,
44+
uint64_t* resp_bits_tag_ptr,
45+
uint64_t* resp_bits_inst_ptr
46+
);
47+
48+
void cyclotron_fetch(
49+
uint8_t req_valid,
50+
uint64_t req_bits_tag,
51+
uint32_t req_bits_pc,
52+
uint8_t* resp_valid_ptr,
53+
uint64_t* resp_bits_tag_ptr,
54+
uint64_t* resp_bits_inst_ptr
55+
) {
56+
cyclotron_fetch_rs(
57+
req_valid,
58+
req_bits_tag,
59+
req_bits_pc,
60+
resp_valid_ptr,
61+
resp_bits_tag_ptr,
62+
resp_bits_inst_ptr
63+
);
64+
}
65+
3966
void cyclotron_frontend_rs(
4067
const uint8_t* ibuf_ready_vec,
4168
uint8_t* ibuf_valid_vec,

src/main/resources/vsrc/Cyclotron.vh

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ import "DPI-C" function void cyclotron_init(input string elffile);
88

99
import "DPI-C" function string vpi_get_binary();
1010

11-
import "DPI-C" function cyclotron_difftest_reg(
12-
input bit trace_sim_tick,
13-
input bit trace_valid,
14-
input int trace_pc,
15-
input int trace_warpId,
16-
input bit trace_regs_0_enable,
17-
input byte trace_regs_0_address,
18-
input int trace_regs_0_data[NUM_LANES],
19-
input bit trace_regs_1_enable,
20-
input byte trace_regs_1_address,
21-
input int trace_regs_1_data[NUM_LANES],
22-
input bit trace_regs_2_enable,
23-
input byte trace_regs_2_address,
24-
input int trace_regs_2_data[NUM_LANES]
25-
);
11+
task automatic cyclotron_init_task();
12+
string elffile;
13+
elffile = vpi_get_binary();
14+
cyclotron_init(elffile);
15+
endtask
2616

2717
import "DPI-C" function void cyclotron_imem(
2818
output bit imem_req_ready,
@@ -38,4 +28,3 @@ import "DPI-C" function void cyclotron_imem(
3828
output byte imem_resp_bits_tag,
3929
output longint imem_resp_bits_data
4030
);
41-

src/main/resources/vsrc/CyclotronBackend.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ module CyclotronBackendBlackBox #(
376376
longint __imem_resp_bits_data;
377377

378378
// initialize model at the rtl sim start
379-
initial begin
380-
cyclotron_init();
381-
end
379+
// use BINARY= argument (i.e. first non-plusarg argument) as the Cyclotron
380+
// ELF
381+
initial cyclotron_init_task();
382382

383383
// TODO: simulate backpressure
384384

src/main/resources/vsrc/CyclotronDiffTest.v

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ module CyclotronDiffTestBlackBox #(
3636
);
3737
`include "Cyclotron.vh"
3838

39+
import "DPI-C" function cyclotron_difftest_reg(
40+
input bit trace_sim_tick,
41+
input bit trace_valid,
42+
input int trace_pc,
43+
input int trace_warpId,
44+
input bit trace_regs_0_enable,
45+
input byte trace_regs_0_address,
46+
input int trace_regs_0_data[NUM_LANES],
47+
input bit trace_regs_1_enable,
48+
input byte trace_regs_1_address,
49+
input int trace_regs_1_data[NUM_LANES],
50+
input bit trace_regs_2_enable,
51+
input byte trace_regs_2_address,
52+
input int trace_regs_2_data[NUM_LANES]
53+
);
54+
3955
// "in": C->verilog, "out": verilog->C
4056
// need to be in ascending order to match with C array memory layout
4157
bit __out_trace_valid;
@@ -53,15 +69,10 @@ module CyclotronDiffTestBlackBox #(
5369

5470
bit __in_finished;
5571

56-
string elffile;
57-
5872
// initialize model at the rtl sim start
5973
// use BINARY= argument (i.e. first non-plusarg argument) as the Cyclotron
6074
// ELF
61-
initial begin
62-
elffile = vpi_get_binary();
63-
cyclotron_init(elffile);
64-
end
75+
initial cyclotron_init_task();
6576

6677
// connect regtrace signals
6778
assign __out_trace_valid = trace_valid;

src/main/resources/vsrc/CyclotronFrontend.v

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,10 @@ module CyclotronFrontendBlackBox #(
102102

103103
bit __in_finished;
104104

105-
string elffile;
106-
107105
// initialize model at the rtl sim start
108106
// use BINARY= argument (i.e. first non-plusarg argument) as the Cyclotron
109107
// ELF
110-
initial begin
111-
elffile = vpi_get_binary();
112-
cyclotron_init(elffile);
113-
end
108+
initial cyclotron_init_task();
114109

115110
always @(negedge clock) begin
116111
cyclotron_imem(

src/main/scala/radiance/muon/LSU.scala

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -762,26 +762,36 @@ class LsuResponse(implicit p: Parameters) extends CoreBundle {
762762
val debugId: Option[UInt] = lsuDerived.debugIdBits.map { bits => UInt(bits.W) }
763763
}
764764

765-
/*
766-
# Downstream memory interface
767-
768-
The LSU Memory Request interface is per-warp with separate data / address / tmask per lane,
769-
but the tag is shared across all lanes.
770-
771-
The core's memory interface is fully per-LSU-lane, with a per-LSU-lane tag as well. Generally, for coalesced requests,
772-
the responses will come back together, but for uncoalesced requests, no such guarantee is made. As such, we
773-
need to support partial writes into the load data staging SRAM, and we need to keep track of which words in a row
774-
are valid, only advancing the state machine to begin writing back once all of them are.
775-
776-
As such, we need to convert from LSU memory request to core memory request, and the LSU Memory Response interface
777-
should support per-LSU-lane valids. We don't need to have a separate tag for each core memory request lane, since
778-
the coalescer treats each lane as a separate client with a separate source id space.
779-
We also need to convert from core memory response to LSU memory response(s). This is done very naively,
780-
by picking the first valid lane on the core side, and filtering only those responses whose tag matches it.
781-
782-
In the future, it may be possible to begin writing back to register files once a packet is ready (or even
783-
individual lanes within a packet), rather than the full warp
784-
*/
765+
// ---------------------------
766+
// Downstream memory interface
767+
// ---------------------------
768+
//
769+
// The LSU Memory Request has a full-warp-wide interface, with a single tag
770+
// shared across all lanes, and with per-lane data / address / tmask.
771+
//
772+
// On the other hand, the core's memory interface is fully per-LSU-lane, with a
773+
// per-LSU-lane tag as well. Generally, for coalesced requests, the responses
774+
// will come back together, but for uncoalesced requests, no such guarantee is
775+
// made.
776+
//
777+
// Because the LSU always expects responses for all per-lane reqs to come back
778+
// at the same time "atomically" as a result of its warp-wide interface, we
779+
// need to support partial writes into the load data staging SRAM, and keep
780+
// track of which words in a row are valid, only advancing the state machine to
781+
// begin writing back once all of them are.
782+
//
783+
// As such, we need to convert from LSU request to core request, and the LSU
784+
// response should be converted from per-LSU-lane core responses. We don't need
785+
// to have a separate tag for each core memory request lane, since the
786+
// coalescer treats each lane as a separate client with a separate source id
787+
// space. Converting from core memory response to LSU memory response(s) is
788+
// done very naively, by picking the first valid lane on the core side, and
789+
// filtering only those responses whose tag matches it.
790+
//
791+
// In the future, it may be possible to begin writing back to register files
792+
// once a packet is ready (or even individual lanes within a packet), rather
793+
// than the full warp.
794+
785795
class LsuMemTag(implicit p: Parameters) extends CoreBundle {
786796
val token = new LsuQueueToken
787797
val packet = UInt(lsuDerived.packetBits.W)

src/main/scala/radiance/muon/MuonTile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class MuonTile(
162162
emits = TLMasterToSlaveTransferSizes(
163163
get = TransferSizes(1, muonParams.core.instBytes)
164164
),
165-
sourceId = IdRange(0, muonParams.core.numWarps * muonParams.core.ibufDepth)
165+
sourceId = IdRange(0, muonParams.core.l0iReqTagBits)
166166
)),
167167
channelBytes = TLChannelBeatBytes(muonParams.core.instBytes),
168168
)))

src/main/scala/radiance/unittest/Configs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class WithMuonLSUDebugIds(width: Int) extends Config((_, _, _) => {
2727
case MuonLoadStoreUnitDebugIdKey => Some(width)
2828
})
2929

30-
class MuonTestConfig extends Config(
31-
new WithMuonUnitTestHarness(new MuonTest()(_)) ++
30+
class MuonCoreTestConfig extends Config(
31+
new WithMuonUnitTestHarness(new MuonCoreTest()(_)) ++
3232
new WithMuonCores(1, headless = true) ++
3333
new WithSIMTConfig(numWarps = 8, numLanes = 16, numLsuLanes = 16, numSMEMInFlights = 4) ++
3434
new BaseSubsystemConfig)

0 commit comments

Comments
 (0)