From 9b2c6a636d63e58ca3a9ab24193a47267d16bcef Mon Sep 17 00:00:00 2001 From: Jennifer Dupaquier <11723765+jmawet@users.noreply.github.com> Date: Sat, 1 Feb 2025 23:06:42 +0000 Subject: [PATCH 1/2] complete czero instructions --- arch/inst/Zicond/czero.eqz.yaml | 18 +++++++++++++++--- arch/inst/Zicond/czero.nez.yaml | 16 ++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/inst/Zicond/czero.eqz.yaml b/arch/inst/Zicond/czero.eqz.yaml index 63e65aa53..8afd6fcc5 100644 --- a/arch/inst/Zicond/czero.eqz.yaml +++ b/arch/inst/Zicond/czero.eqz.yaml @@ -3,9 +3,12 @@ $schema: "inst_schema.json#" kind: instruction name: czero.eqz -long_name: No synopsis available. +long_name: Conditional zero, if condition is equal to zero. description: | - No description available. + If rs2 contains the value zero, this instruction writes the value zero to rd. Otherwise, this instruction + copies the contents of rs1 to rd. + This instruction carries a syntactic dependency from both rs1 and rs2 to rd. Furthermore, if the Zkt + extension is implemented, this instruction’s timing is independent of the data values in rs1 and rs2.. definedBy: Zicond assembly: xd, xs1, xs2 encoding: @@ -24,12 +27,21 @@ access: vu: always data_independent_timing: false operation(): | + XReg input1 = X[rs1]; + XReg input2 = X[rs2]; + XReg output = 0; + + if(input2 != 0) { + output = input1; + } + + X[rd] = output; sail(): | { let value = X(rs1); let condition = X(rs2); - let result : xlenbits = if (condition != zeros()) then zeros() + let result : xlenbits = if (condition == zeros()) then zeros() else value; X(rd) = result; RETIRE_SUCCESS diff --git a/arch/inst/Zicond/czero.nez.yaml b/arch/inst/Zicond/czero.nez.yaml index f3824848a..17338729d 100644 --- a/arch/inst/Zicond/czero.nez.yaml +++ b/arch/inst/Zicond/czero.nez.yaml @@ -3,9 +3,12 @@ $schema: "inst_schema.json#" kind: instruction name: czero.nez -long_name: No synopsis available. +long_name: Conditional zero, if condition is nonzero. description: | - No description available. + If rs2 contains a nonzero value, this instruction writes the value zero to rd. Otherwise, this + instruction copies the contents of rs1 to rd. + This instruction carries a syntactic dependency from both rs1 and rs2 to rd. Furthermore, if the Zkt + extension is implemented, this instruction’s timing is independent of the data values in rs1 and rs2. definedBy: Zicond assembly: xd, xs1, xs2 encoding: @@ -24,6 +27,15 @@ access: vu: always data_independent_timing: false operation(): | + XReg input1 = X[rs1]; + XReg input2 = X[rs2]; + XReg output = 0; + + if(input2 == 0) { + output = input1; + } + + X[rd] = output; sail(): | { From 38633e95c0c18bfbbece0635b2b9d086d8bf5301 Mon Sep 17 00:00:00 2001 From: Jennifer Dupaquier <11723765+jmawet@users.noreply.github.com> Date: Tue, 4 Feb 2025 03:04:48 +0000 Subject: [PATCH 2/2] syntax and style change --- arch/inst/Zicond/czero.eqz.yaml | 12 ++---------- arch/inst/Zicond/czero.nez.yaml | 10 +--------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/arch/inst/Zicond/czero.eqz.yaml b/arch/inst/Zicond/czero.eqz.yaml index 8afd6fcc5..63bdc5a6b 100644 --- a/arch/inst/Zicond/czero.eqz.yaml +++ b/arch/inst/Zicond/czero.eqz.yaml @@ -8,7 +8,7 @@ description: | If rs2 contains the value zero, this instruction writes the value zero to rd. Otherwise, this instruction copies the contents of rs1 to rd. This instruction carries a syntactic dependency from both rs1 and rs2 to rd. Furthermore, if the Zkt - extension is implemented, this instruction’s timing is independent of the data values in rs1 and rs2.. + extension is implemented, this instruction’s timing is independent of the data values in rs1 and rs2. definedBy: Zicond assembly: xd, xs1, xs2 encoding: @@ -27,15 +27,7 @@ access: vu: always data_independent_timing: false operation(): | - XReg input1 = X[rs1]; - XReg input2 = X[rs2]; - XReg output = 0; - - if(input2 != 0) { - output = input1; - } - - X[rd] = output; + X[rd] = (X[rs2] == 0) ? 0 : X[rs1]; sail(): | { diff --git a/arch/inst/Zicond/czero.nez.yaml b/arch/inst/Zicond/czero.nez.yaml index 17338729d..1e969a605 100644 --- a/arch/inst/Zicond/czero.nez.yaml +++ b/arch/inst/Zicond/czero.nez.yaml @@ -27,15 +27,7 @@ access: vu: always data_independent_timing: false operation(): | - XReg input1 = X[rs1]; - XReg input2 = X[rs2]; - XReg output = 0; - - if(input2 == 0) { - output = input1; - } - - X[rd] = output; + X[rd] = (X[rs2] != 0) ? 0 : X[rs1]; sail(): | {