Skip to content
Merged
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
20 changes: 18 additions & 2 deletions src/bin/nl_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use eqmap::pass::{Error, Pass, PrintVerilog};
use eqmap::register_passes;
use eqmap::verilog::sv_parse_wrapper;
use nl_compiler::{from_vast, from_vast_overrides};
use safety_net::{Identifier, Instantiable, MultiDiGraph, Netlist, format_id};
use safety_net::{Identifier, Instantiable, MultiDiGraph, Netlist, SimpleCombDepth, format_id};
use std::io::Read;
use std::path::PathBuf;
use std::rc::Rc;
Expand Down Expand Up @@ -130,8 +130,24 @@ impl Pass for ReportSccs {
}
}

// Report the longest path in the netlist

pub struct ReportDepth;

impl Pass for ReportDepth {
type I = PrimitiveCell;
fn run(&self, netlist: &Rc<Netlist<Self::I>>) -> Result<String, Error> {
let analysis = netlist.get_analysis::<SimpleCombDepth<_>>()?;
match analysis.get_max_depth() {
Some(depth) => Ok(format!("Maximum combinational depth: {depth}")),
None => Ok("Maximum combinational depth: undefined".to_string()),
}
}
}

register_passes!(PrimitiveCell; PrintVerilog, DotGraph, Clean, DisconnectRegisters,
DisconnectArcSet, MarkArcSet, RenameNets, ReportSccs);
DisconnectArcSet, MarkArcSet, RenameNets, ReportSccs,
ReportDepth);

/// Netlist optimization debugging tool
#[derive(Parser, Debug)]
Expand Down