mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-24 13:57:19 -04:00
This commit implements the Bit Manipulation Extension ZBB instruction group: clz, ctz, pcnt, slo, sro, rol, ror, rev, rev8, orcb, pack packu, packh, min, max, andn, orn, and xnor. * Bit counting instructions clz, ctz and pcnt can be implemented to share much of the architecture: clz: Count Leading Zeros. Counts the number of 0 bits at the MSB end of the argument. ctz: Count Trailing Zeros. Counts the number of 0 bits at the LSB end of the argument. pcnt: Counts the number of set bits of the argument. The implementation uses: - 32 one bit adders, counting the set bits of a signal bitcnt_bits, starting from the LSB end. - For pcnt the argument is fed directly into bitcnt_bits. - For clz, the operand is reversed such that leading zeros are located at the LSB end of bitcnt_bits. - For ctz and clz: counter enable signal for 1-bit counter i is high, if the previous enable signal, and its corresponting bitcnt_bit was high. * Instructions sll[i], srl[i],slo[i], sro[i], rol, ror[i], rev, rev8 and orc.b are summarized as shifting instructions and related: The following instructions are slight variations of the existing base spec's sll, srl and sra instructions. - slo[i] and sro[i]: shift left/right ones: similar to shift-logical operations from base spec, but shifting in ones instead of zeros. - rol and ror[i]: rotate left/right ones: circular shift operations. shifting in values from the oposite end of the operand instead of zeros. Those instructions can be implemented, sharing the base spec's shifting structure. In order to support rotate operations, a 64-bit shifting structure is needed. In the existing ALU, hardware is described only for right shifts. For left shifts the operand is initially reversed, right shifted and the result is reversed back. This gives rise to an additional resource sharing oportunity for some more zbb operations: - rev: bitwise reversal. - rev8: byte-order swap. - orc.b: byte-wise reverse and or-combine. * Instructions min, max: For the B-extension's min/max instructions, we can share the existing comparison operations. The result is obtained by activating the comparison structure accordingly and multiplexing the operands using the comparison result. * Logic-with-negate instructions andn, orn, xnor: For the B-extension's logic-with-negate instructions we can share the structures of the base spec's logic structures already present for 'xnor', 'or' and 'and' instructions as well as the conditionally negated b operand generated for subtraction operations. * Instructions pack, packu, packh: For the pack, packh and packu instructions I don't see any opportunities for resource sharing. However, the architecture is quite simple. - pack: pack the lower halves of rs1 and rs2 into rd, with rs1 in the lower half and rs2 in the upper half. - packu: pack the upper halves of rs1 and rs2 into rd, with rs1 in the lower half and rs2 in the upper half. - packh: pack the LSB bytes of rs1 and rs2 into rd, with rs1 in the lower half and rs2 in the upper half. Signed-off-by: ganoam <gnoam@live.com> |
||
---|---|---|
.. | ||
verilator_waiver.vlt |