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

Add support for custom vexriscv instructions #37

Merged
merged 3 commits into from Mar 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions asm.S
Expand Up @@ -273,3 +273,10 @@ RW(0x7A3, tdata3) // Third Debug/Trace trigger data register
RW(0x7B0, dcsr) // Debug control and status register
RW(0x7B1, dpc) // Debug PC
RW(0x7B2, dscratch) // Debug scratch register

// VexRiscv custom registers
RW(0xBC0, vmim) // Machine IRQ Mask
RO(0xFC0, vmip) // Machine IRQ Pending
RW(0x9C0, vsim) // Supervisor IRQ Mask
RO(0xDC0, vsip) // Supervisor IRQ Pending
RO(0xCC0, vdci) // DCache Info
19 changes: 19 additions & 0 deletions assemble.ps1
@@ -0,0 +1,19 @@
New-Item -Force -Name bin -Type Directory

# remove existing blobs because otherwise this will append object files to the old blobs
Remove-Item -Force bin/*.a

$crate = "riscv"

riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32i asm.S -o bin/$crate.o
riscv64-unknown-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o

riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imc asm.S -o bin/$crate.o
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o

riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
riscv64-unknown-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
riscv64-unknown-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o

Remove-Item bin/$crate.o
Binary file modified bin/riscv32i-unknown-none-elf.a
Binary file not shown.
Binary file modified bin/riscv32imac-unknown-none-elf.a
Binary file not shown.
Binary file modified bin/riscv32imc-unknown-none-elf.a
Binary file not shown.
Binary file modified bin/riscv64gc-unknown-none-elf.a
Binary file not shown.
Binary file modified bin/riscv64imac-unknown-none-elf.a
Binary file not shown.
4 changes: 4 additions & 0 deletions src/register/mod.rs
Expand Up @@ -108,3 +108,7 @@ pub use self::mhpmeventx::*;


// TODO: Debug Mode Registers


// Vexriscv custom CSRs
pub mod vexriscv;
10 changes: 10 additions & 0 deletions src/register/vexriscv/dci.rs
@@ -0,0 +1,10 @@
//! vexriscv dci register -- dcache info
//!
//! This register is only available if the core was built with
//! `DBusCachedPlugin` enabled and `csrInfo` set to `true`.
//!
//! See
//! [DBusCachedPlugin.scala](https://github.com/SpinalHDL/VexRiscv/blob/95237b23ea2d658cb3e0aa77680ca2851ef5d882/src/main/scala/vexriscv/plugin/DBusCachedPlugin.scala#L358)
//! for more information.

read_csr_as_usize!(0xCC0, __read_vdci);
4 changes: 4 additions & 0 deletions src/register/vexriscv/mim.rs
@@ -0,0 +1,4 @@
//! vexriscv mim register -- machine irq mask

read_csr_as_usize!(0xBC0, __read_vmim);
write_csr_as_usize!(0xBC0, __write_vmim);
3 changes: 3 additions & 0 deletions src/register/vexriscv/mip.rs
@@ -0,0 +1,3 @@
//! vexriscv mip register -- machine irq pending

read_csr_as_usize!(0xFC0, __read_vmip);
13 changes: 13 additions & 0 deletions src/register/vexriscv/mod.rs
@@ -0,0 +1,13 @@
//! VexRiscv CSRs
//!
//! [VexRiscv](https://github.com/SpinalHDL/VexRiscv) is a RISC-V softcore
//! written in Scala. It is highly configurable, and can be built with features
//! such as a dcache and an external interrupt controller.
//!
//! These features use vendor-specific CSRs, which are available using this
//! module.
pub mod dci;
pub mod mim;
pub mod mip;
pub mod sim;
pub mod sip;
4 changes: 4 additions & 0 deletions src/register/vexriscv/sim.rs
@@ -0,0 +1,4 @@
//! vexriscv sim register -- supervisor irq mask

read_csr_as_usize!(0x9C0, __read_vsim);
write_csr_as_usize!(0x9C0, __write_vsim);
3 changes: 3 additions & 0 deletions src/register/vexriscv/sip.rs
@@ -0,0 +1,3 @@
//! vexriscv sip register -- supervisor irq pending

read_csr_as_usize!(0xDC0, __read_vsip);