VexRiscv
VexRiscv copied to clipboard
Help for custom instruction
I try to create a custom instruction for fast context switching The opcode will save a register value and at the same time restore the register to last saved value. My code looks like below, it does not seem to work. I am doing this right? Thx
override def build(pipeline: VexRiscv): Unit = { import pipeline._ import pipeline.config._
// Custom opcode will save RS1 and restore last saved value to RD
execute plug new Area {
val rs1 = execute.input(RS1).asUInt
val save_reg = Reg(UInt(32 bits))
when(execute.input(IS_FAST_CONTEXT_SWITCH)) {
execute.output(REGFILE_WRITE_DATA) := save_reg;
save_reg := rs1;
}
}
}