Implement all missing instructions

This commit is contained in:
2023-12-03 15:48:31 +01:00
parent ebecd4e763
commit 71c766736a
10 changed files with 137 additions and 32 deletions

View File

@@ -1,6 +0,0 @@
[build]
target = "aarch64-unknown-none"
rustflags = [
"-C", "link-arg=-Taarch64-gem5.ld",
]

View File

@@ -1,7 +1,10 @@
cargo-features = ["per-package-target"]
[package]
name = "pim-os"
version = "0.1.0"
edition = "2021"
forced-target = "aarch64-unknown-none"
[dependencies]
aarch64-cpu = "9.4.0"

15
pim-os/build.rs Normal file
View File

@@ -0,0 +1,15 @@
use std::env;
use std::fs;
use std::path::PathBuf;
const LINKER_SCRIPT: &str = "aarch64-gem5.ld";
fn main() {
// Put `aarch64-gem5.ld` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
fs::copy(LINKER_SCRIPT, out.join(LINKER_SCRIPT)).unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed={LINKER_SCRIPT}");
println!("cargo:rustc-link-arg=-T{LINKER_SCRIPT}");
}

View File

@@ -28,7 +28,7 @@ pub extern "C" fn entry() -> ! {
let mut compute_array: ComputeArray<3> = ComputeArray([
BankArray([f16::from_f32(0.1); 512]),
BankArray([f16::from_f32(0.2); 512]),
BankArray([f16::ZERO; 512]),
BankArray([f16::from_f32(0.3); 512]),
]);
let dummy_array = BankArray::default();
let mut uart = Uart0;
@@ -40,12 +40,22 @@ pub extern "C" fn entry() -> ! {
)
.unwrap();
writeln!(
&mut uart,
"BankArray0: [{:?}, ...]\nBankArray1: [{:?}, ...]\nBankArray2: [{:?}, ...]",
compute_array.0[0].0[0], compute_array.0[1].0[0], compute_array.0[2].0[0]
)
.unwrap();
writeln!(&mut uart, "MAC: BankArray2 += BankArray0 * BankArray1",).unwrap();
// Invalidate and flush array just in case
compute_array.invalidate_flush();
dummy_array.invalidate_flush();
pim_state.set_bank_mode(BankMode::PimAllBank);
compute_array.0[0].execute_instruction_read();
compute_array.0[2].execute_instruction_read();
compute_array.0[1].execute_instruction_read();
compute_array.0[2].execute_instruction_write();
dummy_array.execute_instruction_read();
@@ -55,8 +65,8 @@ pub extern "C" fn entry() -> ! {
writeln!(
&mut uart,
"BankArray 0: [{:?}, ...]\nBankArray 1: [{:?}, ...]\nBankArray 2: [{:?}, ...]",
compute_array.0[0].0[0], compute_array.0[1].0[0], compute_array.0[2].0[0]
"BankArray2: [{:?}, ...]",
compute_array.0[2].0[0]
)
.unwrap();

View File

@@ -51,7 +51,7 @@ impl BankArray {
pub fn invalidate_single_bank(&self, idx: usize) {
unsafe {
// Invalidate and flush first bank
// Invalidate first bank
asm!("dc ivac, {val}", val = in(reg) &self.0[idx]);
asm!("dsb sy");
}

View File

@@ -5,12 +5,20 @@ pub const TEST_KERNEL: Kernel = Kernel([
src: File::Bank,
dst: File::Grf { index: 0 },
},
Instruction::ADD {
src0: File::Bank,
src1: File::Grf { index: 0 },
dst: File::Grf { index: 0 },
Instruction::MOV {
src: File::Bank,
dst: File::Grf { index: 1 },
},
Instruction::MAC {
src0: File::Grf { index: 0 },
src1: File::Bank,
src2: File::Grf { index: 1 },
dst: File::Grf { index: 1 },
},
Instruction::FILL {
src: File::Grf { index: 1 },
dst: File::Bank,
},
Instruction::FILL { src: File::Grf { index: 0 }, dst: File::Bank },
Instruction::EXIT,
Instruction::NOP,
Instruction::NOP,
@@ -39,5 +47,4 @@ pub const TEST_KERNEL: Kernel = Kernel([
Instruction::NOP,
Instruction::NOP,
Instruction::NOP,
Instruction::NOP,
]);