Compare commits
3 Commits
c67217a6b8
...
a0b02cb955
| Author | SHA1 | Date | |
|---|---|---|---|
| a0b02cb955 | |||
| 240f0e553f | |||
| 25a59a6b19 |
@@ -0,0 +1,37 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"label": "Run Emulator",
|
||||||
|
"command": "cargo run --bin emulator",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Compiler",
|
||||||
|
"command": "cargo run --bin compiler",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Assembler",
|
||||||
|
"command": "cargo run --bin assembler",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Build System (dsx-build)",
|
||||||
|
"command": "cargo run --bin dsx-build",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Build All (Release)",
|
||||||
|
"command": "cargo build --release",
|
||||||
|
"use_new_terminal": false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Tests",
|
||||||
|
"command": "cargo test",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Profile Emulator with perf",
|
||||||
|
"command": "cargo build --profile profiling; perf record -g -F 999 target/profiling/emulator; perf script -F +pid | save test.perf",
|
||||||
|
"use_new_terminal": true,
|
||||||
|
},
|
||||||
|
]
|
||||||
@@ -83,7 +83,7 @@ impl MemoryUnit for MainStore {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_word(&mut self, addr: u32) -> Result<u32, ProcessorError> {
|
fn read_word(&mut self, addr: u32) -> Result<u32, ProcessorError> {
|
||||||
if addr % 4 != 0 {
|
if !addr.is_multiple_of(4) {
|
||||||
return Err(ProcessorError::BadMemoryAccess(addr));
|
return Err(ProcessorError::BadMemoryAccess(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ impl MemoryUnit for MainStore {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> {
|
fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> {
|
||||||
if addr % 4 != 0 {
|
if !addr.is_multiple_of(4) {
|
||||||
return Err(ProcessorError::BadMemoryAccess(addr));
|
return Err(ProcessorError::BadMemoryAccess(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,6 @@ impl RegFile {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub const fn get(&self, reg: Register) -> Result<u32, ProcessorError> {
|
pub const fn get(&self, reg: Register) -> Result<u32, ProcessorError> {
|
||||||
Ok(match reg {
|
Ok(match reg {
|
||||||
Register::Rg0 => self.rg0,
|
Register::Rg0 => self.rg0,
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ pub struct Processor {
|
|||||||
pub cache: Cache,
|
pub cache: Cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(message: &str) {
|
|
||||||
println!("\x1b[32mINFO:\x1b[0m {message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Processor {
|
impl Processor {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(memory: Box<dyn MemoryUnit>, io_devices: Vec<Arc<dyn IODevice>>) -> Self {
|
pub fn new(memory: Box<dyn MemoryUnit>, io_devices: Vec<Arc<dyn IODevice>>) -> Self {
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ fn test_shift_left_with_shamt() {
|
|||||||
let shl_instr = Instruction::ShiftLeft(RTypeArgs::new(
|
let shl_instr = Instruction::ShiftLeft(RTypeArgs::new(
|
||||||
Some(Register::Rg1),
|
Some(Register::Rg1),
|
||||||
Some(Register::Zero),
|
Some(Register::Zero),
|
||||||
None,
|
Some(Register::Rg1),
|
||||||
Some(2),
|
Some(2),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ fn test_shift_right_with_shamt() {
|
|||||||
let shr_instr = Instruction::ShiftRight(RTypeArgs::new(
|
let shr_instr = Instruction::ShiftRight(RTypeArgs::new(
|
||||||
Some(Register::Rg1),
|
Some(Register::Rg1),
|
||||||
Some(Register::Zero),
|
Some(Register::Zero),
|
||||||
None,
|
Some(Register::Rg1),
|
||||||
Some(2),
|
Some(2),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -117,10 +117,7 @@ impl Editor {
|
|||||||
.file_name()
|
.file_name()
|
||||||
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
||||||
.to_str()
|
.to_str()
|
||||||
.map_or_else(
|
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||||
|| unreachable!("File name should be valid UTF-8."),
|
|
||||||
|ext| ext,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"Unnamed!"
|
"Unnamed!"
|
||||||
}
|
}
|
||||||
@@ -129,12 +126,9 @@ impl Editor {
|
|||||||
if let Some(path) = &self.path {
|
if let Some(path) = &self.path {
|
||||||
return path
|
return path
|
||||||
.extension()
|
.extension()
|
||||||
.map_or_else(|| OsStr::new("Unknown!"), |ext| ext)
|
.unwrap_or_else(|| OsStr::new("Unknown!"))
|
||||||
.to_str()
|
.to_str()
|
||||||
.map_or_else(
|
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||||
|| unreachable!("File name should be valid UTF-8."),
|
|
||||||
|ext| ext,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"Unknown!"
|
"Unknown!"
|
||||||
}
|
}
|
||||||
@@ -398,7 +392,7 @@ impl Editor {
|
|||||||
_ => Syntax::default(),
|
_ => Syntax::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ed = CodeEditor::default()
|
let mut editor = CodeEditor::default()
|
||||||
.id_source("editor")
|
.id_source("editor")
|
||||||
.with_fontsize(12.0)
|
.with_fontsize(12.0)
|
||||||
.with_rows(0)
|
.with_rows(0)
|
||||||
@@ -407,8 +401,6 @@ impl Editor {
|
|||||||
.with_numlines(true)
|
.with_numlines(true)
|
||||||
.desired_width(available_width - 500.0);
|
.desired_width(available_width - 500.0);
|
||||||
|
|
||||||
let mut editor = ed.clone();
|
|
||||||
|
|
||||||
editor.show(ui, &mut self.text);
|
editor.show(ui, &mut self.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +443,7 @@ impl Editor {
|
|||||||
Some("dsc") => {
|
Some("dsc") => {
|
||||||
let output_path = Path::new(path).with_extension("dsa");
|
let output_path = Path::new(path).with_extension("dsa");
|
||||||
if let Err(e) = compiler::compile_file(path, &output_path) {
|
if let Err(e) = compiler::compile_file(path, &output_path) {
|
||||||
self.error = Some(format!("Compiler error: {}", e));
|
self.error = Some(format!("Compiler error: {e}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut compiler = CompilerEngine::new();
|
let mut compiler = CompilerEngine::new();
|
||||||
@@ -461,7 +453,7 @@ impl Editor {
|
|||||||
let instructions = match compiler.wait_for_result() {
|
let instructions = match compiler.wait_for_result() {
|
||||||
Ok(instructions) => instructions,
|
Ok(instructions) => instructions,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.error = Some(format!("Assembler error: {}", e));
|
self.error = Some(format!("Assembler error: {e}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ impl Loader {
|
|||||||
.file_name()
|
.file_name()
|
||||||
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
||||||
.to_str()
|
.to_str()
|
||||||
.map_or_else(
|
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||||
|| unreachable!("File name should be valid UTF-8."),
|
|
||||||
|ext| ext,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"Unnamed!"
|
"Unnamed!"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user