|
|
@ -1,13 +1,14 @@
|
|
|
|
mod verilog;
|
|
|
|
mod verilog;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use std::f32::consts::PI;
|
|
|
|
use std::io;
|
|
|
|
use std::io;
|
|
|
|
use std::path::Path;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
|
|
|
|
use logicworld_subassembly::create_subassembly;
|
|
|
|
use logicworld_subassembly::create_subassembly;
|
|
|
|
use logicworld_subassembly::lw;
|
|
|
|
use logicworld_subassembly::lw;
|
|
|
|
use logicworld_subassembly::lw::PegAddress;
|
|
|
|
|
|
|
|
use logicworld_subassembly::COMPONENT_MAP;
|
|
|
|
use logicworld_subassembly::COMPONENT_MAP;
|
|
|
|
use verilog::run_yosys;
|
|
|
|
use verilog::compile_module;
|
|
|
|
|
|
|
|
use verilog::get_modules;
|
|
|
|
|
|
|
|
|
|
|
|
fn write_subassembly() -> io::Result<()> {
|
|
|
|
fn write_subassembly() -> io::Result<()> {
|
|
|
|
let components = vec![
|
|
|
|
let components = vec![
|
|
|
@ -21,14 +22,14 @@ fn write_subassembly() -> io::Result<()> {
|
|
|
|
outputs: vec![],
|
|
|
|
outputs: vec![],
|
|
|
|
custom_data: lw::CircuitBoard::default()
|
|
|
|
custom_data: lw::CircuitBoard::default()
|
|
|
|
.with_color(0, 100, 50)
|
|
|
|
.with_color(0, 100, 50)
|
|
|
|
.with_size(5, 10)
|
|
|
|
.with_size(5, 13)
|
|
|
|
.custom_data(),
|
|
|
|
.custom_data(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
lw::Component {
|
|
|
|
lw::Component {
|
|
|
|
address: 2,
|
|
|
|
address: 2,
|
|
|
|
parent: 1,
|
|
|
|
parent: 1,
|
|
|
|
numeric_id: COMPONENT_MAP["MHG.AndGate"],
|
|
|
|
numeric_id: COMPONENT_MAP["MHG.AndGate"],
|
|
|
|
position: [150+1*300, 150, 150+2*300],
|
|
|
|
position: [150 + 1 * 300, 150, 150 + 7 * 300],
|
|
|
|
rotation: quaternion::id(),
|
|
|
|
rotation: quaternion::id(),
|
|
|
|
inputs: vec![lw::Input::new(1), lw::Input::new(2), lw::Input::new(3)],
|
|
|
|
inputs: vec![lw::Input::new(1), lw::Input::new(2), lw::Input::new(3)],
|
|
|
|
outputs: vec![lw::Output::new(4)],
|
|
|
|
outputs: vec![lw::Output::new(4)],
|
|
|
@ -38,16 +39,32 @@ fn write_subassembly() -> io::Result<()> {
|
|
|
|
address: 3,
|
|
|
|
address: 3,
|
|
|
|
parent: 1,
|
|
|
|
parent: 1,
|
|
|
|
numeric_id: COMPONENT_MAP["MHG.XorGate"],
|
|
|
|
numeric_id: COMPONENT_MAP["MHG.XorGate"],
|
|
|
|
position: [150+1*300, 150, 150+5*300],
|
|
|
|
position: [150 + 1 * 300, 150, 150 + 10 * 300],
|
|
|
|
rotation: quaternion::id(),
|
|
|
|
rotation: quaternion::id(),
|
|
|
|
inputs: vec![lw::Input::new(5), lw::Input::new(4)],
|
|
|
|
inputs: vec![lw::Input::new(5), lw::Input::new(4)],
|
|
|
|
outputs: vec![lw::Output::new(6)],
|
|
|
|
outputs: vec![lw::Output::new(6)],
|
|
|
|
custom_data: vec![],
|
|
|
|
custom_data: vec![],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
lw::Component {
|
|
|
|
|
|
|
|
address: 4,
|
|
|
|
|
|
|
|
parent: 1,
|
|
|
|
|
|
|
|
numeric_id: COMPONENT_MAP["MHG.PanelLabel"],
|
|
|
|
|
|
|
|
position: [150 + 3 * 300, 150, 150 + 1 * 300],
|
|
|
|
|
|
|
|
rotation: quaternion::euler_angles(0.0, -PI / 2.0, 0.0),
|
|
|
|
|
|
|
|
inputs: vec![],
|
|
|
|
|
|
|
|
outputs: vec![],
|
|
|
|
|
|
|
|
custom_data: lw::Label::new("Lmao")
|
|
|
|
|
|
|
|
.mono()
|
|
|
|
|
|
|
|
.with_size(2.5)
|
|
|
|
|
|
|
|
.with_color(0, 100, 250)
|
|
|
|
|
|
|
|
.with_align(lw::HorizontalAlign::Right, lw::VerticalAlign::Bottom)
|
|
|
|
|
|
|
|
.with_dimensions(4, 3)
|
|
|
|
|
|
|
|
.custom_data(),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
let wires = vec![lw::Wire {
|
|
|
|
let wires = vec![lw::Wire {
|
|
|
|
first_point: PegAddress::output(2, 0),
|
|
|
|
first_point: lw::PegAddress::output(2, 0),
|
|
|
|
second_point: PegAddress::input(3, 1),
|
|
|
|
second_point: lw::PegAddress::input(3, 1),
|
|
|
|
circuit_state_id: 4,
|
|
|
|
circuit_state_id: 4,
|
|
|
|
wire_rotation: 0.0,
|
|
|
|
wire_rotation: 0.0,
|
|
|
|
}];
|
|
|
|
}];
|
|
|
@ -63,11 +80,19 @@ fn write_subassembly() -> io::Result<()> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn main() {
|
|
|
|
let result = run_yosys("proc;", None, &["gates.v"]);
|
|
|
|
let files = ["gates.v"];
|
|
|
|
|
|
|
|
let result = get_modules(&files);
|
|
|
|
println!("{:?}", result);
|
|
|
|
println!("{:?}", result);
|
|
|
|
|
|
|
|
|
|
|
|
let result = run_yosys("proc; flatten; wreduce; opt; fsm; opt; memory -nomap -nordff; opt; muxpack; peepopt; async2sync; wreduce; opt -mux_bool", Some("$abstract\\gates"), &["gates.v"]);
|
|
|
|
let Ok(modules) = result else {
|
|
|
|
println!("{:?}", result);
|
|
|
|
println!("Error while getting modules: {:?}", result);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for module in modules {
|
|
|
|
|
|
|
|
let result = compile_module(&module, &files);
|
|
|
|
|
|
|
|
println!("{}: {:?}", module, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let result = write_subassembly();
|
|
|
|
let result = write_subassembly();
|
|
|
|
println!("{:?}", result);
|
|
|
|
println!("{:?}", result);
|
|
|
|