UNZIP

RISC-V UNZIP Instruction Details

Instruction ManualI-type

RV32 bit deinterleave (Zbkb), RV32-only.

Instruction Syntax

unzip rd, rs1

RV32 Zbkb 1.0 only; syntax unzip rd, rs1, both integer registers, with no assembly immediate.

32-bit I-type: bits31:20=000010001111, funct3=101, opcode=0010011; the fixed selector is not an arithmetic immediate.

For i=0..15, rd[i]=rs1[2*i] and rd[i+16]=rs1[2*i+1]; inverse of ZIP, with no memory access.

Read the source before writeback; rd=rs1 uses the old source, x0 sources are zero, and rd=x0 discards writeback.

ZbkbBit Manipulation

Instruction Behavior

UNZIP (Zbkb, RV32-only) gathers even-numbered bits of rs1 into the low 16 bits of rd and odd-numbered bits into the high 16 bits: for i=0..15, rd[i]=rs1[2*i] and rd[i+16]=rs1[2*i+1]. It is the inverse of ZIP.

UNZIP Decode & Execute Animation

Shows only specification-defined encodings, conditions, and architectural state.

unzip a0, a1
unzip,
Execution Context

Assumes RV32 Zbkb is implemented. Inputs are unsigned 32-bit patterns; teaching steps are not processor cycles.

Instruction Encoding
31..20
imm[11:0]
000010001111
19..15
rs1
01011
14..12
funct3
101
11..7
rd
01010
6..0
opcode
0010011 OP-IMM
Decode fixed fields
x[a1]=0xD2C4B8A1
rd[i] = rs1[2*i], rd[i+16] = rs1[2*i+1], i=0..15
Architectural state has not been committed.

Quick Understanding & Search Notes

UNZIP gathers even bits of a 32-bit source into the low 16 bits and odd bits into the high 16 bits.

The official encoding and semantics are RV32-only.
It rearranges even source bits into the low half and odd source bits into the high half without accessing memory.

Common Usage Scenarios

Bit deinterleaving

Assume RV32 Zbkb and a1=0xD2C4B8A1; unzip a0, a1 gives a0=0x98ECCA41, leaving the source and memory unchanged.

RV32 SHA3 bit-interleaved representation

Assume RV32 Zbkb and a1=0xD2C4B8A1; unzip a0, a1 gives a0=0x98ECCA41, leaving the source and memory unchanged.

Pre-Use Checklist

Syntax Check
  • RV32 Zbkb 1.0 only; syntax unzip rd, rs1, both integer registers, with no assembly immediate.
  • 32-bit I-type: bits31:20=000010001111, funct3=101, opcode=0010011; the fixed selector is not an arithmetic immediate.
Semantic Check
  • For i=0..15, rd[i]=rs1[2*i] and rd[i+16]=rs1[2*i+1]; inverse of ZIP, with no memory access.
  • Read the source before writeback; rd=rs1 uses the old source, x0 sources are zero, and rd=x0 discards writeback.

Pitfalls / Common Confusions

UNZIP is defined only on RV32; there is no RV64 form.
It deinterleaves bits, not bytes or halfwords.

FAQ

Does UNZIP access memory?

No. It only rearranges bit fields in integer registers.

Which extension contains UNZIP?

It belongs to the Zbkb cryptographic bit-manipulation extension.