姜冠宇
RISC-V B extension. i.e., Zba, Zbb, and Zbs.
FDEXBundle
Pipeline
EXWBBundle
EXWBBundle
forwarding
Harzard detection with flush
each of these smaller extensions is grouped by common function and use case, and each has its own Zb*-extension name.
Some instructions are available in only one extension while others are available in several
sh1add, sh2add, sh3add,
andn, orn, xnor,
clz, ctz, cpop,
max, maxu, min, minu,
sext.b, sext.h, zext.h
rol, ror, rori,
orc.b, rev8
clmul, clmulh, clmulr,
bclr, bclri, bext, bexti, binv, binvi, bset, bseti
0010011
(I-type)Decode order : Opcode -> Funct3 -> Funct7 -> Shamt
funct7 | shamt | rs1 | funct3 | rd | opcode | Instruction(s) |
---|---|---|---|---|---|---|
IB1 | ||||||
0010100 | 5 bits | 5 bits | 001 | 5 bits | 0010011 | bseti |
0100100 | 5 bits | 5 bits | 001 | 5 bits | 0010011 | bclri |
0110000 | 00000 | 5 bits | 001 | 5 bits | 0010011 | clz |
0110000 | 00001 | 5 bits | 001 | 5 bits | 0010011 | ctz |
0110000 | 00010 | 5 bits | 001 | 5 bits | 0010011 | cpop |
0110000 | 00100 | 5 bits | 001 | 5 bits | 0010011 | sext.b |
0110000 | 00101 | 5 bits | 001 | 5 bits | 0010011 | sext.h |
0110100 | 5 bits | 5 bits | 001 | 5 bits | 0010011 | binvi |
IB2 | ||||||
0010100 | 00111 | 5 bits | 101 | 5 bits | 0010011 | orc.b |
0100100 | 5 bits | 5 bits | 101 | 5 bits | 0010011 | bexti |
0110000 | 5 bits | 5 bits | 101 | 5 bits | 0010011 | rori |
0110100 | 11000 | 5 bits | 101 | 5 bits | 0010011 | rev8 |
0110011
(RMType)Decode order : Opcode -> Funct7 -> Funct3 -> Shamt
funct7 | rs2 | rs1 | funct3 | rd | opcode | instruction |
---|---|---|---|---|---|---|
RB1 | ||||||
0000101 | 5 bits | 5 bits | 001 | 5 bits | 0110011 | clmul |
0000101 | 5 bits | 5 bits | 010 | 5 bits | 0110011 | clmulr |
0000101 | 5 bits | 5 bits | 011 | 5 bits | 0110011 | clmulh |
0000101 | 5 bits | 5 bits | 100 | 5 bits | 0110011 | min |
0000101 | 5 bits | 5 bits | 101 | 5 bits | 0110011 | minu |
0000101 | 5 bits | 5 bits | 110 | 5 bits | 0110011 | max |
0000101 | 5 bits | 5 bits | 111 | 5 bits | 0110011 | maxu |
0000100 | 00000 |
5 bits | 100 | 5 bits | 0110011 | zext.h |
RB2 | ||||||
0010000 | 5 bits | 5 bits | 010 | 5 bits | 0110011 | sh1add |
0010000 | 5 bits | 5 bits | 100 | 5 bits | 0110011 | sh2add |
0010000 | 5 bits | 5 bits | 110 | 5 bits | 0110011 | sh3add |
0010100 | 5 bits | 5 bits | 001 | 5 bits | 0110011 | bset |
RB3 | ||||||
0100000 | 5 bits | 5 bits | 100 | 5 bits | 0110011 | xnor |
0100000 | 5 bits | 5 bits | 110 | 5 bits | 0110011 | orn |
0100000 | 5 bits | 5 bits | 111 | 5 bits | 0110011 | andn |
RB4 | ||||||
0100100 | 5 bits | 5 bits | 001 | 5 bits | 0110011 | bclr |
0100100 | 5 bits | 5 bits | 101 | 5 bits | 0110011 | bext |
RB5 | ||||||
0110000 | 5 bits | 5 bits | 001 | 5 bits | 0110011 | rol |
0110000 | 5 bits | 5 bits | 101 | 5 bits | 0110011 | ror |
binv | ||||||
0110100 | 5 bits | 5 bits | 001 | 5 bits | 0110011 | binv |
Output | sh1add | sh2add | sh3add |
---|---|---|---|
regs_reg1_read_address: | rs1 | rs1 | rs1 |
ex_aluop1_source: | 0 | 0 | 0 |
ex_aluop2_source: | 0 | 0 | 0 |
memory_read_enable: | 0 | 0 | 0 |
memory_write_enable: | 0 | 0 | 0 |
wb_reg_write_source: | 0 | 0 | 0 |
reg_write_enable: | 1 | 1 | 1 |
sh1add rd, rs1, rs2: X(rd) = X(rs2) + (X(rs1) << 1);
sh2add rd, rs1, rs2 X(rd) = X(rs2) + (X(rs1) << 2);
sh3add rd, rs1, rs2 X(rd) = X(rs2) + (X(rs1) << 3);
andn rd, rs1, rs2: X(rd) = X(rs1) & ~X(rs2);
orn rd, rs1, rs2: X(rd) = X(rs1) | ~X(rs2);
xnor rd, rs1, rs2: X(rd) = ~(X(rs1) ^ X(rs2));
clz rd, rs:
ctz rd, rs
cpop rd, rs
max rd, rs1, rs2
maxu rd, rs1, rs2
min rd, rs1, rs2
minu rd, rs1, rs2
sext.b rd, rs: X(rd) = EXTS(X(rs)[7..0]);
sext.h rd, rs: X(rd) = EXTS(X(rs)[15..0]);
zext.h rd, rs: X(rd) = EXTZ(X(rs)[15..0]);
rol rd, rs1, rs2
ror rd, rs1, rs2
rori rd, rs1, shamt
orc.b rd, rs
rev8 rd, rs:
clmul rd, rs1, rs2: clmul produces the lower half of the 2·XLEN carry-less product.
clmulh rd, rs1, rs2: clmulh produces the upper half of the 2·XLEN carry-less product.
clmulr rd, rs1, rs2: produces bits 2·XLEN−2:XLEN-1 of the 2·XLEN carry-less product.
Operation
bclr rd, rs1, rs2: This instruction returns rs1 with a single bit cleared at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2.
bclri rd, rs1, shamt:
bext rd, rs1, rs2 Single-Bit Extract (Register)
bext rd, rs1, shamt:
binv rd, rs1, rs2: Single-Bit Invert (Register)
binvi rd, rs1, shamt:
bset rd, rs1, rs2: Single-Bit Set (Register)
bseti rd, rs1, shamt:
e.g.
Test the execution of pepeline and whether adding extension causes errors.
chisel-tutorial
Macbook M1使用vscode+iverilog+gtkwave实现Verilog代码的编译与运行
如何在Mac OS X上安裝Verilog環境
riscv-mini
RV32I Instruction
Pseudocode for instruction semantics
Lab3: Construct a single-cycle RISC-V CPU with Chisel
"B" Extension for Bit Manipulation, Version 1.0.0