diff --git a/t1rocketemu/online_dpi/src/dpi.rs b/t1rocketemu/online_dpi/src/dpi.rs index 632c96a304..c04be53481 100644 --- a/t1rocketemu/online_dpi/src/dpi.rs +++ b/t1rocketemu/online_dpi/src/dpi.rs @@ -37,26 +37,27 @@ unsafe fn fill_axi_read_payload(dst: *mut SvBitVecVal, dlen: u32, payload: &AxiR unsafe fn load_from_payload( payload: &*const SvBitVecVal, data_width: usize, - dlen: usize, + size: usize, ) -> (Vec, &[u8]) { let src = *payload as *mut u8; - let data_width_in_byte = dlen / 8; - let strb_width_in_byte = dlen / data_width; + let data_width_in_byte = size; + let strb_width_per_byte = if data_width < 64 { 4 } else { 8 }; + let strb_width_in_byte = size / strb_width_per_byte; + let payload_size_in_byte = strb_width_in_byte + data_width_in_byte; // data width in byte let byte_vec = std::slice::from_raw_parts(src, payload_size_in_byte); let strobe = &byte_vec[0..strb_width_in_byte]; let data = &byte_vec[strb_width_in_byte..]; - let strb_width_in_bit = data_width / 8; let masks: Vec = strobe .into_iter() .flat_map(|strb| { - let mask: Vec = (0..strb_width_in_bit).map(|i| (strb & (1 << i)) != 0).collect(); + let mask: Vec = (0..strb_width_per_byte).map(|i| (strb & (1 << i)) != 0).collect(); mask }) .collect(); - assert!( - masks.len() == data.len(), + assert_eq!( + masks.len(), data.len(), "strobe bit width is not aligned with data byte width" ); @@ -99,8 +100,7 @@ unsafe extern "C" fn axi_write_highBandwidthAXI( ); let mut driver = DPI_TARGET.lock().unwrap(); let driver = driver.as_mut().unwrap(); - let data_width = 32; // TODO: get from driver - let (strobe, data) = load_from_payload(&payload, 32, driver.dlen as usize); + let (strobe, data) = load_from_payload(&payload, driver.dlen as usize, (1 << awsize) as usize); driver.axi_write_high_bandwidth(awaddr as u32, awsize as u64, &strobe, data); } @@ -156,8 +156,7 @@ unsafe extern "C" fn axi_write_highOutstandingAXI( ); let mut driver = DPI_TARGET.lock().unwrap(); let driver = driver.as_mut().unwrap(); - let data_width = 32; // TODO: get from driver - let (strobe, data) = load_from_payload(&payload, data_width, 32); + let (strobe, data) = load_from_payload(&payload, 32, (1 << awsize) as usize); driver.axi_write_high_outstanding(awaddr as u32, awsize as u64, &strobe, data); } @@ -211,8 +210,8 @@ unsafe extern "C" fn axi_write_loadStoreAXI( ); let mut driver = DPI_TARGET.lock().unwrap(); let driver = driver.as_mut().unwrap(); - let data_width = 32; // TODO: get from sim - let (strobe, data) = load_from_payload(&payload, data_width, driver.dlen as usize); + let data_width = if awsize <= 2 { 32 } else { 8 * (1 << awsize) } as usize; + let (strobe, data) = load_from_payload(&payload, data_width, (driver.dlen / 8) as usize); driver.axi_write_load_store(awaddr as u32, awsize as u64, &strobe, data); } diff --git a/t1rocketemu/perf.txt b/t1rocketemu/perf.txt new file mode 100644 index 0000000000..7ad90e47e1 --- /dev/null +++ b/t1rocketemu/perf.txt @@ -0,0 +1 @@ +total_cycles: 516110 \ No newline at end of file