From: Luke Kenneth Casson Leighton Date: Thu, 5 Sep 2019 08:00:13 +0000 (+0100) Subject: add c code on daxpy X-Git-Tag: convert-csv-opcode-to-binary~4159 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2a4345c36c278109faeb648910d60d869f43d3ce;p=libreriscv.git add c code on daxpy --- diff --git a/simple_v_extension/daxpy_example.mdwn b/simple_v_extension/daxpy_example.mdwn index 587d9354a..3e26b25d4 100644 --- a/simple_v_extension/daxpy_example.mdwn +++ b/simple_v_extension/daxpy_example.mdwn @@ -1,6 +1,14 @@ - # a0 is n, a1 is ptr to x[0], a2 is ptr to y[0], fa0 is a - VBLK.REG[0] = {type: F, regkey: a3, regidx: a3, elwidth: dflt} - VBLK.REG[1] = {type: F, regkey: a7, regidx: a7, elwidth: dflt} + # c code + void daxpy(size_t n, double a, const double x[], double y[]) + { + for (size_t i = 0; i < n; i++) { + y[i] = a*x[i] + y[i]; + } + } + + # a0 is n, a1 is ptr to x[0], a2 is ptr to y[0], fa0 is a (scalar) + VBLK.REG[0] = {type: F, isvec: 1, regkey: a3, regidx: a3, elwidth: dflt} + VBLK.REG[1] = {type: F, isvec: 1, regkey: a7, regidx: a7, elwidth: dflt} VBLK.MVL = 4 loop: setvl t0, a0 # vl = t0 = min(a0, MVL))