VexRiscv icon indicating copy to clipboard operation
VexRiscv copied to clipboard

Help for custom instruction

Open ztachip opened this issue 3 weeks ago • 5 comments

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;
  }
}

}

ztachip avatar Jun 08 '24 19:06 ztachip