R32V2020 Adding an Instruction to the ISA
Jump to navigation
Jump to search
Contents
Example: Add LIX instruction
For this example, we will add a new instruction, LIX, which loads a register with an extended immediate value.
Add opcode to ops.csv file
- Duplicate LIL and shift opcode table values
- This may break all past code since the .hex values will be changed for opcodes after the inserted opcode in that category
- If past code is "broken" then it will need to be recompiled since the opcode decode values will have changed
- In this case the LIX will be added after LIU so it won't break past code
Immed IMM_DEST Load reg immediate extend LIX 0 1 0 0 0 0 1 0
- Save ops.csv file (as CSV file)
Create Opcode Constants File
- In assembler folder, run (per this procedure):
python assembler.py --gen-constants
Result will be:
Constants written to OpCodeConstants.vhd
Edit R32V2020_Pkg.vhd
- Opcodes are packaged in R32V2020_Pkg.vhd
- Open OpCodeConstants.vhd in editor
- Copy all OpCodeConstants.vhd
- Replace in R32V2020_Pkg.vhd
Edit OpCodeConstants.vhd
- Edit OpCodeDecoder.vhd
- Add opcode to entity
- If opcode affects writes to register, add to o_WrRegFile
- This example does, so added: Op_LIX = '1' or
- Create Op_ function
Edit R32V2020.vhd
- Find similar group opcode
- Copy and change name to new opcode
- Take note of all VHDL files which use the similar opcode
- In this case, the following VHDL files changed:
- OpCodeDecoder.vhd (already fixed above)
- CCRControl.vhd
- RegisterFile.vhd
- In this case, the following VHDL files changed: