Skip to content

Commit

Permalink
Merge branch 'master' into lekcyjna/bump-amaranth-31012024-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekcyjna committed Mar 2, 2024
2 parents fcc53b4 + 14d7fc4 commit b7f8a19
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
9 changes: 6 additions & 3 deletions coreblocks/frontend/instr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,23 @@ class Encoding:
Encoding(Opcode.OP, Funct3.MIN, Funct7.MIN),
Encoding(Opcode.OP, Funct3.MINU, Funct7.MIN),
Encoding(Opcode.OP, Funct3.ORN, Funct7.ORN),
Encoding(Opcode.OP, Funct3.XNOR, Funct7.XNOR),
],
OpType.BIT_ROTATION: [
Encoding(Opcode.OP, Funct3.ROL, Funct7.ROL),
Encoding(Opcode.OP, Funct3.ROR, Funct7.ROR),
Encoding(Opcode.OP_IMM, Funct3.ROR, Funct7.ROR),
Encoding(Opcode.OP, Funct3.XNOR, Funct7.XNOR),
],
OpType.UNARY_BIT_MANIPULATION_1: [
Encoding(Opcode.OP_IMM, Funct3.ORCB, funct12=Funct12.ORCB),
Encoding(Opcode.OP_IMM, Funct3.REV8, funct12=Funct12.REV8_32),
Encoding(Opcode.OP_IMM, Funct3.SEXTB, funct12=Funct12.SEXTB),
Encoding(Opcode.OP, Funct3.ZEXTH, funct12=Funct12.ZEXTH),
],
# Instructions SEXTH, SEXTHB, CPOP, CLZ and CTZ cannot be distiguished by their Funct7 code
# Instructions SEXTH, SEXTHB, CPOP, CLZ and CTZ cannot be distiguished by their Funct7 code
# ORCB is here because of optimization to not lookup Funct7 in UNARY_BIT_MANIPULATION_1
OpType.UNARY_BIT_MANIPULATION_2: [
Encoding(Opcode.OP_IMM, Funct3.SEXTH, funct12=Funct12.SEXTH),
Encoding(Opcode.OP_IMM, Funct3.ORCB, funct12=Funct12.ORCB),
],
OpType.UNARY_BIT_MANIPULATION_3: [
Encoding(Opcode.OP_IMM, Funct3.CLZ, funct12=Funct12.CLZ),
Expand Down
16 changes: 8 additions & 8 deletions coreblocks/fu/alu.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def get_instructions(self) -> Sequence[tuple]:
(self.Fn.MAXU, OpType.BIT_MANIPULATION, Funct3.MAXU, Funct7.MAX),
(self.Fn.MIN, OpType.BIT_MANIPULATION, Funct3.MIN, Funct7.MIN),
(self.Fn.MINU, OpType.BIT_MANIPULATION, Funct3.MINU, Funct7.MIN),
(self.Fn.ORCB, OpType.UNARY_BIT_MANIPULATION_1, Funct3.ORCB, Funct7.ORCB),
(self.Fn.REV8, OpType.UNARY_BIT_MANIPULATION_1, Funct3.REV8, Funct7.REV8),
(self.Fn.SEXTB, OpType.UNARY_BIT_MANIPULATION_1, Funct3.SEXTB, Funct7.SEXTB),
(self.Fn.ZEXTH, OpType.UNARY_BIT_MANIPULATION_1, Funct3.ZEXTH, Funct7.ZEXTH),
(self.Fn.CPOP, OpType.UNARY_BIT_MANIPULATION_5, Funct3.CPOP, Funct7.CPOP),
(self.Fn.SEXTH, OpType.UNARY_BIT_MANIPULATION_2, Funct3.SEXTH, Funct7.SEXTH),
(self.Fn.CLZ, OpType.UNARY_BIT_MANIPULATION_3, Funct3.CLZ, Funct7.CLZ),
(self.Fn.CTZ, OpType.UNARY_BIT_MANIPULATION_4, Funct3.CTZ, Funct7.CTZ),
(self.Fn.REV8, OpType.UNARY_BIT_MANIPULATION_1, Funct3.REV8),
(self.Fn.SEXTB, OpType.UNARY_BIT_MANIPULATION_1, Funct3.SEXTB),
(self.Fn.ZEXTH, OpType.UNARY_BIT_MANIPULATION_1, Funct3.ZEXTH),
(self.Fn.ORCB, OpType.UNARY_BIT_MANIPULATION_2, Funct3.ORCB),
(self.Fn.SEXTH, OpType.UNARY_BIT_MANIPULATION_2, Funct3.SEXTH),
(self.Fn.CLZ, OpType.UNARY_BIT_MANIPULATION_3, Funct3.CLZ),
(self.Fn.CTZ, OpType.UNARY_BIT_MANIPULATION_4, Funct3.CTZ),
(self.Fn.CPOP, OpType.UNARY_BIT_MANIPULATION_5, Funct3.CPOP),
]
* self.zbb_enable
)
Expand Down
4 changes: 2 additions & 2 deletions coreblocks/fu/shift_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def get_instructions(self) -> Sequence[tuple]:
(self.Fn.SRL, OpType.SHIFT, Funct3.SR, Funct7.SL),
(self.Fn.SRA, OpType.SHIFT, Funct3.SR, Funct7.SA),
] + [
(self.Fn.ROR, OpType.BIT_MANIPULATION, Funct3.ROR, Funct7.ROR),
(self.Fn.ROL, OpType.BIT_MANIPULATION, Funct3.ROL, Funct7.ROL),
(self.Fn.ROR, OpType.BIT_ROTATION, Funct3.ROR),
(self.Fn.ROL, OpType.BIT_ROTATION, Funct3.ROL),
] * self.zbb_enable


Expand Down
2 changes: 2 additions & 0 deletions coreblocks/params/optypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OpType(IntEnum):
SINGLE_BIT_MANIPULATION = auto()
ADDRESS_GENERATION = auto()
BIT_MANIPULATION = auto()
BIT_ROTATION = auto()
UNARY_BIT_MANIPULATION_1 = auto()
UNARY_BIT_MANIPULATION_2 = auto()
UNARY_BIT_MANIPULATION_3 = auto()
Expand Down Expand Up @@ -88,6 +89,7 @@ class OpType(IntEnum):
],
Extension.ZBB: [
OpType.BIT_MANIPULATION,
OpType.BIT_ROTATION,
OpType.UNARY_BIT_MANIPULATION_1,
OpType.UNARY_BIT_MANIPULATION_2,
OpType.UNARY_BIT_MANIPULATION_3,
Expand Down
2 changes: 1 addition & 1 deletion test/frontend/test_instr_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_decoded_distinguishable(self):
Encoding(Opcode.OP_IMM, Funct3.BSET, Funct7.BSET),
Encoding(Opcode.OP_IMM, Funct3.BINV, Funct7.BINV),
},
OpType.BIT_MANIPULATION: {
OpType.BIT_ROTATION: {
Encoding(Opcode.OP_IMM, Funct3.ROR, Funct7.ROR),
},
}
Expand Down
16 changes: 8 additions & 8 deletions test/fu/test_alu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class AluUnitTest(FunctionalUnitTestCase[AluFn.Fn]):
AluFn.Fn.MAXU: ExecFn(OpType.BIT_MANIPULATION, Funct3.MAXU, Funct7.MAX),
AluFn.Fn.MIN: ExecFn(OpType.BIT_MANIPULATION, Funct3.MIN, Funct7.MIN),
AluFn.Fn.MINU: ExecFn(OpType.BIT_MANIPULATION, Funct3.MINU, Funct7.MIN),
AluFn.Fn.CPOP: ExecFn(OpType.UNARY_BIT_MANIPULATION_5, Funct3.CPOP, Funct7.CPOP),
AluFn.Fn.SEXTB: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.SEXTB, Funct7.SEXTB),
AluFn.Fn.ZEXTH: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.ZEXTH, Funct7.ZEXTH),
AluFn.Fn.SEXTH: ExecFn(OpType.UNARY_BIT_MANIPULATION_2, Funct3.SEXTH, Funct7.SEXTH),
AluFn.Fn.ORCB: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.ORCB, Funct7.ORCB),
AluFn.Fn.REV8: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.REV8, Funct7.REV8),
AluFn.Fn.CLZ: ExecFn(OpType.UNARY_BIT_MANIPULATION_3, Funct3.CLZ, Funct7.CLZ),
AluFn.Fn.CTZ: ExecFn(OpType.UNARY_BIT_MANIPULATION_4, Funct3.CTZ, Funct7.CTZ),
AluFn.Fn.SEXTB: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.SEXTB),
AluFn.Fn.ZEXTH: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.ZEXTH),
AluFn.Fn.REV8: ExecFn(OpType.UNARY_BIT_MANIPULATION_1, Funct3.REV8),
AluFn.Fn.SEXTH: ExecFn(OpType.UNARY_BIT_MANIPULATION_2, Funct3.SEXTH),
AluFn.Fn.ORCB: ExecFn(OpType.UNARY_BIT_MANIPULATION_2, Funct3.ORCB),
AluFn.Fn.CLZ: ExecFn(OpType.UNARY_BIT_MANIPULATION_3, Funct3.CLZ),
AluFn.Fn.CTZ: ExecFn(OpType.UNARY_BIT_MANIPULATION_4, Funct3.CTZ),
AluFn.Fn.CPOP: ExecFn(OpType.UNARY_BIT_MANIPULATION_5, Funct3.CPOP),
}

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions test/fu/test_shift_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class ShiftUnitTest(FunctionalUnitTestCase[ShiftUnitFn.Fn]):
ShiftUnitFn.Fn.SLL: ExecFn(OpType.SHIFT, Funct3.SLL),
ShiftUnitFn.Fn.SRL: ExecFn(OpType.SHIFT, Funct3.SR, Funct7.SL),
ShiftUnitFn.Fn.SRA: ExecFn(OpType.SHIFT, Funct3.SR, Funct7.SA),
ShiftUnitFn.Fn.ROL: ExecFn(OpType.BIT_MANIPULATION, Funct3.ROL, Funct7.ROL),
ShiftUnitFn.Fn.ROR: ExecFn(OpType.BIT_MANIPULATION, Funct3.ROR, Funct7.ROR),
ShiftUnitFn.Fn.ROL: ExecFn(OpType.BIT_ROTATION, Funct3.ROL, Funct7.ROL),
ShiftUnitFn.Fn.ROR: ExecFn(OpType.BIT_ROTATION, Funct3.ROR, Funct7.ROR),
}

@staticmethod
Expand Down

0 comments on commit b7f8a19

Please sign in to comment.