Add decoder for C extension#241
Conversation
5f40d07 to
5160b8a
Compare
🔧 DE1-SoC Synthesis Report Summary Diff
Comparing synthesis results from main branch vs. this PR |
| 2'b00: begin // Quadrant 0 | ||
| case (funct3) | ||
| 3'b000: begin | ||
| instr_out = {ciw_imm, 5'd2, 3'b000, rd_prime, IType_logic}; // C.ADDI4SPN |
There was a problem hiding this comment.
i think since there are a lot compositions here, im wondering if we can cook up a function here like build_<opcode>_instr that can be passed all the needed parameters for a particular opcode, and this would make things a bit more readable here + force a bit more wire width checking as part of compilation, i.e. in my head it looks like something along the lines of
| instr_out = {ciw_imm, 5'd2, 3'b000, rd_prime, IType_logic}; // C.ADDI4SPN | |
| instr_out = build_immlogic_instr( .imm (ciw_imm), .rs1 (5'd2), .funct3 (3'b000), .rd (rd_prime) ); // C.ADDI4SPN |
There was a problem hiding this comment.
Sure but we would probably need to add like 8 functions to get all the composition types
There was a problem hiding this comment.
I think that's fine, we might be able to reuse them in tests maybe, but even if not -- there are essentially just for readability, and don't add any overhead at runtime.
476c407 to
0b66ced
Compare
| is_illegal = 1'b0; | ||
|
|
||
| case (quadrant) // Opcode | ||
| 2'b11: instr_out = {16'b0, instr_c}; // Not a compressed instruction, just pass through (should not actually happen i think?) |
There was a problem hiding this comment.
i think we can just say its illegal in this case, since the spec does not even define 2'b11 as its own quadrant
0b66ced to
f68d968
Compare
| case (instr_c[11:10]) | ||
| 2'b00: begin | ||
| instr_out = build_i_shift_instr(.funct7(7'h00), .shamt(shamt), .rs1(rs1_prime), .funct3(3'b101), .rd(rs1_prime), .opcode(IType_logic)); // C.SRLI | ||
| if (instr_c[12]) is_illegal = 1'b1; |
There was a problem hiding this comment.
can you point to the spec for this condition? i did not find it in C extension spec, might be elsewhere
There was a problem hiding this comment.
I think it's because instr_c[12] represents shamt[5]
"For RV32C, shamt[5] must be zero; the code points with shamt[5]=1 are designated for custom extensions."
Issue #239
Implemented decompression for all rv32 instructions other than F and D extension ones
Also added checking for illegal/reserved and unimplemented instructions though I don't think we have a way to handle that properly yet?
Note C.JAL and C.JALR need extra handling to work properly (I think)