From fcb44d972fca4c026a714ab6770788ac4c7b3741 Mon Sep 17 00:00:00 2001 From: FranchuFranchu Date: Tue, 19 Mar 2024 10:37:35 -0300 Subject: [PATCH] Fix flipped CTR ports in readback. --- src/stdlib.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/stdlib.rs b/src/stdlib.rs index a3651093..62f0b951 100644 --- a/src/stdlib.rs +++ b/src/stdlib.rs @@ -238,12 +238,9 @@ impl AsBoxDef for ReadbackDef { Tag::Num => { unsafe { *(def.data.tree.0) = Tree::Num { val: port.num() } }; net.link_port_port(def.data.out, port) - } + }, Tag::Mat => { - unsafe { - *(def.data.tree.0) = - Tree::Mat { zero: Box::new(Tree::Era), succ: Box::new(Tree::Era), out: Box::new(Tree::Era) } - }; + unsafe { *(def.data.tree.0) = Tree::Mat { zero: Box::new(Tree::Era), succ: Box::new(Tree::Era), out: Box::new(Tree::Era) } }; let Tree::Mat { zero, succ, out } = (unsafe { &mut *(def.data.tree.0) }) else { unreachable!() }; let old = port.clone().consume_node(); let new = net.create_node(Tag::Mat, old.lab); @@ -265,18 +262,20 @@ impl AsBoxDef for ReadbackDef { *(def.data.tree.0) = Tree::Op { op: port.op(), rhs: Box::new(Tree::Era), out: Box::new(Tree::Era) } }; let Tree::Op { rhs, out, .. } = (unsafe { &mut *(def.data.tree.0) }) else { unreachable!() }; - (out.as_mut(), rhs.as_mut()) + (rhs.as_mut(), out.as_mut()) } Tag::Ctr => { - unsafe { *(def.data.tree.0) = Tree::Ctr { lab: port.lab(), ports: vec![Tree::Era, Tree::Era] } }; + unsafe { + *(def.data.tree.0) = Tree::Ctr { lab: port.lab(), ports: vec![Tree::Era, Tree::Era] } + }; let Tree::Ctr { ports, .. } = (unsafe { &mut *(def.data.tree.0) }) else { unreachable!() }; (&mut ports[0], &mut ports[1]) } _ => unreachable!(), }; net.link_port_port(def.data.out.clone(), new.p0); - net.link_wire_port(old.p1, def.data.with(rhs, new.p1)); - net.link_wire_port(old.p2, def.data.with(lhs, new.p2)); + net.link_wire_port(old.p1, def.data.with(lhs, new.p1)); + net.link_wire_port(old.p2, def.data.with(rhs, new.p2)); } } Self::maybe_finish(DynNetMut::from(net), def.data.root);