|
|
|
|
|
by Traster
2114 days ago
|
|
It's kind of a good demonstration of the problem with software versus hardware, here's xls solution (just for one function): fn decode_i_instruction(ins: u32) -> (u12, u5, u3, u5, u7) {
let imm_11_0 = (ins >> u32:20);
let rs1 = (ins >> u32:15) & u32:0x1F;
let funct3 = (ins >> u32:12) & u32:0x07;
let rd = (ins >> u32:7) & u32:0x1F;
let opcode = ins & u32:0x7F;
(imm_11_0 as u12, rs1 as u5, funct3 as u3, rd as u5, opcode as u7)
}
here's the systemverilog solution {im_11_0,rs1,funct3,rd,opcode} <= ins;
Obviously, in software, you can't slice data in the same way since as far as I can tell, it's assuming all variables are a certain size and so there's no naturally way of bit slicing. |
|