code wiki / _hdl_build / nx_rvc_expand.nx

nx_rvc_expand.nx

buildroot/runtime/_hdl_build/nx_rvc_expand.nx

8287 B144 linesdepth 2pulls 2 transitivereach 67 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rvc_expand.nx -- RV64 C (compressed) extension expander: takes a 16-bit compressed instruction and returns the equivalent 32-bit base instruction word (so the existing 32-bit decoder/execute path runs it unchanged). Covers the common INTEGER RVC encodings gcc emits (quadrants 0/1/2; float c.f* skipped). Returns 0 for unsupported/illegal. A 16-bit halfword is compressed iff (h & 3) != 3. Validated by differential test vs qemu-system-riscv64.

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_rvc_expand.nx nx_rv64_fast.nx nx_rvc_kat.nx rv64im_min_sim.nx

imports: nx_syscalls.nx

imported by: nx_rv64_fast.nxnx_rvc_kat.nxrv64im_min_sim.nx

structs

none

consts

none

functions

8func rvc_i(op: i64, f3: i64, rd: i64, rs1: i64, imm: i64) -> i64 { return ((imm & 0xFFF) << 20) | ((rs1 & 0x1F) << 15) | ((f3 & 7) << 12) | ((rd & 0x1F) << 7) | op }
called by 1: nx_rvc_expand
9func rvc_r(op: i64, f3: i64, f7: i64, rd: i64, rs1: i64, rs2: i64) -> i64 { return ((f7 & 0x7F) << 25) | ((rs2 & 0x1F) << 20) | ((rs1 & 0x1F) << 15) | ((f3 & 7) << 12) | ((rd & 0x1F) << 7) | op }
called by 1: nx_rvc_expand
10func rvc_s(op: i64, f3: i64, rs1: i64, rs2: i64, imm: i64) -> i64 { return (((imm >> 5) & 0x7F) << 25) | ((rs2 & 0x1F) << 20) | ((rs1 & 0x1F) << 15) | ((f3 & 7) << 12) | ((imm & 0x1F) << 7) | op }
called by 1: nx_rvc_expand
11func rvc_b(f3: i64, rs1: i64, rs2: i64, imm: i64) -> i64 { return (((imm>>12)&1)<<31) | (((imm>>5)&0x3F)<<25) | ((rs2&0x1F)<<20) | ((rs1&0x1F)<<15) | ((f3&7)<<12) | (((imm>>1)&0xF)<<8) | (((imm>>11)&1)<<7) | 0x63 }
called by 1: nx_rvc_expand
12func rvc_u(op: i64, rd: i64, imm: i64) -> i64 { return (imm & 0xFFFFF000) | ((rd & 0x1F) << 7) | op }
called by 1: nx_rvc_expand
13func rvc_j(rd: i64, imm: i64) -> i64 { return (((imm>>20)&1)<<31) | (((imm>>1)&0x3FF)<<21) | (((imm>>11)&1)<<20) | (((imm>>12)&0xFF)<<12) | ((rd&0x1F)<<7) | 0x6F }
called by 1: nx_rvc_expand
14func rvc_sext(v: i64, bits: i64) -> i64 { let m: i64 = 1 << (bits-1); if (v & m) != 0 { return v - (1 << bits) } return v }
called by 1: nx_rvc_expand
15func rvc_bit(h: i64, b: i64) -> i64 { return (h >> b) & 1 }
called by 1: nx_rvc_expand
18func nx_rvc_is_compressed(h: i64) -> i64 { if (h & 3) == 3 { return 0 } return 1 }
21func nx_rvc_expand(h: i64) -> i64
144func nx_rvc_main_ignore() -> i64 { return 0 }