Compare commits

...

2 Commits

Author SHA1 Message Date
D4VID d66e60c888 Improve inputs and outputs
1 month ago
D4VID af7f1fe19a More outputs
1 month ago

@ -1,3 +1,7 @@
module gates(input a, input b, input c, output wire out); module gates(
input a,b,c,d,
output wire out, out2
);
assign out = a & b | c; assign out = a & b | c;
assign out2 = a & b ^ d;
endmodule endmodule

@ -88,7 +88,10 @@ pub fn route(module: Module) -> Result<(Vec<lw::Component>, Vec<lw::Wire>), Erro
&mut connection_map, &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]); let mut next_position = vec3_add(origin, [1 * SQUARE, 0, 3 * SQUARE]);
@ -137,7 +140,10 @@ pub fn route(module: Module) -> Result<(Vec<lw::Component>, Vec<lw::Wire>), Erro
&mut connection_map, &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 { let board = lw::Component {
@ -199,33 +205,33 @@ fn input_port(
next_position: &mut Vector3<lw::Int>, next_position: &mut Vector3<lw::Int>,
connection_map: &mut HashMap<(usize, &str), lw::PegAddress>, connection_map: &mut HashMap<(usize, &str), lw::PegAddress>,
) -> Vec<lw::Component> { ) -> Vec<lw::Component> {
let peg = lw::Component {
let label = lw::Component {
address: *next_address, address: *next_address,
parent: parent_address, parent: parent_address,
numeric_id: COMPONENT_MAP["MHG.Peg"], numeric_id: COMPONENT_MAP["MHG.PanelLabel"],
position: *next_position, position: *next_position,
rotation: quaternion::id(), rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0),
inputs: vec![lw::Input::new(bit_id as lw::Int)], inputs: vec![],
outputs: 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; *next_address += 1;
let label = lw::Component { let peg = lw::Component {
address: *next_address, address: *next_address,
parent: parent_address, parent: parent_address,
numeric_id: COMPONENT_MAP["MHG.PanelLabel"], numeric_id: COMPONENT_MAP["MHG.Peg"],
position: vec3_add(*next_position, [0, 0, SQUARE]), position: vec3_add(*next_position, [0, 0, SQUARE]),
rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), rotation: quaternion::id(),
inputs: vec![], inputs: vec![lw::Input::new(bit_id as lw::Int)],
outputs: vec![], 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_address += 1;
next_position[0] += SQUARE / 3; // third of a square next_position[0] += SQUARE / 3; // third of a square
return vec![peg, label]; return vec![peg, label];
@ -239,34 +245,33 @@ fn output_port(
next_position: &mut Vector3<lw::Int>, next_position: &mut Vector3<lw::Int>,
connection_map: &mut HashMap<(usize, &str), lw::PegAddress>, connection_map: &mut HashMap<(usize, &str), lw::PegAddress>,
) -> Vec<lw::Component> { ) -> Vec<lw::Component> {
let peg = lw::Component {
let label = lw::Component {
address: *next_address, address: *next_address,
parent: parent_address, parent: parent_address,
numeric_id: COMPONENT_MAP["MHG.Peg"], numeric_id: COMPONENT_MAP["MHG.PanelLabel"],
position: vec3_add(*next_position, [0, 0, SQUARE]), position: vec3_add(*next_position, [0, 0, SQUARE]),
rotation: quaternion::id(), rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0),
inputs: vec![lw::Input::new(bit_id as lw::Int)], inputs: vec![],
outputs: 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; *next_address += 1;
let label = lw::Component { let peg = lw::Component {
address: *next_address, address: *next_address,
parent: parent_address, parent: parent_address,
numeric_id: COMPONENT_MAP["MHG.PanelLabel"], numeric_id: COMPONENT_MAP["MHG.Peg"],
position: *next_position, position: *next_position,
rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0), rotation: quaternion::id(),
inputs: vec![], inputs: vec![lw::Input::new(bit_id as lw::Int)],
outputs: vec![], 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_address += 1;
next_position[0] += SQUARE / 3; // third of a square next_position[0] += SQUARE / 3; // third of a square
return vec![peg, label]; return vec![peg, label];

Loading…
Cancel
Save