From 08da70a8a63ae83ec33e3f6e640fb2dc6fcb47dc Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 26 Jun 2019 09:24:28 +0100 Subject: [PATCH] add pseudocode to setvl --- .../specification/sv.setvl.mdwn | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 + } -- 2.30.2