mirror of
https://github.com/SpinalHDL/VexRiscv.git
synced 2025-01-03 03:43:39 -05:00
Better readme about custum instruction testing
This commit is contained in:
parent
54b06e6438
commit
1653548140
3 changed files with 51 additions and 31 deletions
23
README.md
23
README.md
|
@ -438,22 +438,26 @@ class SimdAddPlugin extends Plugin[VexRiscv]{
|
||||||
import pipeline._
|
import pipeline._
|
||||||
import pipeline.config._
|
import pipeline.config._
|
||||||
|
|
||||||
|
//Add a new scope on the execute stage (used to give a name to signals)
|
||||||
|
execute plug new Area {
|
||||||
//Define some signals used internally to the plugin
|
//Define some signals used internally to the plugin
|
||||||
val rs1 = execute.input(RS1).asUInt //32 bits UInt value of the regfile[RS1]
|
val rs1 = execute.input(RS1).asUInt
|
||||||
|
//32 bits UInt value of the regfile[RS1]
|
||||||
val rs2 = execute.input(RS2).asUInt
|
val rs2 = execute.input(RS2).asUInt
|
||||||
val rd = UInt(32 bits)
|
val rd = UInt(32 bits)
|
||||||
|
|
||||||
//Do some computation
|
//Do some computation
|
||||||
rd( 7 downto 0) := rs1( 7 downto 0) + rs2( 7 downto 0)
|
rd(7 downto 0) := rs1(7 downto 0) + rs2(7 downto 0)
|
||||||
rd(16 downto 8) := rs1(16 downto 8) + rs2(16 downto 8)
|
rd(16 downto 8) := rs1(16 downto 8) + rs2(16 downto 8)
|
||||||
rd(23 downto 16) := rs1(23 downto 16) + rs2(23 downto 16)
|
rd(23 downto 16) := rs1(23 downto 16) + rs2(23 downto 16)
|
||||||
rd(31 downto 24) := rs1(31 downto 24) + rs2(31 downto 24)
|
rd(31 downto 24) := rs1(31 downto 24) + rs2(31 downto 24)
|
||||||
|
|
||||||
//When the instruction is a SIMD_ADD one, then write the result into the register file data path.
|
//When the instruction is a SIMD_ADD one, then write the result into the register file data path.
|
||||||
when(execute.input(IS_SIMD_ADD)){
|
when(execute.input(IS_SIMD_ADD)) {
|
||||||
execute.output(REGFILE_WRITE_DATA) := rd.asBits
|
execute.output(REGFILE_WRITE_DATA) := rd.asBits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -469,3 +473,16 @@ This example is a very simple one, but each plugin can really have access to the
|
||||||
- override published signals values
|
- override published signals values
|
||||||
- Provide an alternative implementation
|
- Provide an alternative implementation
|
||||||
- ...
|
- ...
|
||||||
|
|
||||||
|
As a demonstrator, this SimdAddPlugin was integrated in the src/main/scala/vexriscv/demo/GenCustomSimdAdd.scala CPU configuration and is self tested by the src/test/cpp/custom/simd_add application by running the following commands :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd src/test/cpp/regression/
|
||||||
|
|
||||||
|
# Optionally add TRACE=yes if you want to get the VCD waveform from the simulation.
|
||||||
|
# Also you have to know that by default, the testbench introduce instruction/data bus stall.
|
||||||
|
# Note the CUSTOM_SIMD_ADD flag is set to yes.
|
||||||
|
make clean run IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no DHRYSTONE=no REDO=2 CUSTOM_SIMD_ADD=yes
|
||||||
|
```
|
||||||
|
|
||||||
|
To retrieve the plugin related signals in the wave, just filter with `simd`.
|
||||||
|
|
|
@ -53,20 +53,23 @@ class SimdAddPlugin extends Plugin[VexRiscv]{
|
||||||
import pipeline._
|
import pipeline._
|
||||||
import pipeline.config._
|
import pipeline.config._
|
||||||
|
|
||||||
|
//Add a new scope on the execute stage (used to give a name to signals)
|
||||||
|
execute plug new Area {
|
||||||
//Define some signals used internally to the plugin
|
//Define some signals used internally to the plugin
|
||||||
val rs1 = execute.input(RS1).asUInt //32 bits UInt value of the regfile[RS1]
|
val rs1 = execute.input(RS1).asUInt //32 bits UInt value of the regfile[RS1]
|
||||||
val rs2 = execute.input(RS2).asUInt
|
val rs2 = execute.input(RS2).asUInt
|
||||||
val rd = UInt(32 bits)
|
val rd = UInt(32 bits)
|
||||||
|
|
||||||
//Do some computation
|
//Do some computation
|
||||||
rd( 7 downto 0) := rs1( 7 downto 0) + rs2( 7 downto 0)
|
rd(7 downto 0) := rs1(7 downto 0) + rs2(7 downto 0)
|
||||||
rd(16 downto 8) := rs1(16 downto 8) + rs2(16 downto 8)
|
rd(16 downto 8) := rs1(16 downto 8) + rs2(16 downto 8)
|
||||||
rd(23 downto 16) := rs1(23 downto 16) + rs2(23 downto 16)
|
rd(23 downto 16) := rs1(23 downto 16) + rs2(23 downto 16)
|
||||||
rd(31 downto 24) := rs1(31 downto 24) + rs2(31 downto 24)
|
rd(31 downto 24) := rs1(31 downto 24) + rs2(31 downto 24)
|
||||||
|
|
||||||
//When the instruction is a SIMD_ADD one, then write the result into the register file data path.
|
//When the instruction is a SIMD_ADD one, then write the result into the register file data path.
|
||||||
when(execute.input(IS_SIMD_ADD)){
|
when(execute.input(IS_SIMD_ADD)) {
|
||||||
execute.output(REGFILE_WRITE_DATA) := rd.asBits
|
execute.output(REGFILE_WRITE_DATA) := rd.asBits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@ object GenCustomSimdAdd extends App{
|
||||||
separatedAddSub = false,
|
separatedAddSub = false,
|
||||||
executeInsertion = false
|
executeInsertion = false
|
||||||
),
|
),
|
||||||
new LightShifterPlugin,
|
new FullBarrielShifterPlugin,
|
||||||
new HazardSimplePlugin(
|
new HazardSimplePlugin(
|
||||||
bypassExecute = false,
|
bypassExecute = true,
|
||||||
bypassMemory = false,
|
bypassMemory = true,
|
||||||
bypassWriteBack = false,
|
bypassWriteBack = true,
|
||||||
bypassWriteBackBuffer = false,
|
bypassWriteBackBuffer = true,
|
||||||
pessimisticUseSrc = false,
|
pessimisticUseSrc = false,
|
||||||
pessimisticWriteRegFile = false,
|
pessimisticWriteRegFile = false,
|
||||||
pessimisticAddressMatch = false
|
pessimisticAddressMatch = false
|
||||||
|
|
Loading…
Reference in a new issue