From: Luke Kenneth Casson Leighton Date: Wed, 26 Jun 2019 08:24:28 +0000 (+0100) Subject: add pseudocode to setvl X-Git-Tag: convert-csv-opcode-to-binary~4400 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08da70a8a63ae83ec33e3f6e640fb2dc6fcb47dc;p=libreriscv.git add pseudocode to setvl --- diff --git a/simple_v_extension/specification/sv.setvl.mdwn b/simple_v_extension/specification/sv.setvl.mdwn index f05e9bd24..a14a4d840 100644 --- a/simple_v_extension/specification/sv.setvl.mdwn +++ b/simple_v_extension/specification/sv.setvl.mdwn @@ -51,3 +51,31 @@ instructions (brownfield encodings). | vsetvl | 7 | TBD | | vsetvl | 8 | TBD | + +pseudocode: + + regs = [0u64; 128]; + vl = 0; + + // instruction fields: + rd = get_rd_field(); + rs1 = get_rs1_field(); + vlmax = get_immed_field(); + + // handle illegal instruction decoding + if vlmax > XLEN { + trap() + } + + // calculate VL + if rs1 == 0 { // rs1 is x0 + vl = vlmax + } else { + vl = min(regs[rs1], vlmax) + } + + // write rd + if rd != 0 { + // rd is not x0 + regs[rd] = vl + }