diff --git a/src/pcf.rs b/src/pcf.rs index ac4e49b..74aced0 100644 --- a/src/pcf.rs +++ b/src/pcf.rs @@ -25,7 +25,7 @@ impl PcfFile { } pub fn pinvec(&self, name: &str, index: u32) -> Option { // construct a name of the form [] - let realname = format!("{name}[{index}]", name = name, index = index); + let realname = format!("{name}[{index}]"); self.map.get(&realname).cloned() } } diff --git a/src/yosys_parser.rs b/src/yosys_parser.rs index 869990c..8fb39d6 100644 --- a/src/yosys_parser.rs +++ b/src/yosys_parser.rs @@ -1,4 +1,5 @@ use crate::gal::Pin; +use crate::pcf::PcfFile; use serde::{de::Error, Deserialize, Deserializer, Serialize}; use serde_with::{serde_as, BoolFromInt}; use std::collections::HashMap; @@ -181,7 +182,7 @@ pub enum AnyCell { // we look it up by id. But we can also match based on type. type Netlist = HashMap; -// we know that the yosys moduel uses unique names. well at least it should. +// we know that the yosys module uses unique names. well at least it should. impl YosysDoc { pub fn to_netlist(&self) -> Netlist { @@ -202,7 +203,6 @@ impl YosysDoc { } } } - for (name, cell) in &m.cells { println!("Found Cell {}", name); match cell { @@ -216,6 +216,37 @@ impl YosysDoc { } } -fn get_netlist_nodes(nl: &Netlist) -> Vec<&T> { - Vec::new() +/* constraint mapping pipeline + * take yosys document -> look at top-level module ports + * use constraints pcf file to map. This creates a HashMap for mapping nets to pins. + * only do this for *ports*, not cells. + */ + +enum PortValue { + Single(u32), + Register(Vec), +} + +/* + * this fn + */ +fn port_lookup(name: &str, cell: &AnyCell, pcf: &PcfFile) -> Option { + match cell { + AnyCell::Input(p) => { + if p.bits.len() == 1 { + pcf.pin(name).map(PortValue::Single) + } else { + // check upto + if p.upto { + for (idx, net) in p.bits.iter().enumerate() { + } + None + } else { + None + } + } + }, + + _ => None + } } diff --git a/tests/pcf_test.rs b/tests/pcf_test.rs index df06900..1137db4 100644 --- a/tests/pcf_test.rs +++ b/tests/pcf_test.rs @@ -25,7 +25,7 @@ set_io vec[1] 3"; #[test] #[should_panic] -fn test_invalid() { +fn test_name_collision() { let test = " set_io scalar 1 set_io scalar 2";