Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions crates/celox/src/backend/native/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,7 @@ fn format_native_codegen_trace(
comb: &CompiledNativeFunction,
ff_codes: &HashMap<usize, CompiledNativeFunction>,
tasks: &[NativeCompileTask<'_>],
processes: &[CompiledNativeFunction],
) -> NativeCodegenTrace {
let mut optimized_sir = String::from("=== Optimized SIR used by native emission ===\n");
let mut mir = String::from("=== MIR used by native emission ===\n");
Expand Down Expand Up @@ -1845,6 +1846,20 @@ fn format_native_codegen_trace(
.expect("explicit native trace must capture every FF function"),
);
}
for (index, process) in processes.iter().enumerate() {
append_native_function_trace(
&mut optimized_sir,
&mut mir,
&mut reactive_graph,
&mut state_layout,
&format!("process[{index}]"),
&[],
process
.trace
.as_ref()
.expect("explicit native trace must capture every process"),
);
}
NativeCodegenTrace {
optimized_sir,
mir,
Expand Down Expand Up @@ -2712,7 +2727,7 @@ fn compile_program_with_outlining_threshold(
NativeMergeKind::Complete,
None,
&process_options,
false,
capture_trace,
&options.optimize_options.diagnostics,
cancel,
)
Expand Down Expand Up @@ -2743,8 +2758,9 @@ fn compile_program_with_outlining_threshold(
}
}
}
let codegen_trace = capture_trace
.then(|| format_native_codegen_trace(&comb_jit, &compiled_ff_codes, &compile_tasks));
let codegen_trace = capture_trace.then(|| {
format_native_codegen_trace(&comb_jit, &compiled_ff_codes, &compile_tasks, &process_jits)
});
let semantic_memory_size = layout
.merged_total_size
.checked_add(layout.triggered_bits_total_size)
Expand Down
32 changes: 32 additions & 0 deletions crates/celox/tests/native_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,35 @@ fn many_clocks_compile_the_comb_program_once() {
assert_eq!(functions(2), (1, 2));
assert_eq!(functions(12), (1, 0));
}

#[test]
fn trace_contains_native_testbench_processes() {
let code = r#"
#[test(test_top)]
module Top {
var q: logic<8>;
initial {
q = 1;
$assert(q == 1);
}
}
"#;
let result = SimulatorBuilder::new(code, "Top")
.trace_mir()
.build_with_trace();
result.res.expect("native testbench build should succeed");
assert!(
result
.trace
.native_optimized_sir
.unwrap()
.contains("=== Native function process[0] ===")
);
assert!(
result
.trace
.mir
.unwrap()
.contains("=== Native function process[0] ===")
);
}
Loading