forked from libre-chip/fayalite
fix Simulator panicking when you use PhantomConst
This commit is contained in:
parent
840c5e1895
commit
0b77d1bea0
11 changed files with 756 additions and 55 deletions
|
|
@ -2244,3 +2244,41 @@ fn test_sim_resettable_counter_async_immediate_reset() {
|
|||
panic!();
|
||||
}
|
||||
}
|
||||
|
||||
#[hdl_module(outline_generated)]
|
||||
pub fn phantom_const() {
|
||||
#[hdl]
|
||||
let out: Array<PhantomConst<Vec<String>>, 2> =
|
||||
m.output(Array::new_static(PhantomConst::new_sized(vec![
|
||||
"a".into(),
|
||||
"b".into(),
|
||||
])));
|
||||
let _ = out;
|
||||
#[hdl]
|
||||
let mut mem = memory(PhantomConst::new("mem_element"));
|
||||
mem.depth(1);
|
||||
let port = mem.new_read_port();
|
||||
connect_any(port.addr, 0u8);
|
||||
connect(port.clk, false.to_clock());
|
||||
connect(port.en, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_phantom_const() {
|
||||
let _n = SourceLocation::normalize_files_for_tests();
|
||||
let mut sim = Simulation::new(phantom_const());
|
||||
let mut writer = RcWriter::default();
|
||||
sim.add_trace_writer(VcdWriterDecls::new(writer.clone()));
|
||||
sim.advance_time(SimDuration::from_micros(1));
|
||||
sim.flush_traces().unwrap();
|
||||
let vcd = String::from_utf8(writer.take()).unwrap();
|
||||
println!("####### VCD:\n{vcd}\n#######");
|
||||
if vcd != include_str!("sim/expected/phantom_const.vcd") {
|
||||
panic!();
|
||||
}
|
||||
let sim_debug = format!("{sim:#?}");
|
||||
println!("#######\n{sim_debug}\n#######");
|
||||
if sim_debug != include_str!("sim/expected/phantom_const.txt") {
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue