Webcentive RISC-V Reference

zip

Bit interleave

Extension
Zbkb, Zk, Zkn, Zks
XLEN
RV32 only
Assembly (riscv-unified-db)
zip xd, xs1
Length
32-bit

Encoding

31252420191514121176210
000010001111rs1001rd0010011

Match 0x08f01013, mask 0xfff0707f. Source: zip rd rs1 31..25=4 24..20=15 14..12=1 6..2=4 1..0=3 in riscv-opcodes/extensions/rv32_zbkb.

FieldBitsriscv-opcodes name
rs119:15rs1
rd11:7rd

Description

Scatters all of the odd and even bits of a source word into the high and low halves of a destination word. It is the inverse of the unzip instruction. This instruction is available only on RV32.

Description from riscv-unified-db, reformatted.

Operation

XReg input = X[xs1];
XReg output = 0;

for(U32 i=0; i < (xlen()/2); i = i+1){
  output[2*i] = input[i];
  output[2*i+1] = input[i+xlen()/2];
}

X[xd] = output;

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages