Skip to content

Commit

Permalink
[t1rocketemu & dpi] early return in dpi when reset is asserted.
Browse files Browse the repository at this point in the history
Fix t1rocketemu for verialtor.
  • Loading branch information
FanShupei committed Jan 20, 2025
1 parent 8eeb024 commit 114bd62
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions difftest/dpi_t1rocketemu/src/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ unsafe fn write_to_pointer(dst: *mut u8, data: &[u8]) {
dst.copy_from_slice(data);
}

unsafe fn fill_axi_read_payload_zero(dst: *mut SvBitVecVal, dlen: u32) {
let dst = std::slice::from_raw_parts_mut(dst, dlen as usize / 8);
dst.fill(0);
}

unsafe fn fill_axi_read_payload(dst: *mut SvBitVecVal, dlen: u32, payload: &[u8]) {
assert!(payload.len() * 8 <= dlen as usize);
write_to_pointer(dst as *mut u8, payload);
Expand Down Expand Up @@ -65,6 +70,7 @@ unsafe fn load_from_payload(
/// evaluate after AW and W is finished at corresponding channel_id.
#[no_mangle]
unsafe extern "C" fn axi_write_highBandwidthAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
awid: c_longlong,
Expand All @@ -81,6 +87,10 @@ unsafe extern "C" fn axi_write_highBandwidthAXI(
// bit [255:0][DLEN/8:0] strb; } payload
payload: *const SvBitVecVal,
) {
if reset != 0 {
return;
}

debug!(
"axi_write_highBandwidth (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \
awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \
Expand All @@ -101,6 +111,7 @@ unsafe extern "C" fn axi_write_highBandwidthAXI(
/// evaluate at AR fire at corresponding channel_id.
#[no_mangle]
unsafe extern "C" fn axi_read_highBandwidthAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
arid: c_longlong,
Expand All @@ -116,6 +127,12 @@ unsafe extern "C" fn axi_read_highBandwidthAXI(
// struct packed {bit [255:0][DLEN:0] data; byte beats; } payload
payload: *mut SvBitVecVal,
) {
if reset != 0 {
// TODO: zero payload.
// Since payload contains no control signal, safe to omit the clear.
return;
}

debug!(
"axi_read_highBandwidth (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \
arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \
Expand All @@ -136,6 +153,7 @@ unsafe extern "C" fn axi_read_highBandwidthAXI(
/// evaluate after AW and W is finished at corresponding channel_id.
#[no_mangle]
unsafe extern "C" fn axi_write_highOutstandingAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
awid: c_longlong,
Expand All @@ -151,6 +169,10 @@ unsafe extern "C" fn axi_write_highOutstandingAXI(
// struct packed {bit [255:0][31:0] data; bit [255:0][3:0] strb; } payload
payload: *const SvBitVecVal,
) {
if reset != 0 {
return;
}

debug!(
"axi_write_high_outstanding (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \
awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \
Expand All @@ -170,6 +192,7 @@ unsafe extern "C" fn axi_write_highOutstandingAXI(
/// evaluate at AR fire at corresponding channel_id.
#[no_mangle]
unsafe extern "C" fn axi_read_highOutstandingAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
arid: c_longlong,
Expand All @@ -185,6 +208,12 @@ unsafe extern "C" fn axi_read_highOutstandingAXI(
// struct packed {bit [255:0][DLEN:0] data; byte beats; } payload
payload: *mut SvBitVecVal,
) {
if reset != 0 {
// TODO: zero payload.
// Since payload contains no control signal, safe to omit the clear.
return;
}

debug!(
"axi_read_high_outstanding (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \
arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \
Expand All @@ -203,6 +232,7 @@ unsafe extern "C" fn axi_read_highOutstandingAXI(

#[no_mangle]
unsafe extern "C" fn axi_write_loadStoreAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
awid: c_longlong,
Expand All @@ -217,6 +247,10 @@ unsafe extern "C" fn axi_write_loadStoreAXI(
awregion: c_longlong,
payload: *const SvBitVecVal,
) {
if reset != 0 {
return;
}

debug!(
"axi_write_loadStore (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \
awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \
Expand All @@ -237,6 +271,7 @@ unsafe extern "C" fn axi_write_loadStoreAXI(

#[no_mangle]
unsafe extern "C" fn axi_read_loadStoreAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
arid: c_longlong,
Expand All @@ -259,6 +294,12 @@ unsafe extern "C" fn axi_read_loadStoreAXI(
return;
}

if reset != 0 {
// TODO: zero payload.
// Since payload contains no control signal, safe to omit the clear.
return;
}

debug!(
"axi_read_loadStoreAXI (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \
arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \
Expand All @@ -277,6 +318,7 @@ unsafe extern "C" fn axi_read_loadStoreAXI(

#[no_mangle]
unsafe extern "C" fn axi_read_instructionFetchAXI(
reset: i64,
channel_id: c_longlong,
data_width: i64,
arid: c_longlong,
Expand All @@ -299,6 +341,12 @@ unsafe extern "C" fn axi_read_instructionFetchAXI(
return;
}

if reset != 0 {
// TODO: zero payload.
// Since payload contains no control signal, safe to omit the clear.
return;
}

debug!(
"axi_read_instructionFetchAXI (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \
arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \
Expand Down
2 changes: 2 additions & 0 deletions t1rocketemu/src/AXI4SlaveAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class AXI4SlaveAgent(parameter: AXI4SlaveAgentParameter)
RawClockedVoidFunctionCall(s"axi_write_${parameter.name}")(
io.clock,
when.cond && !io.gateWrite,
io.reset.asTypeOf(UInt(64.W)),
io.channelId,
parameter.axiParameter.dataWidth.U(64.W),
// handle AW and W at same beat.
Expand Down Expand Up @@ -198,6 +199,7 @@ class AXI4SlaveAgent(parameter: AXI4SlaveAgentParameter)
)(
io.clock,
!io.gateRead && arFire,
io.reset.asTypeOf(UInt(64.W)),
io.channelId,
parameter.axiParameter.dataWidth.U(64.W),
channel.ARID.asTypeOf(UInt(64.W)),
Expand Down

0 comments on commit 114bd62

Please sign in to comment.