🐛 Fix encoding issue (undetected illegal instr)

This commit is contained in:
Florian Zaruba 2018-03-14 14:01:47 +01:00
parent 96eb8cdf26
commit d90a9b00a0
No known key found for this signature in database
GPG key ID: E742FFE8EC38A792
2 changed files with 25 additions and 16 deletions

View file

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Bugfix in non-detected illegal instruction #12
- Bugfix in non-detected illegal instruction JALR (funct3 != 0)
- Bugfix in non-detected illegal instruction FENCE (some bit-checks missing)
### 2.0.0 - 2018-01-26

View file

@ -206,24 +206,28 @@ module decoder (
default: illegal_instr = 1'b1;
endcase
end
// Memory ordering instructions
OPCODE_FENCE: begin
// FENCE.I
if (instr.itype.funct3 == 3'b001) begin
instruction_o.fu = CSR;
instruction_o.op = FENCE_I;
instruction_o.rs1 = '0;
instruction_o.rs2 = '0;
instruction_o.rd = '0;
// FENCE
end else begin
instruction_o.fu = CSR;
instruction_o.rs1 = '0;
instruction_o.rs2 = '0;
instruction_o.rd = '0;
case (instr.stype.funct3)
// FENCE
// Currently implemented as a whole DCache flush boldly ignoring other things
instruction_o.fu = CSR;
instruction_o.op = FENCE;
instruction_o.rs1 = '0;
instruction_o.rs2 = '0;
instruction_o.rd = '0;
end
3'b000: instruction_o.op = FENCE;
// FENCE.I
3'b001: begin
if (instr.instr[31:20] != '0)
illegal_instr = 1'b1;
instruction_o.op = FENCE_I;
end
default: illegal_instr = 1'b1;
endcase
if (instr.stype.rs1 != '0 || instr.stype.imm0 != '0 || instr.instr[31:28] != '0)
illegal_instr = 1'b1;
end
// --------------------------
@ -461,6 +465,9 @@ module decoder (
imm_select = IIMM;
instruction_o.rd = instr.itype.rd;
is_control_flow_instr_o = 1'b1;
// invalid jump and link register -> reserved for vector encoding
if (instr.itype.funct3 != 3'b0)
illegal_instr = 1'b1;
end
// Jump and link
OPCODE_JAL: begin