prjunnamed_netlist/cell/
target.rs1use crate::{IoValue, Net, TargetPrototype, Value};
2
3use crate::ParamValue;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct TargetCell {
7 pub kind: String,
8 pub params: Vec<ParamValue>,
9 pub inputs: Value,
10 pub output_len: usize,
11 pub ios: IoValue,
12}
13
14impl TargetCell {
15 pub fn new(kind: impl Into<String>, prototype: &TargetPrototype) -> Self {
16 let mut result = Self {
17 kind: kind.into(),
18 params: vec![],
19 inputs: Value::new(),
20 output_len: prototype.output_len,
21 ios: IoValue::floating(prototype.io_len),
22 };
23 for param in &prototype.params {
24 result.params.push(param.default.clone());
25 }
26 for input in &prototype.inputs {
27 result.inputs.extend(Value::from(&input.default));
28 }
29 result
30 }
31
32 pub fn visit(&self, f: impl FnMut(Net)) {
33 self.inputs.visit(f);
34 }
35
36 pub fn visit_mut(&mut self, f: impl FnMut(&mut Net)) {
37 self.inputs.visit_mut(f);
38 }
39}