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

Added Mips related compoennts, change wire ui, new UI helpers, new misc compoents #87

Merged
merged 142 commits into from
Oct 3, 2024

Conversation

Spooky-Firefox
Copy link
Collaborator

@Spooky-Firefox Spooky-Firefox commented Sep 12, 2024

Syncrim

simulator common etc

  • syncrim::common::Input now derives partial eq and eq.
  • The EguiCompoennt trait was expanded with a new function get_input_location which is used to get a location of a port based upon its relevant input struct.
  • component_store now saves JSON with pretty formatting.
  • Changed some unwrap in editor to expect with better error messages.
  • Editor now uses Wire::new
  • Gui now uses primary mouse button to pan
  • Added helper functions that constructs most of an ui for a component
  • Added an auto wire function that uses get_input_location to create wires
  • Better Error logging in Simulator

Component changes

Most constants for out id has been changed from "out" to "{component_type}_out".
Most components now implement get_input_location.

Add

Now supports a scale variable allowing the scale of the rendered component to be modified.

Mem

Documented some code.

Mux

Now supports a scale variable allowing the scale of the rendered component to be modified.

Wire

Wire color was added, this changed how active is implemented, if component now read from is inactive wire is dashed
Changed om hover is handed, using distance from line.
In editor, added duplicate point button and color editor

Probe edit

if unable to format as signal signed try formatting as signal unsigned

new components

And

bitwise logical and.

clk

adds input with a 4.

equals

sends a 1 if the inputs are equal 0 else (if a == b => 1).

shift_left_const

shifts left by a constant value.

zero_extend

zero extends.

Mips-Lib

components required to implement a single cycle and pile lined mips

New components and related

PhysMem

This component has no input nor outputs, this is because this is basically a wrapper for a MipsMem struct which takes care of reset and unclock. This was necessary since there are multiple components that need to access the memory (IM, DM).
access to mips_mem is done in this not so nice way

let mut mips_mem_mut_ref = {
    let v = &simulator.ordered_components;
    let comp = v
        .into_iter()
        .find(|x| x.get_id_ports().0 == self.phys_mem_id)
        .expect(&format!("cant find {} in simulator", self.phys_mem_id));
    // deref to get Rc
    // deref again to get &dyn EguiComponent
    let comp_any = (**comp).as_any();
    let phys_mem: &PhysicalMem = comp_any
        .downcast_ref()
        .expect("can't downcast to physical memory");
    phys_mem
        .mem
        .borrow_mut()
    };

This should probably be updated to not panic and instead return condition::error

MipsMem

A struct which contains the memory as well as the symbols and sections of that memory it has methods to read and write to addresses with sizes of byte half and word, endianes can be specified. There exist version which would return error when a write is unaligned. Each write also returns a MemWriteReturn which is used with the revert method to undo an operation, note the order of which reverts are called matters, revert the newest operation first.

MipsMem also has the ability be created from an elf, note this method panics when an the passed byte slice is not en elf

IM

The instruction memory components reads the given address from its associated physical memory, this component will panic if its physical memory is not found.
When IM encounters a break point from its MemViewWindow a halt condition is returned stopping the simulation.
There is also a button that loads an elf to memory by passing the bytes to physmem.

DM

When the control signal is one of the read ones (read-byte, -half, -word), the data at the address is returned. If the address is unaligned the component will return an condition::error, this is also true for the write operations. When a read or write happens at an address that is a breakpoint (determined according to MemViewWindow) a condition::halt is returned.

MemViewWindow

This is used to display a window showing the content of the passed mips_mem.
features

  • Formatting options such as hex, signed decimal, utf-8 and mips assembly with symbol resolution
  • Jumping to symbols and sections
  • Jumping to registers, such as were sp and ra points
  • Displaying sections and symbols
  • Displaying where registers point
  • Setting and removing breakpoints
    image
    image
    image

RegFile

This component have 32 internal registers that can be written to and can output 2 two of those registers. This component displays the internal registers when rendered. Format and reg names can be chosen.

ALU

This an simple ALU which support basic orations such as add, add, sub and bit-wise operations (including shifting but not roll), other supported operations are slt sltu and lui. The operations are supplied trough the op input.

Branch Logic

This component compares both rs and rt in in accordance to what operation is done (jr, beq and ect) and outputs a signal to control mux which determines next pc.

Jump merger

Combines the instruction with current pc to calculate the jump address of an jump instruction.

Instructions splitter

Takes an 32 bit instruction and splits it into rs, rt, rd, shamt, funct, immediate, and target.

SignZeroExtend

compoents sign or zero extend the input signal according to its control input

ControlUnit

Sends control signal to muxes, alu and other mips components according to the given instruction

Models

This includes PR includes a functioning single cycle mips and a work in progresses pipeline version

Single cycle MIPS

image

Pipe-lined MIPS

Work In Progress

@Spooky-Firefox Spooky-Firefox marked this pull request as ready for review October 1, 2024 10:21
Copy link
Collaborator

@onsdagens onsdagens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 1fadfac

src/autowire.rs Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warnings here can be allowed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 3c77dbf

#[command(author, version, about, long_about = None)]
struct Args {
/// Path to the model to load on startup
#[arg(short, long, default_value = "empty.json")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change this to the single cycle mips?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in d19ff00

fn to_(&self) {
trace!("jump_merge");
}
// #[cfg(feature = "gui-egui")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code can be removed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a bunch of random commented code scattered about, we can probably get rid of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 29d9553

}),
Rc::new(Register {
id: "reg".to_string(),
pos: (0.0, 0.0),
r_in: dummy_input.clone(),
}),
Rc::new(MIPSCLK {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 1fadfac

let render_return = (*Rc::get_mut(c).unwrap()).render_editor(
let debug_id = c.get_id_ports().0;
let render_return = (*Rc::get_mut(c)
.expect(&format!("More than one reference exist to {}, can't get mut, therefore not render editor", debug_id)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just #[allow] this lgtm

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 3c77dbf

Copy link
Collaborator

@onsdagens onsdagens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Spooky-Firefox Spooky-Firefox merged commit b888888 into perlindgren:master Oct 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants