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

Merge new V20 into 0.2.1 branch #119

Merged
merged 11 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ icon.png
/install/output/screenshots/*
/install/output/traces/*
/install/output/dumps/*
/install/output/tests/test_summary.csv

# Dev machines not completed or functional
/install/configs/machines/acid88.toml
Expand All @@ -77,3 +78,5 @@ icon.png
/flopgen/flopgen_LICENSE.txt
/tree.txt

/test-gen/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ serialport = { git = "https://github.com/dbalsom/serialport-rs", branch = "ardui
web-time = "0.2.4"
toml = "0.8"
fxhash = "0.2.1"
enum_dispatch = "0.3.13"
indexmap = "2.2.6"

[workspace.dependencies.image]
version = "0.24"
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ strum_macros = "0.26"
toml = "0.5.10"
uuid = { version = "1.1.2", features = ["v4"] }
fxhash.workspace = true
enum_dispatch.workspace = true

[dev-dependencies]
criterion = "0.5"
Expand Down
98 changes: 59 additions & 39 deletions core/src/arduino8088_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum ServerCommand {
CmdReset = 0x02,
CmdLoad = 0x03,
CmdCycle = 0x04,
CmdReadAddress = 0x05,
CmdReadAddressLatch = 0x05,
CmdReadStatus = 0x06,
CmdRead8288Command = 0x07,
CmdRead8288Control = 0x08,
Expand All @@ -63,11 +63,13 @@ pub enum ServerCommand {
CmdGetLastError = 0x13,
CmdGetCycleState = 0x14,
CmdCGetCycleState = 0x15,
CmdInvalid = 0x16,
CmdPrefetchStore = 0x16,
CmdReadAddressU = 0x17,
CmdInvalid,
}

#[derive(Debug, PartialEq)]
pub enum ProgramState {
pub enum ValidatorState {
Reset = 0,
JumpVector,
Load,
Expand Down Expand Up @@ -419,7 +421,20 @@ impl CpuClient {
/// Return the value of the address latches (Latched on ALE)
pub fn read_address_latch(&mut self) -> Result<u32, CpuClientError> {
let mut buf: [u8; 3] = [0; 3];
self.send_command_byte(ServerCommand::CmdReadAddress)?;
self.send_command_byte(ServerCommand::CmdReadAddressLatch)?;
self.recv_buf(&mut buf)?;
self.read_result_code()?;

let address = buf[0] as u32 | (buf[1] as u32) << 8 | (buf[2] as u32) << 16;

Ok(address)
}

/// Server command - ReadAddress
/// Return the current value of the address bus
pub fn read_address(&mut self) -> Result<u32, CpuClientError> {
let mut buf: [u8; 3] = [0; 3];
self.send_command_byte(ServerCommand::CmdReadAddressU)?;
self.recv_buf(&mut buf)?;
self.read_result_code()?;

Expand Down Expand Up @@ -474,28 +489,33 @@ impl CpuClient {
Ok(true)
}

pub fn write_store_pgm(&mut self) -> Result<bool, CpuClientError> {
self.send_command_byte(ServerCommand::CmdPrefetchStore)?;
self.read_result_code()
}

pub fn finalize(&mut self) -> Result<bool, CpuClientError> {
self.send_command_byte(ServerCommand::CmdFinalize)?;
self.read_result_code()
}

pub fn get_program_state(&mut self) -> Result<ProgramState, CpuClientError> {
pub fn get_program_state(&mut self) -> Result<ValidatorState, CpuClientError> {
let mut buf: [u8; 1] = [0; 1];
self.send_command_byte(ServerCommand::CmdGetProgramState)?;
self.recv_buf(&mut buf)?;
self.read_result_code()?;

match buf[0] {
0x00 => Ok(ProgramState::Reset),
0x01 => Ok(ProgramState::JumpVector),
0x02 => Ok(ProgramState::Load),
0x03 => Ok(ProgramState::LoadDone),
0x04 => Ok(ProgramState::Execute),
0x05 => Ok(ProgramState::ExecuteFinalize),
0x06 => Ok(ProgramState::ExecuteDone),
0x07 => Ok(ProgramState::Store),
0x08 => Ok(ProgramState::StoreDone),
0x09 => Ok(ProgramState::Done),
0x00 => Ok(ValidatorState::Reset),
0x01 => Ok(ValidatorState::JumpVector),
0x02 => Ok(ValidatorState::Load),
0x03 => Ok(ValidatorState::LoadDone),
0x04 => Ok(ValidatorState::Execute),
0x05 => Ok(ValidatorState::ExecuteFinalize),
0x06 => Ok(ValidatorState::ExecuteDone),
0x07 => Ok(ValidatorState::Store),
0x08 => Ok(ValidatorState::StoreDone),
0x09 => Ok(ValidatorState::Done),
_ => Err(CpuClientError::BadValue),
}
}
Expand All @@ -510,24 +530,24 @@ impl CpuClient {
Ok(err_string.to_string())
}

pub fn get_cycle_state(&mut self) -> Result<(ProgramState, u8, u8, u8, u8), CpuClientError> {
pub fn get_cycle_state(&mut self) -> Result<(ValidatorState, u8, u8, u8, u8), CpuClientError> {
let mut buf: [u8; 4] = [0; 4];
self.send_command_byte(ServerCommand::CmdGetCycleState)?;
self.recv_buf(&mut buf)?;
self.read_result_code()?;

let state_bits: u8 = buf[0] >> 4;
let state: ProgramState = match state_bits {
0x00 => ProgramState::Reset,
0x01 => ProgramState::JumpVector,
0x02 => ProgramState::Load,
0x03 => ProgramState::LoadDone,
0x04 => ProgramState::Execute,
0x05 => ProgramState::ExecuteFinalize,
0x06 => ProgramState::ExecuteDone,
0x07 => ProgramState::Store,
0x08 => ProgramState::StoreDone,
0x09 => ProgramState::Done,
let state: ValidatorState = match state_bits {
0x00 => ValidatorState::Reset,
0x01 => ValidatorState::JumpVector,
0x02 => ValidatorState::Load,
0x03 => ValidatorState::LoadDone,
0x04 => ValidatorState::Execute,
0x05 => ValidatorState::ExecuteFinalize,
0x06 => ValidatorState::ExecuteDone,
0x07 => ValidatorState::Store,
0x08 => ValidatorState::StoreDone,
0x09 => ValidatorState::Done,
_ => {
return Err(CpuClientError::BadValue);
}
Expand All @@ -538,24 +558,24 @@ impl CpuClient {
Ok((state, control_bits, buf[1], buf[2], buf[3]))
}

pub fn cycle_get_cycle_state(&mut self) -> Result<(ProgramState, u8, u8, u8, u8), CpuClientError> {
pub fn cycle_get_cycle_state(&mut self) -> Result<(ValidatorState, u8, u8, u8, u8), CpuClientError> {
let mut buf: [u8; 4] = [0; 4];
self.send_command_byte(ServerCommand::CmdCGetCycleState)?;
self.recv_buf(&mut buf)?;
self.read_result_code()?;

let state_bits: u8 = buf[0] >> 4;
let state: ProgramState = match state_bits {
0x00 => ProgramState::Reset,
0x01 => ProgramState::JumpVector,
0x02 => ProgramState::Load,
0x03 => ProgramState::LoadDone,
0x04 => ProgramState::Execute,
0x05 => ProgramState::ExecuteFinalize,
0x06 => ProgramState::ExecuteDone,
0x07 => ProgramState::Store,
0x08 => ProgramState::StoreDone,
0x09 => ProgramState::Done,
let state: ValidatorState = match state_bits {
0x00 => ValidatorState::Reset,
0x01 => ValidatorState::JumpVector,
0x02 => ValidatorState::Load,
0x03 => ValidatorState::LoadDone,
0x04 => ValidatorState::Execute,
0x05 => ValidatorState::ExecuteFinalize,
0x06 => ValidatorState::ExecuteDone,
0x07 => ValidatorState::Store,
0x08 => ValidatorState::StoreDone,
0x09 => ValidatorState::Done,
_ => {
return Err(CpuClientError::BadValue);
}
Expand Down
Loading