summaryrefslogtreecommitdiff
path: root/src/pin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pin.rs')
-rw-r--r--src/pin.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/pin.rs b/src/pin.rs
new file mode 100644
index 0000000..2602d26
--- /dev/null
+++ b/src/pin.rs
@@ -0,0 +1,41 @@
+use crate::types::*;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum PinType {
+ Undetermined,
+ ChipInput,
+ GateInput,
+ GateOutput,
+ ChipOutput,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct Pin {
+ pub id: usize,
+ pub kind: PinType,
+ pub gate_id: usize,
+ pub val: Option<PinValue>,
+}
+
+impl Pin {
+ pub fn new(kind: PinType, gate_id: usize, val: PinValue) -> Self {
+ static mut ID: usize = 0;
+ unsafe {
+ ID += 1;
+ match kind {
+ PinType::Undetermined => Pin {
+ id: ID,
+ gate_id,
+ kind,
+ val: None,
+ },
+ _ => Pin {
+ id: ID,
+ gate_id,
+ kind,
+ val: Some(val),
+ },
+ }
+ }
+ }
+}