HLV.H

RISC-V HLV.H Instruction Details

Instruction ManualSYSTEM (R-type encoding)

Hypervisor virtual-machine load of a signed halfword using VS/VU effective privilege and two-stage translation.

Instruction Syntax

hlv.h rd, (rs1)
Operand Breakdown
Destination rd: receives the sign-extended 16-bit loaded value; when rd=x0 the writeback value is discarded, but the explicit access still executes.
Address register rs1: directly supplies the explicit-access address; HLV.H assembly has no offset immediate field.
The SYSTEM encoding fixes funct7=0110010, rs2=00000, funct3=100, and opcode=1110011; do not decode it as an ordinary I-type load.
HSystem & Privilege

Instruction Behavior

HLV.H is the H-extension virtual-machine load corresponding to LH. It reads a 16-bit halfword at the address in rs1 and sign-extends it to XLEN; the instruction has no immediate offset. It is valid only in M-mode, HS-mode, or U-mode with hstatus.HU=1. The explicit access uses the VU or VS effective privilege selected by hstatus.SPVP and two-stage translation.

HLV.H Decode And Execute Animation

Shows HLV.H SYSTEM decoding, privilege checks, two-stage translation, and sign-extended writeback without modeling page walks or TLB implementation.

rd
rs1
hlv.h
,(
)

Assumes H is implemented, relevant privilege modes use the same XLEN, and pointer masking is disabled. Input is an assembled memory value; the selector supplies the access outcome without validating page tables. rs1=x0 fixes address zero. Steps are teaching stages, not processor cycles.

31..25
24..20
19..15
14..12
11..7
6..0
0110010
funct7
00000
rs2=x0
01011
rs1/address
100
PRIVM
01010
rd
1110011
SYSTEM
Architectural Data Path
instruction
0x6405C573
decode
funct7=0110010, rs2=00000, funct3=100, rd=01010 -> HLV.H
address
a1(x11) -> 0x0000000040001000 (no immediate offset)
privilege
HS: execution permitted
translation
VU effective privilege -> VS-stage -> G-stage; HS SUM ignored; MPRV is not used
load
16-bit 0x8001 -> sign-extend (-32767) -> 0xFFFFFFFFFFFF8001
state
Architectural state is not committed; the final rd state is shown only at writeback.
Architectural state is not committed; the final rd state is shown only at writeback.

This animation shows only official architectural conditions and outcomes; page walks, TLBs, caches, and platform exception handling are not modeled.

Quick Understanding & Search Notes

HLV.H reads 16 bits at rs1, sign-extends to XLEN into rd.

SPVP=0/1 selects VU/VS. HS-level SUM is ignored; MPRV has no effect.
HS-level MXR applies to both stages; vsstatus.MXR only to VS-stage. Either stage may be Bare.
rd=x0 discards only the value; exceptions and side effects remain. rs1=x0 supplies address zero.

Common Usage Scenarios

Virtual-machine memory load

Understand this scenario with real code like «# RV64; H 扩展 / H extension; HS-mode, SPVP=0; pointer masking disabled # x11=0x40001000; VS/G-stage access succeeds # 16-bit memory value = 0x8001 hlv.h x10, (x11) # x10 = 0xFFFFFFFFFFFF8001».

VS/VU effective privilege

Understand this scenario with real code like «# RV64; H 扩展 / H extension; HS-mode, SPVP=0; pointer masking disabled # x11=0x40001000; VS/G-stage access succeeds # 16-bit memory value = 0x8001 hlv.h x10, (x11) # x10 = 0xFFFFFFFFFFFF8001».

Two-stage address translation

Understand this scenario with real code like «# RV64; H 扩展 / H extension; HS-mode, SPVP=0; pointer masking disabled # x11=0x40001000; VS/G-stage access succeeds # 16-bit memory value = 0x8001 hlv.h x10, (x11) # x10 = 0xFFFFFFFFFFFF8001».

Pre-Use Checklist

Syntax Check
  • Confirm the assembly syntax is hlv.h rd, (rs1): rs1 supplies the address directly and there is no offset immediate.
  • Confirm the SYSTEM encoding fixes rs2=00000, funct7=0110010, funct3=100, and opcode=1110011.
Semantic Check
  • Confirm execution is in M/HS, or in U-mode with hstatus.HU=1; V=1 raises a virtual-instruction exception.
  • Confirm the 16-bit load uses sign extension, and preserve handling for VS-stage/G-stage access faults, page faults, and guest-page faults.

Pitfalls / Common Confusions

Executing HLV/HLVX/HSV when virtualization mode V=1 raises a virtual-instruction exception.
U-mode execution is legal only when hstatus.HU=1; otherwise it raises illegal-instruction.
Access faults, guest-page faults, and page faults are still possible under the VS/G-stage translations.

FAQ

Can it execute in U-mode?

With H implemented: M/HS or V=0 U-mode with HU=1 may execute. V=0 U-mode with HU=0 raises illegal-instruction; V=1 raises virtual-instruction.

What happens with rs1=x0 or rd=rs1?

rs1=x0 supplies zero. With rd=rs1, read the address before writeback. rd=x0 retains exceptions and side effects.