Skip to content

Commit

Permalink
Fixed needed_until incorrectly extended by function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Jul 9, 2024
1 parent 35a1a8c commit 2ab9aab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn parse_args() -> Vec<PathBuf> {
"--debug-latency" => {
config.debug_print_latency_graph = true;
}
"--module-and-dependencies" => {
"--standalone" => {
config.codegen_module_and_dependencies_one_file = Some(args.next().unwrap());
}
other => {
Expand Down
30 changes: 18 additions & 12 deletions src/instantiation/latency_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,26 @@ impl<'fl, 'l> InstantiationContext<'fl, 'l> {
self.report_error(&domain_info.latency_node_meanings, err);
}
};

// Compute needed_untils
for (latency_idx, wire_id) in domain_info.latency_node_meanings.iter().enumerate() {
let wire = &self.wires[*wire_id];
let mut needed_until = wire.absolute_latency;
for target_fanout in &fanouts[latency_idx] {
let target_wire = &self.wires[domain_info.latency_node_meanings[target_fanout.other]];

needed_until = max(needed_until, target_wire.absolute_latency);
}

// Compute needed_untils
for (_id, w) in &mut self.wires {
w.needed_until = w.absolute_latency;
}
let mut_wires_ref : *mut _ = &mut self.wires;
for (_id, w) in &self.wires {
w.source.iter_sources_with_min_latency(|other, _| {
// SAFETY: Need some unsafe code to modify needed_until while iterating through the wires
// We write to needed_until everywhere, and for the information we need we never read needed_until
unsafe{
let nu = &mut (*mut_wires_ref)[other].needed_until;

*nu = max(*nu, w.absolute_latency);
}
self.wires[*wire_id].needed_until = needed_until;
}
});
}



// Finally update interface absolute latencies
for (_id, port) in self.interface_ports.iter_valids_mut() {
port.absolute_latency = self.wires[port.wire].absolute_latency;
Expand Down

0 comments on commit 2ab9aab

Please sign in to comment.