diff --git a/verilog2logicworld/src/router.rs b/verilog2logicworld/src/router.rs index 7a186ae..04082cd 100644 --- a/verilog2logicworld/src/router.rs +++ b/verilog2logicworld/src/router.rs @@ -88,7 +88,10 @@ pub fn route(module: Module) -> Result<(Vec, Vec), Erro &mut connection_map, )); } - next_input_position[0] += SQUARE; + // align back to middle + next_input_position[0] += SQUARE/2; + next_input_position[0] -= next_input_position[0] % SQUARE; + next_input_position[0] += SQUARE/2; } let mut next_position = vec3_add(origin, [1 * SQUARE, 0, 3 * SQUARE]); @@ -137,7 +140,10 @@ pub fn route(module: Module) -> Result<(Vec, Vec), Erro &mut connection_map, )); } - next_output_position[0] += SQUARE; + // align back to middle + next_output_position[0] += SQUARE/2; + next_output_position[0] -= next_output_position[0] % SQUARE; + next_output_position[0] += SQUARE/2; } let board = lw::Component { @@ -199,33 +205,33 @@ fn input_port( next_position: &mut Vector3, connection_map: &mut HashMap<(usize, &str), lw::PegAddress>, ) -> Vec { - let peg = lw::Component { + + let label = lw::Component { address: *next_address, parent: parent_address, - numeric_id: COMPONENT_MAP["MHG.Peg"], + numeric_id: COMPONENT_MAP["MHG.PanelLabel"], position: *next_position, - rotation: quaternion::id(), - inputs: vec![lw::Input::new(bit_id as lw::Int)], + rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), + inputs: vec![], outputs: vec![], - custom_data: vec![], + custom_data: lw::Label::new(port_name).with_size(2.0).custom_data(), }; - connection_map.insert((bit_id, "input"), lw::PegAddress::input(peg.address, 0)); *next_address += 1; - let label = lw::Component { + let peg = lw::Component { address: *next_address, parent: parent_address, - numeric_id: COMPONENT_MAP["MHG.PanelLabel"], + numeric_id: COMPONENT_MAP["MHG.Peg"], position: vec3_add(*next_position, [0, 0, SQUARE]), - rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), - inputs: vec![], + rotation: quaternion::id(), + inputs: vec![lw::Input::new(bit_id as lw::Int)], outputs: vec![], - custom_data: lw::Label::new(port_name).with_size(2.0).custom_data(), + custom_data: vec![], }; + connection_map.insert((bit_id, "input"), lw::PegAddress::input(peg.address, 0)); *next_address += 1; - next_position[0] += SQUARE / 3; // third of a square return vec![peg, label]; @@ -239,34 +245,33 @@ fn output_port( next_position: &mut Vector3, connection_map: &mut HashMap<(usize, &str), lw::PegAddress>, ) -> Vec { - let peg = lw::Component { + + let label = lw::Component { address: *next_address, parent: parent_address, - numeric_id: COMPONENT_MAP["MHG.Peg"], + numeric_id: COMPONENT_MAP["MHG.PanelLabel"], position: vec3_add(*next_position, [0, 0, SQUARE]), - rotation: quaternion::id(), - inputs: vec![lw::Input::new(bit_id as lw::Int)], + rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), + inputs: vec![], outputs: vec![], - custom_data: vec![], + custom_data: lw::Label::new(port_name).with_size(2.0).custom_data(), }; - connection_map.insert((bit_id, "output"), lw::PegAddress::input(peg.address, 0)); - *next_address += 1; - let label = lw::Component { + let peg = lw::Component { address: *next_address, parent: parent_address, - numeric_id: COMPONENT_MAP["MHG.PanelLabel"], + numeric_id: COMPONENT_MAP["MHG.Peg"], position: *next_position, - rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), - inputs: vec![], + rotation: quaternion::id(), + inputs: vec![lw::Input::new(bit_id as lw::Int)], outputs: vec![], - custom_data: lw::Label::new(port_name).with_size(2.0).custom_data(), + custom_data: vec![], }; + connection_map.insert((bit_id, "output"), lw::PegAddress::input(peg.address, 0)); *next_address += 1; - next_position[0] += SQUARE / 3; // third of a square return vec![peg, label];