Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egui editor #40

Merged
merged 64 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
636d6e3
Initial work on editor, start with ctrl+e
vaneri-9 Jul 13, 2023
be66429
quick cleanup
vaneri-9 Jul 13, 2023
c7da50c
Moving components works, connections do not change/work
vaneri-9 Jul 14, 2023
31505a2
Left side library (very limited), drag in new objects (to be better)
vaneri-9 Jul 14, 2023
d06db4f
properties window (only for add right now)
vaneri-9 Jul 19, 2023
91603b1
merge with master to get new ids
vaneri-9 Jul 19, 2023
3ecaad9
properties window now allows to select inputs and their fields as wel…
vaneri-9 Jul 19, 2023
4e04f01
merge with wire-vec
vaneri-9 Jul 21, 2023
1521379
wire work on the editor, massive changes coming
vaneri-9 Jul 21, 2023
401a7a5
Wires now somewhat work properly, small overhaul
vaneri-9 Jul 22, 2023
31bd526
Added an input mode
vaneri-9 Jul 22, 2023
a9ea568
can now connect inputs and outputs, workable state
vaneri-9 Jul 23, 2023
48580b4
big ui rework for egui, a lot less code
vaneri-9 Jul 23, 2023
5f21d01
Removed the useage of refcell and enabled serialize and deserialize a…
vaneri-9 Jul 24, 2023
210c68c
merge with master and add saving
vaneri-9 Jul 24, 2023
f6847f1
Fixed bug with the tmp id not being set when default is made
vaneri-9 Jul 24, 2023
e561f31
Fix almost all tests/examples
vaneri-9 Jul 24, 2023
9a4854d
Fixed issues with vizia (doesn't compile still though for some reason)
vaneri-9 Jul 24, 2023
0cd1376
Forgot to readd the paths for EguiExtra
vaneri-9 Jul 24, 2023
e3bb2a4
Renamed InputId to InputPort
vaneri-9 Jul 25, 2023
1683a1b
Fixed warnings, renamed files/functions moved most editor struct enum…
vaneri-9 Jul 25, 2023
63684b6
Fixed mem bug
vaneri-9 Jul 25, 2023
9e2eb01
Fixed all clippy messages
vaneri-9 Jul 25, 2023
502e7cc
Merge with master
vaneri-9 Jul 25, 2023
db9c50c
Missed one merge conflict...
vaneri-9 Jul 25, 2023
79288e6
apparently there was a new component added, but not for egui
vaneri-9 Jul 25, 2023
21b0c4d
ci :upside_down_smile:
vaneri-9 Jul 25, 2023
ea3bd8b
Fixed various bugs
vaneri-9 Jul 25, 2023
3244876
Fixed properties window out of bounds clicking and clippy error
vaneri-9 Jul 25, 2023
d3978d7
Auto-save when switching between editor and simulator mode
vaneri-9 Jul 25, 2023
b809dad
Fixed setting constant value, mixed up keyword for clippy so fixed it
vaneri-9 Jul 25, 2023
5a5a044
Added loading functionality
vaneri-9 Jul 25, 2023
db61e9b
Added open/save/save as
vaneri-9 Jul 25, 2023
cb56b50
Fixed numerous issues with wires
vaneri-9 Jul 26, 2023
1f81071
clippy
vaneri-9 Jul 26, 2023
5cc773d
Massve rework #3 or 4, don't remember
vaneri-9 Jul 26, 2023
53fd94e
Forgot to fix 3 examples
vaneri-9 Jul 26, 2023
c8c7657
Added sext and mem and fixed some stuff
vaneri-9 Jul 27, 2023
2ee6468
Added mux
vaneri-9 Jul 27, 2023
677597c
Added reg
vaneri-9 Jul 27, 2023
4615651
mux removable/addable inputs
vaneri-9 Jul 27, 2023
329534d
right click to get out of wire and input mode
vaneri-9 Jul 27, 2023
6312fbf
Merge with master and fix riscv
vaneri-9 Aug 7, 2023
5e33d27
Changed Slider into DragValue for positions and constants, fixed form…
vaneri-9 Aug 7, 2023
8f877d8
Added wire mode button
vaneri-9 Aug 7, 2023
0b936c0
Probe edit
vaneri-9 Aug 7, 2023
2470e3e
Visualize port locations, fix id change bug
vaneri-9 Aug 8, 2023
ee980c7
Fixed scaling not taken into account when placing components
vaneri-9 Aug 10, 2023
9155b7d
Fixed wire properties ui, added possible to add/remove wire segments
vaneri-9 Aug 18, 2023
29b0e14
Added grid
vaneri-9 Aug 18, 2023
13394f0
Added grid snapping for wires
vaneri-9 Aug 18, 2023
7fbf9d6
Delete with del key
vaneri-9 Aug 19, 2023
1e7ee57
Added snapping to grid with placing components
vaneri-9 Aug 19, 2023
56e7d70
Fixed grid
vaneri-9 Aug 19, 2023
feb5924
Fixed snapping when moving components
vaneri-9 Aug 19, 2023
bea39b1
Merge branch 'master' into egui-editor
vaneri-9 Aug 19, 2023
058aedd
Fix merge errors
vaneri-9 Aug 19, 2023
38d7c57
Fixed linter error since I used github gui
vaneri-9 Aug 19, 2023
6ce2e6f
Simulator::new now returns result
vaneri-9 Aug 26, 2023
f64ca54
Fixed simulator for vizia frontend
vaneri-9 Aug 26, 2023
7bb3f58
Fixed all tests broken previously
vaneri-9 Aug 26, 2023
3f9ca1e
Also fix mips and riscv tests
vaneri-9 Aug 26, 2023
2d91836
Fix bug with open crashing egui
vaneri-9 Aug 30, 2023
ebd1d09
Also fix crash for when opening in editor mode
vaneri-9 Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/add_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/add_mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/add_reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/add_reg_compound_wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/data_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/mux_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/probe_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/probe_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/probe_stim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/probe_stim_assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions examples/sext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions mips/examples/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
4 changes: 2 additions & 2 deletions mips/examples/reg_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
16 changes: 12 additions & 4 deletions mips/src/components/instr_mem.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use serde::{Deserialize, Serialize};
use std::rc::Rc;
use syncrim::common::{
Component, Condition, Input, OutputType, Ports, SignalUnsigned, SignalValue, Simulator,
Component, Condition, Input, InputPort, OutputType, Ports, SignalUnsigned, SignalValue,
Simulator,
};

pub const INSTR_MEM_PC_ID: &str = "pc";

pub const INSTR_MEM_OUT_ID: &str = "out";

#[derive(Serialize, Deserialize)]
pub struct InstrMem {
pub(crate) id: String,
Expand All @@ -24,9 +29,12 @@ impl Component for InstrMem {
(
self.id.clone(),
Ports {
inputs: vec![self.pc.clone()],
inputs: vec![InputPort {
port_id: INSTR_MEM_PC_ID.to_string(),
input: self.pc.clone(),
}],
out_type: OutputType::Combinatorial,
outputs: vec!["out".into()],
outputs: vec![INSTR_MEM_OUT_ID.to_string()],
},
)
}
Expand All @@ -47,7 +55,7 @@ impl Component for InstrMem {

// set output
trace!("--- output {:?}", instr);
simulator.set_out_value(&self.id, "out", instr);
simulator.set_out_value(&self.id, INSTR_MEM_OUT_ID, instr);
Ok(())
}
}
Expand Down
44 changes: 35 additions & 9 deletions mips/src/components/reg_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use num_enum::TryFromPrimitive;
use serde::{Deserialize, Serialize};
use std::ops::{Deref, Range};
use std::{cell::RefCell, rc::Rc};
use syncrim::common::{Component, Condition, Input, OutputType, Ports, SignalUnsigned, Simulator};
use syncrim::common::{
Component, Condition, Input, InputPort, OutputType, Ports, SignalUnsigned, Simulator,
};

#[allow(non_camel_case_types)]
#[rustfmt::skip]
Expand Down Expand Up @@ -44,6 +46,15 @@ pub enum Reg {
ra = 31, // Return address (used by function calls)
}

pub const REG_FILE_READ_ADDR1_ID: &str = "read_addr1";
pub const REG_FILE_READ_ADDR2_ID: &str = "read_addr2";
pub const REG_FILE_WRITE_DATA_ID: &str = "write_data";
pub const REG_FILE_WRITE_ADDR_ID: &str = "write_addr";
pub const REG_FILE_WRITE_ENABLE_ID: &str = "write_enable";

pub const REG_FILE_REG_A_OUT: &str = "reg_a";
pub const REG_FILE_REG_B_OUT: &str = "reg_b";

#[derive(Serialize, Deserialize)]
pub struct RegFile {
pub(crate) id: String,
Expand Down Expand Up @@ -203,11 +214,26 @@ impl Component for RegFile {
self.id.clone(),
Ports {
inputs: vec![
self.read_addr1.clone(),
self.read_addr2.clone(),
self.write_addr.clone(),
self.write_data.clone(),
self.write_enable.clone(),
InputPort {
port_id: REG_FILE_READ_ADDR1_ID.to_string(),
input: self.read_addr1.clone(),
},
InputPort {
port_id: REG_FILE_READ_ADDR2_ID.to_string(),
input: self.read_addr2.clone(),
},
InputPort {
port_id: REG_FILE_WRITE_DATA_ID.to_string(),
input: self.write_data.clone(),
},
InputPort {
port_id: REG_FILE_WRITE_ADDR_ID.to_string(),
input: self.write_addr.clone(),
},
InputPort {
port_id: REG_FILE_WRITE_ENABLE_ID.to_string(),
input: self.write_enable.clone(),
},
],
out_type: OutputType::Combinatorial,
outputs: vec!["reg_a".into(), "reg_b".into()],
Expand All @@ -230,11 +256,11 @@ impl Component for RegFile {
// read after write
let reg_value_a = self.read_reg(simulator, &self.read_addr1);
trace!("reg_value {}", reg_value_a);
simulator.set_out_value(&self.id, "reg_a", reg_value_a);
simulator.set_out_value(&self.id, REG_FILE_REG_A_OUT, reg_value_a);

let reg_value_b = self.read_reg(simulator, &self.read_addr2);
trace!("reg_value {}", reg_value_b);
simulator.set_out_value(&self.id, "reg_b", reg_value_b);
simulator.set_out_value(&self.id, REG_FILE_REG_B_OUT, reg_value_b);
Ok(())
}
}
Expand Down Expand Up @@ -279,7 +305,7 @@ mod test {
],
};

let mut simulator = Simulator::new(&cs);
let mut simulator = Simulator::new(cs).unwrap();

assert_eq!(simulator.cycle, 1);

Expand Down
7 changes: 5 additions & 2 deletions mips/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ fn main() {
fern_setup();

let path = PathBuf::from("mips.json");
let _cs = ComponentStore::load_file(&path);
let cs = ComponentStore::load_file(&path);

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&_cs, &path);
syncrim::gui_vizia::gui(cs, &path);

#[cfg(not(any(feature = "gui-vizia", feature = "gui-egui")))]
syncrim::common::Simulator::new(cs);
}
4 changes: 2 additions & 2 deletions riscv/examples/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ fn main() {
cs.save_file(&path);

#[cfg(feature = "gui-egui")]
syncrim::gui_egui::gui(&cs, &path).ok();
syncrim::gui_egui::gui(cs, &path).ok();

#[cfg(feature = "gui-vizia")]
syncrim::gui_vizia::gui(&cs, &path);
syncrim::gui_vizia::gui(cs, &path);
}
#[allow(unused_imports)]
use log::LevelFilter;
Expand Down
38 changes: 27 additions & 11 deletions riscv/src/components/alu.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use log::trace;
use serde::{Deserialize, Serialize};
use syncrim::{
common::{Component, Condition, Input, OutputType, Ports, SignalValue, Simulator},
common::{Component, Condition, Input, InputPort, OutputType, Ports, SignalValue, Simulator},
signal::SignalSigned,
};

pub const ALU_OPERATOR_I_ID: &str = "operator_i";
pub const ALU_OPERAND_A_I_ID: &str = "operand_a_i";
pub const ALU_OPERAND_B_I_ID: &str = "operand_b_i";

pub const ALU_RESULT_O_ID: &str = "result_o";

#[derive(Serialize, Deserialize)]
pub struct ALU {
pub id: String,
Expand All @@ -24,20 +30,30 @@ impl Component for ALU {
fn get_id_ports(&self) -> (String, Ports) {
(
self.id.clone(),
Ports {
inputs: vec![
self.operator_i.clone(),
self.operand_a_i.clone(),
self.operand_b_i.clone(),
Ports::new(
vec![
&InputPort {
port_id: ALU_OPERATOR_I_ID.to_string(),
input: self.operator_i.clone(),
},
&InputPort {
port_id: ALU_OPERAND_A_I_ID.to_string(),
input: self.operand_a_i.clone(),
},
&InputPort {
port_id: ALU_OPERAND_B_I_ID.to_string(),
input: self.operand_b_i.clone(),
},
//self.operand_c_i.clone(),
],
out_type: OutputType::Combinatorial,
outputs: vec![
"result_o".into(),
OutputType::Combinatorial,
vec![
ALU_RESULT_O_ID,
//"result_o".into(),
//"comparison_result_o".into(),
//"ready_o".into(),
],
},
),
)
}
#[allow(non_snake_case)]
Expand Down Expand Up @@ -159,7 +175,7 @@ mod test {
],
};

let mut simulator = Simulator::new(&cs);
let mut simulator = Simulator::new(cs).unwrap();
assert_eq!(simulator.cycle, 1);

// outputs
Expand Down
Loading
Loading