qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] target/riscv: Lower bound of VLEN is 32, and check VLEN


From: Weiwei Li
Subject: Re: [PATCH 1/2] target/riscv: Lower bound of VLEN is 32, and check VLEN >= ELEN
Date: Sat, 9 Jul 2022 17:48:31 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0


在 2022/7/8 下午3:39, Kito Cheng 写道:
According RVV spec 1.0, the minmal requirement of VLEN is great than or
equal to ELEN, and minmal possible ELEN is 32, and also spec has mention
`Minimum VLEN` for zve32* is 32, so the lower bound of VLEN is 32 I
think.

[1] 
https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#2-implementation-defined-constant-parameters
[2] 
https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#182-zve-vector-extensions-for-embedded-processors

Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
---
  target/riscv/cpu.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 1bb3973806..487d0faa63 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -740,10 +740,10 @@ static void riscv_cpu_realize(DeviceState *dev, Error 
**errp)
                          "Vector extension VLEN must be power of 2");
                  return;
              }
-            if (cpu->cfg.vlen > RV_VLEN_MAX || cpu->cfg.vlen < 128) {
+            if (cpu->cfg.vlen > RV_VLEN_MAX || cpu->cfg.vlen < 32) {
                  error_setg(errp,
                          "Vector extension implementation only supports VLEN "
-                        "in the range [128, %d]", RV_VLEN_MAX);
+                        "in the range [32, %d]", RV_VLEN_MAX);
                  return;
              }

The check for "VLEN in the range [128, RV_VLEN_MAX]" seems right here, since this check is for

V vector extension in current implementation and  "The V vector extension requires Zvl128b"(in section 18.3).

Regards,

Weiwei Li

              if (!is_power_of_2(cpu->cfg.elen)) {
@@ -757,6 +757,12 @@ static void riscv_cpu_realize(DeviceState *dev, Error 
**errp)
                          "in the range [8, 64]");
                  return;
              }
+            if (cpu->cfg.vlen < cpu->cfg.elen) {
+                error_setg(errp,
+                        "Vector extension VLEN must be greater than or equal "
+                        "to ELEN");
+                return;
+            }
              if (cpu->cfg.vext_spec) {
                  if (!g_strcmp0(cpu->cfg.vext_spec, "v1.0")) {
                      vext_version = VEXT_VERSION_1_00_0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]