implement simulation of extern modules
All checks were successful
/ deps (pull_request) Successful in 11m39s
/ test (pull_request) Successful in 3m55s

This commit is contained in:
Jacob Lifshay 2025-03-19 17:11:41 -07:00
parent 920d8d875f
commit d1bd176b28
Signed by: programmerjake
SSH key fingerprint: SHA256:HnFTLGpSm4Q4Fj502oCFisjZSoakwEuTsJJMSke63RQ
21 changed files with 2702 additions and 6958 deletions

View file

@ -2258,6 +2258,7 @@ impl<'a> Exporter<'a> {
ModuleBody::Extern(ExternModuleBody { ModuleBody::Extern(ExternModuleBody {
verilog_name, verilog_name,
parameters, parameters,
simulation: _,
}) => { }) => {
let verilog_name = Ident(verilog_name); let verilog_name = Ident(verilog_name);
writeln!(body, "{indent}defname = {verilog_name}").unwrap(); writeln!(body, "{indent}defname = {verilog_name}").unwrap();

View file

@ -21,6 +21,7 @@ use crate::{
memory::{Mem, MemBuilder, MemBuilderTarget, PortName}, memory::{Mem, MemBuilder, MemBuilderTarget, PortName},
reg::Reg, reg::Reg,
reset::{AsyncReset, Reset, ResetType, ResetTypeDispatch, SyncReset}, reset::{AsyncReset, Reset, ResetType, ResetTypeDispatch, SyncReset},
sim::{ExternModuleSimGenerator, ExternModuleSimulation},
source_location::SourceLocation, source_location::SourceLocation,
ty::{CanonicalType, Type}, ty::{CanonicalType, Type},
util::ScopedRef, util::ScopedRef,
@ -1081,6 +1082,7 @@ pub struct ExternModuleBody<
> { > {
pub verilog_name: Interned<str>, pub verilog_name: Interned<str>,
pub parameters: P, pub parameters: P,
pub simulation: Option<ExternModuleSimulation<Bundle>>,
} }
impl From<ExternModuleBody<Vec<ExternModuleParameter>>> for ExternModuleBody { impl From<ExternModuleBody<Vec<ExternModuleParameter>>> for ExternModuleBody {
@ -1088,11 +1090,13 @@ impl From<ExternModuleBody<Vec<ExternModuleParameter>>> for ExternModuleBody {
let ExternModuleBody { let ExternModuleBody {
verilog_name, verilog_name,
parameters, parameters,
simulation,
} = value; } = value;
let parameters = Intern::intern_owned(parameters); let parameters = Intern::intern_owned(parameters);
Self { Self {
verilog_name, verilog_name,
parameters, parameters,
simulation,
} }
} }
} }
@ -1283,10 +1287,12 @@ impl<T: BundleType> fmt::Debug for DebugModuleBody<T> {
ModuleBody::Extern(ExternModuleBody { ModuleBody::Extern(ExternModuleBody {
verilog_name, verilog_name,
parameters, parameters,
simulation,
}) => { }) => {
debug_struct debug_struct
.field("verilog_name", verilog_name) .field("verilog_name", verilog_name)
.field("parameters", parameters); .field("parameters", parameters)
.field("simulation", simulation);
} }
} }
debug_struct.finish_non_exhaustive() debug_struct.finish_non_exhaustive()
@ -1761,7 +1767,12 @@ impl AssertValidityState {
ModuleBody::Extern(ExternModuleBody { ModuleBody::Extern(ExternModuleBody {
verilog_name: _, verilog_name: _,
parameters: _, parameters: _,
}) => {} simulation,
}) => {
if let Some(simulation) = simulation {
simulation.check_io_ty(self.module.io_ty);
}
}
ModuleBody::Normal(NormalModuleBody { body }) => { ModuleBody::Normal(NormalModuleBody { body }) => {
let body = self.make_block_index(body); let body = self.make_block_index(body);
assert_eq!(body, 0); assert_eq!(body, 0);
@ -2108,6 +2119,7 @@ impl ModuleBuilder {
ModuleKind::Extern => ModuleBody::Extern(ExternModuleBody { ModuleKind::Extern => ModuleBody::Extern(ExternModuleBody {
verilog_name: name.0, verilog_name: name.0,
parameters: vec![], parameters: vec![],
simulation: None,
}), }),
ModuleKind::Normal => ModuleBody::Normal(NormalModuleBody { ModuleKind::Normal => ModuleBody::Normal(NormalModuleBody {
body: BuilderModuleBody { body: BuilderModuleBody {
@ -2229,6 +2241,15 @@ impl ModuleBuilder {
value: ExternModuleParameterValue::RawVerilog(raw_verilog.intern()), value: ExternModuleParameterValue::RawVerilog(raw_verilog.intern()),
}); });
} }
#[track_caller]
pub fn extern_module_simulation<G: ExternModuleSimGenerator>(&self, generator: G) {
let mut impl_ = self.impl_.borrow_mut();
let simulation = &mut impl_.body.builder_extern_body().simulation;
if simulation.is_some() {
panic!("already added an extern module simulation");
}
*simulation = Some(ExternModuleSimulation::new(generator));
}
} }
#[track_caller] #[track_caller]

View file

@ -31,6 +31,7 @@ use crate::{
phantom_const::PhantomConst, phantom_const::PhantomConst,
reg::Reg, reg::Reg,
reset::{AsyncReset, Reset, ResetType, SyncReset}, reset::{AsyncReset, Reset, ResetType, SyncReset},
sim::ExternModuleSimulation,
source_location::SourceLocation, source_location::SourceLocation,
ty::{CanonicalType, Type}, ty::{CanonicalType, Type},
wire::Wire, wire::Wire,

File diff suppressed because it is too large Load diff

View file

@ -5,11 +5,14 @@ use fayalite::{
int::UIntValue, int::UIntValue,
prelude::*, prelude::*,
reset::ResetType, reset::ResetType,
sim::{time::SimDuration, vcd::VcdWriterDecls, Simulation, ToSimValue}, sim::{
time::SimDuration, vcd::VcdWriterDecls, ExternModuleSimGenerator,
ExternModuleSimulationState, Simulation, ToSimValue,
},
ty::StaticType, ty::StaticType,
util::RcWriter, util::RcWriter,
}; };
use std::num::NonZeroUsize; use std::{future::IntoFuture, num::NonZeroUsize};
#[hdl_module(outline_generated)] #[hdl_module(outline_generated)]
pub fn connect_const() { pub fn connect_const() {
@ -1443,3 +1446,61 @@ fn test_conditional_assignment_last() {
panic!(); panic!();
} }
} }
#[hdl_module(outline_generated, extern)]
pub fn extern_module() {
#[hdl]
let i: Bool = m.input();
#[hdl]
let o: Bool = m.output();
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
struct Sim {
i: Expr<Bool>,
o: Expr<Bool>,
}
impl ExternModuleSimGenerator for Sim {
type IOType = extern_module;
fn run<'a>(
&'a self,
mut sim: ExternModuleSimulationState<Self::IOType>,
) -> impl IntoFuture<Output = ()> + 'a {
let Self { i, o } = *self;
async move {
sim.write(o, true).await;
sim.advance_time(SimDuration::from_nanos(500)).await;
let mut invert = false;
loop {
sim.advance_time(SimDuration::from_micros(1)).await;
let v = sim.read_bool(i).await;
sim.write(o, v ^ invert).await;
invert = !invert;
}
}
}
}
m.extern_module_simulation(Sim { i, o });
}
#[test]
fn test_extern_module() {
let _n = SourceLocation::normalize_files_for_tests();
let mut sim = Simulation::new(extern_module());
let mut writer = RcWriter::default();
sim.add_trace_writer(VcdWriterDecls::new(writer.clone()));
sim.write(sim.io().i, false);
sim.advance_time(SimDuration::from_micros(10));
sim.write(sim.io().i, true);
sim.advance_time(SimDuration::from_micros(10));
sim.flush_traces().unwrap();
let vcd = String::from_utf8(writer.take()).unwrap();
println!("####### VCD:\n{vcd}\n#######");
if vcd != include_str!("sim/expected/extern_module.vcd") {
panic!();
}
let sim_debug = format!("{sim:#?}");
println!("#######\n{sim_debug}\n#######");
if sim_debug != include_str!("sim/expected/extern_module.txt") {
panic!();
}
}

File diff suppressed because it is too large Load diff

View file

@ -92,45 +92,30 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::conditional_assignment_last, name: <simulator>::conditional_assignment_last,
instantiated: Module { instantiated: Module {
name: conditional_assignment_last, name: conditional_assignment_last,
.. ..
},
}.i: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(conditional_assignment_last: conditional_assignment_last).conditional_assignment_last::i",
ty: Bool,
},
],
..
},
}, },
body: Scalar, }.i,
}, ],
range: TypeIndexRange { uninitialized_ios: {},
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, io_targets: {
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 }, Instance {
}, name: <simulator>::conditional_assignment_last,
write: None, instantiated: Module {
name: conditional_assignment_last,
..
},
}.i,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "conditional_assignment_last", name: "conditional_assignment_last",
children: [ children: [

View file

@ -68,45 +68,30 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::connect_const, name: <simulator>::connect_const,
instantiated: Module { instantiated: Module {
name: connect_const, name: connect_const,
.. ..
},
}.o: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<8>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(connect_const: connect_const).connect_const::o",
ty: UInt<8>,
},
],
..
},
}, },
body: Scalar, }.o,
}, ],
range: TypeIndexRange { uninitialized_ios: {},
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, io_targets: {
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 }, Instance {
}, name: <simulator>::connect_const,
write: None, instantiated: Module {
name: connect_const,
..
},
}.o,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "connect_const", name: "connect_const",
children: [ children: [

View file

@ -97,79 +97,44 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::connect_const_reset, name: <simulator>::connect_const_reset,
instantiated: Module { instantiated: Module {
name: connect_const_reset, name: connect_const_reset,
.. ..
},
}.bit_out: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(connect_const_reset: connect_const_reset).connect_const_reset::bit_out",
ty: Bool,
},
],
..
},
}, },
body: Scalar, }.reset_out,
}, Instance {
range: TypeIndexRange { name: <simulator>::connect_const_reset,
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, instantiated: Module {
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 }, name: connect_const_reset,
}, ..
write: None,
},
Instance {
name: <simulator>::connect_const_reset,
instantiated: Module {
name: connect_const_reset,
..
},
}.reset_out: CompiledValue {
layout: CompiledTypeLayout {
ty: AsyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(connect_const_reset: connect_const_reset).connect_const_reset::reset_out",
ty: AsyncReset,
},
],
..
},
}, },
body: Scalar, }.bit_out,
}, ],
range: TypeIndexRange { uninitialized_ios: {},
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, io_targets: {
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 }, Instance {
}, name: <simulator>::connect_const_reset,
write: None, instantiated: Module {
name: connect_const_reset,
..
},
}.bit_out,
Instance {
name: <simulator>::connect_const_reset,
instantiated: Module {
name: connect_const_reset,
..
},
}.reset_out,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "connect_const_reset", name: "connect_const_reset",
children: [ children: [

View file

@ -203,213 +203,58 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::counter, name: <simulator>::counter,
instantiated: Module { instantiated: Module {
name: counter, name: counter,
.. ..
},
}.cd: CompiledValue {
layout: CompiledTypeLayout {
ty: Bundle {
/* offset = 0 */
clk: Clock,
/* offset = 1 */
rst: AsyncReset,
}, },
layout: TypeLayout { }.cd,
small_slots: StatePartLayout<SmallSlots> { Instance {
len: 0, name: <simulator>::counter,
debug_data: [], instantiated: Module {
.. name: counter,
}, ..
big_slots: StatePartLayout<BigSlots> {
len: 2,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::cd.clk",
ty: Clock,
},
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::cd.rst",
ty: AsyncReset,
},
],
..
},
}, },
body: Bundle { }.count,
fields: [ ],
CompiledBundleField { uninitialized_ios: {},
offset: TypeIndex { io_targets: {
small_slots: StatePartIndex<SmallSlots>(0), Instance {
big_slots: StatePartIndex<BigSlots>(0), name: <simulator>::counter,
}, instantiated: Module {
ty: CompiledTypeLayout { name: counter,
ty: Clock, ..
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(1),
},
ty: CompiledTypeLayout {
ty: AsyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: AsyncReset,
},
],
..
},
},
body: Scalar,
},
},
],
}, },
}, }.cd,
range: TypeIndexRange { Instance {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, name: <simulator>::counter,
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 2 }, instantiated: Module {
}, name: counter,
write: None, ..
}, },
Instance { }.cd.clk,
name: <simulator>::counter, Instance {
instantiated: Module { name: <simulator>::counter,
name: counter, instantiated: Module {
.. name: counter,
}, ..
}.cd.clk: CompiledValue { },
layout: CompiledTypeLayout { }.cd.rst,
ty: Clock, Instance {
layout: TypeLayout { name: <simulator>::counter,
small_slots: StatePartLayout<SmallSlots> { instantiated: Module {
len: 0, name: counter,
debug_data: [], ..
.. },
}, }.count,
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::counter,
instantiated: Module {
name: counter,
..
},
}.cd.rst: CompiledValue {
layout: CompiledTypeLayout {
ty: AsyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: AsyncReset,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::counter,
instantiated: Module {
name: counter,
..
},
}.count: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::count",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "counter", name: "counter",
children: [ children: [

View file

@ -184,213 +184,58 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::counter, name: <simulator>::counter,
instantiated: Module { instantiated: Module {
name: counter, name: counter,
.. ..
},
}.cd: CompiledValue {
layout: CompiledTypeLayout {
ty: Bundle {
/* offset = 0 */
clk: Clock,
/* offset = 1 */
rst: SyncReset,
}, },
layout: TypeLayout { }.cd,
small_slots: StatePartLayout<SmallSlots> { Instance {
len: 0, name: <simulator>::counter,
debug_data: [], instantiated: Module {
.. name: counter,
}, ..
big_slots: StatePartLayout<BigSlots> {
len: 2,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::cd.clk",
ty: Clock,
},
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::cd.rst",
ty: SyncReset,
},
],
..
},
}, },
body: Bundle { }.count,
fields: [ ],
CompiledBundleField { uninitialized_ios: {},
offset: TypeIndex { io_targets: {
small_slots: StatePartIndex<SmallSlots>(0), Instance {
big_slots: StatePartIndex<BigSlots>(0), name: <simulator>::counter,
}, instantiated: Module {
ty: CompiledTypeLayout { name: counter,
ty: Clock, ..
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(1),
},
ty: CompiledTypeLayout {
ty: SyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SyncReset,
},
],
..
},
},
body: Scalar,
},
},
],
}, },
}, }.cd,
range: TypeIndexRange { Instance {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, name: <simulator>::counter,
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 2 }, instantiated: Module {
}, name: counter,
write: None, ..
}, },
Instance { }.cd.clk,
name: <simulator>::counter, Instance {
instantiated: Module { name: <simulator>::counter,
name: counter, instantiated: Module {
.. name: counter,
}, ..
}.cd.clk: CompiledValue { },
layout: CompiledTypeLayout { }.cd.rst,
ty: Clock, Instance {
layout: TypeLayout { name: <simulator>::counter,
small_slots: StatePartLayout<SmallSlots> { instantiated: Module {
len: 0, name: counter,
debug_data: [], ..
.. },
}, }.count,
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::counter,
instantiated: Module {
name: counter,
..
},
}.cd.rst: CompiledValue {
layout: CompiledTypeLayout {
ty: SyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SyncReset,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::counter,
instantiated: Module {
name: counter,
..
},
}.count: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(counter: counter).counter::count",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "counter", name: "counter",
children: [ children: [

View file

@ -88,10 +88,14 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: {}, base_targets: [],
made_initial_step: true, uninitialized_ios: {},
needs_settle: false, io_targets: {},
did_initial_settle: true,
},
extern_modules: [],
state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "duplicate_names", name: "duplicate_names",
children: [ children: [

View file

@ -1215,389 +1215,128 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::enums, name: <simulator>::enums,
instantiated: Module { instantiated: Module {
name: enums, name: enums,
.. ..
},
}.b_out: CompiledValue {
layout: CompiledTypeLayout {
ty: Enum {
HdlNone,
HdlSome(Bundle {0: UInt<1>, 1: Bool}),
}, },
layout: TypeLayout { }.cd,
small_slots: StatePartLayout<SmallSlots> { Instance {
len: 0, name: <simulator>::enums,
debug_data: [], instantiated: Module {
.. name: enums,
}, ..
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::b_out",
ty: Enum {
HdlNone,
HdlSome(Bundle {0: UInt<1>, 1: Bool}),
},
},
],
..
},
}, },
body: Scalar, }.en,
}, Instance {
range: TypeIndexRange { name: <simulator>::enums,
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, instantiated: Module {
big_slots: StatePartIndexRange<BigSlots> { start: 7, len: 1 }, name: enums,
}, ..
write: None, },
}, }.which_in,
Instance { Instance {
name: <simulator>::enums, name: <simulator>::enums,
instantiated: Module { instantiated: Module {
name: enums, name: enums,
.. ..
}, },
}.cd: CompiledValue { }.data_in,
layout: CompiledTypeLayout { Instance {
ty: Bundle { name: <simulator>::enums,
/* offset = 0 */ instantiated: Module {
clk: Clock, name: enums,
/* offset = 1 */ ..
rst: SyncReset, },
}, }.which_out,
layout: TypeLayout { Instance {
small_slots: StatePartLayout<SmallSlots> { name: <simulator>::enums,
len: 0, instantiated: Module {
debug_data: [], name: enums,
.. ..
}, },
big_slots: StatePartLayout<BigSlots> { }.data_out,
len: 2, Instance {
debug_data: [ name: <simulator>::enums,
SlotDebugData { instantiated: Module {
name: "InstantiatedModule(enums: enums).enums::cd.clk", name: enums,
ty: Clock, ..
}, },
SlotDebugData { }.b_out,
name: "InstantiatedModule(enums: enums).enums::cd.rst", ],
ty: SyncReset, uninitialized_ios: {},
}, io_targets: {
], Instance {
.. name: <simulator>::enums,
}, instantiated: Module {
}, name: enums,
body: Bundle { ..
fields: [ },
CompiledBundleField { }.b_out,
offset: TypeIndex { Instance {
small_slots: StatePartIndex<SmallSlots>(0), name: <simulator>::enums,
big_slots: StatePartIndex<BigSlots>(0), instantiated: Module {
}, name: enums,
ty: CompiledTypeLayout { ..
ty: Clock, },
layout: TypeLayout { }.cd,
small_slots: StatePartLayout<SmallSlots> { Instance {
len: 0, name: <simulator>::enums,
debug_data: [], instantiated: Module {
.. name: enums,
}, ..
big_slots: StatePartLayout<BigSlots> { },
len: 1, }.cd.clk,
debug_data: [ Instance {
SlotDebugData { name: <simulator>::enums,
name: "", instantiated: Module {
ty: Clock, name: enums,
}, ..
], },
.. }.cd.rst,
}, Instance {
}, name: <simulator>::enums,
body: Scalar, instantiated: Module {
}, name: enums,
}, ..
CompiledBundleField { },
offset: TypeIndex { }.data_in,
small_slots: StatePartIndex<SmallSlots>(0), Instance {
big_slots: StatePartIndex<BigSlots>(1), name: <simulator>::enums,
}, instantiated: Module {
ty: CompiledTypeLayout { name: enums,
ty: SyncReset, ..
layout: TypeLayout { },
small_slots: StatePartLayout<SmallSlots> { }.data_out,
len: 0, Instance {
debug_data: [], name: <simulator>::enums,
.. instantiated: Module {
}, name: enums,
big_slots: StatePartLayout<BigSlots> { ..
len: 1, },
debug_data: [ }.en,
SlotDebugData { Instance {
name: "", name: <simulator>::enums,
ty: SyncReset, instantiated: Module {
}, name: enums,
], ..
.. },
}, }.which_in,
}, Instance {
body: Scalar, name: <simulator>::enums,
}, instantiated: Module {
}, name: enums,
], ..
}, },
}, }.which_out,
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 2 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.cd.clk: CompiledValue {
layout: CompiledTypeLayout {
ty: Clock,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.cd.rst: CompiledValue {
layout: CompiledTypeLayout {
ty: SyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SyncReset,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.data_in: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::data_in",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 4, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.data_out: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::data_out",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 6, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.en: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::en",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.which_in: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::which_in",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 3, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::enums,
instantiated: Module {
name: enums,
..
},
}.which_out: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(enums: enums).enums::which_out",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 5, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "enums", name: "enums",
children: [ children: [

View file

@ -0,0 +1,224 @@
Simulation {
state: State {
insns: Insns {
state_layout: StateLayout {
ty: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 2,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(extern_module: extern_module).extern_module::i",
ty: Bool,
},
SlotDebugData {
name: "InstantiatedModule(extern_module: extern_module).extern_module::o",
ty: Bool,
},
],
..
},
},
memories: StatePartLayout<Memories> {
len: 0,
debug_data: [],
layout_data: [],
..
},
},
insns: [
// at: module-XXXXXXXXXX.rs:1:1
0: Return,
],
..
},
pc: 0,
memory_write_log: [],
memories: StatePart {
value: [],
},
small_slots: StatePart {
value: [],
},
big_slots: StatePart {
value: [
1,
1,
],
},
},
io: Instance {
name: <simulator>::extern_module,
instantiated: Module {
name: extern_module,
..
},
},
main_module: SimulationModuleState {
base_targets: [
Instance {
name: <simulator>::extern_module,
instantiated: Module {
name: extern_module,
..
},
}.i,
Instance {
name: <simulator>::extern_module,
instantiated: Module {
name: extern_module,
..
},
}.o,
],
uninitialized_ios: {},
io_targets: {
Instance {
name: <simulator>::extern_module,
instantiated: Module {
name: extern_module,
..
},
}.i,
Instance {
name: <simulator>::extern_module,
instantiated: Module {
name: extern_module,
..
},
}.o,
},
did_initial_settle: true,
},
extern_modules: [
SimulationExternModuleState {
module_state: SimulationModuleState {
base_targets: [
ModuleIO {
name: extern_module::i,
is_input: true,
ty: Bool,
..
},
ModuleIO {
name: extern_module::o,
is_input: false,
ty: Bool,
..
},
],
uninitialized_ios: {},
io_targets: {
ModuleIO {
name: extern_module::i,
is_input: true,
ty: Bool,
..
},
ModuleIO {
name: extern_module::o,
is_input: false,
ty: Bool,
..
},
},
did_initial_settle: true,
},
io_ty: Bundle {
#[hdl(flip)] /* offset = 0 */
i: Bool,
/* offset = 1 */
o: Bool,
},
sim: ExternModuleSimulation {
generator: Sim {
i: ModuleIO {
name: extern_module::i,
is_input: true,
ty: Bool,
..
},
o: ModuleIO {
name: extern_module::o,
is_input: false,
ty: Bool,
..
},
},
source_location: SourceLocation(
module-XXXXXXXXXX.rs:4:1,
),
_phantom: PhantomData<fayalite::bundle::Bundle>,
},
running_generator: Some(
...,
),
wait_target: Some(
Instant(
20.500000000000 μs,
),
),
},
],
state_ready_to_run: false,
trace_decls: TraceModule {
name: "extern_module",
children: [
TraceModuleIO {
name: "i",
child: TraceBool {
location: TraceScalarId(0),
name: "i",
flow: Source,
},
ty: Bool,
flow: Source,
},
TraceModuleIO {
name: "o",
child: TraceBool {
location: TraceScalarId(1),
name: "o",
flow: Sink,
},
ty: Bool,
flow: Sink,
},
],
},
traces: [
SimTrace {
id: TraceScalarId(0),
kind: BigBool {
index: StatePartIndex<BigSlots>(0),
},
state: 0x1,
last_state: 0x1,
},
SimTrace {
id: TraceScalarId(1),
kind: BigBool {
index: StatePartIndex<BigSlots>(1),
},
state: 0x1,
last_state: 0x1,
},
],
trace_memories: {},
trace_writers: [
Running(
VcdWriter {
finished_init: true,
timescale: 1 ps,
..
},
),
],
instant: 20 μs,
clocks_triggered: [],
..
}

View file

@ -0,0 +1,51 @@
$timescale 1 ps $end
$scope module extern_module $end
$var wire 1 ! i $end
$var wire 1 " o $end
$upscope $end
$enddefinitions $end
$dumpvars
0!
1"
$end
#500000
#1500000
0"
#2500000
1"
#3500000
0"
#4500000
1"
#5500000
0"
#6500000
1"
#7500000
0"
#8500000
1"
#9500000
0"
#10000000
1!
#10500000
#11500000
1"
#12500000
0"
#13500000
1"
#14500000
0"
#15500000
1"
#16500000
0"
#17500000
1"
#18500000
0"
#19500000
1"
#20000000

File diff suppressed because it is too large Load diff

View file

@ -598,514 +598,79 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::memories2, name: <simulator>::memories2,
instantiated: Module { instantiated: Module {
name: memories2, name: memories2,
.. ..
},
}.rw: CompiledValue {
layout: CompiledTypeLayout {
ty: Bundle {
/* offset = 0 */
addr: UInt<3>,
/* offset = 3 */
en: Bool,
/* offset = 4 */
clk: Clock,
#[hdl(flip)] /* offset = 5 */
rdata: UInt<2>,
/* offset = 7 */
wmode: Bool,
/* offset = 8 */
wdata: UInt<2>,
/* offset = 10 */
wmask: Bool,
}, },
layout: TypeLayout { }.rw,
small_slots: StatePartLayout<SmallSlots> { ],
len: 0, uninitialized_ios: {},
debug_data: [], io_targets: {
.. Instance {
}, name: <simulator>::memories2,
big_slots: StatePartLayout<BigSlots> { instantiated: Module {
len: 7, name: memories2,
debug_data: [ ..
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.addr",
ty: UInt<3>,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.en",
ty: Bool,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.clk",
ty: Clock,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.rdata",
ty: UInt<2>,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.wmode",
ty: Bool,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.wdata",
ty: UInt<2>,
},
SlotDebugData {
name: "InstantiatedModule(memories2: memories2).memories2::rw.wmask",
ty: Bool,
},
],
..
},
}, },
body: Bundle { }.rw,
fields: [ Instance {
CompiledBundleField { name: <simulator>::memories2,
offset: TypeIndex { instantiated: Module {
small_slots: StatePartIndex<SmallSlots>(0), name: memories2,
big_slots: StatePartIndex<BigSlots>(0), ..
},
ty: CompiledTypeLayout {
ty: UInt<3>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<3>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(1),
},
ty: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(2),
},
ty: CompiledTypeLayout {
ty: Clock,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(3),
},
ty: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(4),
},
ty: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(5),
},
ty: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(6),
},
ty: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
},
],
}, },
}, }.rw.addr,
range: TypeIndexRange { Instance {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, name: <simulator>::memories2,
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 7 }, instantiated: Module {
}, name: memories2,
write: None, ..
}, },
Instance { }.rw.clk,
name: <simulator>::memories2, Instance {
instantiated: Module { name: <simulator>::memories2,
name: memories2, instantiated: Module {
.. name: memories2,
}, ..
}.rw.addr: CompiledValue { },
layout: CompiledTypeLayout { }.rw.en,
ty: UInt<3>, Instance {
layout: TypeLayout { name: <simulator>::memories2,
small_slots: StatePartLayout<SmallSlots> { instantiated: Module {
len: 0, name: memories2,
debug_data: [], ..
.. },
}, }.rw.rdata,
big_slots: StatePartLayout<BigSlots> { Instance {
len: 1, name: <simulator>::memories2,
debug_data: [ instantiated: Module {
SlotDebugData { name: memories2,
name: "", ..
ty: UInt<3>, },
}, }.rw.wdata,
], Instance {
.. name: <simulator>::memories2,
}, instantiated: Module {
}, name: memories2,
body: Scalar, ..
}, },
range: TypeIndexRange { }.rw.wmask,
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, Instance {
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 }, name: <simulator>::memories2,
}, instantiated: Module {
write: None, name: memories2,
}, ..
Instance { },
name: <simulator>::memories2, }.rw.wmode,
instantiated: Module {
name: memories2,
..
},
}.rw.clk: CompiledValue {
layout: CompiledTypeLayout {
ty: Clock,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::memories2,
instantiated: Module {
name: memories2,
..
},
}.rw.en: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::memories2,
instantiated: Module {
name: memories2,
..
},
}.rw.rdata: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 3, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::memories2,
instantiated: Module {
name: memories2,
..
},
}.rw.wdata: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 5, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::memories2,
instantiated: Module {
name: memories2,
..
},
}.rw.wmask: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 6, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::memories2,
instantiated: Module {
name: memories2,
..
},
}.rw.wmode: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 4, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "memories2", name: "memories2",
children: [ children: [

File diff suppressed because it is too large Load diff

View file

@ -216,313 +216,58 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::mod1, name: <simulator>::mod1,
instantiated: Module { instantiated: Module {
name: mod1, name: mod1,
.. ..
},
}.o: CompiledValue {
layout: CompiledTypeLayout {
ty: Bundle {
#[hdl(flip)] /* offset = 0 */
i: UInt<4>,
/* offset = 4 */
o: SInt<2>,
#[hdl(flip)] /* offset = 6 */
i2: SInt<2>,
/* offset = 8 */
o2: UInt<4>,
}, },
layout: TypeLayout { }.o,
small_slots: StatePartLayout<SmallSlots> { ],
len: 0, uninitialized_ios: {},
debug_data: [], io_targets: {
.. Instance {
}, name: <simulator>::mod1,
big_slots: StatePartLayout<BigSlots> { instantiated: Module {
len: 4, name: mod1,
debug_data: [ ..
SlotDebugData {
name: "InstantiatedModule(mod1: mod1).mod1::o.i",
ty: UInt<4>,
},
SlotDebugData {
name: "InstantiatedModule(mod1: mod1).mod1::o.o",
ty: SInt<2>,
},
SlotDebugData {
name: "InstantiatedModule(mod1: mod1).mod1::o.i2",
ty: SInt<2>,
},
SlotDebugData {
name: "InstantiatedModule(mod1: mod1).mod1::o.o2",
ty: UInt<4>,
},
],
..
},
}, },
body: Bundle { }.o,
fields: [ Instance {
CompiledBundleField { name: <simulator>::mod1,
offset: TypeIndex { instantiated: Module {
small_slots: StatePartIndex<SmallSlots>(0), name: mod1,
big_slots: StatePartIndex<BigSlots>(0), ..
},
ty: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(1),
},
ty: CompiledTypeLayout {
ty: SInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SInt<2>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(2),
},
ty: CompiledTypeLayout {
ty: SInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SInt<2>,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(3),
},
ty: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
},
],
}, },
}, }.o.i,
range: TypeIndexRange { Instance {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, name: <simulator>::mod1,
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 4 }, instantiated: Module {
}, name: mod1,
write: None, ..
}, },
Instance { }.o.i2,
name: <simulator>::mod1, Instance {
instantiated: Module { name: <simulator>::mod1,
name: mod1, instantiated: Module {
.. name: mod1,
}, ..
}.o.i: CompiledValue { },
layout: CompiledTypeLayout { }.o.o,
ty: UInt<4>, Instance {
layout: TypeLayout { name: <simulator>::mod1,
small_slots: StatePartLayout<SmallSlots> { instantiated: Module {
len: 0, name: mod1,
debug_data: [], ..
.. },
}, }.o.o2,
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::mod1,
instantiated: Module {
name: mod1,
..
},
}.o.i2: CompiledValue {
layout: CompiledTypeLayout {
ty: SInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::mod1,
instantiated: Module {
name: mod1,
..
},
}.o.o: CompiledValue {
layout: CompiledTypeLayout {
ty: SInt<2>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SInt<2>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::mod1,
instantiated: Module {
name: mod1,
..
},
}.o.o2: CompiledValue {
layout: CompiledTypeLayout {
ty: UInt<4>,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: UInt<4>,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 3, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "mod1", name: "mod1",
children: [ children: [

View file

@ -265,247 +265,72 @@ Simulation {
.. ..
}, },
}, },
uninitialized_inputs: {}, main_module: SimulationModuleState {
io_targets: { base_targets: [
Instance { Instance {
name: <simulator>::shift_register, name: <simulator>::shift_register,
instantiated: Module { instantiated: Module {
name: shift_register, name: shift_register,
.. ..
},
}.cd: CompiledValue {
layout: CompiledTypeLayout {
ty: Bundle {
/* offset = 0 */
clk: Clock,
/* offset = 1 */
rst: SyncReset,
}, },
layout: TypeLayout { }.cd,
small_slots: StatePartLayout<SmallSlots> { Instance {
len: 0, name: <simulator>::shift_register,
debug_data: [], instantiated: Module {
.. name: shift_register,
}, ..
big_slots: StatePartLayout<BigSlots> {
len: 2,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(shift_register: shift_register).shift_register::cd.clk",
ty: Clock,
},
SlotDebugData {
name: "InstantiatedModule(shift_register: shift_register).shift_register::cd.rst",
ty: SyncReset,
},
],
..
},
}, },
body: Bundle { }.d,
fields: [ Instance {
CompiledBundleField { name: <simulator>::shift_register,
offset: TypeIndex { instantiated: Module {
small_slots: StatePartIndex<SmallSlots>(0), name: shift_register,
big_slots: StatePartIndex<BigSlots>(0), ..
},
ty: CompiledTypeLayout {
ty: Clock,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: Clock,
},
],
..
},
},
body: Scalar,
},
},
CompiledBundleField {
offset: TypeIndex {
small_slots: StatePartIndex<SmallSlots>(0),
big_slots: StatePartIndex<BigSlots>(1),
},
ty: CompiledTypeLayout {
ty: SyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SyncReset,
},
],
..
},
},
body: Scalar,
},
},
],
}, },
}, }.q,
range: TypeIndexRange { ],
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, uninitialized_ios: {},
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 2 }, io_targets: {
}, Instance {
write: None, name: <simulator>::shift_register,
}, instantiated: Module {
Instance { name: shift_register,
name: <simulator>::shift_register, ..
instantiated: Module { },
name: shift_register, }.cd,
.. Instance {
}, name: <simulator>::shift_register,
}.cd.clk: CompiledValue { instantiated: Module {
layout: CompiledTypeLayout { name: shift_register,
ty: Clock, ..
layout: TypeLayout { },
small_slots: StatePartLayout<SmallSlots> { }.cd.clk,
len: 0, Instance {
debug_data: [], name: <simulator>::shift_register,
.. instantiated: Module {
}, name: shift_register,
big_slots: StatePartLayout<BigSlots> { ..
len: 1, },
debug_data: [ }.cd.rst,
SlotDebugData { Instance {
name: "", name: <simulator>::shift_register,
ty: Clock, instantiated: Module {
}, name: shift_register,
], ..
.. },
}, }.d,
}, Instance {
body: Scalar, name: <simulator>::shift_register,
}, instantiated: Module {
range: TypeIndexRange { name: shift_register,
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 }, ..
big_slots: StatePartIndexRange<BigSlots> { start: 0, len: 1 }, },
}, }.q,
write: None,
},
Instance {
name: <simulator>::shift_register,
instantiated: Module {
name: shift_register,
..
},
}.cd.rst: CompiledValue {
layout: CompiledTypeLayout {
ty: SyncReset,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "",
ty: SyncReset,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 1, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::shift_register,
instantiated: Module {
name: shift_register,
..
},
}.d: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(shift_register: shift_register).shift_register::d",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 2, len: 1 },
},
write: None,
},
Instance {
name: <simulator>::shift_register,
instantiated: Module {
name: shift_register,
..
},
}.q: CompiledValue {
layout: CompiledTypeLayout {
ty: Bool,
layout: TypeLayout {
small_slots: StatePartLayout<SmallSlots> {
len: 0,
debug_data: [],
..
},
big_slots: StatePartLayout<BigSlots> {
len: 1,
debug_data: [
SlotDebugData {
name: "InstantiatedModule(shift_register: shift_register).shift_register::q",
ty: Bool,
},
],
..
},
},
body: Scalar,
},
range: TypeIndexRange {
small_slots: StatePartIndexRange<SmallSlots> { start: 0, len: 0 },
big_slots: StatePartIndexRange<BigSlots> { start: 3, len: 1 },
},
write: None,
}, },
did_initial_settle: true,
}, },
made_initial_step: true, extern_modules: [],
needs_settle: false, state_ready_to_run: false,
trace_decls: TraceModule { trace_decls: TraceModule {
name: "shift_register", name: "shift_register",
children: [ children: [

View file

@ -160,7 +160,8 @@
"data": { "data": {
"$kind": "Struct", "$kind": "Struct",
"verilog_name": "Visible", "verilog_name": "Visible",
"parameters": "Visible" "parameters": "Visible",
"simulation": "Visible"
} }
}, },
"ExternModuleParameter": { "ExternModuleParameter": {
@ -1269,6 +1270,12 @@
"$kind": "Opaque" "$kind": "Opaque"
}, },
"generics": "<T: ?Sized + crate::phantom_const::PhantomConstValue>" "generics": "<T: ?Sized + crate::phantom_const::PhantomConstValue>"
},
"ExternModuleSimulation": {
"data": {
"$kind": "Opaque"
},
"generics": "<T: BundleType>"
} }
} }
} }