diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2d36cb7fb..08a40d68e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -53,11 +53,6 @@ jobs: warnOnFileChanged "* Cargo format fail, please run 'cd difftest; cargo -- format'" popd - pushd t1rocketemu - nix shell '.#cargo' '.#rustfmt' -c cargo fmt - warnOnFileChanged "* Cargo format fail, please run 'cd t1rocketemu; cargo fmt'" - popd - # Disable for now # if nix run '.#ripgrep' -- '\p{Script=Han}' t1 > zh-hans.txt; then # RET=1 diff --git a/README.md b/README.md index 943dbc423..4b6884e0c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ T1 supports standard `Zve32f` and `Zve32x`, and `VLEN`/`DLEN` can be increased u T1 ships important vector machine features, e.g., lanes, chaining, and large LSU outstanding by default, but it can also be a general platform for MMIO DSA(Domain-Specific-Accelerators). -T1 is designed with [Chisel](https://github.com/chipsalliance/chisel) and releasing `IPEmulator` to users. +T1 is designed with [Chisel](https://github.com/chipsalliance/chisel) and releasing `T1Emulator` to users. T1 uses a forked version of the Rocket Core as the scalar part of T1. But we don't officially support it for now; it can be replaced by any other RISC-V Scalar CPU. @@ -58,11 +58,11 @@ For tuning the ideal vector machines, follow these performance-tuning methodolog - Matching bandwidth for VRF, VFU, and LSU. - Based on your workload, determine the required VLEN as it dictates the VRF memory area. - Choose the memory type for the VRF, which will determine the chip frequency. -- Run the IPEmulator and PnR for your workloads to tune micro-architecture. +- Run the T1Emulator and PnR for your workloads to tune micro-architecture. ## Development Guide -We have a IP emulator under the directory `./ipemu`. [Spike](https://github.com/riscv/riscv-isa-sim) is used as the reference scalar core, integrated with the verilated vector IP. Under the online differential-test strategy, the emulator compares the load/store and VRF writes between Spike and T1 to verify T1’s correctness. +We have a IP emulator under the directory `./t1emu`. [Spike](https://github.com/riscv/riscv-isa-sim) is used as the reference scalar core, integrated with the verilated vector IP. Under the online differential-test strategy, the emulator compares the load/store and VRF writes between Spike and T1 to verify T1’s correctness. ### Docker images @@ -248,7 +248,7 @@ $ mill -i elaborator # build and run elaborator #### Developing DPI ```shell $ nix develop .#t1..ip.vcs-dpi-lib # replace with your configuration name -$ cd ipemu/csrc +$ cd t1emu/csrc $ cargo build --feature dpicommon/vcs ``` diff --git a/build.sc b/build.sc index 6a576625a..18db1ccc3 100644 --- a/build.sc +++ b/build.sc @@ -137,9 +137,9 @@ trait T1Rocket extends millbuild.common.T1RocketModule with ScalafmtModule { def chiselIvy = None } -object ipemu extends IPEmulator +object t1emu extends T1Emulator -trait IPEmulator extends millbuild.common.IPEmulatorModule { +trait T1Emulator extends millbuild.common.T1EmulatorModule { def scalaVersion = T(v.scala) def t1Module = t1 @@ -197,7 +197,7 @@ trait Elaborator extends millbuild.common.ElaboratorModule { def generators = Seq( t1, - ipemu, + t1emu, rocketv, rocketemu, t1rocket, @@ -256,7 +256,7 @@ trait OMReader extends millbuild.common.OMReaderModule { */ object t1package extends ScalaModule { def scalaVersion = T(v.scala) - def moduleDeps = super.moduleDeps ++ Seq(t1, ipemu, panamaconverter, omreaderlib) + def moduleDeps = super.moduleDeps ++ Seq(t1, t1emu, panamaconverter, omreaderlib) override def sourceJar: T[PathRef] = T( Jvm.createJar( T.traverse(transitiveModuleDeps)(dep => T.sequence(Seq(dep.allSources, dep.resources, dep.compileResources)))() diff --git a/common.sc b/common.sc index 0f39a2376..7b4089ec4 100644 --- a/common.sc +++ b/common.sc @@ -104,7 +104,7 @@ trait EmuHelperModule extends ScalaModule with HasChisel -trait IPEmulatorModule +trait T1EmulatorModule extends ScalaModule with HasChisel { def t1Module: ScalaModule diff --git a/difftest/Cargo.lock b/difftest/Cargo.lock index a6e2dc63c..14b0f1a16 100644 --- a/difftest/Cargo.lock +++ b/difftest/Cargo.lock @@ -124,17 +124,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "common" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "spike_rs", - "tracing", - "tracing-subscriber", -] - [[package]] name = "dpi_common" version = "0.1.0" @@ -280,12 +269,27 @@ dependencies = [ ] [[package]] -name = "offline" +name = "offline_t1" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "libloading", + "num-bigint", + "serde", + "serde_json", + "spike_rs", + "tracing", + "tracing-subscriber", + "xmas-elf", +] + +[[package]] +name = "offline_t1rocket" version = "0.1.0" dependencies = [ "anyhow", "clap", - "common", "libloading", "num-bigint", "serde", @@ -433,8 +437,10 @@ name = "spike_rs" version = "0.1.0" dependencies = [ "anyhow", + "clap", "libc", "tracing", + "tracing-subscriber", "xmas-elf", ] diff --git a/difftest/Cargo.toml b/difftest/Cargo.toml index d5f4d98f2..06f733a27 100644 --- a/difftest/Cargo.toml +++ b/difftest/Cargo.toml @@ -1,9 +1,9 @@ [workspace] resolver = "2" members = [ - "test_common", "spike_rs", - "offline", + "offline_t1", + "offline_t1rocket", "dpi_t1", "dpi_t1rocket", "dpi_common", diff --git a/difftest/default.nix b/difftest/default.nix index 598c331d2..acdff20d2 100644 --- a/difftest/default.nix +++ b/difftest/default.nix @@ -6,13 +6,17 @@ }: { outputName -, emuType -, buildType +, emuType ? "" +, moduleType , enableTrace ? false }: -assert lib.assertMsg (lib.elem emuType [ "verilator" "vcs" ]) "emuType is either 'vcs' nor 'verilator'"; -assert lib.assertMsg (lib.elem buildType [ "t1" "t1rocket" ]) "emuType is either 't1' nor 't1rocket'"; +assert let + available = [ "dpi_t1" "dpi_t1rocket" "offline_t1" "offline_t1rocket" ]; +in +lib.assertMsg (lib.elem moduleType available) "emuType is not in ${lib.concatStringsSep ", " available}"; +# if emuType is empty, then moduleType must be offline-*, or user should give valid emuType +assert lib.assertMsg ((emuType == "" && lib.hasPrefix "offline" moduleType) || (lib.elem emuType [ "verilator" "vcs" ])) "emuType is either 'vcs' nor 'verilator'"; rustPlatform.buildRustPackage { name = outputName; @@ -20,18 +24,18 @@ rustPlatform.buildRustPackage { root = ./.; fileset = unions [ ./spike_rs - ./offline + ./offline_t1 + ./offline_t1rocket ./dpi_common ./dpi_t1 ./dpi_t1rocket - ./test_common ./Cargo.lock ./Cargo.toml ]; }; - buildFeatures = [ "dpi_common/${emuType}" ] ++ lib.optionals enableTrace [ "dpi_common/trace" ]; - buildAndTestSubdir = "./dpi_${buildType}"; + buildFeatures = [ ] ++ lib.optionals (lib.hasPrefix "dpi" moduleType) [ "dpi_common/${emuType}" ] ++ lib.optionals enableTrace [ "dpi_common/trace" ]; + buildAndTestSubdir = "./${moduleType}"; env = { SPIKE_LIB_DIR = "${libspike}/lib"; @@ -45,8 +49,13 @@ rustPlatform.buildRustPackage { lockFile = ./Cargo.lock; }; + postInstall = lib.optionalString (lib.hasPrefix "offline" moduleType) '' + exe=$(find $out/bin -type f -name 'offline_*') + ln -s "$exe" $out/bin/offline + ''; + passthru = { - dpiLibPath = "/lib/libdpi_${buildType}.a"; + dpiLibPath = "/lib/libdpi_${moduleType}.a"; inherit enableTrace; }; } diff --git a/difftest/dpi_t1/src/drive.rs b/difftest/dpi_t1/src/drive.rs index 8a39ffc94..d63485cd1 100644 --- a/difftest/dpi_t1/src/drive.rs +++ b/difftest/dpi_t1/src/drive.rs @@ -124,6 +124,7 @@ impl Driver { &SpikeArgs { elf_file: args.elf_file.clone(), log_file: args.log_file.clone(), + log_level: "info".to_string(), vlen: args.vlen, dlen: args.dlen, set: args.set.clone(), diff --git a/difftest/offline-checker.nix b/difftest/offline-checker.nix deleted file mode 100644 index dc24a1e44..000000000 --- a/difftest/offline-checker.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ lib -, rustPlatform -, libspike -, libspike_interfaces -, rtlDesignMetadata -}: - -rustPlatform.buildRustPackage { - name = "offline-checker"; - src = with lib.fileset; toSource { - root = ./.; - fileset = unions [ - ./spike_rs - ./offline - ./dpi_common - ./dpi_t1 - ./dpi_t1rocket - ./test_common - ./Cargo.lock - ./Cargo.toml - ]; - }; - - buildFeatures = [ ]; - buildAndTestSubdir = "./offline"; - - env = { - SPIKE_LIB_DIR = "${libspike}/lib"; - SPIKE_INTERFACES_LIB_DIR = "${libspike_interfaces}/lib"; - DESIGN_VLEN = rtlDesignMetadata.vlen; - DESIGN_DLEN = rtlDesignMetadata.dlen; - SPIKE_ISA_STRING = rtlDesignMetadata.march; - }; - - cargoLock = { - lockFile = ./Cargo.lock; - }; -} diff --git a/difftest/offline/Cargo.toml b/difftest/offline_t1/Cargo.toml similarity index 87% rename from difftest/offline/Cargo.toml rename to difftest/offline_t1/Cargo.toml index 2824a161e..8d77199be 100644 --- a/difftest/offline/Cargo.toml +++ b/difftest/offline_t1/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "offline" +name = "offline_t1" version = "0.1.0" edition = "2021" @@ -15,5 +15,4 @@ num-bigint = { workspace = true } libloading = "0.8.1" xmas-elf = "0.9.1" -common = { path = "../test_common" } spike_rs = { path = "../spike_rs" } diff --git a/difftest/offline/src/difftest.rs b/difftest/offline_t1/src/difftest.rs similarity index 84% rename from difftest/offline/src/difftest.rs rename to difftest/offline_t1/src/difftest.rs index 66a0173d9..454edb09e 100644 --- a/difftest/offline/src/difftest.rs +++ b/difftest/offline_t1/src/difftest.rs @@ -1,9 +1,5 @@ -use common::spike_runner::SpikeRunner; +use spike_rs::runner::*; use std::path::Path; -use tracing::info; - -use common::rtl_config::RTLConfig; -use common::CommonArgs; use crate::dut::Dut; use crate::json_events::*; @@ -11,20 +7,15 @@ use crate::json_events::*; pub struct Difftest { runner: SpikeRunner, dut: Dut, - - #[allow(dead_code)] - config: RTLConfig, } impl Difftest { - pub fn new(args: CommonArgs) -> Self { - let config = RTLConfig { vlen: args.vlen, dlen: args.dlen }; + pub fn new(args: SpikeArgs) -> Self { Self { runner: SpikeRunner::new(&args, true), dut: Dut::new(Path::new( &args.log_file.expect("difftest must be run with a log file"), )), - config, } } @@ -39,9 +30,7 @@ impl Difftest { Ok(()) } JsonEvents::SimulationStop { reason, cycle } => { - info!("simulation stopped at cycle {}, reason {}", cycle, reason); - self.runner.cycle = *cycle; - Ok(()) + anyhow::bail!("stop: simulation stopped at cycle {cycle}, reason {reason}") } JsonEvents::Issue { idx, cycle } => { self.runner.cycle = *cycle; diff --git a/difftest/offline/src/dut.rs b/difftest/offline_t1/src/dut.rs similarity index 100% rename from difftest/offline/src/dut.rs rename to difftest/offline_t1/src/dut.rs diff --git a/difftest/offline/src/json_events.rs b/difftest/offline_t1/src/json_events.rs similarity index 98% rename from difftest/offline/src/json_events.rs rename to difftest/offline_t1/src/json_events.rs index 24652f04d..60bf8a388 100644 --- a/difftest/offline/src/json_events.rs +++ b/difftest/offline_t1/src/json_events.rs @@ -1,18 +1,9 @@ -use common::spike_runner::SpikeRunner; use num_bigint::BigUint; use serde::{Deserialize, Deserializer}; +use spike_rs::runner::SpikeRunner; use spike_rs::spike_event::LSU_IDX_DEFAULT; use tracing::{debug, info}; -#[derive(Deserialize, Debug, PartialEq, Clone)] -pub enum Opcode { - PutFullData = 0, - PutPartialData = 1, - Get = 4, - // AccessAckData = 0, - // AccessAck = 0, -} - fn bigint_to_vec_u8<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, @@ -338,7 +329,7 @@ impl JsonEventRunner for SpikeRunner { ); // if instruction writes rd, it will retire in check_rd() - if count == se.vrf_access_record.retired_writes && !se.is_rd_written { + if count == se.vrf_access_record.retired_writes && !se.is_rd_written && !se.is_fd_written { should_retire = Some(issue_idx); } // if all writes are committed, retire the se diff --git a/difftest/offline/src/main.rs b/difftest/offline_t1/src/main.rs similarity index 85% rename from difftest/offline/src/main.rs rename to difftest/offline_t1/src/main.rs index 0328e2cf3..b79909454 100644 --- a/difftest/offline/src/main.rs +++ b/difftest/offline_t1/src/main.rs @@ -5,12 +5,11 @@ mod json_events; use clap::Parser; use tracing::info; -use common::spike_runner::SpikeRunner; -use common::CommonArgs; +use spike_rs::runner::*; use crate::difftest::Difftest; -fn run_spike(args: &CommonArgs) -> anyhow::Result<()> { +fn run_spike(args: &SpikeArgs) -> anyhow::Result<()> { let mut count: u64 = 0; let spike = SpikeRunner::new(args, true); @@ -32,7 +31,7 @@ fn run_spike(args: &CommonArgs) -> anyhow::Result<()> { fn main() -> anyhow::Result<()> { // parse args - let args = CommonArgs::parse(); + let args = SpikeArgs::parse(); args.setup_logger()?; diff --git a/t1rocketemu/offline/Cargo.toml b/difftest/offline_t1rocket/Cargo.toml similarity index 87% rename from t1rocketemu/offline/Cargo.toml rename to difftest/offline_t1rocket/Cargo.toml index 2824a161e..19aa68c01 100644 --- a/t1rocketemu/offline/Cargo.toml +++ b/difftest/offline_t1rocket/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "offline" +name = "offline_t1rocket" version = "0.1.0" edition = "2021" @@ -15,5 +15,4 @@ num-bigint = { workspace = true } libloading = "0.8.1" xmas-elf = "0.9.1" -common = { path = "../test_common" } spike_rs = { path = "../spike_rs" } diff --git a/t1rocketemu/offline/src/difftest.rs b/difftest/offline_t1rocket/src/difftest.rs similarity index 92% rename from t1rocketemu/offline/src/difftest.rs rename to difftest/offline_t1rocket/src/difftest.rs index d8ce0a225..23fd39f24 100644 --- a/t1rocketemu/offline/src/difftest.rs +++ b/difftest/offline_t1rocket/src/difftest.rs @@ -1,29 +1,21 @@ -use common::spike_runner::SpikeRunner; +use spike_rs::runner::{SpikeArgs, SpikeRunner}; use std::path::Path; -use common::rtl_config::RTLConfig; -use common::CommonArgs; - use crate::dut::Dut; use crate::json_events::*; pub struct Difftest { runner: SpikeRunner, dut: Dut, - - #[allow(dead_code)] - config: RTLConfig, } impl Difftest { - pub fn new(args: CommonArgs) -> Self { - let config = RTLConfig { vlen: args.vlen, dlen: args.dlen }; + pub fn new(args: SpikeArgs) -> Self { Self { runner: SpikeRunner::new(&args, true), dut: Dut::new(Path::new( &args.log_file.expect("difftest must be run with a log file"), )), - config, } } diff --git a/t1rocketemu/offline/src/dut.rs b/difftest/offline_t1rocket/src/dut.rs similarity index 100% rename from t1rocketemu/offline/src/dut.rs rename to difftest/offline_t1rocket/src/dut.rs diff --git a/t1rocketemu/offline/src/json_events.rs b/difftest/offline_t1rocket/src/json_events.rs similarity index 99% rename from t1rocketemu/offline/src/json_events.rs rename to difftest/offline_t1rocket/src/json_events.rs index 6a324a37c..bf470a9f8 100644 --- a/t1rocketemu/offline/src/json_events.rs +++ b/difftest/offline_t1rocket/src/json_events.rs @@ -1,6 +1,6 @@ -use common::spike_runner::SpikeRunner; use num_bigint::BigUint; use serde::{Deserialize, Deserializer}; +use spike_rs::runner::SpikeRunner; use spike_rs::spike_event::LSU_IDX_DEFAULT; use tracing::{debug, info}; diff --git a/t1rocketemu/offline/src/main.rs b/difftest/offline_t1rocket/src/main.rs similarity index 85% rename from t1rocketemu/offline/src/main.rs rename to difftest/offline_t1rocket/src/main.rs index c9382462d..1bf119223 100644 --- a/t1rocketemu/offline/src/main.rs +++ b/difftest/offline_t1rocket/src/main.rs @@ -5,12 +5,11 @@ mod json_events; use clap::Parser; use tracing::info; -use common::spike_runner::SpikeRunner; -use common::CommonArgs; +use spike_rs::runner::{SpikeArgs, SpikeRunner}; use crate::difftest::Difftest; -fn run_spike(args: &CommonArgs) -> anyhow::Result<()> { +fn run_spike(args: &SpikeArgs) -> anyhow::Result<()> { let mut count: u64 = 0; let spike = SpikeRunner::new(args, true); @@ -32,7 +31,7 @@ fn run_spike(args: &CommonArgs) -> anyhow::Result<()> { fn main() -> anyhow::Result<()> { // parse args - let args = CommonArgs::parse(); + let args = SpikeArgs::parse(); args.setup_logger()?; diff --git a/difftest/spike_rs/Cargo.toml b/difftest/spike_rs/Cargo.toml index 411d44f72..b1dee9f83 100644 --- a/difftest/spike_rs/Cargo.toml +++ b/difftest/spike_rs/Cargo.toml @@ -5,6 +5,9 @@ edition = "2021" [dependencies] anyhow = { workspace = true } +clap = { workspace = true } tracing = { workspace = true } +tracing-subscriber = { workspace = true } + libc = "0.2.155" xmas-elf = "0.9.1" diff --git a/difftest/spike_rs/src/runner.rs b/difftest/spike_rs/src/runner.rs index e5e24407a..e96722307 100644 --- a/difftest/spike_rs/src/runner.rs +++ b/difftest/spike_rs/src/runner.rs @@ -1,6 +1,8 @@ +use clap::Parser; use std::collections::VecDeque; use std::path::{Path, PathBuf}; -use tracing::debug; +use tracing::{debug, Level}; +use tracing_subscriber::{EnvFilter, FmtSubscriber}; use crate::spike_event::SpikeEvent; use crate::util::load_elf; @@ -19,6 +21,16 @@ pub struct SpikeRunner { /// front of the queue, and it must be a fence pub commit_queue: VecDeque, + /// vector queue to arrange the order of vector instructions, because of the register write + /// dependency, the vector instruction should be issued in order. + pub vector_queue: VecDeque, + + /// scalar queue to arrange the order of scalar reg write instructions + pub scalar_queue: VecDeque, + + /// float queue to arrange the order of scalar freg write instructions + pub float_queue: VecDeque, + /// config for v extension pub vlen: u32, pub dlen: u32, @@ -30,22 +42,38 @@ pub struct SpikeRunner { pub spike_cycle: u64, pub do_log_vrf: bool, + + // register file scoreboard + pub rf_board: Vec>, + // float reg file scoreboard + pub frf_board: Vec>, } +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] pub struct SpikeArgs { /// Path to the ELF file + #[arg(long)] pub elf_file: PathBuf, /// Path to the log file + #[arg(long)] pub log_file: Option, + /// Log level: trace, debug, info, warn, error + #[arg(long, default_value = "info")] + pub log_level: String, + /// vlen config + #[arg(long, default_value = env!("DESIGN_VLEN"))] pub vlen: u32, /// dlen config + #[arg(long, default_value = env!("DESIGN_DLEN"))] pub dlen: u32, /// ISA config + #[arg(long, default_value = env!("SPIKE_ISA_STRING"))] pub set: String, } @@ -54,6 +82,23 @@ impl SpikeArgs { let lvl = "M"; Spike::new(&self.set, lvl, (self.dlen / 32) as usize, MEM_SIZE) } + + pub fn setup_logger(&self) -> anyhow::Result<()> { + // setup log + let log_level: Level = self.log_level.parse()?; + let global_logger = FmtSubscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .with_max_level(log_level) + .without_time() + .with_target(false) + .with_ansi(true) + .compact() + .finish(); + tracing::subscriber::set_global_default(global_logger) + .expect("internal error: fail to setup log subscriber"); + + Ok(()) + } } pub const MEM_SIZE: usize = 1usize << 32; @@ -75,11 +120,16 @@ impl SpikeRunner { SpikeRunner { spike, commit_queue: VecDeque::new(), + vector_queue: VecDeque::new(), + scalar_queue: VecDeque::new(), + float_queue: VecDeque::new(), vlen: args.vlen, dlen: args.dlen, cycle: 0, spike_cycle: 0, do_log_vrf, + rf_board: vec![None; 32], + frf_board: vec![None; 32], } } @@ -131,6 +181,7 @@ impl SpikeRunner { ); let new_pc_ = proc.func(); event.log_mem_write(spike).unwrap(); + event.log_reg_write(spike).unwrap(); new_pc_ }; @@ -156,4 +207,61 @@ impl SpikeRunner { } } } + + pub fn find_reg_se(&mut self) -> SpikeEvent { + if !self.scalar_queue.is_empty() { + // return the back (oldest) scalar insn + self.scalar_queue.pop_back().unwrap() + } else { + // else, loop until find a se, and push the se to the front + loop { + let se = self.spike_step(); + if se.is_scalar() && se.is_rd_written { + return se; + } else if se.is_scalar() && se.is_fd_written { + self.float_queue.push_front(se.clone()); + } else if se.is_v() { + self.vector_queue.push_front(se.clone()); + } + } + } + } + + pub fn find_freg_se(&mut self) -> SpikeEvent { + if !self.float_queue.is_empty() { + // return the back (oldest) float insn + self.float_queue.pop_back().unwrap() + } else { + // else, loop until find a se, and push the se to the front + loop { + let se = self.spike_step(); + if se.is_scalar() && se.is_rd_written { + self.scalar_queue.push_front(se.clone()); + } else if se.is_scalar() && se.is_fd_written { + return se; + } else if se.is_v() { + self.vector_queue.push_front(se.clone()); + } + } + } + } + + pub fn find_v_se(&mut self) -> SpikeEvent { + if !self.vector_queue.is_empty() { + // return the back (oldest) vector insn + self.vector_queue.pop_back().unwrap() + } else { + // else, loop until find a se, and push the se to the front + loop { + let se = self.spike_step(); + if se.is_scalar() && se.is_rd_written { + self.scalar_queue.push_front(se.clone()); + } else if se.is_scalar() && se.is_fd_written { + self.float_queue.push_front(se.clone()); + } else if se.is_v() { + return se; + } + } + } + } } diff --git a/difftest/spike_rs/src/spike_event.rs b/difftest/spike_rs/src/spike_event.rs index 3487499b2..e05039bea 100644 --- a/difftest/spike_rs/src/spike_event.rs +++ b/difftest/spike_rs/src/spike_event.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use tracing::{info, trace}; +use tracing::trace; use Default; use crate::clip; @@ -92,6 +92,7 @@ pub struct SpikeEvent { // mutable states pub is_rd_written: bool, + pub is_fd_written: bool, pub vd_write_record: VdWriteRecord, pub mem_access_record: MemAccessRecord, pub vrf_access_record: VrfAccessRecord, @@ -143,6 +144,7 @@ impl SpikeEvent { rd_bits: Default::default(), is_rd_written: false, + is_fd_written: false, vd_write_record: Default::default(), mem_access_record: Default::default(), vrf_access_record: Default::default(), @@ -326,18 +328,15 @@ impl SpikeEvent { pub fn pre_log_arch_changes(&mut self, spike: &Spike, vlen: u32) -> anyhow::Result<()> { if self.do_log_vrf { - self.rd_bits = spike.get_proc().get_rd(); - // record the vrf writes before executing the insn - let vlen_in_bytes = vlen; - let proc = spike.get_proc(); - let (start, len) = self.get_vrf_write_range(vlen_in_bytes).unwrap(); + self.rd_bits = proc.get_state().get_reg(self.rd_idx, false); + let (start, len) = self.get_vrf_write_range(vlen).unwrap(); self.vd_write_record.vd_bytes.resize(len as usize, 0u8); for i in 0..len { let offset = start + i; - let vreg_index = offset / vlen_in_bytes; - let vreg_offset = offset % vlen_in_bytes; + let vreg_index = offset / vlen; + let vreg_offset = offset % vlen; let cur_byte = proc.get_vreg_data(vreg_index, vreg_offset); self.vd_write_record.vd_bytes[i as usize] = cur_byte; } @@ -391,7 +390,7 @@ impl SpikeEvent { Ok(()) } - fn log_reg_write(&mut self, spike: &Spike) -> anyhow::Result<()> { + pub fn log_reg_write(&mut self, spike: &Spike) -> anyhow::Result<()> { let proc = spike.get_proc(); let state = proc.get_state(); // in spike, log_reg_write is arrange: @@ -402,36 +401,39 @@ impl SpikeEvent { // xx0100 <- csr let reg_write_size = state.get_reg_write_size(); // TODO: refactor it. - (0..reg_write_size).for_each(|idx| match state.get_reg_write_index(idx) & 0xf { - 0b0000 => { - // scalar rf - let data = state.get_reg(self.rd_idx, false); - self.is_rd_written = true; - if data != self.rd_bits { - trace!( - "ScalarRFChange: idx={}, change_from={}, change_to={data}", - self.rd_idx, - self.rd_bits - ); - self.rd_bits = data; + (0..reg_write_size).for_each(|idx| { + let rd_idx_type = state.get_reg_write_index(idx); + match rd_idx_type & 0xf { + 0b0000 => { + // scalar rf + self.rd_idx = rd_idx_type >> 4; + if self.rd_idx != 0 { + let data = state.get_reg(self.rd_idx, false); + self.is_rd_written = true; + self.rd_bits = data; + trace!( + "ScalarRFChange: idx={:#02x}, data={:08x}", + self.rd_idx, + self.rd_bits + ); + } } - } - 0b0001 => { - let data = state.get_reg(self.rd_idx, true); - self.is_rd_written = true; - if data != self.rd_bits { + 0b0001 => { + self.rd_idx = rd_idx_type >> 4; + let data = state.get_reg(self.rd_idx, true); + self.is_fd_written = true; + self.rd_bits = data; trace!( - "FloatRFChange: idx={}, change_from={}, change_to={data}", + "FloatRFChange: idx={:#02x}, data={:08x}", self.rd_idx, self.rd_bits ); - self.rd_bits = data; } + _ => trace!( + "UnknownRegChange, idx={:#02x}, spike detect unknown reg change", + self.rd_idx + ), } - _ => trace!( - "UnknownRegChange, idx={}, spike detect unknown reg change", - state.get_reg_write_index(idx) - ), }); Ok(()) @@ -459,7 +461,7 @@ impl SpikeEvent { trace!("SpikeMemWrite: addr={addr:x}, value={value:x}, size={size}"); if addr == 0x4000_0000 && value == 0xdead_beef { - info!("SpikeExit: exit by writing 0xdeadbeef to 0x40000000"); + trace!("SpikeExit: exit by writing 0xdeadbeef to 0x40000000"); self.is_exit = true; return; diff --git a/difftest/test_common/Cargo.toml b/difftest/test_common/Cargo.toml deleted file mode 100644 index d5b3f32aa..000000000 --- a/difftest/test_common/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "common" -version.workspace = true -edition = "2021" - -[dependencies] -spike_rs = { path = "../spike_rs" } -clap = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -anyhow = { workspace = true } diff --git a/difftest/test_common/src/lib.rs b/difftest/test_common/src/lib.rs deleted file mode 100644 index e9690d3a2..000000000 --- a/difftest/test_common/src/lib.rs +++ /dev/null @@ -1,63 +0,0 @@ -use anyhow::Result; -use clap::Parser; -use spike_rs::Spike; -use std::path::PathBuf; -use tracing::Level; -use tracing_subscriber::{EnvFilter, FmtSubscriber}; - -pub mod rtl_config; -pub mod spike_runner; - -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -pub struct CommonArgs { - /// Path to the ELF file - #[arg(long)] - pub elf_file: PathBuf, - - /// Path to the log file - #[arg(long)] - pub log_file: Option, - - /// Log level: trace, debug, info, warn, error - #[arg(long, default_value = "info")] - pub log_level: String, - - /// vlen config - #[arg(long, default_value = env!("DESIGN_VLEN"))] - pub vlen: u32, - - /// dlen config - #[arg(long, default_value = env!("DESIGN_DLEN"))] - pub dlen: u32, - - /// ISA config - #[arg(long, default_value = env!("SPIKE_ISA_STRING"))] - pub set: String, -} - -pub static MEM_SIZE: usize = 1usize << 32; - -impl CommonArgs { - pub fn to_spike_c_handler(&self) -> Box { - let lvl = "M"; - - Spike::new(&self.set, lvl, (self.dlen / 32) as usize, MEM_SIZE) - } - - pub fn setup_logger(&self) -> Result<()> { - // setup log - let log_level: Level = self.log_level.parse()?; - let global_logger = FmtSubscriber::builder() - .with_env_filter(EnvFilter::from_default_env()) - .with_max_level(log_level) - .without_time() - .with_target(false) - .with_ansi(true) - .compact() - .finish(); - tracing::subscriber::set_global_default(global_logger) - .expect("internal error: fail to setup log subscriber"); - Ok(()) - } -} diff --git a/difftest/test_common/src/rtl_config.rs b/difftest/test_common/src/rtl_config.rs deleted file mode 100644 index 0daf72624..000000000 --- a/difftest/test_common/src/rtl_config.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub struct RTLConfig { - pub vlen: u32, - pub dlen: u32, -} - -// TODO: read from json - -impl RTLConfig { - pub fn xlen(&self) -> u32 { - 32 // TODO: configurable - } - - pub fn vlen_in_bytes(&self) -> u32 { - self.vlen / 8 - } - - pub fn lane_num(&self) -> u32 { - self.dlen / self.xlen() - } -} diff --git a/difftest/test_common/src/spike_runner.rs b/difftest/test_common/src/spike_runner.rs deleted file mode 100644 index ded02898c..000000000 --- a/difftest/test_common/src/spike_runner.rs +++ /dev/null @@ -1,135 +0,0 @@ -use std::collections::VecDeque; -use std::path::Path; -use tracing::debug; - -use spike_rs::spike_event::SpikeEvent; -use spike_rs::util::load_elf; -use spike_rs::Spike; - -use crate::CommonArgs; - -pub struct SpikeRunner { - spike: Box, - - /// commit queue - /// in the spike thread, spike should detech if this queue is full, if not - /// full, execute until a vector instruction, record the behavior of this - /// instruction, and send to commit queue. - /// Note: - /// - The event issued earliest is at the back of the queue - /// - The queue may contain at most one unissued event. If so, the unissued event must be at the - /// front of the queue, and it must be a fence - pub commit_queue: VecDeque, - - /// config for v extension - pub vlen: u32, - pub dlen: u32, - - /// implement the get_t() for mcycle csr update - pub cycle: u64, - - /// for mcycle csr update - pub spike_cycle: u64, - - pub do_log_vrf: bool, -} - -impl SpikeRunner { - pub fn new(args: &CommonArgs, do_log_vrf: bool) -> Self { - // load the elf file - // initialize spike - let mut spike = args.to_spike_c_handler(); - - let entry_addr = load_elf(&mut spike, Path::new(&args.elf_file)).unwrap(); - - // initialize processor - let proc = spike.get_proc(); - let state = proc.get_state(); - proc.reset(); - state.set_pc(entry_addr); - - SpikeRunner { - spike, - commit_queue: VecDeque::new(), - vlen: args.vlen, - dlen: args.dlen, - cycle: 0, - spike_cycle: 0, - do_log_vrf, - } - } - - pub fn load_elf(&mut self, fname: &Path) -> anyhow::Result { - load_elf(&mut *self.spike, fname) - } - - // just execute one instruction for non-difftest - pub fn exec(&self) -> anyhow::Result<()> { - let spike = &self.spike; - let proc = spike.get_proc(); - let state = proc.get_state(); - - let new_pc = proc.func(); - - state.handle_pc(new_pc).unwrap(); - - Ok(()) - } - - // execute the spike processor for one instruction and record - // the spike event for difftest - pub fn spike_step(&mut self) -> SpikeEvent { - let spike = &self.spike; - let proc = self.spike.get_proc(); - let state = proc.get_state(); - - let mcycle = (self.cycle + self.spike_cycle) as usize; - state.set_mcycle(0); - - let mut event = SpikeEvent::new(spike, self.do_log_vrf); - state.clear(); - - let new_pc = if event.is_v() || event.is_exit() { - // inst is v / quit - debug!( - "SpikeStep: spike run vector insn ({}), mcycle={mcycle}", - event.describe_insn(), - ); - event.pre_log_arch_changes(spike, self.vlen).unwrap(); - let new_pc_ = proc.func(); - event.log_arch_changes(spike, self.vlen).unwrap(); - new_pc_ - } else { - // inst is scalar - debug!( - "SpikeStep: spike run scalar insn ({}), mcycle={mcycle}", - event.describe_insn(), - ); - let new_pc_ = proc.func(); - event.log_mem_write(spike).unwrap(); - new_pc_ - }; - - state.handle_pc(new_pc).unwrap(); - - self.spike_cycle += 1; - - event - } - - pub fn find_v_se_to_issue(&mut self) -> SpikeEvent { - if !self.commit_queue.is_empty() && self.commit_queue.front().unwrap().is_vfence() { - // if the front (latest) se is a vfence, return the vfence - self.commit_queue.front().unwrap().clone() - } else { - // else, loop until find a se, and push the se to the front - loop { - let se = self.spike_step(); - if se.is_v() { - self.commit_queue.push_front(se.clone()); - break se.clone(); - } - } - } - } -} diff --git a/elaborator/src/Main.scala b/elaborator/src/Main.scala index 8cd5bc48f..a6faf72a8 100644 --- a/elaborator/src/Main.scala +++ b/elaborator/src/Main.scala @@ -102,8 +102,8 @@ object Main { @main def ip(elaborateConfig: ElaborateConfig, ipConfig: IPConfig): Unit = elaborateConfig.elaborate(() => ipConfig.generator.module()) - @main def ipemu(elaborateConfig: ElaborateConfig, ipConfig: IPConfig): Unit = - elaborateConfig.elaborate(() => new org.chipsalliance.t1.ipemu.TestBench(ipConfig.generator)) + @main def t1emu(elaborateConfig: ElaborateConfig, ipConfig: IPConfig): Unit = + elaborateConfig.elaborate(() => new org.chipsalliance.t1.t1emu.TestBench(ipConfig.generator)) @main def rocketemu(elaborateConfig: ElaborateConfig, rocketConfig: RocketConfig): Unit = elaborateConfig.elaborate(() => new org.chipsalliance.t1.rocketv.TestBench(rocketConfig.generator)) diff --git a/nix/t1/mill-modules.nix b/nix/t1/mill-modules.nix index 44a8acf86..b7f95811d 100644 --- a/nix/t1/mill-modules.nix +++ b/nix/t1/mill-modules.nix @@ -26,7 +26,7 @@ let ./../../t1 ./../../omreader ./../../omreaderlib - ./../../ipemu/src + ./../../t1emu/src ./../../elaborator ./../../configgen/src ./../../rocketv diff --git a/nix/t1/release/default.nix b/nix/t1/release/default.nix index 7e156f000..1e693272c 100644 --- a/nix/t1/release/default.nix +++ b/nix/t1/release/default.nix @@ -45,12 +45,12 @@ lib.makeScope newScope (scope: rec { mkdir -p $out/bin makeWrapper ${t1-helper}/bin/t1-helper $out/bin/ip-emulator \ - --add-flags "ipemu" \ + --add-flags "t1emu" \ --add-flags "--config ${elaborateConfigJson}" \ --add-flags "--emulator-path ${ip.emu}/bin/emulator" makeWrapper ${t1-helper}/bin/t1-helper $out/bin/ip-emulator-trace \ - --add-flags "ipemu" \ + --add-flags "t1emu" \ --add-flags "--config ${elaborateConfigJson}" \ --add-flags "--trace" \ --add-flags "--emulator-path ${ip.emu-trace}/bin/emulator" diff --git a/nix/t1/t1.nix b/nix/t1/t1.nix index 32deb12c3..3f6daa337 100644 --- a/nix/t1/t1.nix +++ b/nix/t1/t1.nix @@ -61,7 +61,7 @@ lib.mapAttrs # --------------------------------------------------------------------------------- emu-mlirbc = t1Scope.chisel-to-mlirbc { outputName = "t1-emu.mlirbc"; - elaboratorArgs = [ "ipemu" "--ip-config" "${elaborateConfigJson}" ]; + elaboratorArgs = [ "t1emu" "--ip-config" "${elaborateConfigJson}" ]; }; lowered-emu-mlirbc = t1Scope.finalize-mlirbc { @@ -97,17 +97,17 @@ lib.mapAttrs # --------------------------------------------------------------------------------- # VERILATOR # --------------------------------------------------------------------------------- - makeDPI = ipScope.callPackage ../../difftest { }; + makeDifftest = ipScope.callPackage ../../difftest { }; - verilator-dpi-lib = ipScope.makeDPI { + verilator-dpi-lib = ipScope.makeDifftest { outputName = "t1-verilator-dpi-lib"; emuType = "verilator"; - buildType = "t1"; + moduleType = "dpi_t1"; }; - verilator-dpi-lib-trace = ipScope.makeDPI { + verilator-dpi-lib-trace = ipScope.makeDifftest { outputName = "t1-verilator-trace-dpi-lib"; emuType = "verilator"; - buildType = "t1"; + moduleType = "dpi_t1"; enableTrace = true; }; @@ -126,16 +126,21 @@ lib.mapAttrs # --------------------------------------------------------------------------------- # VCS # --------------------------------------------------------------------------------- - vcs-dpi-lib = ipScope.makeDPI { + vcs-dpi-lib = ipScope.makeDifftest { outputName = "t1-vcs-dpi-lib"; emuType = "vcs"; - buildType = "t1"; + moduleType = "dpi_t1"; }; - vcs-dpi-lib-trace = ipScope.makeDPI { + vcs-dpi-lib-trace = ipScope.makeDifftest { outputName = "t1-vcs-dpi-trace-lib"; emuType = "vcs"; enableTrace = true; - buildType = "t1"; + moduleType = "dpi_t1"; + }; + + offline-checker = ipScope.makeDifftest { + outputName = "t1-offline-checker"; + moduleType = "offline_t1"; }; vcs-emu = t1Scope.sv-to-vcs-simulator { @@ -150,8 +155,6 @@ lib.mapAttrs vcsLinkLibs = [ "${ipScope.vcs-dpi-lib-trace}/lib/libdpi_t1.a" ]; }; - offline-checker = ipScope.callPackage ../../difftest/offline-checker.nix { }; - run = ipScope.callPackage ./run { }; }); # end of ipScope diff --git a/nix/t1/t1rocket.nix b/nix/t1/t1rocket.nix index 9a35a7bb7..6abf8788f 100644 --- a/nix/t1/t1rocket.nix +++ b/nix/t1/t1rocket.nix @@ -41,14 +41,14 @@ ]; }; - makeDPI = scope.callPackage ../../difftest { }; - verilator-dpi-lib = scope.makeDPI { + makeDifftest = scope.callPackage ../../difftest { }; + verilator-dpi-lib = scope.makeDifftest { outputName = "t1rocket-verilator-dpi-lib"; - buildType = "t1rocket"; + moduleType = "dpi_t1rocket"; }; - verilator-dpi-lib-trace = scope.makeDPI { + verilator-dpi-lib-trace = scope.makeDifftest { outputName = "t1rocket-verilator-trace-dpi-lib"; - buildType = "t1rocket"; + moduleType = "dpi_t1rocket"; enableTrace = true; }; @@ -72,20 +72,23 @@ ]; }; - offline-checker = scope.callPackage ../../t1rocketemu/offline { }; - - vcs-dpi-lib = scope.makeDPI { + vcs-dpi-lib = scope.makeDifftest { outputName = "t1rocket-vcs-dpi-lib"; - buildType = "t1rocket"; + moduleType = "dpi_t1rocket"; emuType = "vcs"; }; - vcs-dpi-lib-trace = scope.makeDPI { + vcs-dpi-lib-trace = scope.makeDifftest { outputName = "t1rocket-vcs-dpi-trace-lib"; - buildType = "t1rocket"; + moduleType = "dpi_t1rocket"; emuType = "vcs"; enableTrace = true; }; + offline-checker = scope.makeDifftest { + outputName = "t1rocket-offline-checker"; + moduleType = "offline_t1rocket"; + }; + vcs-emu = sv-to-vcs-simulator { mainProgram = "t1rocket-vcs-simulator"; rtl = scope.rtl; diff --git a/ipemu/src/AXI4SlaveAgent.scala b/t1emu/src/AXI4SlaveAgent.scala similarity index 99% rename from ipemu/src/AXI4SlaveAgent.scala rename to t1emu/src/AXI4SlaveAgent.scala index 963b04ebf..5767714b6 100644 --- a/ipemu/src/AXI4SlaveAgent.scala +++ b/t1emu/src/AXI4SlaveAgent.scala @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022-2024 Jiuyang Liu -package org.chipsalliance.t1.ipemu.dpi +package org.chipsalliance.t1.t1emu.dpi // TODO: upstream to AMBA as VIP import chisel3._ diff --git a/ipemu/src/TestBench.scala b/t1emu/src/TestBench.scala similarity index 99% rename from ipemu/src/TestBench.scala rename to t1emu/src/TestBench.scala index 318377932..d623263ef 100644 --- a/ipemu/src/TestBench.scala +++ b/t1emu/src/TestBench.scala @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 Jiuyang Liu -package org.chipsalliance.t1.ipemu +package org.chipsalliance.t1.t1emu import chisel3._ import chisel3.experimental.dataview.DataViewable @@ -11,7 +11,7 @@ import chisel3.properties.{AnyClassType, Class, ClassType, Property} import chisel3.util.circt.dpi.{RawClockedNonVoidFunctionCall, RawClockedVoidFunctionCall, RawUnclockedNonVoidFunctionCall} import chisel3.util.{HasExtModuleInline, PopCount, UIntToOH, Valid} import org.chipsalliance.amba.axi4.bundle._ -import org.chipsalliance.t1.ipemu.dpi._ +import org.chipsalliance.t1.t1emu.dpi._ import org.chipsalliance.t1.rtl.{T1, T1Parameter} @instantiable diff --git a/t1rocketemu/.clang-format b/t1rocketemu/.clang-format deleted file mode 100644 index 57d55c245..000000000 --- a/t1rocketemu/.clang-format +++ /dev/null @@ -1,236 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignArrayOfStructures: None -AlignConsecutiveAssignments: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: true -AlignConsecutiveBitFields: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: false -AlignConsecutiveDeclarations: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: false -AlignConsecutiveMacros: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: false -AlignConsecutiveShortCaseStatements: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: false -AlignEscapedNewlines: Right -AlignOperands: Align -AlignTrailingComments: - Kind: Always - OverEmptyLines: 0 -AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine -AttributeMacros: - - __capability -BinPackArguments: true -BinPackParameters: true -BitFieldColonSpacing: Both -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterExternBlock: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakAfterAttributes: Never -BreakAfterJavaFieldAnnotations: false -BreakArrays: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: Always -BreakBeforeBraces: Attach -BreakBeforeInlineASMColon: OnlyMultiline -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IfMacros: - - KJ_IF_MAYBE -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - SortPriority: 0 - CaseSensitive: false - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - SortPriority: 0 - CaseSensitive: false - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false -IncludeIsMainRegex: '(Test)?$' -IncludeIsMainSourceRegex: '' -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentCaseLabels: false -IndentExternBlock: AfterExternBlock -IndentGotoLabels: true -IndentPPDirectives: None -IndentRequiresClause: true -IndentWidth: 2 -IndentWrappedFunctionNames: false -InsertBraces: false -InsertNewlineAtEOF: false -InsertTrailingCommas: None -IntegerLiteralSeparator: - Binary: 0 - BinaryMinDigits: 0 - Decimal: 0 - DecimalMinDigits: 0 - Hex: 0 - HexMinDigits: 0 -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -KeepEmptyLinesAtEOF: false -LambdaBodyIndentation: Signature -LineEnding: DeriveLF -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 2 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PackConstructorInitializers: BinPack -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakOpenParenthesis: 0 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyIndentedWhitespace: 0 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -PPIndentWidth: -1 -QualifierAlignment: Leave -ReferenceAlignment: Pointer -ReflowComments: true -RemoveBracesLLVM: false -RemoveParentheses: Leave -RemoveSemicolon: false -RequiresClausePosition: OwnLine -RequiresExpressionIndentation: OuterScope -SeparateDefinitionBlocks: Leave -ShortNamespaceLines: 1 -SortIncludes: CaseSensitive -SortJavaStaticImport: Before -SortUsingDeclarations: LexicographicNumeric -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeJsonColon: false -SpaceBeforeParens: ControlStatements -SpaceBeforeParensOptions: - AfterControlStatements: true - AfterForeachMacros: true - AfterFunctionDefinitionName: false - AfterFunctionDeclarationName: false - AfterIfMacros: true - AfterOverloadedOperator: false - AfterRequiresInClause: false - AfterRequiresInExpression: false - BeforeNonEmptyParentheses: false -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: Never -SpacesInContainerLiterals: true -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParens: Never -SpacesInParensOptions: - InCStyleCasts: false - InConditionalStatements: false - InEmptyParentheses: false - Other: false -SpacesInSquareBrackets: false -Standard: Latest -StatementAttributeLikeMacros: - - Q_EMIT -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseTab: Never -VerilogBreakBetweenInstancePorts: true -WhitespaceSensitiveMacros: - - BOOST_PP_STRINGIZE - - CF_SWIFT_NAME - - NS_SWIFT_NAME - - PP_STRINGIZE - - STRINGIZE -... - diff --git a/t1rocketemu/.gitignore b/t1rocketemu/.gitignore deleted file mode 100644 index 9f970225a..000000000 --- a/t1rocketemu/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ \ No newline at end of file diff --git a/t1rocketemu/.rustfmt.toml b/t1rocketemu/.rustfmt.toml deleted file mode 100644 index bf1a32fd3..000000000 --- a/t1rocketemu/.rustfmt.toml +++ /dev/null @@ -1,4 +0,0 @@ -hard_tabs = false -tab_spaces = 2 -chain_width = 100 -struct_lit_width = 50 diff --git a/t1rocketemu/Cargo.lock b/t1rocketemu/Cargo.lock deleted file mode 100644 index 4eea84c63..000000000 --- a/t1rocketemu/Cargo.lock +++ /dev/null @@ -1,666 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "cc" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" - -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - -[[package]] -name = "common" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "spike_rs", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "elf" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "libloading" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" -dependencies = [ - "cfg-if", - "windows-targets", -] - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "offline" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "common", - "libloading", - "num-bigint", - "serde", - "serde_json", - "spike_rs", - "tracing", - "tracing-subscriber", - "xmas-elf", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "online_dpi" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "common", - "elf", - "hex", - "spike_rs", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "online_drive" -version = "0.1.0" -dependencies = [ - "cmake", - "online_dpi", -] - -[[package]] -name = "online_vcs" -version = "0.1.0" -dependencies = [ - "online_dpi", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "serde" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.118" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "spike_rs" -version = "0.1.0" -dependencies = [ - "anyhow", - "libc", - "tracing", - "xmas-elf", -] - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "syn" -version = "2.0.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - -[[package]] -name = "xmas-elf" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42c49817e78342f7f30a181573d82ff55b88a35f86ccaf07fc64b3008f56d1c6" -dependencies = [ - "zero", -] - -[[package]] -name = "zero" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" diff --git a/t1rocketemu/Cargo.toml b/t1rocketemu/Cargo.toml deleted file mode 100644 index b4488928c..000000000 --- a/t1rocketemu/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[workspace] -resolver = "2" -members = [ - "test_common", - "spike_rs", - "offline", - "online_dpi", - "online_drive", - "online_vcs", -] -exclude = [ - "spike_interfaces" -] - -[workspace.package] -version = "0.1.0" - -[workspace.dependencies] -anyhow = "1.0.79" -clap = { version = "4.4.18", features = ["derive"] } -tracing = "0.1.40" -tracing-subscriber = { version = "0.3", features = ["env-filter", "ansi"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -num-bigint = "0.4.6" diff --git a/t1rocketemu/offline/default.nix b/t1rocketemu/offline/default.nix deleted file mode 100644 index d74475e12..000000000 --- a/t1rocketemu/offline/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ lib -, rustPlatform -, libspike -, libspike_interfaces -, rtlDesignMetadata -}: - - -rustPlatform.buildRustPackage { - name = "vcs-offline-checker"; - buildAndTestSubdir = "./offline"; - - src = with lib.fileset; toSource { - root = ../.; - fileset = unions [ - ../spike_rs - ../offline - ../online_dpi - ../online_drive - ../online_vcs - ../test_common - ../Cargo.lock - ../Cargo.toml - ]; - }; - - env = { - SPIKE_LIB_DIR = "${libspike}/lib"; - SPIKE_INTERFACES_LIB_DIR = "${libspike_interfaces}/lib"; - DESIGN_VLEN = rtlDesignMetadata.vlen; - DESIGN_DLEN = rtlDesignMetadata.dlen; - SPIKE_ISA_STRING = rtlDesignMetadata.march; - }; - - cargoLock = { - lockFile = ../Cargo.lock; - }; -} diff --git a/t1rocketemu/online_dpi/Cargo.toml b/t1rocketemu/online_dpi/Cargo.toml deleted file mode 100644 index 5d2cb5f5d..000000000 --- a/t1rocketemu/online_dpi/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "online_dpi" -edition = "2021" -version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -common = { path = "../test_common" } -spike_rs = { path = "../spike_rs" } -clap = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -anyhow = { workspace = true } - -elf = "0.7.4" -hex = "0.4.3" - -[features] -sv2023 = [] -svvpi = [] -trace = [] diff --git a/t1rocketemu/online_dpi/src/dpi.rs b/t1rocketemu/online_dpi/src/dpi.rs deleted file mode 100644 index 2d7f88a5f..000000000 --- a/t1rocketemu/online_dpi/src/dpi.rs +++ /dev/null @@ -1,338 +0,0 @@ -#![allow(non_snake_case)] -#![allow(unused_variables)] - -use clap::Parser; -use std::ffi::{c_char, c_longlong, CString}; -use std::sync::Mutex; -use tracing::debug; - -use crate::drive::Driver; -use crate::svdpi::SvScope; -use crate::OfflineArgs; - -pub type SvBitVecVal = u32; - -// -------------------------- -// preparing data structures -// -------------------------- - -static DPI_TARGET: Mutex>> = Mutex::new(None); - -pub(crate) struct AxiReadPayload { - pub(crate) data: Vec, -} - -unsafe fn write_to_pointer(dst: *mut u8, data: &[u8]) { - let dst = std::slice::from_raw_parts_mut(dst, data.len()); - dst.copy_from_slice(data); -} - -unsafe fn fill_axi_read_payload(dst: *mut SvBitVecVal, dlen: u32, payload: &AxiReadPayload) { - let data_len = 256 * (dlen / 8) as usize; - assert!(payload.data.len() <= data_len); - write_to_pointer(dst as *mut u8, &payload.data); -} - -// Return (strobe in bit, data in byte) -unsafe fn load_from_payload( - payload: &*const SvBitVecVal, - data_width: usize, - size: usize, -) -> (Vec, &[u8]) { - let src = *payload as *mut u8; - let data_width_in_byte = std::cmp::max(size, 4); - let strb_width_per_byte = if data_width < 64 { 4 } else { 8 }; - let strb_width_in_byte = size.div_ceil(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 masks: Vec = strobe - .into_iter() - .flat_map(|strb| { - let mask: Vec = (0..strb_width_per_byte).map(|i| (strb & (1 << i)) != 0).collect(); - mask - }) - .collect(); - assert_eq!( - masks.len(), - data.len(), - "strobe bit width is not aligned with data byte width" - ); - - debug!( - "load {payload_size_in_byte} byte from payload: raw_data={} strb={} data={}", - hex::encode(byte_vec), - hex::encode(strobe), - hex::encode(data), - ); - - (masks, data) -} - -//---------------------- -// dpi functions -//---------------------- - -/// evaluate after AW and W is finished at corresponding channel_id. -#[no_mangle] -unsafe extern "C" fn axi_write_highBandwidthAXI( - channel_id: c_longlong, - awid: c_longlong, - awaddr: c_longlong, - awlen: c_longlong, - awsize: c_longlong, - awburst: c_longlong, - awlock: c_longlong, - awcache: c_longlong, - awprot: c_longlong, - awqos: c_longlong, - awregion: c_longlong, - // struct packed {bit [255:0][DLEN:0] data; - // bit [255:0][DLEN/8:0] strb; } payload - payload: *const SvBitVecVal, -) { - debug!( - "axi_write_highBandwidth (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \ - awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \ - awprot={awprot}, awqos={awqos}, awregion={awregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - 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); -} - -/// evaluate at AR fire at corresponding channel_id. -#[no_mangle] -unsafe extern "C" fn axi_read_highBandwidthAXI( - channel_id: c_longlong, - arid: c_longlong, - araddr: c_longlong, - arlen: c_longlong, - arsize: c_longlong, - arburst: c_longlong, - arlock: c_longlong, - arcache: c_longlong, - arprot: c_longlong, - arqos: c_longlong, - arregion: c_longlong, - // struct packed {bit [255:0][DLEN:0] data; byte beats; } payload - payload: *mut SvBitVecVal, -) { - debug!( - "axi_read_highBandwidth (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \ - arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \ - arprot={arprot}, arqos={arqos}, arregion={arregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - let response = driver.axi_read_high_bandwidth(araddr as u32, arsize as u64); - fill_axi_read_payload(payload, driver.dlen, &response); -} - -/// evaluate after AW and W is finished at corresponding channel_id. -#[no_mangle] -unsafe extern "C" fn axi_write_highOutstandingAXI( - channel_id: c_longlong, - awid: c_longlong, - awaddr: c_longlong, - awlen: c_longlong, - awsize: c_longlong, - awburst: c_longlong, - awlock: c_longlong, - awcache: c_longlong, - awprot: c_longlong, - awqos: c_longlong, - awregion: c_longlong, - // struct packed {bit [255:0][31:0] data; bit [255:0][3:0] strb; } payload - payload: *const SvBitVecVal, -) { - debug!( - "axi_write_high_outstanding (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \ - awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \ - awprot={awprot}, awqos={awqos}, awregion={awregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - 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); -} - -/// evaluate at AR fire at corresponding channel_id. -#[no_mangle] -unsafe extern "C" fn axi_read_highOutstandingAXI( - channel_id: c_longlong, - arid: c_longlong, - araddr: c_longlong, - arlen: c_longlong, - arsize: c_longlong, - arburst: c_longlong, - arlock: c_longlong, - arcache: c_longlong, - arprot: c_longlong, - arqos: c_longlong, - arregion: c_longlong, - // struct packed {bit [255:0][DLEN:0] data; byte beats; } payload - payload: *mut SvBitVecVal, -) { - debug!( - "axi_read_high_outstanding (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \ - arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \ - arprot={arprot}, arqos={arqos}, arregion={arregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - let response = driver.axi_read_high_outstanding(araddr as u32, arsize as u64); - fill_axi_read_payload(payload, driver.dlen, &response); -} - -#[no_mangle] -unsafe extern "C" fn axi_write_loadStoreAXI( - channel_id: c_longlong, - awid: c_longlong, - awaddr: c_longlong, - awlen: c_longlong, - awsize: c_longlong, - awburst: c_longlong, - awlock: c_longlong, - awcache: c_longlong, - awprot: c_longlong, - awqos: c_longlong, - awregion: c_longlong, - payload: *const SvBitVecVal, -) { - debug!( - "axi_write_loadStore (channel_id={channel_id}, awid={awid}, awaddr={awaddr:#x}, \ - awlen={awlen}, awsize={awsize}, awburst={awburst}, awlock={awlock}, awcache={awcache}, \ - awprot={awprot}, awqos={awqos}, awregion={awregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - 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); -} - -#[no_mangle] -unsafe extern "C" fn axi_read_loadStoreAXI( - channel_id: c_longlong, - arid: c_longlong, - araddr: c_longlong, - arlen: c_longlong, - arsize: c_longlong, - arburst: c_longlong, - arlock: c_longlong, - arcache: c_longlong, - arprot: c_longlong, - arqos: c_longlong, - arregion: c_longlong, - payload: *mut SvBitVecVal, -) { - debug!( - "axi_read_loadStoreAXI (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \ - arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \ - arprot={arprot}, arqos={arqos}, arregion={arregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - let response = driver.axi_read_load_store(araddr as u32, arsize as u64); - fill_axi_read_payload(payload, driver.dlen, &response); -} - -#[no_mangle] -unsafe extern "C" fn axi_read_instructionFetchAXI( - channel_id: c_longlong, - arid: c_longlong, - araddr: c_longlong, - arlen: c_longlong, - arsize: c_longlong, - arburst: c_longlong, - arlock: c_longlong, - arcache: c_longlong, - arprot: c_longlong, - arqos: c_longlong, - arregion: c_longlong, - payload: *mut SvBitVecVal, -) { - debug!( - "axi_read_instructionFetchAXI (channel_id={channel_id}, arid={arid}, araddr={araddr:#x}, \ - arlen={arlen}, arsize={arsize}, arburst={arburst}, arlock={arlock}, arcache={arcache}, \ - arprot={arprot}, arqos={arqos}, arregion={arregion})" - ); - let mut driver = DPI_TARGET.lock().unwrap(); - let driver = driver.as_mut().unwrap(); - let response = driver.axi_read_instruction_fetch(araddr as u32, arsize as u64); - fill_axi_read_payload(payload, driver.dlen, &response); -} - -#[no_mangle] -unsafe extern "C" fn t1rocket_cosim_init() { - let args = OfflineArgs::parse(); - args.common_args.setup_logger().unwrap(); - - let scope = SvScope::get_current().expect("failed to get scope in t1rocket_cosim_init"); - - let driver = Box::new(Driver::new(scope, &args)); - let mut dpi_target = DPI_TARGET.lock().unwrap(); - assert!( - dpi_target.is_none(), - "t1rocket_cosim_init should be called only once" - ); - *dpi_target = Some(driver); -} - -/// evaluate at every 1024 cycles, return reason = 0 to continue simulation, -/// other value is used as error code. -#[no_mangle] -unsafe extern "C" fn cosim_watchdog(reason: *mut c_char) { - // watchdog dpi call would be called before initialization, guard on null target - let mut driver = DPI_TARGET.lock().unwrap(); - if let Some(driver) = driver.as_mut() { - *reason = driver.watchdog() as c_char - } -} - -/// evaluate at every cycle, return quit_flag = false to continue simulation, -#[no_mangle] -unsafe extern "C" fn cosim_quit(quit_flag: *mut bool) { - // watchdog dpi call would be called before initialization, guard on null target - let mut driver = DPI_TARGET.lock().unwrap(); - if let Some(driver) = driver.as_mut() { - *quit_flag = driver.quit as bool - } -} - -#[no_mangle] -unsafe extern "C" fn get_resetvector(resetvector: *mut c_longlong) { - let mut driver = DPI_TARGET.lock().unwrap(); - if let Some(driver) = driver.as_mut() { - *resetvector = driver.e_entry as c_longlong - } -} - -//-------------------------------- -// import functions and wrappers -//-------------------------------- - -mod dpi_export { - use std::ffi::c_char; - extern "C" { - #[cfg(feature = "trace")] - /// `export "DPI-C" function dump_wave(input string file)` - pub fn dump_wave(path: *const c_char); - } -} - -#[cfg(feature = "trace")] -pub(crate) fn dump_wave(scope: crate::svdpi::SvScope, path: &str) { - use crate::svdpi; - let path_cstring = CString::new(path).unwrap(); - - svdpi::set_scope(scope); - unsafe { - dpi_export::dump_wave(path_cstring.as_ptr()); - } -} diff --git a/t1rocketemu/online_dpi/src/drive.rs b/t1rocketemu/online_dpi/src/drive.rs deleted file mode 100644 index 4288cdf70..000000000 --- a/t1rocketemu/online_dpi/src/drive.rs +++ /dev/null @@ -1,409 +0,0 @@ -use crate::dpi::*; -use crate::svdpi::SvScope; -use crate::OfflineArgs; -use crate::{get_t, EXIT_CODE, EXIT_POS}; - -use anyhow::Context; -use common::MEM_SIZE; -use elf::{ - abi::{EM_RISCV, ET_EXEC, PT_LOAD, STT_FUNC}, - endian::LittleEndian, - ElfStream, -}; -use std::collections::HashMap; -use std::os::unix::fs::FileExt; -use std::{fs, path::Path}; -use tracing::{debug, error, info, trace}; - -struct ShadowMem { - mem: Vec, -} - -impl ShadowMem { - pub fn new() -> Self { - Self { mem: vec![0; MEM_SIZE] } - } - - pub fn read_mem(&self, addr: u32, size: u32) -> &[u8] { - let start = addr as usize; - let end = (addr + size) as usize; - &self.mem[start..end] - } - - // size: 1 << arsize - // bus_size: AXI bus width in bytes - // return: Vec with len=bus_size - // if size < bus_size, the result is padded due to AXI narrow transfer rules - pub fn read_mem_axi(&self, addr: u32, size: u32, bus_size: u32) -> Vec { - assert!( - addr % size == 0 && bus_size % size == 0, - "unaligned access addr={addr:#x} size={size}B dlen={bus_size}B" - ); - - let data = self.read_mem(addr, size); - if size < bus_size { - // narrow - let mut data_padded = vec![0; bus_size as usize]; - let start = (addr % bus_size) as usize; - let end = start + data.len(); - data_padded[start..end].copy_from_slice(data); - - data_padded - } else { - // normal - data.to_vec() - } - } - - // size: 1 << awsize - // bus_size: AXI bus width in bytes - // masks: write strokes, len=bus_size - // data: write data, len=bus_size - pub fn write_mem_axi( - &mut self, - addr: u32, - size: u32, - bus_size: u32, - masks: &[bool], - data: &[u8], - ) { - assert!( - addr % size == 0 && bus_size % size == 0, - "unaligned write access addr={addr:#x} size={size}B dlen={bus_size}B" - ); - - // handle strb=0 AXI payload - if !masks.iter().any(|&x| x) { - trace!("Mask 0 write detect"); - return; - } - - // TODO: we do not check strobe is compatible with (addr, awsize) - let addr_align = addr & ((!bus_size) + 1); - - let bus_size = bus_size as usize; - // should not check this, in scalar narrow write, bus_size is not equal to data.len() - // assert_eq!(bus_size, masks.len()); - // assert_eq!(bus_size, data.len()); - - for i in 0..bus_size { - if masks[i] { - self.mem[addr_align as usize + i] = data[i]; - } - } - } -} - -#[derive(Debug)] -#[allow(dead_code)] -pub struct FunctionSym { - #[allow(dead_code)] - pub(crate) name: String, - #[allow(dead_code)] - pub(crate) info: u8, -} -pub type FunctionSymTab = HashMap; - -pub(crate) struct Driver { - // SvScope from t1rocket_cosim_init - scope: SvScope, - - #[cfg(feature = "trace")] - wave_path: String, - #[cfg(feature = "trace")] - dump_start: u64, - #[cfg(feature = "trace")] - dump_end: u64, - #[cfg(feature = "trace")] - dump_started: bool, - - pub(crate) dlen: u32, - pub(crate) e_entry: u64, - - timeout: u64, - last_commit_cycle: u64, - - shadow_mem: ShadowMem, - - pub(crate) quit: bool, -} - -#[cfg(feature = "trace")] -fn parse_range(input: &str) -> (u64, u64) { - if input.is_empty() { - return (0, 0); - } - - let parts: Vec<&str> = input.split(",").collect(); - - if parts.len() != 1 && parts.len() != 2 { - error!("invalid dump wave range: `{input}` was given"); - return (0, 0); - } - - const INVALID_NUMBER: &'static str = "invalid number"; - - if parts.len() == 1 { - return (parts[0].parse().expect(INVALID_NUMBER), 0); - } - - if parts[0].is_empty() { - return (0, parts[1].parse().expect(INVALID_NUMBER)); - } - - let start = parts[0].parse().expect(INVALID_NUMBER); - let end = parts[1].parse().expect(INVALID_NUMBER); - if start > end { - panic!("dump start is larger than end: `{input}`"); - } - - (start, end) -} - -impl Driver { - pub(crate) fn new(scope: SvScope, args: &OfflineArgs) -> Self { - #[cfg(feature = "trace")] - let (dump_start, dump_end) = parse_range(&args.dump_range); - - // pass e_entry to rocket - let (e_entry, shadow_mem, _fn_sym_tab) = - Self::load_elf(&args.common_args.elf_file).expect("fail creating simulator"); - - Self { - scope, - - #[cfg(feature = "trace")] - wave_path: args.wave_path.to_owned(), - #[cfg(feature = "trace")] - dump_start, - #[cfg(feature = "trace")] - dump_end, - #[cfg(feature = "trace")] - dump_started: false, - - dlen: args.common_args.dlen, - e_entry, - - timeout: args.timeout, - last_commit_cycle: 0, - - shadow_mem, - - quit: false, - } - } - - pub fn load_elf(path: &Path) -> anyhow::Result<(u64, ShadowMem, FunctionSymTab)> { - let file = fs::File::open(path).with_context(|| "reading ELF file")?; - let mut elf: ElfStream = - ElfStream::open_stream(&file).with_context(|| "parsing ELF file")?; - - if elf.ehdr.e_machine != EM_RISCV { - anyhow::bail!("ELF is not in RISC-V"); - } - - if elf.ehdr.e_type != ET_EXEC { - anyhow::bail!("ELF is not an executable"); - } - - if elf.ehdr.e_phnum == 0 { - anyhow::bail!("ELF has zero size program header"); - } - - debug!("ELF entry: 0x{:x}", elf.ehdr.e_entry); - let mut mem = ShadowMem::new(); - elf.segments().iter().filter(|phdr| phdr.p_type == PT_LOAD).for_each(|phdr| { - let vaddr: usize = phdr.p_vaddr.try_into().expect("fail converting vaddr(u64) to usize"); - let filesz: usize = phdr.p_filesz.try_into().expect("fail converting p_filesz(u64) to usize"); - debug!( - "Read loadable segments 0x{:x}..0x{:x} to memory 0x{:x}", - phdr.p_offset, - phdr.p_offset + filesz as u64, - vaddr - ); - - // Load file start from offset into given mem slice - // The `offset` of the read_at method is relative to the start of the file and thus independent from the current cursor. - let mem_slice = &mut mem.mem[vaddr..vaddr + filesz]; - file.read_at(mem_slice, phdr.p_offset).unwrap_or_else(|err| { - panic!( - "fail reading ELF into mem with vaddr={}, filesz={}, offset={}. Error detail: {}", - vaddr, filesz, phdr.p_offset, err - ) - }); - }); - - // FIXME: now the symbol table doesn't contain any function value - let mut fn_sym_tab = FunctionSymTab::new(); - let symbol_table = - elf.symbol_table().with_context(|| "reading symbol table(SHT_SYMTAB) from ELF")?; - if let Some((parsed_table, string_table)) = symbol_table { - parsed_table - .iter() - // st_symtype = symbol.st_info & 0xf (But why masking here?) - .filter(|sym| sym.st_symtype() == STT_FUNC) - .for_each(|sym| { - let name = string_table - .get(sym.st_name as usize) - .unwrap_or_else(|_| panic!("fail to get name at st_name={}", sym.st_name)); - fn_sym_tab.insert( - sym.st_value, - FunctionSym { name: name.to_string(), info: sym.st_symtype() }, - ); - }); - } else { - debug!("load_elf: symtab not found"); - }; - - Ok((elf.ehdr.e_entry, mem, fn_sym_tab)) - } - - pub(crate) fn axi_read_high_bandwidth(&mut self, addr: u32, arsize: u64) -> AxiReadPayload { - let size = 1 << arsize; - let data = self.shadow_mem.read_mem_axi(addr, size, self.dlen / 8); - let data_hex = hex::encode(&data); - self.last_commit_cycle = get_t(); - trace!( - "[{}] axi_read_high_bandwidth (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - AxiReadPayload { data } - } - - pub(crate) fn axi_write_high_bandwidth( - &mut self, - addr: u32, - awsize: u64, - strobe: &[bool], - data: &[u8], - ) { - let size = 1 << awsize; - self.shadow_mem.write_mem_axi(addr, size, self.dlen / 8, &strobe, data); - let data_hex = hex::encode(data); - self.last_commit_cycle = get_t(); - trace!( - "[{}] axi_write_high_bandwidth (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - } - - pub(crate) fn axi_read_high_outstanding(&mut self, addr: u32, arsize: u64) -> AxiReadPayload { - let size = 1 << arsize; - assert!(size <= 4); - let data = self.shadow_mem.read_mem_axi(addr, size, 4); - let data_hex = hex::encode(&data); - self.last_commit_cycle = get_t(); - trace!( - "[{}] axi_read_high_outstanding (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - AxiReadPayload { data } - } - - pub(crate) fn axi_write_high_outstanding( - &mut self, - addr: u32, - awsize: u64, - strobe: &[bool], - data: &[u8], - ) { - let size = 1 << awsize; - self.shadow_mem.write_mem_axi(addr, size, 4, strobe, data); - let data_hex = hex::encode(data); - self.last_commit_cycle = get_t(); - trace!( - "[{}] axi_write_high_outstanding (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - } - - pub(crate) fn axi_read_load_store(&mut self, addr: u32, arsize: u64) -> AxiReadPayload { - let size = 1 << arsize; - let bus_size = if size == 32 { 32 } else { 4 }; - let data = self.shadow_mem.read_mem_axi(addr, size, bus_size); - let data_hex = hex::encode(&data); - self.last_commit_cycle = get_t(); - trace!( - "[{}] axi_read_load_store (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - AxiReadPayload { data } - } - - pub(crate) fn axi_write_load_store( - &mut self, - addr: u32, - awsize: u64, - strobe: &[bool], - data: &[u8], - ) { - let size = 1 << awsize; - let bus_size = if size == 32 { 32 } else { 4 }; - self.shadow_mem.write_mem_axi(addr, size, bus_size, strobe, data); - let data_hex = hex::encode(data); - self.last_commit_cycle = get_t(); - - trace!( - "[{}] axi_write_load_store (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - - // check exit with code - if addr == EXIT_POS { - let exit_data_slice = data[..4].try_into().expect("slice with incorrect length"); - if u32::from_le_bytes(exit_data_slice) == EXIT_CODE { - info!("driver is ready to quit"); - self.quit = true; - } - } - } - - pub(crate) fn axi_read_instruction_fetch(&mut self, addr: u32, arsize: u64) -> AxiReadPayload { - let size = 1 << arsize; - let data = self.shadow_mem.read_mem_axi(addr, size, 32); - let data_hex = hex::encode(&data); - trace!( - "[{}] axi_read_instruction_fetch (addr={addr:#x}, size={size}, data={data_hex})", - get_t() - ); - AxiReadPayload { data } - } - - pub(crate) fn watchdog(&mut self) -> u8 { - const WATCHDOG_CONTINUE: u8 = 0; - const WATCHDOG_TIMEOUT: u8 = 1; - - let tick = get_t(); - if tick - self.last_commit_cycle > self.timeout { - error!( - "[{}] watchdog timeout (last_commit_cycle={})", - get_t(), - self.last_commit_cycle - ); - WATCHDOG_TIMEOUT - } else { - #[cfg(feature = "trace")] - if self.dump_end != 0 && tick > self.dump_end { - info!( - "[{tick}] run to dump end, exiting (last_commit_cycle={})", - self.last_commit_cycle - ); - return WATCHDOG_TIMEOUT; - } - - #[cfg(feature = "trace")] - if !self.dump_started && tick >= self.dump_start { - self.start_dump_wave(); - self.dump_started = true; - } - - trace!("[{}] watchdog continue", get_t()); - WATCHDOG_CONTINUE - } - } - - #[cfg(feature = "trace")] - fn start_dump_wave(&mut self) { - dump_wave(self.scope, &self.wave_path); - } -} diff --git a/t1rocketemu/online_dpi/src/lib.rs b/t1rocketemu/online_dpi/src/lib.rs deleted file mode 100644 index 2f875209e..000000000 --- a/t1rocketemu/online_dpi/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -use clap::Parser; -use common::CommonArgs; - -pub mod dpi; -pub mod drive; -pub mod svdpi; -#[cfg(feature = "svvpi")] -pub mod svvpi; - -#[derive(Parser)] -pub(crate) struct OfflineArgs { - #[command(flatten)] - pub common_args: CommonArgs, - - #[cfg(feature = "trace")] - #[arg(long)] - pub wave_path: String, - - #[cfg(feature = "trace")] - #[arg(long, default_value = "")] - pub dump_range: String, - - #[arg(long, default_value_t = 1000000)] - pub timeout: u64, -} - -// quit signal -const EXIT_POS: u32 = 0x4000_0000; -const EXIT_CODE: u32 = 0xdead_beef; - -// keep in sync with TestBench.ClockGen -pub const CYCLE_PERIOD: u64 = 20; - -/// get cycle -#[cfg(any(feature = "sv2023", feature = "svvpi"))] -pub fn get_t() -> u64 { - get_time() / CYCLE_PERIOD -} - -#[cfg(feature = "sv2023")] -pub fn get_time() -> u64 { - svdpi::get_time() -} - -#[cfg(all(not(feature = "sv2023"), feature = "svvpi"))] -pub fn get_time() -> u64 { - svvpi::get_time() -} diff --git a/t1rocketemu/online_dpi/src/svdpi.rs b/t1rocketemu/online_dpi/src/svdpi.rs deleted file mode 100644 index 32d2af9b0..000000000 --- a/t1rocketemu/online_dpi/src/svdpi.rs +++ /dev/null @@ -1,53 +0,0 @@ -use std::{ - ffi::{c_void, CString}, - ptr::{self, NonNull}, -}; - -#[rustfmt::skip] -pub mod sys; - -/// get current simulation time in _simulation time unit_ -#[cfg(feature = "sv2023")] -pub fn get_time() -> u64 { - let mut time = sys::svTimeVal { - type_: sys::sv_sim_time as i32, - high: 0, - low: 0, - real: 0.0, - }; - unsafe { - let ret = sys::svGetTime(ptr::null_mut(), &mut time); - assert!(ret == 0, "svGetTime failed"); - } - - ((time.high as u64) << 32) + (time.low as u64) -} - -pub fn set_scope_by_name(name: &str) { - let name_cstr = CString::new(name).unwrap(); - unsafe { - let scope = sys::svGetScopeFromName(name_cstr.as_ptr()); - assert!(!scope.is_null(), "unrecognized scope `{name}`"); - sys::svSetScope(scope); - } -} - -pub fn set_scope(scope: SvScope) { - unsafe { - sys::svSetScope(scope.ptr.as_ptr()); - } -} - -#[derive(Debug, Clone, Copy)] -pub struct SvScope { - ptr: NonNull, -} - -unsafe impl Send for SvScope {} - -impl SvScope { - pub fn get_current() -> Option { - let ptr = unsafe { sys::svGetScope() }; - NonNull::new(ptr).map(|ptr| Self { ptr }) - } -} diff --git a/t1rocketemu/online_dpi/src/svdpi/sys.rs b/t1rocketemu/online_dpi/src/svdpi/sys.rs deleted file mode 100644 index 892d7534b..000000000 --- a/t1rocketemu/online_dpi/src/svdpi/sys.rs +++ /dev/null @@ -1,750 +0,0 @@ -// modified from `bindgen --allowlist-item 'sv.*' svdpi.h` -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -/* automatically generated by rust-bindgen 0.69.4 */ - -pub const sv_0: u32 = 0; -pub const sv_1: u32 = 1; -pub const sv_z: u32 = 2; -pub const sv_x: u32 = 3; -pub const sv_scaled_real_time: u32 = 1; -pub const sv_sim_time: u32 = 2; -pub type svScalar = u8; -pub type svBit = svScalar; -pub type svLogic = svScalar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_vecval { - pub aval: u32, - pub bval: u32, -} -#[test] -fn bindgen_test_layout_t_vpi_vecval() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(t_vpi_vecval)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(t_vpi_vecval)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).aval) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vecval), - "::", - stringify!(aval) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bval) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vecval), - "::", - stringify!(bval) - ) - ); -} -pub type s_vpi_vecval = t_vpi_vecval; -pub type svLogicVecVal = s_vpi_vecval; -pub type svBitVecVal = u32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_time { - pub type_: i32, - pub high: u32, - pub low: u32, - pub real: f64, -} -#[test] -fn bindgen_test_layout_t_vpi_time() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(t_vpi_time)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_time)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).high) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(high) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).low) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(low) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).real) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(real) - ) - ); -} -pub type s_vpi_time = t_vpi_time; -pub type svTimeVal = s_vpi_time; -extern "C" { - pub fn svDpiVersion() -> *const ::std::os::raw::c_char; -} -pub type svScope = *mut ::std::os::raw::c_void; -pub type svOpenArrayHandle = *mut ::std::os::raw::c_void; -extern "C" { - pub fn svGetBitselBit(s: *const svBitVecVal, i: ::std::os::raw::c_int) -> svBit; -} -extern "C" { - pub fn svGetBitselLogic(s: *const svLogicVecVal, i: ::std::os::raw::c_int) -> svLogic; -} -extern "C" { - pub fn svPutBitselBit(d: *mut svBitVecVal, i: ::std::os::raw::c_int, s: svBit); -} -extern "C" { - pub fn svPutBitselLogic(d: *mut svLogicVecVal, i: ::std::os::raw::c_int, s: svLogic); -} -extern "C" { - pub fn svGetPartselBit( - d: *mut svBitVecVal, - s: *const svBitVecVal, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetPartselLogic( - d: *mut svLogicVecVal, - s: *const svLogicVecVal, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutPartselBit( - d: *mut svBitVecVal, - s: svBitVecVal, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutPartselLogic( - d: *mut svLogicVecVal, - s: svLogicVecVal, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svLeft(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svRight(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svLow(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svHigh(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svIncrement(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svSize(h: svOpenArrayHandle, d: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svDimensions(h: svOpenArrayHandle) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svGetArrayPtr(arg1: svOpenArrayHandle) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svSizeOfArray(arg1: svOpenArrayHandle) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svGetArrElemPtr( - arg1: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ... - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svGetArrElemPtr1( - arg1: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svGetArrElemPtr2( - arg1: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svGetArrElemPtr3( - arg1: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svPutBitArrElemVecVal( - d: svOpenArrayHandle, - s: *const svBitVecVal, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svPutBitArrElem1VecVal( - d: svOpenArrayHandle, - s: *const svBitVecVal, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem2VecVal( - d: svOpenArrayHandle, - s: *const svBitVecVal, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem3VecVal( - d: svOpenArrayHandle, - s: *const svBitVecVal, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElemVecVal( - d: svOpenArrayHandle, - s: *const svLogicVecVal, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svPutLogicArrElem1VecVal( - d: svOpenArrayHandle, - s: *const svLogicVecVal, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElem2VecVal( - d: svOpenArrayHandle, - s: *const svLogicVecVal, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElem3VecVal( - d: svOpenArrayHandle, - s: *const svLogicVecVal, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElemVecVal( - d: *mut svBitVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svGetBitArrElem1VecVal( - d: *mut svBitVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElem2VecVal( - d: *mut svBitVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElem3VecVal( - d: *mut svBitVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElemVecVal( - d: *mut svLogicVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svGetLogicArrElem1VecVal( - d: *mut svLogicVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElem2VecVal( - d: *mut svLogicVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElem3VecVal( - d: *mut svLogicVecVal, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElem(s: svOpenArrayHandle, indx1: ::std::os::raw::c_int, ...) -> svBit; -} -extern "C" { - pub fn svGetBitArrElem1(s: svOpenArrayHandle, indx1: ::std::os::raw::c_int) -> svBit; -} -extern "C" { - pub fn svGetBitArrElem2( - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ) -> svBit; -} -extern "C" { - pub fn svGetBitArrElem3( - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ) -> svBit; -} -extern "C" { - pub fn svGetLogicArrElem(s: svOpenArrayHandle, indx1: ::std::os::raw::c_int, ...) -> svLogic; -} -extern "C" { - pub fn svGetLogicArrElem1(s: svOpenArrayHandle, indx1: ::std::os::raw::c_int) -> svLogic; -} -extern "C" { - pub fn svGetLogicArrElem2( - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ) -> svLogic; -} -extern "C" { - pub fn svGetLogicArrElem3( - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ) -> svLogic; -} -extern "C" { - pub fn svPutLogicArrElem( - d: svOpenArrayHandle, - value: svLogic, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svPutLogicArrElem1(d: svOpenArrayHandle, value: svLogic, indx1: ::std::os::raw::c_int); -} -extern "C" { - pub fn svPutLogicArrElem2( - d: svOpenArrayHandle, - value: svLogic, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElem3( - d: svOpenArrayHandle, - value: svLogic, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem(d: svOpenArrayHandle, value: svBit, indx1: ::std::os::raw::c_int, ...); -} -extern "C" { - pub fn svPutBitArrElem1(d: svOpenArrayHandle, value: svBit, indx1: ::std::os::raw::c_int); -} -extern "C" { - pub fn svPutBitArrElem2( - d: svOpenArrayHandle, - value: svBit, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem3( - d: svOpenArrayHandle, - value: svBit, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetScope() -> svScope; -} -extern "C" { - pub fn svSetScope(scope: svScope) -> svScope; -} -extern "C" { - pub fn svGetNameFromScope(arg1: svScope) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn svGetScopeFromName(scopeName: *const ::std::os::raw::c_char) -> svScope; -} -extern "C" { - pub fn svPutUserData( - scope: svScope, - userKey: *mut ::std::os::raw::c_void, - userData: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svGetUserData( - scope: svScope, - userKey: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn svGetCallerInfo( - fileName: *mut *const ::std::os::raw::c_char, - lineNumber: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svIsDisabledState() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svAckDisabledState(); -} -#[cfg(feature = "sv2023")] -extern "C" { - pub fn svGetTime(scope: svScope, time: *mut svTimeVal) -> ::std::os::raw::c_int; -} -#[cfg(feature = "sv2023")] -extern "C" { - pub fn svGetTimeUnit(scope: svScope, time_unit: *mut i32) -> ::std::os::raw::c_int; -} -#[cfg(feature = "sv2023")] -extern "C" { - pub fn svGetTimePrecision(scope: svScope, time_precision: *mut i32) -> ::std::os::raw::c_int; -} -pub type svBitVec32 = ::std::os::raw::c_uint; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct svLogicVec32 { - pub c: ::std::os::raw::c_uint, - pub d: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_svLogicVec32() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(svLogicVec32)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(svLogicVec32)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(svLogicVec32), - "::", - stringify!(c) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(svLogicVec32), - "::", - stringify!(d) - ) - ); -} -pub type svBitPackedArrRef = *mut ::std::os::raw::c_void; -pub type svLogicPackedArrRef = *mut ::std::os::raw::c_void; -extern "C" { - pub fn svSizeOfBitPackedArr(width: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svSizeOfLogicPackedArr(width: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn svPutBitVec32(d: svBitPackedArrRef, s: *const svBitVec32, w: ::std::os::raw::c_int); -} -extern "C" { - pub fn svPutLogicVec32( - d: svLogicPackedArrRef, - s: *const svLogicVec32, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitVec32(d: *mut svBitVec32, s: svBitPackedArrRef, w: ::std::os::raw::c_int); -} -extern "C" { - pub fn svGetLogicVec32(d: *mut svLogicVec32, s: svLogicPackedArrRef, w: ::std::os::raw::c_int); -} -extern "C" { - pub fn svGetSelectBit(s: svBitPackedArrRef, i: ::std::os::raw::c_int) -> svBit; -} -extern "C" { - pub fn svGetSelectLogic(s: svLogicPackedArrRef, i: ::std::os::raw::c_int) -> svLogic; -} -extern "C" { - pub fn svPutSelectBit(d: svBitPackedArrRef, i: ::std::os::raw::c_int, s: svBit); -} -extern "C" { - pub fn svPutSelectLogic(d: svLogicPackedArrRef, i: ::std::os::raw::c_int, s: svLogic); -} -extern "C" { - pub fn svGetPartSelectBit( - d: *mut svBitVec32, - s: svBitPackedArrRef, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBits( - s: svBitPackedArrRef, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ) -> svBitVec32; -} -extern "C" { - pub fn svGet32Bits(s: svBitPackedArrRef, i: ::std::os::raw::c_int) -> svBitVec32; -} -extern "C" { - pub fn svGet64Bits(s: svBitPackedArrRef, i: ::std::os::raw::c_int) -> u64; -} -extern "C" { - pub fn svGetPartSelectLogic( - d: *mut svLogicVec32, - s: svLogicPackedArrRef, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutPartSelectBit( - d: svBitPackedArrRef, - s: svBitVec32, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutPartSelectLogic( - d: svLogicPackedArrRef, - s: *const svLogicVec32, - i: ::std::os::raw::c_int, - w: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElemVec32( - d: svOpenArrayHandle, - s: *const svBitVec32, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svPutBitArrElem1Vec32( - d: svOpenArrayHandle, - s: *const svBitVec32, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem2Vec32( - d: svOpenArrayHandle, - s: *const svBitVec32, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutBitArrElem3Vec32( - d: svOpenArrayHandle, - s: *const svBitVec32, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElemVec32( - d: svOpenArrayHandle, - s: *const svLogicVec32, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svPutLogicArrElem1Vec32( - d: svOpenArrayHandle, - s: *const svLogicVec32, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElem2Vec32( - d: svOpenArrayHandle, - s: *const svLogicVec32, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svPutLogicArrElem3Vec32( - d: svOpenArrayHandle, - s: *const svLogicVec32, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElemVec32( - d: *mut svBitVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svGetBitArrElem1Vec32( - d: *mut svBitVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElem2Vec32( - d: *mut svBitVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetBitArrElem3Vec32( - d: *mut svBitVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElemVec32( - d: *mut svLogicVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ... - ); -} -extern "C" { - pub fn svGetLogicArrElem1Vec32( - d: *mut svLogicVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElem2Vec32( - d: *mut svLogicVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn svGetLogicArrElem3Vec32( - d: *mut svLogicVec32, - s: svOpenArrayHandle, - indx1: ::std::os::raw::c_int, - indx2: ::std::os::raw::c_int, - indx3: ::std::os::raw::c_int, - ); -} diff --git a/t1rocketemu/online_dpi/src/svvpi.rs b/t1rocketemu/online_dpi/src/svvpi.rs deleted file mode 100644 index f0cd8b8bd..000000000 --- a/t1rocketemu/online_dpi/src/svvpi.rs +++ /dev/null @@ -1,18 +0,0 @@ -#[rustfmt::skip] -pub mod sys; - -use std::ptr; - -/// get current simulation time in _simulation time unit_ -pub fn get_time() -> u64 { - let mut time = sys::s_vpi_time { - type_: sys::vpiSimTime as i32, - high: 0, - low: 0, - real: 0.0, - }; - unsafe { - sys::vpi_get_time(ptr::null_mut(), &mut time); - } - ((time.high as u64) << 32) + (time.low as u64) -} diff --git a/t1rocketemu/online_dpi/src/svvpi/sys.rs b/t1rocketemu/online_dpi/src/svvpi/sys.rs deleted file mode 100644 index c3d269855..000000000 --- a/t1rocketemu/online_dpi/src/svvpi/sys.rs +++ /dev/null @@ -1,2102 +0,0 @@ -// modified from `bindgen --allowlist-item 'vpi.*' sv_vpi_user.h` -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -/* automatically generated by rust-bindgen 0.69.4 */ - -pub const vpiAlways: u32 = 1; -pub const vpiAssignStmt: u32 = 2; -pub const vpiAssignment: u32 = 3; -pub const vpiBegin: u32 = 4; -pub const vpiCase: u32 = 5; -pub const vpiCaseItem: u32 = 6; -pub const vpiConstant: u32 = 7; -pub const vpiContAssign: u32 = 8; -pub const vpiDeassign: u32 = 9; -pub const vpiDefParam: u32 = 10; -pub const vpiDelayControl: u32 = 11; -pub const vpiDisable: u32 = 12; -pub const vpiEventControl: u32 = 13; -pub const vpiEventStmt: u32 = 14; -pub const vpiFor: u32 = 15; -pub const vpiForce: u32 = 16; -pub const vpiForever: u32 = 17; -pub const vpiFork: u32 = 18; -pub const vpiFuncCall: u32 = 19; -pub const vpiFunction: u32 = 20; -pub const vpiGate: u32 = 21; -pub const vpiIf: u32 = 22; -pub const vpiIfElse: u32 = 23; -pub const vpiInitial: u32 = 24; -pub const vpiIntegerVar: u32 = 25; -pub const vpiInterModPath: u32 = 26; -pub const vpiIterator: u32 = 27; -pub const vpiIODecl: u32 = 28; -pub const vpiMemory: u32 = 29; -pub const vpiMemoryWord: u32 = 30; -pub const vpiModPath: u32 = 31; -pub const vpiModule: u32 = 32; -pub const vpiNamedBegin: u32 = 33; -pub const vpiNamedEvent: u32 = 34; -pub const vpiNamedFork: u32 = 35; -pub const vpiNet: u32 = 36; -pub const vpiNetBit: u32 = 37; -pub const vpiNullStmt: u32 = 38; -pub const vpiOperation: u32 = 39; -pub const vpiParamAssign: u32 = 40; -pub const vpiParameter: u32 = 41; -pub const vpiPartSelect: u32 = 42; -pub const vpiPathTerm: u32 = 43; -pub const vpiPort: u32 = 44; -pub const vpiPortBit: u32 = 45; -pub const vpiPrimTerm: u32 = 46; -pub const vpiRealVar: u32 = 47; -pub const vpiReg: u32 = 48; -pub const vpiRegBit: u32 = 49; -pub const vpiRelease: u32 = 50; -pub const vpiRepeat: u32 = 51; -pub const vpiRepeatControl: u32 = 52; -pub const vpiSchedEvent: u32 = 53; -pub const vpiSpecParam: u32 = 54; -pub const vpiSwitch: u32 = 55; -pub const vpiSysFuncCall: u32 = 56; -pub const vpiSysTaskCall: u32 = 57; -pub const vpiTableEntry: u32 = 58; -pub const vpiTask: u32 = 59; -pub const vpiTaskCall: u32 = 60; -pub const vpiTchk: u32 = 61; -pub const vpiTchkTerm: u32 = 62; -pub const vpiTimeVar: u32 = 63; -pub const vpiTimeQueue: u32 = 64; -pub const vpiUdp: u32 = 65; -pub const vpiUdpDefn: u32 = 66; -pub const vpiUserSystf: u32 = 67; -pub const vpiVarSelect: u32 = 68; -pub const vpiWait: u32 = 69; -pub const vpiWhile: u32 = 70; -pub const vpiAttribute: u32 = 105; -pub const vpiBitSelect: u32 = 106; -pub const vpiCallback: u32 = 107; -pub const vpiDelayTerm: u32 = 108; -pub const vpiDelayDevice: u32 = 109; -pub const vpiFrame: u32 = 110; -pub const vpiGateArray: u32 = 111; -pub const vpiModuleArray: u32 = 112; -pub const vpiPrimitiveArray: u32 = 113; -pub const vpiNetArray: u32 = 114; -pub const vpiRange: u32 = 115; -pub const vpiRegArray: u32 = 116; -pub const vpiSwitchArray: u32 = 117; -pub const vpiUdpArray: u32 = 118; -pub const vpiContAssignBit: u32 = 128; -pub const vpiNamedEventArray: u32 = 129; -pub const vpiIndexedPartSelect: u32 = 130; -pub const vpiGenScopeArray: u32 = 133; -pub const vpiGenScope: u32 = 134; -pub const vpiGenVar: u32 = 135; -pub const vpiCondition: u32 = 71; -pub const vpiDelay: u32 = 72; -pub const vpiElseStmt: u32 = 73; -pub const vpiForIncStmt: u32 = 74; -pub const vpiForInitStmt: u32 = 75; -pub const vpiHighConn: u32 = 76; -pub const vpiLhs: u32 = 77; -pub const vpiIndex: u32 = 78; -pub const vpiLeftRange: u32 = 79; -pub const vpiLowConn: u32 = 80; -pub const vpiParent: u32 = 81; -pub const vpiRhs: u32 = 82; -pub const vpiRightRange: u32 = 83; -pub const vpiScope: u32 = 84; -pub const vpiSysTfCall: u32 = 85; -pub const vpiTchkDataTerm: u32 = 86; -pub const vpiTchkNotifier: u32 = 87; -pub const vpiTchkRefTerm: u32 = 88; -pub const vpiArgument: u32 = 89; -pub const vpiBit: u32 = 90; -pub const vpiDriver: u32 = 91; -pub const vpiInternalScope: u32 = 92; -pub const vpiLoad: u32 = 93; -pub const vpiModDataPathIn: u32 = 94; -pub const vpiModPathIn: u32 = 95; -pub const vpiModPathOut: u32 = 96; -pub const vpiOperand: u32 = 97; -pub const vpiPortInst: u32 = 98; -pub const vpiProcess: u32 = 99; -pub const vpiVariables: u32 = 100; -pub const vpiUse: u32 = 101; -pub const vpiExpr: u32 = 102; -pub const vpiPrimitive: u32 = 103; -pub const vpiStmt: u32 = 104; -pub const vpiActiveTimeFormat: u32 = 119; -pub const vpiInTerm: u32 = 120; -pub const vpiInstanceArray: u32 = 121; -pub const vpiLocalDriver: u32 = 122; -pub const vpiLocalLoad: u32 = 123; -pub const vpiOutTerm: u32 = 124; -pub const vpiPorts: u32 = 125; -pub const vpiSimNet: u32 = 126; -pub const vpiTaskFunc: u32 = 127; -pub const vpiBaseExpr: u32 = 131; -pub const vpiWidthExpr: u32 = 132; -pub const vpiAutomatics: u32 = 136; -pub const vpiUndefined: i32 = -1; -pub const vpiType: u32 = 1; -pub const vpiName: u32 = 2; -pub const vpiFullName: u32 = 3; -pub const vpiSize: u32 = 4; -pub const vpiFile: u32 = 5; -pub const vpiLineNo: u32 = 6; -pub const vpiTopModule: u32 = 7; -pub const vpiCellInstance: u32 = 8; -pub const vpiDefName: u32 = 9; -pub const vpiProtected: u32 = 10; -pub const vpiTimeUnit: u32 = 11; -pub const vpiTimePrecision: u32 = 12; -pub const vpiDefNetType: u32 = 13; -pub const vpiUnconnDrive: u32 = 14; -pub const vpiHighZ: u32 = 1; -pub const vpiPull1: u32 = 2; -pub const vpiPull0: u32 = 3; -pub const vpiDefFile: u32 = 15; -pub const vpiDefLineNo: u32 = 16; -pub const vpiDefDelayMode: u32 = 47; -pub const vpiDelayModeNone: u32 = 1; -pub const vpiDelayModePath: u32 = 2; -pub const vpiDelayModeDistrib: u32 = 3; -pub const vpiDelayModeUnit: u32 = 4; -pub const vpiDelayModeZero: u32 = 5; -pub const vpiDelayModeMTM: u32 = 6; -pub const vpiDefDecayTime: u32 = 48; -pub const vpiScalar: u32 = 17; -pub const vpiVector: u32 = 18; -pub const vpiExplicitName: u32 = 19; -pub const vpiDirection: u32 = 20; -pub const vpiInput: u32 = 1; -pub const vpiOutput: u32 = 2; -pub const vpiInout: u32 = 3; -pub const vpiMixedIO: u32 = 4; -pub const vpiNoDirection: u32 = 5; -pub const vpiConnByName: u32 = 21; -pub const vpiNetType: u32 = 22; -pub const vpiWire: u32 = 1; -pub const vpiWand: u32 = 2; -pub const vpiWor: u32 = 3; -pub const vpiTri: u32 = 4; -pub const vpiTri0: u32 = 5; -pub const vpiTri1: u32 = 6; -pub const vpiTriReg: u32 = 7; -pub const vpiTriAnd: u32 = 8; -pub const vpiTriOr: u32 = 9; -pub const vpiSupply1: u32 = 10; -pub const vpiSupply0: u32 = 11; -pub const vpiNone: u32 = 12; -pub const vpiUwire: u32 = 13; -pub const vpiNettypeNet: u32 = 14; -pub const vpiNettypeNetSelect: u32 = 15; -pub const vpiInterconnect: u32 = 16; -pub const vpiExplicitScalared: u32 = 23; -pub const vpiExplicitVectored: u32 = 24; -pub const vpiExpanded: u32 = 25; -pub const vpiImplicitDecl: u32 = 26; -pub const vpiChargeStrength: u32 = 27; -pub const vpiArray: u32 = 28; -pub const vpiPortIndex: u32 = 29; -pub const vpiTermIndex: u32 = 30; -pub const vpiStrength0: u32 = 31; -pub const vpiStrength1: u32 = 32; -pub const vpiPrimType: u32 = 33; -pub const vpiAndPrim: u32 = 1; -pub const vpiNandPrim: u32 = 2; -pub const vpiNorPrim: u32 = 3; -pub const vpiOrPrim: u32 = 4; -pub const vpiXorPrim: u32 = 5; -pub const vpiXnorPrim: u32 = 6; -pub const vpiBufPrim: u32 = 7; -pub const vpiNotPrim: u32 = 8; -pub const vpiBufif0Prim: u32 = 9; -pub const vpiBufif1Prim: u32 = 10; -pub const vpiNotif0Prim: u32 = 11; -pub const vpiNotif1Prim: u32 = 12; -pub const vpiNmosPrim: u32 = 13; -pub const vpiPmosPrim: u32 = 14; -pub const vpiCmosPrim: u32 = 15; -pub const vpiRnmosPrim: u32 = 16; -pub const vpiRpmosPrim: u32 = 17; -pub const vpiRcmosPrim: u32 = 18; -pub const vpiRtranPrim: u32 = 19; -pub const vpiRtranif0Prim: u32 = 20; -pub const vpiRtranif1Prim: u32 = 21; -pub const vpiTranPrim: u32 = 22; -pub const vpiTranif0Prim: u32 = 23; -pub const vpiTranif1Prim: u32 = 24; -pub const vpiPullupPrim: u32 = 25; -pub const vpiPulldownPrim: u32 = 26; -pub const vpiSeqPrim: u32 = 27; -pub const vpiCombPrim: u32 = 28; -pub const vpiPolarity: u32 = 34; -pub const vpiDataPolarity: u32 = 35; -pub const vpiPositive: u32 = 1; -pub const vpiNegative: u32 = 2; -pub const vpiUnknown: u32 = 3; -pub const vpiEdge: u32 = 36; -pub const vpiNoEdge: u32 = 0; -pub const vpiEdge01: u32 = 1; -pub const vpiEdge10: u32 = 2; -pub const vpiEdge0x: u32 = 4; -pub const vpiEdgex1: u32 = 8; -pub const vpiEdge1x: u32 = 16; -pub const vpiEdgex0: u32 = 32; -pub const vpiPosedge: u32 = 13; -pub const vpiNegedge: u32 = 50; -pub const vpiAnyEdge: u32 = 63; -pub const vpiPathType: u32 = 37; -pub const vpiPathFull: u32 = 1; -pub const vpiPathParallel: u32 = 2; -pub const vpiTchkType: u32 = 38; -pub const vpiSetup: u32 = 1; -pub const vpiHold: u32 = 2; -pub const vpiPeriod: u32 = 3; -pub const vpiWidth: u32 = 4; -pub const vpiSkew: u32 = 5; -pub const vpiRecovery: u32 = 6; -pub const vpiNoChange: u32 = 7; -pub const vpiSetupHold: u32 = 8; -pub const vpiFullskew: u32 = 9; -pub const vpiRecrem: u32 = 10; -pub const vpiRemoval: u32 = 11; -pub const vpiTimeskew: u32 = 12; -pub const vpiOpType: u32 = 39; -pub const vpiMinusOp: u32 = 1; -pub const vpiPlusOp: u32 = 2; -pub const vpiNotOp: u32 = 3; -pub const vpiBitNegOp: u32 = 4; -pub const vpiUnaryAndOp: u32 = 5; -pub const vpiUnaryNandOp: u32 = 6; -pub const vpiUnaryOrOp: u32 = 7; -pub const vpiUnaryNorOp: u32 = 8; -pub const vpiUnaryXorOp: u32 = 9; -pub const vpiUnaryXNorOp: u32 = 10; -pub const vpiSubOp: u32 = 11; -pub const vpiDivOp: u32 = 12; -pub const vpiModOp: u32 = 13; -pub const vpiEqOp: u32 = 14; -pub const vpiNeqOp: u32 = 15; -pub const vpiCaseEqOp: u32 = 16; -pub const vpiCaseNeqOp: u32 = 17; -pub const vpiGtOp: u32 = 18; -pub const vpiGeOp: u32 = 19; -pub const vpiLtOp: u32 = 20; -pub const vpiLeOp: u32 = 21; -pub const vpiLShiftOp: u32 = 22; -pub const vpiRShiftOp: u32 = 23; -pub const vpiAddOp: u32 = 24; -pub const vpiMultOp: u32 = 25; -pub const vpiLogAndOp: u32 = 26; -pub const vpiLogOrOp: u32 = 27; -pub const vpiBitAndOp: u32 = 28; -pub const vpiBitOrOp: u32 = 29; -pub const vpiBitXorOp: u32 = 30; -pub const vpiBitXNorOp: u32 = 31; -pub const vpiBitXnorOp: u32 = 31; -pub const vpiConditionOp: u32 = 32; -pub const vpiConcatOp: u32 = 33; -pub const vpiMultiConcatOp: u32 = 34; -pub const vpiEventOrOp: u32 = 35; -pub const vpiNullOp: u32 = 36; -pub const vpiListOp: u32 = 37; -pub const vpiMinTypMaxOp: u32 = 38; -pub const vpiPosedgeOp: u32 = 39; -pub const vpiNegedgeOp: u32 = 40; -pub const vpiArithLShiftOp: u32 = 41; -pub const vpiArithRShiftOp: u32 = 42; -pub const vpiPowerOp: u32 = 43; -pub const vpiConstType: u32 = 40; -pub const vpiDecConst: u32 = 1; -pub const vpiRealConst: u32 = 2; -pub const vpiBinaryConst: u32 = 3; -pub const vpiOctConst: u32 = 4; -pub const vpiHexConst: u32 = 5; -pub const vpiStringConst: u32 = 6; -pub const vpiIntConst: u32 = 7; -pub const vpiTimeConst: u32 = 8; -pub const vpiBlocking: u32 = 41; -pub const vpiCaseType: u32 = 42; -pub const vpiCaseExact: u32 = 1; -pub const vpiCaseX: u32 = 2; -pub const vpiCaseZ: u32 = 3; -pub const vpiNetDeclAssign: u32 = 43; -pub const vpiFuncType: u32 = 44; -pub const vpiIntFunc: u32 = 1; -pub const vpiRealFunc: u32 = 2; -pub const vpiTimeFunc: u32 = 3; -pub const vpiSizedFunc: u32 = 4; -pub const vpiSizedSignedFunc: u32 = 5; -pub const vpiSysFuncType: u32 = 44; -pub const vpiSysFuncInt: u32 = 1; -pub const vpiSysFuncReal: u32 = 2; -pub const vpiSysFuncTime: u32 = 3; -pub const vpiSysFuncSized: u32 = 4; -pub const vpiUserDefn: u32 = 45; -pub const vpiScheduled: u32 = 46; -pub const vpiActive: u32 = 49; -pub const vpiAutomatic: u32 = 50; -pub const vpiCell: u32 = 51; -pub const vpiConfig: u32 = 52; -pub const vpiConstantSelect: u32 = 53; -pub const vpiDecompile: u32 = 54; -pub const vpiDefAttribute: u32 = 55; -pub const vpiDelayType: u32 = 56; -pub const vpiModPathDelay: u32 = 1; -pub const vpiInterModPathDelay: u32 = 2; -pub const vpiMIPDelay: u32 = 3; -pub const vpiIteratorType: u32 = 57; -pub const vpiLibrary: u32 = 58; -pub const vpiOffset: u32 = 60; -pub const vpiResolvedNetType: u32 = 61; -pub const vpiSaveRestartID: u32 = 62; -pub const vpiSaveRestartLocation: u32 = 63; -pub const vpiValid: u32 = 64; -pub const vpiValidFalse: u32 = 0; -pub const vpiValidTrue: u32 = 1; -pub const vpiSigned: u32 = 65; -pub const vpiLocalParam: u32 = 70; -pub const vpiModPathHasIfNone: u32 = 71; -pub const vpiIndexedPartSelectType: u32 = 72; -pub const vpiPosIndexed: u32 = 1; -pub const vpiNegIndexed: u32 = 2; -pub const vpiIsMemory: u32 = 73; -pub const vpiIsProtected: u32 = 74; -pub const vpiStop: u32 = 66; -pub const vpiFinish: u32 = 67; -pub const vpiReset: u32 = 68; -pub const vpiSetInteractiveScope: u32 = 69; -pub const vpiScaledRealTime: u32 = 1; -pub const vpiSimTime: u32 = 2; -pub const vpiSuppressTime: u32 = 3; -pub const vpiSupplyDrive: u32 = 128; -pub const vpiStrongDrive: u32 = 64; -pub const vpiPullDrive: u32 = 32; -pub const vpiWeakDrive: u32 = 8; -pub const vpiLargeCharge: u32 = 16; -pub const vpiMediumCharge: u32 = 4; -pub const vpiSmallCharge: u32 = 2; -pub const vpiHiZ: u32 = 1; -pub const vpiBinStrVal: u32 = 1; -pub const vpiOctStrVal: u32 = 2; -pub const vpiDecStrVal: u32 = 3; -pub const vpiHexStrVal: u32 = 4; -pub const vpiScalarVal: u32 = 5; -pub const vpiIntVal: u32 = 6; -pub const vpiRealVal: u32 = 7; -pub const vpiStringVal: u32 = 8; -pub const vpiVectorVal: u32 = 9; -pub const vpiStrengthVal: u32 = 10; -pub const vpiTimeVal: u32 = 11; -pub const vpiObjTypeVal: u32 = 12; -pub const vpiSuppressVal: u32 = 13; -pub const vpiShortIntVal: u32 = 14; -pub const vpiLongIntVal: u32 = 15; -pub const vpiShortRealVal: u32 = 16; -pub const vpiRawTwoStateVal: u32 = 17; -pub const vpiRawFourStateVal: u32 = 18; -pub const vpiNoDelay: u32 = 1; -pub const vpiInertialDelay: u32 = 2; -pub const vpiTransportDelay: u32 = 3; -pub const vpiPureTransportDelay: u32 = 4; -pub const vpiForceFlag: u32 = 5; -pub const vpiReleaseFlag: u32 = 6; -pub const vpiCancelEvent: u32 = 7; -pub const vpiReturnEvent: u32 = 4096; -pub const vpiUserAllocFlag: u32 = 8192; -pub const vpiOneValue: u32 = 16384; -pub const vpiPropagateOff: u32 = 32768; -pub const vpi0: u32 = 0; -pub const vpi1: u32 = 1; -pub const vpiZ: u32 = 2; -pub const vpiX: u32 = 3; -pub const vpiH: u32 = 4; -pub const vpiL: u32 = 5; -pub const vpiDontCare: u32 = 6; -pub const vpiSysTask: u32 = 1; -pub const vpiSysFunc: u32 = 2; -pub const vpiCompile: u32 = 1; -pub const vpiPLI: u32 = 2; -pub const vpiRun: u32 = 3; -pub const vpiNotice: u32 = 1; -pub const vpiWarning: u32 = 2; -pub const vpiError: u32 = 3; -pub const vpiSystem: u32 = 4; -pub const vpiInternal: u32 = 5; -pub const vpiPackage: u32 = 600; -pub const vpiInterface: u32 = 601; -pub const vpiProgram: u32 = 602; -pub const vpiInterfaceArray: u32 = 603; -pub const vpiProgramArray: u32 = 604; -pub const vpiTypespec: u32 = 605; -pub const vpiModport: u32 = 606; -pub const vpiInterfaceTfDecl: u32 = 607; -pub const vpiRefObj: u32 = 608; -pub const vpiTypeParameter: u32 = 609; -pub const vpiVarBit: u32 = 49; -pub const vpiLongIntVar: u32 = 610; -pub const vpiShortIntVar: u32 = 611; -pub const vpiIntVar: u32 = 612; -pub const vpiShortRealVar: u32 = 613; -pub const vpiByteVar: u32 = 614; -pub const vpiClassVar: u32 = 615; -pub const vpiStringVar: u32 = 616; -pub const vpiEnumVar: u32 = 617; -pub const vpiStructVar: u32 = 618; -pub const vpiUnionVar: u32 = 619; -pub const vpiBitVar: u32 = 620; -pub const vpiLogicVar: u32 = 48; -pub const vpiArrayVar: u32 = 116; -pub const vpiClassObj: u32 = 621; -pub const vpiChandleVar: u32 = 622; -pub const vpiPackedArrayVar: u32 = 623; -pub const vpiVirtualInterfaceVar: u32 = 728; -pub const vpiLongIntTypespec: u32 = 625; -pub const vpiShortRealTypespec: u32 = 626; -pub const vpiByteTypespec: u32 = 627; -pub const vpiShortIntTypespec: u32 = 628; -pub const vpiIntTypespec: u32 = 629; -pub const vpiClassTypespec: u32 = 630; -pub const vpiStringTypespec: u32 = 631; -pub const vpiChandleTypespec: u32 = 632; -pub const vpiEnumTypespec: u32 = 633; -pub const vpiEnumConst: u32 = 634; -pub const vpiIntegerTypespec: u32 = 635; -pub const vpiTimeTypespec: u32 = 636; -pub const vpiRealTypespec: u32 = 637; -pub const vpiStructTypespec: u32 = 638; -pub const vpiUnionTypespec: u32 = 639; -pub const vpiBitTypespec: u32 = 640; -pub const vpiLogicTypespec: u32 = 641; -pub const vpiArrayTypespec: u32 = 642; -pub const vpiVoidTypespec: u32 = 643; -pub const vpiTypespecMember: u32 = 644; -pub const vpiPackedArrayTypespec: u32 = 692; -pub const vpiSequenceTypespec: u32 = 696; -pub const vpiPropertyTypespec: u32 = 697; -pub const vpiEventTypespec: u32 = 698; -pub const vpiInterfaceTypespec: u32 = 906; -pub const vpiClockingBlock: u32 = 650; -pub const vpiClockingIODecl: u32 = 651; -pub const vpiClassDefn: u32 = 652; -pub const vpiConstraint: u32 = 653; -pub const vpiConstraintOrdering: u32 = 654; -pub const vpiDistItem: u32 = 645; -pub const vpiAliasStmt: u32 = 646; -pub const vpiThread: u32 = 647; -pub const vpiMethodFuncCall: u32 = 648; -pub const vpiMethodTaskCall: u32 = 649; -pub const vpiAssert: u32 = 686; -pub const vpiAssume: u32 = 687; -pub const vpiCover: u32 = 688; -pub const vpiRestrict: u32 = 901; -pub const vpiDisableCondition: u32 = 689; -pub const vpiClockingEvent: u32 = 690; -pub const vpiPropertyDecl: u32 = 655; -pub const vpiPropertySpec: u32 = 656; -pub const vpiPropertyExpr: u32 = 657; -pub const vpiMulticlockSequenceExpr: u32 = 658; -pub const vpiClockedSeq: u32 = 659; -pub const vpiClockedProp: u32 = 902; -pub const vpiPropertyInst: u32 = 660; -pub const vpiSequenceDecl: u32 = 661; -pub const vpiCaseProperty: u32 = 662; -pub const vpiCasePropertyItem: u32 = 905; -pub const vpiSequenceInst: u32 = 664; -pub const vpiImmediateAssert: u32 = 665; -pub const vpiImmediateAssume: u32 = 694; -pub const vpiImmediateCover: u32 = 695; -pub const vpiReturn: u32 = 666; -pub const vpiAnyPattern: u32 = 667; -pub const vpiTaggedPattern: u32 = 668; -pub const vpiStructPattern: u32 = 669; -pub const vpiDoWhile: u32 = 670; -pub const vpiOrderedWait: u32 = 671; -pub const vpiWaitFork: u32 = 672; -pub const vpiDisableFork: u32 = 673; -pub const vpiExpectStmt: u32 = 674; -pub const vpiForeachStmt: u32 = 675; -pub const vpiReturnStmt: u32 = 691; -pub const vpiFinal: u32 = 676; -pub const vpiExtends: u32 = 677; -pub const vpiDistribution: u32 = 678; -pub const vpiSeqFormalDecl: u32 = 679; -pub const vpiPropFormalDecl: u32 = 699; -pub const vpiArrayNet: u32 = 114; -pub const vpiEnumNet: u32 = 680; -pub const vpiIntegerNet: u32 = 681; -pub const vpiLogicNet: u32 = 36; -pub const vpiTimeNet: u32 = 682; -pub const vpiUnionNet: u32 = 525; -pub const vpiShortRealNet: u32 = 526; -pub const vpiRealNet: u32 = 527; -pub const vpiByteNet: u32 = 528; -pub const vpiShortIntNet: u32 = 529; -pub const vpiIntNet: u32 = 530; -pub const vpiLongIntNet: u32 = 531; -pub const vpiBitNet: u32 = 532; -pub const vpiInterconnectNet: u32 = 533; -pub const vpiInterconnectArray: u32 = 534; -pub const vpiStructNet: u32 = 683; -pub const vpiBreak: u32 = 684; -pub const vpiContinue: u32 = 685; -pub const vpiPackedArrayNet: u32 = 693; -pub const vpiNettypeDecl: u32 = 523; -pub const vpiConstraintExpr: u32 = 747; -pub const vpiElseConst: u32 = 748; -pub const vpiImplication: u32 = 749; -pub const vpiConstrIf: u32 = 738; -pub const vpiConstrIfElse: u32 = 739; -pub const vpiConstrForEach: u32 = 736; -pub const vpiSoftDisable: u32 = 733; -pub const vpiLetDecl: u32 = 903; -pub const vpiLetExpr: u32 = 904; -pub const vpiActual: u32 = 700; -pub const vpiTypedefAlias: u32 = 701; -pub const vpiIndexTypespec: u32 = 702; -pub const vpiBaseTypespec: u32 = 703; -pub const vpiElemTypespec: u32 = 704; -pub const vpiNetTypedefAlias: u32 = 705; -pub const vpiInputSkew: u32 = 706; -pub const vpiOutputSkew: u32 = 707; -pub const vpiGlobalClocking: u32 = 708; -pub const vpiDefaultClocking: u32 = 709; -pub const vpiDefaultDisableIff: u32 = 710; -pub const vpiOrigin: u32 = 713; -pub const vpiPrefix: u32 = 714; -pub const vpiWith: u32 = 715; -pub const vpiProperty: u32 = 718; -pub const vpiValueRange: u32 = 720; -pub const vpiPattern: u32 = 721; -pub const vpiWeight: u32 = 722; -pub const vpiConstraintItem: u32 = 746; -pub const vpiTypedef: u32 = 725; -pub const vpiImport: u32 = 726; -pub const vpiDerivedClasses: u32 = 727; -pub const vpiInterfaceDecl: u32 = 728; -pub const vpiMethods: u32 = 730; -pub const vpiSolveBefore: u32 = 731; -pub const vpiSolveAfter: u32 = 732; -pub const vpiWaitingProcesses: u32 = 734; -pub const vpiMessages: u32 = 735; -pub const vpiLoopVars: u32 = 737; -pub const vpiConcurrentAssertion: u32 = 740; -pub const vpiConcurrentAssertions: u32 = 740; -pub const vpiMatchItem: u32 = 741; -pub const vpiMember: u32 = 742; -pub const vpiElement: u32 = 743; -pub const vpiAssertion: u32 = 744; -pub const vpiInstance: u32 = 745; -pub const vpiTop: u32 = 600; -pub const vpiUnit: u32 = 602; -pub const vpiJoinType: u32 = 603; -pub const vpiJoin: u32 = 0; -pub const vpiJoinNone: u32 = 1; -pub const vpiJoinAny: u32 = 2; -pub const vpiAccessType: u32 = 604; -pub const vpiForkJoinAcc: u32 = 1; -pub const vpiExternAcc: u32 = 2; -pub const vpiDPIExportAcc: u32 = 3; -pub const vpiDPIImportAcc: u32 = 4; -pub const vpiArrayType: u32 = 606; -pub const vpiStaticArray: u32 = 1; -pub const vpiDynamicArray: u32 = 2; -pub const vpiAssocArray: u32 = 3; -pub const vpiQueueArray: u32 = 4; -pub const vpiArrayMember: u32 = 607; -pub const vpiIsRandomized: u32 = 608; -pub const vpiLocalVarDecls: u32 = 609; -pub const vpiOpStrong: u32 = 656; -pub const vpiRandType: u32 = 610; -pub const vpiNotRand: u32 = 1; -pub const vpiRand: u32 = 2; -pub const vpiRandC: u32 = 3; -pub const vpiPortType: u32 = 611; -pub const vpiInterfacePort: u32 = 1; -pub const vpiModportPort: u32 = 2; -pub const vpiConstantVariable: u32 = 612; -pub const vpiStructUnionMember: u32 = 615; -pub const vpiVisibility: u32 = 620; -pub const vpiPublicVis: u32 = 1; -pub const vpiProtectedVis: u32 = 2; -pub const vpiLocalVis: u32 = 3; -pub const vpiOneStepConst: u32 = 9; -pub const vpiUnboundedConst: u32 = 10; -pub const vpiNullConst: u32 = 11; -pub const vpiAlwaysType: u32 = 624; -pub const vpiAlwaysComb: u32 = 2; -pub const vpiAlwaysFF: u32 = 3; -pub const vpiAlwaysLatch: u32 = 4; -pub const vpiDistType: u32 = 625; -pub const vpiEqualDist: u32 = 1; -pub const vpiDivDist: u32 = 2; -pub const vpiPacked: u32 = 630; -pub const vpiTagged: u32 = 632; -pub const vpiRef: u32 = 6; -pub const vpiVirtual: u32 = 635; -pub const vpiHasActual: u32 = 636; -pub const vpiIsConstraintEnabled: u32 = 638; -pub const vpiSoft: u32 = 639; -pub const vpiClassType: u32 = 640; -pub const vpiMailboxClass: u32 = 1; -pub const vpiSemaphoreClass: u32 = 2; -pub const vpiUserDefinedClass: u32 = 3; -pub const vpiProcessClass: u32 = 4; -pub const vpiMethod: u32 = 645; -pub const vpiIsClockInferred: u32 = 649; -pub const vpiIsDeferred: u32 = 657; -pub const vpiIsFinal: u32 = 670; -pub const vpiIsCoverSequence: u32 = 659; -pub const vpiQualifier: u32 = 650; -pub const vpiNoQualifier: u32 = 0; -pub const vpiUniqueQualifier: u32 = 1; -pub const vpiPriorityQualifier: u32 = 2; -pub const vpiTaggedQualifier: u32 = 4; -pub const vpiRandQualifier: u32 = 8; -pub const vpiInsideQualifier: u32 = 16; -pub const vpiInputEdge: u32 = 651; -pub const vpiOutputEdge: u32 = 652; -pub const vpiGeneric: u32 = 653; -pub const vpiCompatibilityMode: u32 = 654; -pub const vpiMode1364v1995: u32 = 1; -pub const vpiMode1364v2001: u32 = 2; -pub const vpiMode1364v2005: u32 = 3; -pub const vpiMode1800v2005: u32 = 4; -pub const vpiMode1800v2009: u32 = 5; -pub const vpiPackedArrayMember: u32 = 655; -pub const vpiStartLine: u32 = 661; -pub const vpiColumn: u32 = 662; -pub const vpiEndLine: u32 = 663; -pub const vpiEndColumn: u32 = 664; -pub const vpiAllocScheme: u32 = 658; -pub const vpiAutomaticScheme: u32 = 1; -pub const vpiDynamicScheme: u32 = 2; -pub const vpiOtherScheme: u32 = 3; -pub const vpiObjId: u32 = 660; -pub const vpiDPIPure: u32 = 665; -pub const vpiDPIContext: u32 = 666; -pub const vpiDPICStr: u32 = 667; -pub const vpiDPI: u32 = 1; -pub const vpiDPIC: u32 = 2; -pub const vpiDPICIdentifier: u32 = 668; -pub const vpiIsModPort: u32 = 669; -pub const vpiImplyOp: u32 = 50; -pub const vpiNonOverlapImplyOp: u32 = 51; -pub const vpiOverlapImplyOp: u32 = 52; -pub const vpiAcceptOnOp: u32 = 83; -pub const vpiRejectOnOp: u32 = 84; -pub const vpiSyncAcceptOnOp: u32 = 85; -pub const vpiSyncRejectOnOp: u32 = 86; -pub const vpiOverlapFollowedByOp: u32 = 87; -pub const vpiNonOverlapFollowedByOp: u32 = 88; -pub const vpiNexttimeOp: u32 = 89; -pub const vpiAlwaysOp: u32 = 90; -pub const vpiEventuallyOp: u32 = 91; -pub const vpiUntilOp: u32 = 92; -pub const vpiUntilWithOp: u32 = 93; -pub const vpiUnaryCycleDelayOp: u32 = 53; -pub const vpiCycleDelayOp: u32 = 54; -pub const vpiIntersectOp: u32 = 55; -pub const vpiFirstMatchOp: u32 = 56; -pub const vpiThroughoutOp: u32 = 57; -pub const vpiWithinOp: u32 = 58; -pub const vpiRepeatOp: u32 = 59; -pub const vpiConsecutiveRepeatOp: u32 = 60; -pub const vpiGotoRepeatOp: u32 = 61; -pub const vpiPostIncOp: u32 = 62; -pub const vpiPreIncOp: u32 = 63; -pub const vpiPostDecOp: u32 = 64; -pub const vpiPreDecOp: u32 = 65; -pub const vpiMatchOp: u32 = 66; -pub const vpiCastOp: u32 = 67; -pub const vpiIffOp: u32 = 68; -pub const vpiWildEqOp: u32 = 69; -pub const vpiWildNeqOp: u32 = 70; -pub const vpiStreamLROp: u32 = 71; -pub const vpiStreamRLOp: u32 = 72; -pub const vpiMatchedOp: u32 = 73; -pub const vpiTriggeredOp: u32 = 74; -pub const vpiAssignmentPatternOp: u32 = 75; -pub const vpiMultiAssignmentPatternOp: u32 = 76; -pub const vpiIfOp: u32 = 77; -pub const vpiIfElseOp: u32 = 78; -pub const vpiCompAndOp: u32 = 79; -pub const vpiCompOrOp: u32 = 80; -pub const vpiImpliesOp: u32 = 94; -pub const vpiInsideOp: u32 = 95; -pub const vpiTypeOp: u32 = 81; -pub const vpiAssignmentOp: u32 = 82; -pub const vpiOtherFunc: u32 = 6; -pub const vpiValidUnknown: u32 = 2; -pub const vpiCoverageStart: u32 = 750; -pub const vpiCoverageStop: u32 = 751; -pub const vpiCoverageReset: u32 = 752; -pub const vpiCoverageCheck: u32 = 753; -pub const vpiCoverageMerge: u32 = 754; -pub const vpiCoverageSave: u32 = 755; -pub const vpiAssertCoverage: u32 = 760; -pub const vpiFsmStateCoverage: u32 = 761; -pub const vpiStatementCoverage: u32 = 762; -pub const vpiToggleCoverage: u32 = 763; -pub const vpiCovered: u32 = 765; -pub const vpiCoverMax: u32 = 766; -pub const vpiCoveredMax: u32 = 766; -pub const vpiCoveredCount: u32 = 767; -pub const vpiAssertAttemptCovered: u32 = 770; -pub const vpiAssertSuccessCovered: u32 = 771; -pub const vpiAssertFailureCovered: u32 = 772; -pub const vpiAssertVacuousSuccessCovered: u32 = 773; -pub const vpiAssertDisableCovered: u32 = 774; -pub const vpiAssertKillCovered: u32 = 777; -pub const vpiFsmStates: u32 = 775; -pub const vpiFsmStateExpression: u32 = 776; -pub const vpiFsm: u32 = 758; -pub const vpiFsmHandle: u32 = 759; -pub const vpiAssertionLock: u32 = 645; -pub const vpiAssertionUnlock: u32 = 646; -pub const vpiAssertionDisable: u32 = 620; -pub const vpiAssertionEnable: u32 = 621; -pub const vpiAssertionReset: u32 = 622; -pub const vpiAssertionKill: u32 = 623; -pub const vpiAssertionEnableStep: u32 = 624; -pub const vpiAssertionDisableStep: u32 = 625; -pub const vpiAssertionClockSteps: u32 = 626; -pub const vpiAssertionSysLock: u32 = 647; -pub const vpiAssertionSysUnlock: u32 = 648; -pub const vpiAssertionSysOn: u32 = 627; -pub const vpiAssertionSysOff: u32 = 628; -pub const vpiAssertionSysKill: u32 = 632; -pub const vpiAssertionSysEnd: u32 = 629; -pub const vpiAssertionSysReset: u32 = 630; -pub const vpiAssertionDisablePassAction: u32 = 633; -pub const vpiAssertionEnablePassAction: u32 = 634; -pub const vpiAssertionDisableFailAction: u32 = 635; -pub const vpiAssertionEnableFailAction: u32 = 636; -pub const vpiAssertionDisableVacuousAction: u32 = 637; -pub const vpiAssertionEnableNonvacuousAction: u32 = 638; -pub const vpiAssertionSysEnablePassAction: u32 = 639; -pub const vpiAssertionSysEnableFailAction: u32 = 640; -pub const vpiAssertionSysDisablePassAction: u32 = 641; -pub const vpiAssertionSysDisableFailAction: u32 = 642; -pub const vpiAssertionSysEnableNonvacuousAction: u32 = 643; -pub const vpiAssertionSysDisableVacuousAction: u32 = 644; -pub type va_list = __builtin_va_list; -pub type PLI_INT64 = i64; -pub type PLI_INT32 = ::std::os::raw::c_int; -pub type PLI_UINT32 = ::std::os::raw::c_uint; -pub type PLI_INT16 = ::std::os::raw::c_short; -pub type PLI_BYTE8 = ::std::os::raw::c_char; -#[doc = " TYPEDEFS"] -pub type vpiHandle = *mut PLI_UINT32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_time { - pub type_: PLI_INT32, - pub high: PLI_UINT32, - pub low: PLI_UINT32, - pub real: f64, -} -#[test] -fn bindgen_test_layout_t_vpi_time() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(t_vpi_time)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_time)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).high) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(high) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).low) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(low) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).real) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_time), - "::", - stringify!(real) - ) - ); -} -pub type s_vpi_time = t_vpi_time; -pub type p_vpi_time = *mut t_vpi_time; -#[doc = " delay structures"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_delay { - pub da: *mut t_vpi_time, - pub no_of_delays: PLI_INT32, - pub time_type: PLI_INT32, - pub mtm_flag: PLI_INT32, - pub append_flag: PLI_INT32, - pub pulsere_flag: PLI_INT32, -} -#[test] -fn bindgen_test_layout_t_vpi_delay() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(t_vpi_delay)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_delay)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).da) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(da) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).no_of_delays) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(no_of_delays) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).time_type) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(time_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mtm_flag) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(mtm_flag) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).append_flag) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(append_flag) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pulsere_flag) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_delay), - "::", - stringify!(pulsere_flag) - ) - ); -} -#[doc = " delay structures"] -pub type p_vpi_delay = *mut t_vpi_delay; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_vecval { - pub aval: PLI_UINT32, - pub bval: PLI_UINT32, -} -#[test] -fn bindgen_test_layout_t_vpi_vecval() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(t_vpi_vecval)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(t_vpi_vecval)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).aval) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vecval), - "::", - stringify!(aval) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bval) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vecval), - "::", - stringify!(bval) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_strengthval { - pub logic: PLI_INT32, - pub s0: PLI_INT32, - pub s1: PLI_INT32, -} -#[test] -fn bindgen_test_layout_t_vpi_strengthval() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(t_vpi_strengthval)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(t_vpi_strengthval)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).logic) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_strengthval), - "::", - stringify!(logic) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).s0) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_strengthval), - "::", - stringify!(s0) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).s1) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_strengthval), - "::", - stringify!(s1) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct t_vpi_value { - pub format: PLI_INT32, - pub value: t_vpi_value__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union t_vpi_value__bindgen_ty_1 { - pub str_: *mut PLI_BYTE8, - pub scalar: PLI_INT32, - pub integer: PLI_INT32, - pub real: f64, - pub time: *mut t_vpi_time, - pub vector: *mut t_vpi_vecval, - pub strength: *mut t_vpi_strengthval, - pub misc: *mut PLI_BYTE8, -} -#[test] -fn bindgen_test_layout_t_vpi_value__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(t_vpi_value__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_value__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).str_) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(str_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).scalar) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(scalar) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).integer) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(integer) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).real) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(real) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).time) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(time) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(vector) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).strength) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(strength) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).misc) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value__bindgen_ty_1), - "::", - stringify!(misc) - ) - ); -} -#[test] -fn bindgen_test_layout_t_vpi_value() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(t_vpi_value)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_value)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value), - "::", - stringify!(format) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_value), - "::", - stringify!(value) - ) - ); -} -pub type p_vpi_value = *mut t_vpi_value; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct t_vpi_arrayvalue { - pub format: PLI_UINT32, - pub flags: PLI_UINT32, - pub value: t_vpi_arrayvalue__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union t_vpi_arrayvalue__bindgen_ty_1 { - pub integers: *mut PLI_INT32, - pub shortints: *mut PLI_INT16, - pub longints: *mut PLI_INT64, - pub rawvals: *mut PLI_BYTE8, - pub vectors: *mut t_vpi_vecval, - pub times: *mut t_vpi_time, - pub reals: *mut f64, - pub shortreals: *mut f32, -} -#[test] -fn bindgen_test_layout_t_vpi_arrayvalue__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(t_vpi_arrayvalue__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_arrayvalue__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).integers) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(integers) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).shortints) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(shortints) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).longints) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(longints) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rawvals) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(rawvals) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vectors) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(vectors) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).times) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(times) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reals) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(reals) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).shortreals) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue__bindgen_ty_1), - "::", - stringify!(shortreals) - ) - ); -} -#[test] -fn bindgen_test_layout_t_vpi_arrayvalue() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(t_vpi_arrayvalue)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_arrayvalue)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue), - "::", - stringify!(format) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_arrayvalue), - "::", - stringify!(value) - ) - ); -} -pub type p_vpi_arrayvalue = *mut t_vpi_arrayvalue; -#[doc = " system task/function structure"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_systf_data { - pub type_: PLI_INT32, - pub sysfunctype: PLI_INT32, - pub tfname: *mut PLI_BYTE8, - pub calltf: ::std::option::Option PLI_INT32>, - pub compiletf: ::std::option::Option PLI_INT32>, - pub sizetf: ::std::option::Option PLI_INT32>, - pub user_data: *mut PLI_BYTE8, -} -#[test] -fn bindgen_test_layout_t_vpi_systf_data() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(t_vpi_systf_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_systf_data)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sysfunctype) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(sysfunctype) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tfname) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(tfname) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).calltf) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(calltf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).compiletf) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(compiletf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sizetf) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(sizetf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).user_data) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_systf_data), - "::", - stringify!(user_data) - ) - ); -} -#[doc = " system task/function structure"] -pub type p_vpi_systf_data = *mut t_vpi_systf_data; -#[doc = " SystemVerilog execution information structure"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_vlog_info { - pub argc: PLI_INT32, - pub argv: *mut *mut PLI_BYTE8, - pub product: *mut PLI_BYTE8, - pub version: *mut PLI_BYTE8, -} -#[test] -fn bindgen_test_layout_t_vpi_vlog_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(t_vpi_vlog_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_vlog_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).argc) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vlog_info), - "::", - stringify!(argc) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).argv) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vlog_info), - "::", - stringify!(argv) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).product) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vlog_info), - "::", - stringify!(product) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_vlog_info), - "::", - stringify!(version) - ) - ); -} -#[doc = " SystemVerilog execution information structure"] -pub type p_vpi_vlog_info = *mut t_vpi_vlog_info; -#[doc = " PLI error information structure"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_error_info { - pub state: PLI_INT32, - pub level: PLI_INT32, - pub message: *mut PLI_BYTE8, - pub product: *mut PLI_BYTE8, - pub code: *mut PLI_BYTE8, - pub file: *mut PLI_BYTE8, - pub line: PLI_INT32, -} -#[test] -fn bindgen_test_layout_t_vpi_error_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(t_vpi_error_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_error_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(state) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(level) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).message) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(message) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).product) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(product) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).file) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(file) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).line) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_error_info), - "::", - stringify!(line) - ) - ); -} -#[doc = " PLI error information structure"] -pub type p_vpi_error_info = *mut t_vpi_error_info; -#[doc = " callback structures"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_cb_data { - pub reason: PLI_INT32, - pub cb_rtn: ::std::option::Option PLI_INT32>, - pub obj: vpiHandle, - pub time: p_vpi_time, - pub value: p_vpi_value, - pub index: PLI_INT32, - pub user_data: *mut PLI_BYTE8, -} -#[test] -fn bindgen_test_layout_t_cb_data() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(t_cb_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_cb_data)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(reason) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cb_rtn) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(cb_rtn) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).obj) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(obj) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).time) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(time) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(index) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).user_data) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(t_cb_data), - "::", - stringify!(user_data) - ) - ); -} -#[doc = " callback structures"] -pub type p_cb_data = *mut t_cb_data; -extern "C" { - pub fn vpi_register_cb(cb_data_p: p_cb_data) -> vpiHandle; -} -extern "C" { - pub fn vpi_remove_cb(cb_obj: vpiHandle) -> PLI_INT32; -} -extern "C" { - pub fn vpi_get_cb_info(object: vpiHandle, cb_data_p: p_cb_data); -} -extern "C" { - pub fn vpi_register_systf(systf_data_p: p_vpi_systf_data) -> vpiHandle; -} -extern "C" { - pub fn vpi_get_systf_info(object: vpiHandle, systf_data_p: p_vpi_systf_data); -} -extern "C" { - pub fn vpi_handle_by_name(name: *mut PLI_BYTE8, scope: vpiHandle) -> vpiHandle; -} -extern "C" { - pub fn vpi_handle_by_index(object: vpiHandle, indx: PLI_INT32) -> vpiHandle; -} -extern "C" { - pub fn vpi_handle(type_: PLI_INT32, refHandle: vpiHandle) -> vpiHandle; -} -extern "C" { - pub fn vpi_handle_multi( - type_: PLI_INT32, - refHandle1: vpiHandle, - refHandle2: vpiHandle, - ... - ) -> vpiHandle; -} -extern "C" { - pub fn vpi_iterate(type_: PLI_INT32, refHandle: vpiHandle) -> vpiHandle; -} -extern "C" { - pub fn vpi_scan(iterator: vpiHandle) -> vpiHandle; -} -extern "C" { - pub fn vpi_get(property: PLI_INT32, object: vpiHandle) -> PLI_INT32; -} -extern "C" { - pub fn vpi_get64(property: PLI_INT32, object: vpiHandle) -> PLI_INT64; -} -extern "C" { - pub fn vpi_get_str(property: PLI_INT32, object: vpiHandle) -> *mut PLI_BYTE8; -} -extern "C" { - pub fn vpi_get_delays(object: vpiHandle, delay_p: p_vpi_delay); -} -extern "C" { - pub fn vpi_put_delays(object: vpiHandle, delay_p: p_vpi_delay); -} -extern "C" { - pub fn vpi_get_value(expr: vpiHandle, value_p: p_vpi_value); -} -extern "C" { - pub fn vpi_put_value( - object: vpiHandle, - value_p: p_vpi_value, - time_p: p_vpi_time, - flags: PLI_INT32, - ) -> vpiHandle; -} -extern "C" { - pub fn vpi_get_value_array( - object: vpiHandle, - arrayvalue_p: p_vpi_arrayvalue, - index_p: *mut PLI_INT32, - num: PLI_UINT32, - ); -} -extern "C" { - pub fn vpi_put_value_array( - object: vpiHandle, - arrayvalue_p: p_vpi_arrayvalue, - index_p: *mut PLI_INT32, - num: PLI_UINT32, - ); -} -extern "C" { - pub fn vpi_get_time(object: vpiHandle, time_p: p_vpi_time); -} -extern "C" { - pub fn vpi_mcd_open(fileName: *mut PLI_BYTE8) -> PLI_UINT32; -} -extern "C" { - pub fn vpi_mcd_close(mcd: PLI_UINT32) -> PLI_UINT32; -} -extern "C" { - pub fn vpi_mcd_name(cd: PLI_UINT32) -> *mut PLI_BYTE8; -} -extern "C" { - pub fn vpi_mcd_printf(mcd: PLI_UINT32, format: *mut PLI_BYTE8, ...) -> PLI_INT32; -} -extern "C" { - pub fn vpi_printf(format: *mut PLI_BYTE8, ...) -> PLI_INT32; -} -extern "C" { - pub fn vpi_compare_objects(object1: vpiHandle, object2: vpiHandle) -> PLI_INT32; -} -extern "C" { - pub fn vpi_chk_error(error_info_p: p_vpi_error_info) -> PLI_INT32; -} -extern "C" { - pub fn vpi_free_object(object: vpiHandle) -> PLI_INT32; -} -extern "C" { - pub fn vpi_release_handle(object: vpiHandle) -> PLI_INT32; -} -extern "C" { - pub fn vpi_get_vlog_info(vlog_info_p: p_vpi_vlog_info) -> PLI_INT32; -} -extern "C" { - pub fn vpi_get_data(id: PLI_INT32, dataLoc: *mut PLI_BYTE8, numOfBytes: PLI_INT32) - -> PLI_INT32; -} -extern "C" { - pub fn vpi_put_data(id: PLI_INT32, dataLoc: *mut PLI_BYTE8, numOfBytes: PLI_INT32) - -> PLI_INT32; -} -extern "C" { - pub fn vpi_get_userdata(obj: vpiHandle) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn vpi_put_userdata(obj: vpiHandle, userdata: *mut ::std::os::raw::c_void) -> PLI_INT32; -} -extern "C" { - pub fn vpi_vprintf(format: *mut PLI_BYTE8, ap: *mut __va_list_tag) -> PLI_INT32; -} -extern "C" { - pub fn vpi_mcd_vprintf( - mcd: PLI_UINT32, - format: *mut PLI_BYTE8, - ap: *mut __va_list_tag, - ) -> PLI_INT32; -} -extern "C" { - pub fn vpi_flush() -> PLI_INT32; -} -extern "C" { - pub fn vpi_mcd_flush(mcd: PLI_UINT32) -> PLI_INT32; -} -extern "C" { - pub fn vpi_control(operation: PLI_INT32, ...) -> PLI_INT32; -} -extern "C" { - pub fn vpi_handle_by_multi_index( - obj: vpiHandle, - num_index: PLI_INT32, - index_array: *mut PLI_INT32, - ) -> vpiHandle; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct t_vpi_assertion_step_info { - pub matched_expression_count: PLI_INT32, - pub matched_exprs: *mut vpiHandle, - pub stateFrom: PLI_INT32, - pub stateTo: PLI_INT32, -} -#[test] -fn bindgen_test_layout_t_vpi_assertion_step_info() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(t_vpi_assertion_step_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_assertion_step_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).matched_expression_count) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_assertion_step_info), - "::", - stringify!(matched_expression_count) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).matched_exprs) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_assertion_step_info), - "::", - stringify!(matched_exprs) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).stateFrom) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_assertion_step_info), - "::", - stringify!(stateFrom) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).stateTo) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_assertion_step_info), - "::", - stringify!(stateTo) - ) - ); -} -pub type p_vpi_assertion_step_info = *mut t_vpi_assertion_step_info; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct t_vpi_attempt_info { - pub detail: t_vpi_attempt_info__bindgen_ty_1, - pub attemptStartTime: s_vpi_time, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union t_vpi_attempt_info__bindgen_ty_1 { - pub failExpr: vpiHandle, - pub step: p_vpi_assertion_step_info, -} -#[test] -fn bindgen_test_layout_t_vpi_attempt_info__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(t_vpi_attempt_info__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(t_vpi_attempt_info__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).failExpr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_attempt_info__bindgen_ty_1), - "::", - stringify!(failExpr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).step) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_attempt_info__bindgen_ty_1), - "::", - stringify!(step) - ) - ); -} -#[test] -fn bindgen_test_layout_t_vpi_attempt_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(t_vpi_attempt_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(t_vpi_attempt_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).detail) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_attempt_info), - "::", - stringify!(detail) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).attemptStartTime) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(t_vpi_attempt_info), - "::", - stringify!(attemptStartTime) - ) - ); -} -pub type p_vpi_attempt_info = *mut t_vpi_attempt_info; -pub type vpi_assertion_callback_func = ::std::option::Option< - unsafe extern "C" fn( - reason: PLI_INT32, - cb_time: p_vpi_time, - assertion: vpiHandle, - info: p_vpi_attempt_info, - user_data: *mut PLI_BYTE8, - ) -> PLI_INT32, ->; -extern "C" { - pub fn vpi_register_assertion_cb( - assertion: vpiHandle, - reason: PLI_INT32, - cb_rtn: vpi_assertion_callback_func, - user_data: *mut PLI_BYTE8, - ) -> vpiHandle; -} -pub type __builtin_va_list = [__va_list_tag; 1usize]; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __va_list_tag { - pub gp_offset: ::std::os::raw::c_uint, - pub fp_offset: ::std::os::raw::c_uint, - pub overflow_arg_area: *mut ::std::os::raw::c_void, - pub reg_save_area: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout___va_list_tag() { - const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__va_list_tag>(), - 24usize, - concat!("Size of: ", stringify!(__va_list_tag)) - ); - assert_eq!( - ::std::mem::align_of::<__va_list_tag>(), - 8usize, - concat!("Alignment of ", stringify!(__va_list_tag)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(gp_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(fp_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(overflow_arg_area) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(reg_save_area) - ) - ); -} diff --git a/t1rocketemu/online_drive/Cargo.toml b/t1rocketemu/online_drive/Cargo.toml deleted file mode 100644 index 929a8b546..000000000 --- a/t1rocketemu/online_drive/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "online_drive" -version = "0.1.0" -edition = "2021" - -[dependencies] -online_dpi = { path = "../online_dpi", features = ["sv2023"] } - -[build-dependencies] -cmake = "0.1.50" - -[features] -trace = ["online_dpi/trace"] diff --git a/t1rocketemu/online_drive/build.rs b/t1rocketemu/online_drive/build.rs deleted file mode 100644 index d08bd0aa5..000000000 --- a/t1rocketemu/online_drive/build.rs +++ /dev/null @@ -1,24 +0,0 @@ -use cmake::Config; - -fn main() { - #[cfg(feature = "trace")] - let dst = Config::new("verilator_shim") - .define("VM_TRACE", "1") - .very_verbose(true) - .always_configure(true) - .build(); - #[cfg(not(feature = "trace"))] - let dst = Config::new("verilator_shim").very_verbose(true).always_configure(true).build(); - - println!("cargo::rustc-link-search=native={}/lib", dst.display()); - - // link order matters! so we use +whole-archive here - // verilator_main <- VTestBench <-- verilated <- verilator_shim <- stdc++ - // verilated <- libz - println!("cargo::rustc-link-lib=static:+whole-archive=verilator_shim"); - println!("cargo::rustc-link-lib=static:+whole-archive=VTestBench"); - println!("cargo::rustc-link-lib=static:+whole-archive=verilated"); - println!("cargo::rustc-link-lib=stdc++"); - println!("cargo::rustc-link-lib=z"); - println!("cargo::rerun-if-env-changed=VERILATED_LIB_DIR"); -} diff --git a/t1rocketemu/online_drive/src/main.rs b/t1rocketemu/online_drive/src/main.rs deleted file mode 100644 index 92f63e02b..000000000 --- a/t1rocketemu/online_drive/src/main.rs +++ /dev/null @@ -1,32 +0,0 @@ -// force link with online_dpi -extern crate online_dpi; - -use std::{ - ffi::{c_char, c_int, CString}, - ptr, -}; - -fn main() { - let c_args: Vec = std::env::args().map(|arg| CString::new(arg).unwrap()).collect(); - - let mut c_args_ptr: Vec<*const c_char> = c_args.iter().map(|arg| arg.as_ptr()).collect(); - c_args_ptr.push(ptr::null()); - - let argc = c_args.len() as c_int; - let argv = c_args_ptr.as_ptr() as *mut *mut c_char; - - let verilator_ret = unsafe { verilator_main_c(argc, argv) }; - - if verilator_ret == 0 { - std::fs::write("perf.txt", format!("total_cycles: {}", online_dpi::get_t())) - .expect("fail to write into perf.txt"); - } else { - eprintln!("verilator_main_c return unexpectedly"); - } - - std::process::exit(verilator_ret); -} - -extern "C" { - fn verilator_main_c(argc: c_int, argv: *mut *mut c_char) -> c_int; -} diff --git a/t1rocketemu/online_drive/verilator_shim/CMakeLists.txt b/t1rocketemu/online_drive/verilator_shim/CMakeLists.txt deleted file mode 100644 index e7aefb74f..000000000 --- a/t1rocketemu/online_drive/verilator_shim/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(verilator_shim) -set(CMAKE_CXX_STANDARD 17) - -message(STATUS "Project '${PROJECT_NAME}' build type: ${CMAKE_BUILD_TYPE}") - -set(THREADS_PREFER_PTHREAD_FLAG ON) - -add_library(verilator_shim - STATIC - verilator_shim.cc -) - -if (NOT DEFINED VERILATED_LIB_DIR) - set(VERILATED_LIB_DIR "$ENV{VERILATED_LIB_DIR}") - if (VERILATED_LIB_DIR STREQUAL "") - message(FATAL_ERROR "You should specify verilated libs via -DVERILATE_LIB_DIR or environment variable VERILATED_LIB_DIR, but it seems not") - endif() -endif() - -if (NOT DEFINED VERILATED_INC_DIR) - set(VERILATED_INC_DIR "$ENV{VERILATED_INC_DIR}") - if (VERILATED_INC_DIR STREQUAL "") - message(FATAL_ERROR "You should specify verilated libs via -DVERILATED_INC_DIR or environment variable VERILATED_INC_DIR, but it seems not") - endif() -endif() - -# include verilator headers -find_package(verilator REQUIRED) -message(STATUS "Found verilator: ${verilator_DIR}") -target_include_directories(verilator_shim PUBLIC ${verilator_DIR}/include) -target_include_directories(verilator_shim PUBLIC ${verilator_DIR}/include/vltstd) - -if(DEFINED VM_TRACE) - target_compile_definitions(verilator_shim PRIVATE VM_TRACE=1) -endif() - -install(TARGETS verilator_shim ARCHIVE) diff --git a/t1rocketemu/online_drive/verilator_shim/verilator_shim.cc b/t1rocketemu/online_drive/verilator_shim/verilator_shim.cc deleted file mode 100644 index 47c81f758..000000000 --- a/t1rocketemu/online_drive/verilator_shim/verilator_shim.cc +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -class VTestBench; - -extern "C" int verilator_main_c(int argc, char **argv) { - // Setup context, defaults, and parse command line - Verilated::debug(0); - - // use unique_ptr to ensure deletion of context and model - std::unique_ptr contextp; - std::unique_ptr topp; - - // Construct the Verilated context - contextp = std::make_unique(); - // Construct the Verilated model, from Vtop.h generated from Verilating - topp = std::make_unique(contextp.get()); - - contextp->fatalOnError(false); - contextp->commandArgs(argc, argv); -#ifdef VM_TRACE - contextp->traceEverOn(true); -#endif - - // Simulate until $finish - while (!contextp->gotFinish()) { - // Evaluate model - topp->eval(); - // Advance time - if (!topp->eventsPending()) - break; - contextp->time(topp->nextTimeSlot()); - } - - if (!contextp->gotFinish()) { - VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n");); - return 1; - } - - if (contextp->gotError()) { - VL_DEBUG_IF(VL_PRINTF("+ Exiting due to errors\n");); - return 1; - } - - // Final model cleanup - topp->final(); - - return 0; -} diff --git a/t1rocketemu/online_vcs/Cargo.toml b/t1rocketemu/online_vcs/Cargo.toml deleted file mode 100644 index d85b2b690..000000000 --- a/t1rocketemu/online_vcs/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "online_vcs" -edition = "2021" -version.workspace = true - -[lib] -crate-type = ["staticlib"] -name = "dpi" - -[dependencies] -online_dpi = { path = "../online_dpi", features = ["svvpi"] } - -[features] -trace = ["online_dpi/trace"] diff --git a/t1rocketemu/online_vcs/src/lib.rs b/t1rocketemu/online_vcs/src/lib.rs deleted file mode 100644 index be27f2116..000000000 --- a/t1rocketemu/online_vcs/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -// force link with online_dpi -extern crate online_dpi; diff --git a/t1rocketemu/spike_interfaces/CMakeLists.txt b/t1rocketemu/spike_interfaces/CMakeLists.txt deleted file mode 100644 index fe5272891..000000000 --- a/t1rocketemu/spike_interfaces/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.20) -project(spike_interfaces LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 17) - -find_package(libspike REQUIRED) - -add_library(${CMAKE_PROJECT_NAME} STATIC spike_interfaces.cc) - -target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC libspike) - -target_include_directories(${CMAKE_PROJECT_NAME} INTERFACE - $ - $ -) - -# just playing with CMake export, maybe not necessary -target_sources(${CMAKE_PROJECT_NAME} PUBLIC - FILE_SET HEADERS - FILES spike_interfaces.h spike_interfaces_c.h) - -install( - TARGETS ${CMAKE_PROJECT_NAME} - EXPORT ${CMAKE_PROJECT_NAME}-config - PUBLIC_HEADER - FILE_SET HEADERS -) - -install( - EXPORT ${CMAKE_PROJECT_NAME}-config - NAMESPACE ${CMAKE_PROJECT_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME} -) diff --git a/t1rocketemu/spike_interfaces/default.nix b/t1rocketemu/spike_interfaces/default.nix deleted file mode 100644 index d95618793..000000000 --- a/t1rocketemu/spike_interfaces/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ lib, stdenv, cmake, libspike }: - -stdenv.mkDerivation { - name = "spike_interfaces"; - src = with lib.fileset; toSource { - root = ./.; - fileset = fileFilter (file: file.name != "default.nix") ./.; - }; - nativeBuildInputs = [ cmake ]; - propagatedBuildInputs = [ libspike ]; -} diff --git a/t1rocketemu/spike_interfaces/spike_interfaces-config.cmake b/t1rocketemu/spike_interfaces/spike_interfaces-config.cmake deleted file mode 100644 index 8a0867895..000000000 --- a/t1rocketemu/spike_interfaces/spike_interfaces-config.cmake +++ /dev/null @@ -1,3 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(libspike 0.1.0) -include(${CMAKE_CURRENT_LIST_DIR}/libspike_interface_targets.cmake) diff --git a/t1rocketemu/spike_interfaces/spike_interfaces.cc b/t1rocketemu/spike_interfaces/spike_interfaces.cc deleted file mode 100644 index 3e92fd2f9..000000000 --- a/t1rocketemu/spike_interfaces/spike_interfaces.cc +++ /dev/null @@ -1,243 +0,0 @@ -#include - -#include "spike_interfaces.h" - -void *ffi_target; - -cfg_t make_spike_cfg() { - cfg_t cfg; - cfg.initrd_bounds = std::make_pair((reg_t)0, (reg_t)0), - cfg.bootargs = nullptr; - cfg.isa = DEFAULT_ISA; - cfg.priv = DEFAULT_PRIV; - cfg.misaligned = false; - cfg.endianness = endianness_little; - cfg.pmpregions = 16; - cfg.pmpgranularity = 4; - cfg.mem_layout = std::vector(); - cfg.hartids = std::vector(); - cfg.explicit_hartids = false; - cfg.real_time_clint = false; - cfg.trigger_count = 4; - return cfg; -} - -Spike::Spike(const char *set, const char *lvl, - size_t lane_number) - : sim(), isa(set, lvl), cfg(make_spike_cfg()), - proc( - /*isa*/ &isa, - /*cfg*/ &cfg, - /*sim*/ &sim, - /*id*/ 0, - /*halt on reset*/ true, - /*log_file_t*/ nullptr, - /*sout*/ std::cerr) { - proc.VU.lane_num = lane_number; - proc.VU.lane_granularity = 32; - - proc.enable_log_commits(); -} - -spike_t *spike_new(const char *set, const char *lvl, - size_t lane_number) { - return new spike_t{new Spike(set, lvl, lane_number)}; -} - -const char *proc_disassemble(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto mmu = proc->p->get_mmu(); - auto disasm = proc->p->get_disassembler(); - auto fetch = mmu->load_insn(pc); - return strdup(disasm->disassemble(fetch.insn).c_str()); -} - -spike_processor_t *spike_get_proc(spike_t *spike) { - return new spike_processor_t{spike->s->get_proc()}; -} - -void proc_reset(spike_processor_t *proc) { proc->p->reset(); } - -spike_state_t *proc_get_state(spike_processor_t *proc) { - return new spike_state_t{proc->p->get_state()}; -} - -reg_t proc_func(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto mmu = proc->p->get_mmu(); - auto fetch = mmu->load_insn(pc); - try { - return fetch.func(proc->p, fetch.insn, pc); - } catch (trap_t &trap) { - std::cerr << "Error: spike trapped with " << trap.name() - << " (tval=" << std::uppercase << std::setfill('0') - << std::setw(8) << std::hex << trap.get_tval() - << ", tval2=" << std::setw(8) << std::hex << trap.get_tval2() - << ", tinst=" << std::setw(8) << std::hex << trap.get_tinst() - << ")" << std::endl; - throw trap; - } -} - -reg_t proc_get_insn(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto mmu = proc->p->get_mmu(); - auto fetch = mmu->load_insn(pc); - return fetch.insn.bits(); -} - -uint8_t proc_get_vreg_data(spike_processor_t *proc, uint32_t vreg_idx, - uint32_t vreg_offset) { - return proc->p->VU.elt(vreg_idx, vreg_offset); -} - -uint32_t extract_f32(freg_t f) { return (uint32_t)f.v[0]; } - -inline uint32_t clip(uint32_t binary, int a, int b) { - int nbits = b - a + 1; - uint32_t mask = nbits >= 32 ? (uint32_t)-1 : (1 << nbits) - 1; - return (binary >> a) & mask; -} - -uint32_t proc_get_rs1(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto fetch = proc->p->get_mmu()->load_insn(pc); - return (uint32_t)fetch.insn.rs1(); -} - -uint32_t proc_get_rs2(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto fetch = proc->p->get_mmu()->load_insn(pc); - return (uint32_t)fetch.insn.rs2(); -} - -uint32_t proc_get_rd(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto fetch = proc->p->get_mmu()->load_insn(pc); - return fetch.insn.rd(); -} - -uint64_t proc_vu_get_vtype(spike_processor_t *proc) { - return proc->p->VU.vtype->read(); -} - -uint32_t proc_vu_get_vxrm(spike_processor_t *proc) { - return proc->p->VU.vxrm->read(); -} - -uint32_t proc_vu_get_vnf(spike_processor_t *proc) { - auto pc = proc->p->get_state()->pc; - auto fetch = proc->p->get_mmu()->load_insn(pc); - return fetch.insn.v_nf(); -} - -bool proc_vu_get_vill(spike_processor_t *proc) { return proc->p->VU.vill; } - -bool proc_vu_get_vxsat(spike_processor_t *proc) { - return proc->p->VU.vxsat->read(); -} - -uint32_t proc_vu_get_vl(spike_processor_t *proc) { - return proc->p->VU.vl->read(); -} - -uint16_t proc_vu_get_vstart(spike_processor_t *proc) { - return proc->p->VU.vstart->read(); -} - -reg_t state_get_pc(spike_state_t *state) { return state->s->pc; } - -void state_set_mcycle(spike_state_t *state, size_t mcycle) { - state->s->mcycle->write((int64_t)mcycle); -} - -void state_clear(spike_state_t *state) { - state->s->log_reg_write.clear(); - state->s->log_mem_read.clear(); - state->s->log_mem_write.clear(); -} - -static void state_set_serialized(spike_state_t *state, bool serialized) { - state->s->serialized = serialized; -} - -uint64_t state_handle_pc(spike_state_t *state, uint64_t new_pc) { - if ((new_pc & 1) == 0) { - state_set_pc(state, new_pc); - } else { - switch (new_pc) { - case PC_SERIALIZE_BEFORE: - state_set_serialized(state, true); - break; - case PC_SERIALIZE_AFTER: - break; - default: - return -1; - } - } - return 0; -} - -void state_set_pc(spike_state_t *state, uint64_t pc) { state->s->pc = pc; } - -uint32_t state_get_reg(spike_state_t *state, uint32_t index, bool is_fp) { - if (is_fp) { - auto &fr = state->s->FPR; - return extract_f32(fr[index]); - } - auto &xr = state->s->XPR; - return (uint32_t)xr[index]; -} - -uint32_t state_get_reg_write_size(spike_state_t *state) { - reg_write_index_vec.clear(); - for (auto [idx, data] : state->s->log_reg_write) { - reg_write_index_vec.push_back(idx); - } - return state->s->log_reg_write.size(); -} - -uint32_t state_get_reg_write_index(spike_state_t *state, uint32_t index) { - return reg_write_index_vec[index]; -} - -uint32_t state_get_mem_write_size(spike_state_t *state) { - return state->s->log_mem_write.size(); -} - -uint32_t state_get_mem_write_addr(spike_state_t *state, uint32_t index) { - return std::get<0>(state->s->log_mem_write[index]) & 0xffffffff; -} - -uint64_t state_get_mem_write_value(spike_state_t *state, uint32_t index) { - return std::get<1>(state->s->log_mem_write[index]); -} - -uint8_t state_get_mem_write_size_by_byte(spike_state_t *state, uint32_t index) { - return std::get<2>(state->s->log_mem_write[index]); -} - -uint32_t state_get_mem_read_size(spike_state_t *state) { - return state->s->log_mem_read.size(); -} - -uint32_t state_get_mem_read_addr(spike_state_t *state, uint32_t index) { - return std::get<0>(state->s->log_mem_read[index]) & 0xffffffff; -} - -uint8_t state_get_mem_read_size_by_byte(spike_state_t *state, uint32_t index) { - return std::get<2>(state->s->log_mem_read[index]); -} - -void spike_register_callback(void *ffi_target_, ffi_callback callback) { - ffi_addr_to_mem = callback; - ffi_target = ffi_target_; - - return; -} - -void spike_destruct(spike_t *spike) { delete spike; } - -void proc_destruct(spike_processor_t *proc) { delete proc; } - -void state_destruct(spike_state_t *state) { delete state; } diff --git a/t1rocketemu/spike_interfaces/spike_interfaces.h b/t1rocketemu/spike_interfaces/spike_interfaces.h deleted file mode 100644 index ceffa8f7f..000000000 --- a/t1rocketemu/spike_interfaces/spike_interfaces.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __SPIKE_INTERFCES_H__ -#define __SPIKE_INTERFCES_H__ - -#include "cfg.h" -#include "decode_macros.h" -#include "disasm.h" -#include "mmu.h" -#include "processor.h" -#include "simif.h" -#include "spike_interfaces_c.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ffi_callback ffi_addr_to_mem; -extern void *ffi_target; -std::vector reg_write_index_vec; - -class sim_t : public simif_t { -public: - sim_t() {} - ~sim_t() {} - char *addr_to_mem(reg_t addr) override { - return ffi_addr_to_mem(ffi_target, addr); - } - bool mmio_load(reg_t addr, size_t len, uint8_t *bytes) override { - throw std::logic_error("not implemented"); - } - bool mmio_store(reg_t addr, size_t len, const uint8_t *bytes) override { - throw std::logic_error("not implemented"); - } - virtual void proc_reset(unsigned id) override {} - virtual const char *get_symbol(uint64_t addr) override { - throw std::logic_error("not implemented"); - } - [[nodiscard]] const cfg_t &get_cfg() const override { - throw std::logic_error("not implemented"); - } - [[nodiscard]] const std::map & - get_harts() const override { - throw std::logic_error("not implemented"); - } -}; - -class Spike { -public: - Spike(const char *set, const char *lvl, size_t lane_number); - processor_t *get_proc() { return &proc; } - -private: - cfg_t cfg; - sim_t sim; - isa_parser_t isa; - processor_t proc; -}; - -struct spike_t { - Spike *s; - ffi_callback ffi_addr_to_mem; -}; -struct spike_processor_t { - processor_t *p; -}; -struct spike_state_t { - state_t *s; -}; -struct spike_mmu_t { - mmu_t *m; -}; - -#ifdef __cplusplus -} -#endif - -#endif // __SPIKE_INTERFCES_H__ diff --git a/t1rocketemu/spike_interfaces/spike_interfaces_c.h b/t1rocketemu/spike_interfaces/spike_interfaces_c.h deleted file mode 100644 index 03fe2c4d5..000000000 --- a/t1rocketemu/spike_interfaces/spike_interfaces_c.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __SPIKE_INTERFCES_C_H__ -#define __SPIKE_INTERFCES_C_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef char *(*ffi_callback)(void *, uint64_t); - -typedef struct spike_t spike_t; -typedef struct spike_processor_t spike_processor_t; -typedef struct spike_state_t spike_state_t; - -void spike_register_callback(void *ffi_target, ffi_callback callback); -spike_t *spike_new(const char *set, const char *lvl, - size_t lane_number); -const char *proc_disassemble(spike_processor_t *proc); -void proc_reset(spike_processor_t *proc); -spike_processor_t *spike_get_proc(spike_t *spike); -spike_state_t *proc_get_state(spike_processor_t *proc); - -uint64_t proc_func(spike_processor_t *proc); -uint64_t proc_get_insn(spike_processor_t *proc); -uint8_t proc_get_vreg_data(spike_processor_t *proc, uint32_t vreg_idx, - uint32_t vreg_offset); -uint32_t proc_get_rs1(spike_processor_t *proc); -uint32_t proc_get_rs2(spike_processor_t *proc); -uint32_t proc_get_rd(spike_processor_t *proc); - -uint64_t proc_vu_get_vtype(spike_processor_t *proc); -uint32_t proc_vu_get_vxrm(spike_processor_t *proc); -uint32_t proc_vu_get_vnf(spike_processor_t *proc); -bool proc_vu_get_vill(spike_processor_t *proc); -bool proc_vu_get_vxsat(spike_processor_t *proc); -uint32_t proc_vu_get_vl(spike_processor_t *proc); -uint16_t proc_vu_get_vstart(spike_processor_t *proc); - -uint64_t state_get_pc(spike_state_t *state); -uint64_t state_handle_pc(spike_state_t *state, uint64_t new_pc); -void state_set_pc(spike_state_t *state, uint64_t pc); -uint32_t state_get_reg(spike_state_t *state, uint32_t index, bool is_fp); -uint32_t state_get_reg_write_size(spike_state_t *state); -uint32_t state_get_reg_write_index(spike_state_t *state, uint32_t index); -uint32_t state_get_mem_write_size(spike_state_t *state); -uint32_t state_get_mem_write_addr(spike_state_t *state, uint32_t index); -uint64_t state_get_mem_write_value(spike_state_t *state, uint32_t index); -uint8_t state_get_mem_write_size_by_byte(spike_state_t *state, uint32_t index); -uint32_t state_get_mem_read_size(spike_state_t *state); -uint32_t state_get_mem_read_addr(spike_state_t *state, uint32_t index); -uint8_t state_get_mem_read_size_by_byte(spike_state_t *state, uint32_t index); -void state_set_mcycle(spike_state_t *state, size_t mcycle); -void state_clear(spike_state_t *state); - -void spike_destruct(spike_t *spike); -void proc_destruct(spike_processor_t *proc); -void state_destruct(spike_state_t *state); - -#ifdef __cplusplus -} -#endif - -#endif // __SPIKE_INTERFCES_C_H__ diff --git a/t1rocketemu/spike_rs/Cargo.toml b/t1rocketemu/spike_rs/Cargo.toml deleted file mode 100644 index 411d44f72..000000000 --- a/t1rocketemu/spike_rs/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "spike_rs" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = { workspace = true } -tracing = { workspace = true } -libc = "0.2.155" -xmas-elf = "0.9.1" diff --git a/t1rocketemu/spike_rs/build.rs b/t1rocketemu/spike_rs/build.rs deleted file mode 100644 index a67a4ba1f..000000000 --- a/t1rocketemu/spike_rs/build.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::env; - -fn main() { - println!( - "cargo::rustc-link-search=native={}", - env::var("SPIKE_LIB_DIR").expect("SPIKE_LIB_DIR should be set") - ); - println!("cargo::rustc-link-lib=static=riscv"); - println!("cargo::rustc-link-lib=static=softfloat"); - println!("cargo::rustc-link-lib=static=disasm"); - println!("cargo::rustc-link-lib=static=fesvr"); - println!("cargo::rustc-link-lib=static=fdt"); - - println!( - "cargo::rustc-link-search=native={}", - env::var("SPIKE_INTERFACES_LIB_DIR").expect("SPIKE_INTERFACES_LIB_DIR should be set") - ); - println!("cargo::rustc-link-lib=static=spike_interfaces"); - - println!("cargo::rerun-if-env-changed=SPIKE_LIB_DIR"); - println!("cargo::rerun-if-env-changed=SPIKE_INTERFACES_LIB_DIR"); - - println!("cargo::rustc-link-lib=stdc++"); -} diff --git a/t1rocketemu/spike_rs/src/lib.rs b/t1rocketemu/spike_rs/src/lib.rs deleted file mode 100644 index 5dd021b0b..000000000 --- a/t1rocketemu/spike_rs/src/lib.rs +++ /dev/null @@ -1,278 +0,0 @@ -pub mod spike_event; -pub mod util; - -use libc::c_char; -use std::ffi::{CStr, CString}; -use tracing::trace; - -pub fn clip(binary: u32, a: i32, b: i32) -> u32 { - assert!(a <= b, "a should be less than or equal to b"); - let nbits = b - a + 1; - let mask = if nbits >= 32 { - u32::MAX - } else { - (1 << nbits) - 1 - }; - (binary >> a) & mask -} - -pub struct Spike { - spike: *mut (), - pub mem: Vec, - pub size: usize, -} - -unsafe impl Send for Spike {} - -extern "C" fn default_addr_to_mem(target: *mut (), addr: u64) -> *mut u8 { - let spike = target as *mut Spike; - let addr = addr as usize; - unsafe { - let spike: &mut Spike = &mut *spike; - let ptr = spike.mem.as_mut_ptr().offset(addr as isize); - ptr - } -} - -type FfiCallback = extern "C" fn(*mut (), u64) -> *mut u8; - -impl Spike { - // we need to have a boxed SpikeCObject, since its pointer will be passed to C to perform FFI call - pub fn new(set: &str, lvl: &str, lane_number: usize, mem_size: usize) -> Box { - let set = CString::new(set).unwrap(); - let lvl = CString::new(lvl).unwrap(); - let spike = unsafe { spike_new(set.as_ptr(), lvl.as_ptr(), lane_number) }; - let mut self_: Box = Box::new(Spike { spike, mem: vec![0; mem_size], size: mem_size }); - - // TODO: support customized ffi - let ffi_target: *mut Spike = &mut *self_; - unsafe { - spike_register_callback(ffi_target as *mut (), default_addr_to_mem); - } - - self_ - } - - pub fn get_proc(&self) -> Processor { - let processor = unsafe { spike_get_proc(self.spike) }; - Processor { processor } - } - - pub fn load_bytes_to_mem( - &mut self, - addr: usize, - len: usize, - bytes: Vec, - ) -> anyhow::Result<()> { - trace!("ld: addr: 0x{:x}, len: 0x{:x}", addr, len); - assert!(addr + len <= self.size); - - let dst = &mut self.mem[addr..addr + len]; - for (i, byte) in bytes.iter().enumerate() { - dst[i] = *byte; - } - - Ok(()) - } - - pub fn mem_byte_on_addr(&self, addr: usize) -> anyhow::Result { - Ok(self.mem[addr]) - } -} - -impl Drop for Spike { - fn drop(&mut self) { - unsafe { spike_destruct(self.spike) } - } -} - -pub struct Processor { - processor: *mut (), -} - -impl Processor { - pub fn disassemble(&self) -> String { - let bytes = unsafe { proc_disassemble(self.processor) }; - let c_str = unsafe { CStr::from_ptr(bytes as *mut c_char) }; - format!("{}", c_str.to_string_lossy()) - } - - pub fn reset(&self) { - unsafe { proc_reset(self.processor) } - } - - pub fn get_state(&self) -> State { - let state = unsafe { proc_get_state(self.processor) }; - State { state } - } - - pub fn func(&self) -> u64 { - unsafe { proc_func(self.processor) } - } - - pub fn get_insn(&self) -> u32 { - unsafe { proc_get_insn(self.processor) as u32 } - } - - pub fn get_vreg_data(&self, idx: u32, offset: u32) -> u8 { - unsafe { proc_get_vreg_data(self.processor, idx, offset) } - } - - pub fn get_rs1(&self) -> u32 { - unsafe { proc_get_rs1(self.processor) } - } - - pub fn get_rs2(&self) -> u32 { - unsafe { proc_get_rs2(self.processor) } - } - - pub fn get_rd(&self) -> u32 { - unsafe { proc_get_rd(self.processor) } - } - - // vu - pub fn vu_get_vtype(&self) -> u32 { - unsafe { proc_vu_get_vtype(self.processor) as u32 } - } - - pub fn vu_get_vxrm(&self) -> u32 { - unsafe { proc_vu_get_vxrm(self.processor) } - } - - pub fn vu_get_vnf(&self) -> u32 { - unsafe { proc_vu_get_vnf(self.processor) } - } - - pub fn vu_get_vill(&self) -> bool { - unsafe { proc_vu_get_vill(self.processor) } - } - - pub fn vu_get_vxsat(&self) -> bool { - unsafe { proc_vu_get_vxsat(self.processor) } - } - - pub fn vu_get_vl(&self) -> u32 { - unsafe { proc_vu_get_vl(self.processor) } - } - - pub fn vu_get_vstart(&self) -> u16 { - unsafe { proc_vu_get_vstart(self.processor) } - } -} - -impl Drop for Processor { - fn drop(&mut self) { - unsafe { proc_destruct(self.processor) } - } -} - -pub struct State { - state: *mut (), -} - -impl State { - pub fn set_pc(&self, pc: u64) { - unsafe { state_set_pc(self.state, pc) } - } - - pub fn get_pc(&self) -> u64 { - unsafe { state_get_pc(self.state) } - } - - pub fn handle_pc(&self, pc: u64) -> anyhow::Result<()> { - match unsafe { state_handle_pc(self.state, pc) } { - 0 => Ok(()), - _ => Err(anyhow::anyhow!("Error handling pc")), - } - } - - pub fn get_reg(&self, idx: u32, is_fp: bool) -> u32 { - unsafe { state_get_reg(self.state, idx, is_fp) } - } - - pub fn get_reg_write_size(&self) -> u32 { - unsafe { state_get_reg_write_size(self.state) } - } - - pub fn get_reg_write_index(&self, index: u32) -> u32 { - unsafe { state_get_reg_write_index(self.state, index) } - } - - pub fn get_mem_write_size(&self) -> u32 { - unsafe { state_get_mem_write_size(self.state) } - } - - pub fn get_mem_write(&self, index: u32) -> (u32, u64, u8) { - let addr = unsafe { state_get_mem_write_addr(self.state, index) }; - let value = unsafe { state_get_mem_write_value(self.state, index) }; - let size_by_byte = unsafe { state_get_mem_write_size_by_byte(self.state, index) }; - (addr, value, size_by_byte) - } - - pub fn get_mem_read_size(&self) -> u32 { - unsafe { state_get_mem_read_size(self.state) } - } - - pub fn get_mem_read(&self, index: u32) -> (u32, u8) { - let addr = unsafe { state_get_mem_read_addr(self.state, index) }; - let size_by_byte = unsafe { state_get_mem_read_size_by_byte(self.state, index) }; - (addr, size_by_byte) - } - - pub fn set_mcycle(&self, mcycle: usize) { - unsafe { state_set_mcycle(self.state, mcycle) } - } - - pub fn clear(&self) { - unsafe { state_clear(self.state) } - } -} - -impl Drop for State { - fn drop(&mut self) { - unsafe { state_destruct(self.state) } - } -} - -#[link(name = "spike_interfaces")] -extern "C" { - pub fn spike_register_callback(target: *mut (), callback: FfiCallback); - fn spike_new(set: *const c_char, lvl: *const c_char, lane_number: usize) -> *mut (); - fn spike_get_proc(spike: *mut ()) -> *mut (); - fn spike_destruct(spike: *mut ()); - fn proc_disassemble(proc: *mut ()) -> *mut c_char; - fn proc_reset(proc: *mut ()); - fn proc_get_state(proc: *mut ()) -> *mut (); - fn proc_func(proc: *mut ()) -> u64; - fn proc_get_insn(proc: *mut ()) -> u64; - fn proc_get_vreg_data(proc: *mut (), vreg_idx: u32, vreg_offset: u32) -> u8; - fn proc_get_rs1(proc: *mut ()) -> u32; - fn proc_get_rs2(proc: *mut ()) -> u32; - fn proc_get_rd(proc: *mut ()) -> u32; - - fn proc_vu_get_vtype(proc: *mut ()) -> u64; - fn proc_vu_get_vxrm(proc: *mut ()) -> u32; - fn proc_vu_get_vnf(proc: *mut ()) -> u32; - fn proc_vu_get_vill(proc: *mut ()) -> bool; - fn proc_vu_get_vxsat(proc: *mut ()) -> bool; - fn proc_vu_get_vl(proc: *mut ()) -> u32; - fn proc_vu_get_vstart(proc: *mut ()) -> u16; - - fn proc_destruct(proc: *mut ()); - fn state_set_pc(state: *mut (), pc: u64); - fn state_get_pc(state: *mut ()) -> u64; - fn state_get_reg(state: *mut (), index: u32, is_fp: bool) -> u32; - fn state_get_reg_write_size(state: *mut ()) -> u32; - fn state_get_reg_write_index(state: *mut (), index: u32) -> u32; - fn state_get_mem_write_size(state: *mut ()) -> u32; - fn state_get_mem_write_addr(state: *mut (), index: u32) -> u32; - fn state_get_mem_write_value(state: *mut (), index: u32) -> u64; - fn state_get_mem_write_size_by_byte(state: *mut (), index: u32) -> u8; - fn state_get_mem_read_size(state: *mut ()) -> u32; - fn state_get_mem_read_addr(state: *mut (), index: u32) -> u32; - fn state_get_mem_read_size_by_byte(state: *mut (), index: u32) -> u8; - fn state_handle_pc(state: *mut (), pc: u64) -> u64; - fn state_set_mcycle(state: *mut (), mcycle: usize); - fn state_clear(state: *mut ()); - fn state_destruct(state: *mut ()); -} diff --git a/t1rocketemu/spike_rs/src/spike_event.rs b/t1rocketemu/spike_rs/src/spike_event.rs deleted file mode 100644 index f91932760..000000000 --- a/t1rocketemu/spike_rs/src/spike_event.rs +++ /dev/null @@ -1,530 +0,0 @@ -use std::collections::HashMap; -use tracing::trace; -use Default; - -use crate::clip; -use crate::Spike; - -#[derive(Debug, Clone)] -pub struct SingleMemWrite { - pub val: u8, - pub executed: bool, // set to true when rtl execute this mem access -} - -#[derive(Debug, Clone)] -pub struct SingleMemRead { - pub val: u8, - pub executed: bool, // set to true when rtl execute this mem access -} - -#[derive(Debug, Clone)] -pub struct MemWriteRecord { - pub writes: Vec, - pub num_completed_writes: usize, -} - -#[derive(Debug, Clone)] -pub struct MemReadRecord { - pub reads: Vec, - pub num_completed_reads: usize, -} - -#[derive(Debug, Clone)] -pub struct SingleVrfWrite { - pub byte: u8, - pub executed: bool, // set to true when rtl execute this mem access -} - -#[derive(Default, Debug, Clone)] -pub struct VdWriteRecord { - vd_bytes: Vec, -} - -#[derive(Default, Debug, Clone)] -pub struct MemAccessRecord { - pub all_writes: HashMap, - pub all_reads: HashMap, -} - -#[derive(Default, Debug, Clone)] -pub struct VrfAccessRecord { - pub all_writes: HashMap, - pub unretired_writes: Option, - pub retired_writes: u32, -} - -pub const LSU_IDX_DEFAULT: u8 = 0xff; -pub const ISSUE_IDX_DEFAULT: u8 = 0xff; - -#[derive(Default, Debug, Clone)] -pub struct SpikeEvent { - pub do_log_vrf: bool, - - // index - pub lsu_idx: u8, - pub issue_idx: u8, - - // instruction - pub disasm: String, - pub pc: u64, - pub inst_bits: u32, - - // scalar to vector interface(used for driver) - pub rs1: u32, - pub rs2: u32, - pub rs1_bits: u32, - pub rs2_bits: u32, - pub rd_idx: u32, - - // vtype - pub vtype: u32, - pub vxrm: u32, - pub vnf: u32, - - // other CSR - pub vill: bool, - pub vxsat: bool, - pub vl: u32, - pub vstart: u16, - - // rd - pub rd_bits: u32, - - // mutable states - pub is_rd_written: bool, - pub is_fd_written: bool, - pub vd_write_record: VdWriteRecord, - pub mem_access_record: MemAccessRecord, - pub vrf_access_record: VrfAccessRecord, - - pub is_quit_inst: bool, -} - -impl SpikeEvent { - pub fn new(spike: &Spike, do_log_vrf: bool) -> Self { - let proc = spike.get_proc(); - let state = proc.get_state(); - let inst_bits = proc.get_insn(); - - let opcode = clip(inst_bits, 0, 6); - let width = clip(inst_bits, 12, 14); - - let is_rs_fp = opcode == 0b1010111 && width == 0b101/* OPFVF */; - // early return vsetvl scalar instruction - - // rs1, rs2 - let (rs1, rs2) = (proc.get_rs1(), proc.get_rs2()); - - SpikeEvent { - do_log_vrf, - - lsu_idx: LSU_IDX_DEFAULT, - issue_idx: ISSUE_IDX_DEFAULT, - - disasm: spike.get_proc().disassemble(), - pc: proc.get_state().get_pc(), - inst_bits, - - rs1, - rs2, - rs1_bits: state.get_reg(rs1, is_rs_fp), - rs2_bits: state.get_reg(rs2, is_rs_fp), - rd_idx: proc.get_rd(), - - vtype: proc.vu_get_vtype(), - vxrm: proc.vu_get_vxrm(), - vnf: proc.vu_get_vnf(), - - vill: proc.vu_get_vill(), - vxsat: proc.vu_get_vxsat(), - vl: proc.vu_get_vl(), - vstart: proc.vu_get_vstart(), - - rd_bits: Default::default(), - - is_rd_written: false, - is_fd_written: false, - vd_write_record: Default::default(), - mem_access_record: Default::default(), - vrf_access_record: Default::default(), - - is_quit_inst: false, - } - } - - pub fn opcode(&self) -> u32 { - clip(self.inst_bits, 0, 6) - } - - pub fn width(&self) -> u32 { - clip(self.inst_bits, 12, 14) - } - - pub fn rs1(&self) -> u32 { - clip(self.inst_bits, 15, 19) - } - - pub fn csr(&self) -> u32 { - clip(self.inst_bits, 20, 31) - } - - pub fn funct6(&self) -> u32 { - clip(self.inst_bits, 26, 31) - } - - pub fn mop(&self) -> u32 { - clip(self.inst_bits, 26, 27) - } - - pub fn lumop(&self) -> u32 { - clip(self.inst_bits, 20, 24) - } - - pub fn vm(&self) -> bool { - clip(self.inst_bits, 25, 25) != 0 - } - - // check whether the instruction is a vector load - pub fn is_vload(&self) -> bool { - self.opcode() == 0b0000111 && self.width().wrapping_sub(1) & 0b100 != 0 - } - - // check whether the instruction is a vector store - pub fn is_vstore(&self) -> bool { - self.opcode() == 0b0100111 && self.width().wrapping_sub(1) & 0b100 != 0 - } - - pub fn is_v(&self) -> bool { - (self.opcode() == 0b1010111 || self.is_vload() || self.is_vstore()) && !self.is_vsetvl() - } - - pub fn is_vsetvl(&self) -> bool { - self.opcode() == 0b1010111 && self.width() == 0b111 - } - - pub fn is_scalar(&self) -> bool { - !self.is_v() - } - - // check whether the instruction is a scalar load - pub fn is_load(&self) -> bool { - self.opcode() == 0b0000011 || self.is_cl() - } - - // check whether the instruction is a scalar store - pub fn is_store(&self) -> bool { - self.opcode() == 0b0100011 || self.is_cw() - } - - pub fn is_whole(&self) -> bool { - self.mop() == 0 && self.lumop() == 8 - } - - pub fn is_widening(&self) -> bool { - self.opcode() == 0b1010111 && (self.funct6() >> 4) == 0b11 - } - - pub fn is_mask_vd(&self) -> bool { - self.opcode() == 0b1010111 && (self.funct6() >> 4) == 0b11 - } - - pub fn is_exit(&self) -> bool { - self.is_quit_inst - } - - pub fn is_vfence(&self) -> bool { - self.is_exit() // only exit instruction is treated as fence now - } - - pub fn is_rd_fp(&self) -> bool { - (self.opcode() == 0b1010111) - && (self.rs1 == 0) - && (self.funct6() == 0b010000) - && self.vm() - && (self.width() == 0b001) - } - - pub fn c_op(&self) -> u32 { - clip(self.inst_bits, 0, 1) - } - - pub fn c_func3(&self) -> u32 { - clip(self.inst_bits, 13, 15) - } - - pub fn is_cl(&self) -> bool { - ( self.c_op() == 0b00 && self.c_func3() & 0b100 == 0 ) || /* c.lw */ - ( self.c_op() == 0b10 && self.c_func3() & 0b100 == 0 ) /* c.lwsp */ - } - - pub fn is_cw(&self) -> bool { - ( self.c_op() == 0b00 && self.c_func3() & 0b100 != 0 ) || /* c.sw */ - ( self.c_op() == 0b10 && self.c_func3() & 0b100 != 0 ) /* c.swsp */ - } - - pub fn vlmul(&self) -> u32 { - clip(self.vtype, 0, 2) - } - - pub fn vma(&self) -> bool { - clip(self.vtype, 7, 7) != 0 - } - - pub fn vta(&self) -> bool { - clip(self.vtype, 6, 6) != 0 - } - - pub fn vsew(&self) -> u32 { - clip(self.vtype, 3, 5) - } - - pub fn vcsr(&self) -> u32 { - self.vxsat as u32 | self.vxrm << 1 - } - - pub fn describe_insn(&self) -> String { - format!( - "pc={:#x}, disasm='{}', bits={:#x}", - self.pc, self.disasm, self.inst_bits - ) - } - - pub fn get_vrf_write_range(&self, vlen_in_bytes: u32) -> anyhow::Result<(u32, u32)> { - if self.is_vstore() { - return Ok((0, 0)); - } - - if self.is_vload() { - let vd_bytes_start = self.rd_idx * vlen_in_bytes; - if self.is_whole() { - return Ok((vd_bytes_start, vlen_in_bytes * (1 + self.vnf))); - } - let len = if self.vlmul() & 0b100 != 0 { - vlen_in_bytes * (1 + self.vnf) - } else { - (vlen_in_bytes * (1 + self.vnf)) << self.vlmul() - }; - return Ok((vd_bytes_start, len)); - } - - let vd_bytes_start = self.rd_idx * vlen_in_bytes; - - if self.is_mask_vd() { - return Ok((vd_bytes_start, vlen_in_bytes)); - } - - let len = if self.vlmul() & 0b100 != 0 { - vlen_in_bytes >> (8 - self.vlmul()) - } else { - vlen_in_bytes << self.vlmul() - }; - - Ok(( - vd_bytes_start, - if self.is_widening() { len * 2 } else { len }, - )) - } - - pub fn pre_log_arch_changes(&mut self, spike: &Spike, vlen: u32) -> anyhow::Result<()> { - if self.do_log_vrf { - // record the vrf writes before executing the insn - let proc = spike.get_proc(); - self.rd_bits = proc.get_state().get_reg(self.rd_idx, false); - let (start, len) = self.get_vrf_write_range(vlen).unwrap(); - self.vd_write_record.vd_bytes.resize(len as usize, 0u8); - for i in 0..len { - let offset = start + i; - let vreg_index = offset / vlen; - let vreg_offset = offset % vlen; - let cur_byte = proc.get_vreg_data(vreg_index, vreg_offset); - self.vd_write_record.vd_bytes[i as usize] = cur_byte; - } - } - - Ok(()) - } - - pub fn log_arch_changes(&mut self, spike: &Spike, vlen: u32) -> anyhow::Result<()> { - if self.do_log_vrf { - self.log_vrf_write(spike, vlen).unwrap(); - self.log_reg_write(spike).unwrap(); - } - self.log_mem_write(spike).unwrap(); - self.log_mem_read(spike).unwrap(); - - Ok(()) - } - - fn log_vrf_write(&mut self, spike: &Spike, vlen: u32) -> anyhow::Result<()> { - let proc = spike.get_proc(); - // record vrf writes - // note that we do not need log_reg_write to find records, we just decode the - // insn and compare bytes - let vlen_in_bytes = vlen / 8; - let (start, len) = self.get_vrf_write_range(vlen_in_bytes).unwrap(); - trace!("vrf write range: start: {start}, len: {len}"); - for i in 0..len { - let offset = start + i; - let origin_byte = self.vd_write_record.vd_bytes[i as usize]; - let vreg_index = offset / vlen_in_bytes; - let vreg_offset = offset % vlen_in_bytes; - let cur_byte = proc.get_vreg_data(vreg_index, vreg_offset); - if origin_byte != cur_byte { - self - .vrf_access_record - .all_writes - .entry(offset as usize) - .or_insert(SingleVrfWrite { byte: cur_byte, executed: false }); - trace!( - "SpikeVRFChange: vrf={:?}, change_from={origin_byte}, change_to={cur_byte}, vrf_idx={offset}", - vec![offset / vlen_in_bytes, offset % vlen_in_bytes], - ); - } else { - trace!( - "SpikeVRFChange: vrf={:?}, change_from={origin_byte}, not changed, vrf_idx={offset}", - vec![offset / vlen_in_bytes, offset % vlen_in_bytes], - ); - } - } - Ok(()) - } - - pub fn log_reg_write(&mut self, spike: &Spike) -> anyhow::Result<()> { - let proc = spike.get_proc(); - let state = proc.get_state(); - // in spike, log_reg_write is arrange: - // xx0000 <- x - // xx0001 <- f - // xx0010 <- vreg - // xx0011 <- vec - // xx0100 <- csr - let reg_write_size = state.get_reg_write_size(); - // TODO: refactor it. - (0..reg_write_size).for_each(|idx| { - let rd_idx_type = state.get_reg_write_index(idx); - match rd_idx_type & 0xf { - 0b0000 => { - // scalar rf - self.rd_idx = rd_idx_type >> 4; - if self.rd_idx != 0 { - let data = state.get_reg(self.rd_idx, false); - self.is_rd_written = true; - self.rd_bits = data; - trace!( - "ScalarRFChange: idx={:#02x}, data={:08x}", - self.rd_idx, - self.rd_bits - ); - } - } - 0b0001 => { - self.rd_idx = rd_idx_type >> 4; - let data = state.get_reg(self.rd_idx, true); - self.is_fd_written = true; - self.rd_bits = data; - trace!( - "FloatRFChange: idx={:#02x}, data={:08x}", - self.rd_idx, - self.rd_bits - ); - } - _ => trace!( - "UnknownRegChange, idx={:#02x}, spike detect unknown reg change", - self.rd_idx - ), - } - }); - - Ok(()) - } - - pub fn log_mem_write(&mut self, spike: &Spike) -> anyhow::Result<()> { - let proc = spike.get_proc(); - let state = proc.get_state(); - - let mem_write_size = state.get_mem_write_size(); - (0..mem_write_size).for_each(|i| { - let (addr, value, size) = state.get_mem_write(i); - (0..size).for_each(|offset| { - self - .mem_access_record - .all_writes - .entry(addr + offset as u32) - .or_insert(MemWriteRecord { writes: vec![], num_completed_writes: 0 }) - .writes - .push(SingleMemWrite { - val: (value >> (offset * 8)) as u8, - executed: false, - }); - }); - if addr == 0x4000_0000 && value == 0xdead_beef { - self.is_quit_inst = true; - trace!("SpikeQuit: detected quit instruction"); - } - trace!("SpikeMemWrite: addr={addr:x}, value={value:x}, size={size}"); - }); - - Ok(()) - } - - fn log_mem_read(&mut self, spike: &Spike) -> anyhow::Result<()> { - let proc = spike.get_proc(); - let state = proc.get_state(); - - let mem_read_size = state.get_mem_read_size(); - (0..mem_read_size).for_each(|i| { - let (addr, size) = state.get_mem_read(i); - let mut value = 0; - (0..size).for_each(|offset| { - let byte = spike.mem_byte_on_addr(addr as usize + offset as usize).unwrap(); - value |= (byte as u64) << (offset * 8); - // record the read - self - .mem_access_record - .all_reads - .entry(addr + offset as u32) - .or_insert(MemReadRecord { reads: vec![], num_completed_reads: 0 }) - .reads - .push(SingleMemRead { val: byte, executed: false }); - }); - trace!("SpikeMemRead: addr={addr:08x}, value={value:08x}, size={size}"); - }); - - Ok(()) - } - - pub fn check_rd(&self, data: u32) -> anyhow::Result<()> { - // TODO: rtl should indicate whether resp_bits_data is valid - if self.is_rd_written { - assert_eq!( - data, self.rd_bits, - "expect to write rd[{}] = {}, actual {}", - self.rd_idx, self.rd_bits, data - ); - } - - Ok(()) - } - - pub fn check_is_ready_for_commit(&self, cycle: u64) -> anyhow::Result<()> { - for (addr, record) in &self.mem_access_record.all_writes { - assert_eq!( - record.num_completed_writes, - record.writes.len(), - "[{cycle}] expect to write mem {addr:#x}, not executed when commit, issue_idx={} ({})", - self.issue_idx, - self.describe_insn(), - ); - } - for (idx, record) in &self.vrf_access_record.all_writes { - assert!( - record.executed, - "[{cycle}] expect to write vrf {idx}, not executed when commit, issue_idx={} ({})", - self.issue_idx, - self.describe_insn() - ); - } - - Ok(()) - } -} diff --git a/t1rocketemu/spike_rs/src/util.rs b/t1rocketemu/spike_rs/src/util.rs deleted file mode 100644 index 6ded0eec5..000000000 --- a/t1rocketemu/spike_rs/src/util.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::Spike; -use std::fs::File; -use std::io::Read; -use std::path::Path; -use xmas_elf::program::{ProgramHeader, Type}; -use xmas_elf::{header, ElfFile}; - -pub fn load_elf(spike: &mut Spike, fname: &Path) -> anyhow::Result { - let mut file = File::open(fname).unwrap(); - let mut buffer = Vec::new(); - file.read_to_end(&mut buffer).unwrap(); - - let elf_file = ElfFile::new(&buffer).unwrap(); - - let header = elf_file.header; - assert_eq!(header.pt2.machine().as_machine(), header::Machine::RISC_V); - assert_eq!(header.pt1.class(), header::Class::ThirtyTwo); - - for ph in elf_file.program_iter() { - if let ProgramHeader::Ph32(ph) = ph { - if ph.get_type() == Ok(Type::Load) { - let offset = ph.offset as usize; - let size = ph.file_size as usize; - let addr = ph.virtual_addr as usize; - - let slice = &buffer[offset..offset + size]; - spike.load_bytes_to_mem(addr, size, slice.to_vec()).unwrap(); - } - } - } - - Ok(header.pt2.entry_point()) -} - -// todo: unify load_elf and load_elf_to_buffer -pub fn load_elf_to_buffer(mem: &mut [u8], fname: &Path) -> anyhow::Result { - let mut file = File::open(fname).unwrap(); - let mut buffer = Vec::new(); - file.read_to_end(&mut buffer).unwrap(); - - let elf_file = ElfFile::new(&buffer).unwrap(); - - let header = elf_file.header; - assert_eq!(header.pt2.machine().as_machine(), header::Machine::RISC_V); - assert_eq!(header.pt1.class(), header::Class::ThirtyTwo); - - for ph in elf_file.program_iter() { - if let ProgramHeader::Ph32(ph) = ph { - if ph.get_type() == Ok(Type::Load) { - let offset = ph.offset as usize; - let size = ph.file_size as usize; - let addr = ph.virtual_addr as usize; - - let slice = &buffer[offset..offset + size]; - - let dst: &mut _ = &mut mem[addr..addr + size]; - for (i, byte) in slice.iter().enumerate() { - dst[i] = *byte; - } - } - } - } - - Ok(header.pt2.entry_point()) -} diff --git a/t1rocketemu/test_common/Cargo.toml b/t1rocketemu/test_common/Cargo.toml deleted file mode 100644 index d5b3f32aa..000000000 --- a/t1rocketemu/test_common/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "common" -version.workspace = true -edition = "2021" - -[dependencies] -spike_rs = { path = "../spike_rs" } -clap = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -anyhow = { workspace = true } diff --git a/t1rocketemu/test_common/src/lib.rs b/t1rocketemu/test_common/src/lib.rs deleted file mode 100644 index e9690d3a2..000000000 --- a/t1rocketemu/test_common/src/lib.rs +++ /dev/null @@ -1,63 +0,0 @@ -use anyhow::Result; -use clap::Parser; -use spike_rs::Spike; -use std::path::PathBuf; -use tracing::Level; -use tracing_subscriber::{EnvFilter, FmtSubscriber}; - -pub mod rtl_config; -pub mod spike_runner; - -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -pub struct CommonArgs { - /// Path to the ELF file - #[arg(long)] - pub elf_file: PathBuf, - - /// Path to the log file - #[arg(long)] - pub log_file: Option, - - /// Log level: trace, debug, info, warn, error - #[arg(long, default_value = "info")] - pub log_level: String, - - /// vlen config - #[arg(long, default_value = env!("DESIGN_VLEN"))] - pub vlen: u32, - - /// dlen config - #[arg(long, default_value = env!("DESIGN_DLEN"))] - pub dlen: u32, - - /// ISA config - #[arg(long, default_value = env!("SPIKE_ISA_STRING"))] - pub set: String, -} - -pub static MEM_SIZE: usize = 1usize << 32; - -impl CommonArgs { - pub fn to_spike_c_handler(&self) -> Box { - let lvl = "M"; - - Spike::new(&self.set, lvl, (self.dlen / 32) as usize, MEM_SIZE) - } - - pub fn setup_logger(&self) -> Result<()> { - // setup log - let log_level: Level = self.log_level.parse()?; - let global_logger = FmtSubscriber::builder() - .with_env_filter(EnvFilter::from_default_env()) - .with_max_level(log_level) - .without_time() - .with_target(false) - .with_ansi(true) - .compact() - .finish(); - tracing::subscriber::set_global_default(global_logger) - .expect("internal error: fail to setup log subscriber"); - Ok(()) - } -} diff --git a/t1rocketemu/test_common/src/rtl_config.rs b/t1rocketemu/test_common/src/rtl_config.rs deleted file mode 100644 index 0daf72624..000000000 --- a/t1rocketemu/test_common/src/rtl_config.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub struct RTLConfig { - pub vlen: u32, - pub dlen: u32, -} - -// TODO: read from json - -impl RTLConfig { - pub fn xlen(&self) -> u32 { - 32 // TODO: configurable - } - - pub fn vlen_in_bytes(&self) -> u32 { - self.vlen / 8 - } - - pub fn lane_num(&self) -> u32 { - self.dlen / self.xlen() - } -} diff --git a/t1rocketemu/test_common/src/spike_runner.rs b/t1rocketemu/test_common/src/spike_runner.rs deleted file mode 100644 index 40b293185..000000000 --- a/t1rocketemu/test_common/src/spike_runner.rs +++ /dev/null @@ -1,191 +0,0 @@ -use std::collections::VecDeque; -use std::path::Path; -use tracing::debug; - -use spike_rs::spike_event::SpikeEvent; -use spike_rs::util::load_elf; -use spike_rs::Spike; - -use crate::CommonArgs; - -pub struct SpikeRunner { - spike: Box, - - /// commit queue - /// in the spike thread, spike should detech if this queue is full, if not - /// full, execute until a vector instruction, record the behavior of this - /// instruction, and send to commit queue. - /// Note: - /// - The event issued earliest is at the back of the queue - /// - The queue may contain at most one unissued event. If so, the unissued event must be at the - /// front of the queue, and it must be a fence - pub commit_queue: VecDeque, - - /// vector queue to arrange the order of vector instructions, because of the register write - /// dependency, the vector instruction should be issued in order. - pub vector_queue: VecDeque, - - /// scalar queue to arrange the order of scalar reg write instructions - pub scalar_queue: VecDeque, - - /// float queue to arrange the order of scalar freg write instructions - pub float_queue: VecDeque, - - /// config for v extension - pub vlen: u32, - pub dlen: u32, - - /// implement the get_t() for mcycle csr update - pub cycle: u64, - - pub do_log_vrf: bool, - - // register file scoreboard - pub rf_board: Vec>, - // float reg file scoreboard - pub frf_board: Vec>, -} - -impl SpikeRunner { - pub fn new(args: &CommonArgs, do_log_vrf: bool) -> Self { - // load the elf file - // initialize spike - let mut spike = args.to_spike_c_handler(); - - let entry_addr = load_elf(&mut spike, Path::new(&args.elf_file)).unwrap(); - - // initialize processor - let proc = spike.get_proc(); - let state = proc.get_state(); - proc.reset(); - state.set_pc(entry_addr); - - SpikeRunner { - spike, - commit_queue: VecDeque::new(), - vector_queue: VecDeque::new(), - scalar_queue: VecDeque::new(), - float_queue: VecDeque::new(), - vlen: args.vlen, - dlen: args.dlen, - cycle: 0, - do_log_vrf, - rf_board: vec![None; 32], - frf_board: vec![None; 32], - } - } - - pub fn load_elf(&mut self, fname: &Path) -> anyhow::Result { - load_elf(&mut *self.spike, fname) - } - - // just execute one instruction for non-difftest - pub fn exec(&self) -> anyhow::Result<()> { - let spike = &self.spike; - let proc = spike.get_proc(); - let state = proc.get_state(); - - let new_pc = proc.func(); - - state.handle_pc(new_pc).unwrap(); - - Ok(()) - } - - // execute the spike processor for one instruction and record - // the spike event for difftest - pub fn spike_step(&mut self) -> SpikeEvent { - let spike = &self.spike; - let proc = self.spike.get_proc(); - let state = proc.get_state(); - - let mcycle = self.cycle as usize; - state.set_mcycle(0); - - let mut event = SpikeEvent::new(spike, self.do_log_vrf); - state.clear(); - - let new_pc = if event.is_v() || event.is_exit() { - // inst is v / quit - debug!( - "SpikeStep: spike run vector insn ({}), mcycle={mcycle}", - event.describe_insn(), - ); - event.pre_log_arch_changes(spike, self.vlen).unwrap(); - let new_pc_ = proc.func(); - event.log_arch_changes(spike, self.vlen).unwrap(); - new_pc_ - } else { - // inst is scalar - debug!( - "SpikeStep: spike run scalar insn ({}), mcycle={mcycle}", - event.describe_insn(), - ); - let new_pc_ = proc.func(); - event.log_mem_write(spike).unwrap(); - event.log_reg_write(spike).unwrap(); - new_pc_ - }; - - state.handle_pc(new_pc).unwrap(); - - event - } - - pub fn find_reg_se(&mut self) -> SpikeEvent { - if !self.scalar_queue.is_empty() { - // return the back (oldest) scalar insn - self.scalar_queue.pop_back().unwrap() - } else { - // else, loop until find a se, and push the se to the front - loop { - let se = self.spike_step(); - if se.is_scalar() && se.is_rd_written { - return se; - } else if se.is_scalar() && se.is_fd_written { - self.float_queue.push_front(se.clone()); - } else if se.is_v() { - self.vector_queue.push_front(se.clone()); - } - } - } - } - - pub fn find_freg_se(&mut self) -> SpikeEvent { - if !self.float_queue.is_empty() { - // return the back (oldest) float insn - self.float_queue.pop_back().unwrap() - } else { - // else, loop until find a se, and push the se to the front - loop { - let se = self.spike_step(); - if se.is_scalar() && se.is_rd_written { - self.scalar_queue.push_front(se.clone()); - } else if se.is_scalar() && se.is_fd_written { - return se; - } else if se.is_v() { - self.vector_queue.push_front(se.clone()); - } - } - } - } - - pub fn find_v_se(&mut self) -> SpikeEvent { - if !self.vector_queue.is_empty() { - // return the back (oldest) vector insn - self.vector_queue.pop_back().unwrap() - } else { - // else, loop until find a se, and push the se to the front - loop { - let se = self.spike_step(); - if se.is_scalar() && se.is_rd_written { - self.scalar_queue.push_front(se.clone()); - } else if se.is_scalar() && se.is_fd_written { - self.float_queue.push_front(se.clone()); - } else if se.is_v() { - return se; - } - } - } - } -}