Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove vector of bools in vext #622

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
166 changes: 83 additions & 83 deletions model/riscv_insts_vext_arith.sail

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions model/riscv_insts_vext_fp.sail
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function clause execute(FVVTYPE(funct6, vm, vs2, vs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs1_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
Expand All @@ -51,7 +51,7 @@ function clause execute(FVVTYPE(funct6, vm, vs2, vs1, vd)) = {
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FVV_VADD => fp_add(rm_3b, vs2_val[i], vs1_val[i]),
FVV_VSUB => fp_sub(rm_3b, vs2_val[i], vs1_val[i]),
Expand Down Expand Up @@ -116,7 +116,7 @@ function clause execute(FVVMATYPE(funct6, vm, vs2, vs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs1_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
Expand All @@ -125,7 +125,7 @@ function clause execute(FVVMATYPE(funct6, vm, vs2, vs1, vd)) = {
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FVV_VMACC => fp_muladd(rm_3b, vs1_val[i], vs2_val[i], vd_val[i]),
FVV_VNMACC => fp_nmulsub(rm_3b, vs1_val[i], vs2_val[i], vd_val[i]),
Expand Down Expand Up @@ -188,7 +188,7 @@ function clause execute(FWVVTYPE(funct6, vm, vs2, vs1, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
Expand All @@ -197,7 +197,7 @@ function clause execute(FWVVTYPE(funct6, vm, vs2, vs1, vd)) = {
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWVV_VADD => fp_add(rm_3b, fp_widen(vs2_val[i]), fp_widen(vs1_val[i])),
FWVV_VSUB => fp_sub(rm_3b, fp_widen(vs2_val[i]), fp_widen(vs1_val[i])),
Expand Down Expand Up @@ -252,7 +252,7 @@ function clause execute(FWVVMATYPE(funct6, vm, vs1, vs2, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
Expand All @@ -261,7 +261,7 @@ function clause execute(FWVVMATYPE(funct6, vm, vs1, vs2, vd)) = {
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWVV_VMACC => fp_muladd(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]),
FWVV_VNMACC => fp_nmulsub(rm_3b, fp_widen(vs1_val[i]), fp_widen(vs2_val[i]), vd_val[i]),
Expand Down Expand Up @@ -314,7 +314,7 @@ function clause execute(FWVTYPE(funct6, vm, vs2, vs1, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);
Expand All @@ -323,7 +323,7 @@ function clause execute(FWVTYPE(funct6, vm, vs2, vs1, vd)) = {
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWV_VADD => fp_add(rm_3b, vs2_val[i], fp_widen(vs1_val[i])),
FWV_VSUB => fp_sub(rm_3b, vs2_val[i], fp_widen(vs1_val[i]))
Expand Down Expand Up @@ -371,15 +371,15 @@ function clause execute(VFUNARY0(vm, vs2, vfunary0, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match vfunary0 {
FV_CVT_XU_F => {
let (fflags, elem) : (bits_fflags, bits('m)) = match 'm {
Expand Down Expand Up @@ -489,15 +489,15 @@ function clause execute(VFWUNARY0(vm, vs2, vfwunary0, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match vfwunary0 {
FWV_CVT_XU_F => {
let (fflags, elem) : (bits_fflags, bits('o)) = match 'm {
Expand Down Expand Up @@ -618,15 +618,15 @@ function clause execute(VFNUNARY0(vm, vs2, vfnunary0, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match vfnunary0 {
FNV_CVT_XU_F => {
let (fflags, elem) : (bits_fflags, bits('m)) = match 'm {
Expand Down Expand Up @@ -748,15 +748,15 @@ function clause execute(VFUNARY1(vm, vs2, vfunary1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match vfunary1 {
FVV_VSQRT => {
let (fflags, elem) : (bits_fflags, bits('m)) = match 'm {
Expand Down Expand Up @@ -871,16 +871,16 @@ function clause execute(FVFTYPE(funct6, vm, vs2, rs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
VF_VADD => fp_add(rm_3b, vs2_val[i], rs1_val),
VF_VSUB => fp_sub(rm_3b, vs2_val[i], rs1_val),
Expand Down Expand Up @@ -960,16 +960,16 @@ function clause execute(FVFMATYPE(funct6, vm, vs2, rs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
VF_VMACC => fp_muladd(rm_3b, rs1_val, vs2_val[i], vd_val[i]),
VF_VNMACC => fp_nmulsub(rm_3b, rs1_val, vs2_val[i], vd_val[i]),
Expand Down Expand Up @@ -1031,16 +1031,16 @@ function clause execute(FWVFTYPE(funct6, vm, vs2, rs1, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);

let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWVF_VADD => fp_add(rm_3b, fp_widen(vs2_val[i]), fp_widen(rs1_val)),
FWVF_VSUB => fp_sub(rm_3b, fp_widen(vs2_val[i]), fp_widen(rs1_val)),
Expand Down Expand Up @@ -1094,16 +1094,16 @@ function clause execute(FWVFMATYPE(funct6, vm, rs1, vs2, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);

let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWVF_VMACC => fp_muladd(rm_3b, fp_widen(rs1_val), fp_widen(vs2_val[i]), vd_val[i]),
FWVF_VNMACC => fp_nmulsub(rm_3b, fp_widen(rs1_val), fp_widen(vs2_val[i]), vd_val[i]),
Expand Down Expand Up @@ -1155,16 +1155,16 @@ function clause execute(FWFTYPE(funct6, vm, vs2, rs1, vd)) = {
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);

let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
if mask[i] == bitone then {
result[i] = match funct6 {
FWF_VADD => fp_add(rm_3b, vs2_val[i], fp_widen(rs1_val)),
FWF_VSUB => fp_sub(rm_3b, vs2_val[i], fp_widen(rs1_val))
Expand Down Expand Up @@ -1207,8 +1207,8 @@ function clause execute(VFMERGE(vs2, rs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, 0b0, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : bits('n) = read_vmask(num_elem, 0b0, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, bits('m)) = vector_init(zeros());
Expand All @@ -1224,7 +1224,7 @@ function clause execute(VFMERGE(vs2, rs1, vd)) = {
}
} else {
/* the merge operates on all body elements */
result[i] = if vm_val[i] then rs1_val else vs2_val[i]
result[i] = if vm_val[i] == bitone then rs1_val else vs2_val[i]
}
};

Expand Down Expand Up @@ -1255,15 +1255,15 @@ function clause execute(VFMV(rs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : vector('n, bool) = read_vmask(num_elem, 0b1, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : bits('n) = read_vmask(num_elem, 0b1, 0b00000);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then result[i] = rs1_val
if mask[i] == bitone then result[i] = rs1_val
};

write_vreg(num_elem, SEW, LMUL_pow, vd, result);
Expand Down Expand Up @@ -1291,15 +1291,15 @@ function clause execute(VFMVSF(rs1, vd)) = {
let 'n = num_elem;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem, 0b1, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : bits('n) = read_vmask(num_elem, 0b1, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vd_val : vector('n, bits('m)) = read_vreg(num_elem, SEW, 0, vd);

let (initial_result, mask) = init_masked_result(num_elem, SEW, 0, vd_val, vm_val);
var result = initial_result;

/* one body element */
if mask[0] then result[0] = rs1_val;
if mask[0] == bitone then result[0] = rs1_val;

/* others treated as tail elements */
let tail_ag : agtype = get_vtype_vta();
Expand Down
16 changes: 8 additions & 8 deletions model/riscv_insts_vext_fp_red.sail
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mapping encdec_rfvvfunct6 : rfvvfunct6 <-> bits(6) = {
mapping clause encdec = RFVVTYPE(funct6, vm, vs2, vs1, vd) if extensionEnabled(Ext_V)
<-> encdec_rfvvfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if extensionEnabled(Ext_V)

val process_rfvv_single: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
val process_rfvv_single: forall 'n 'm 'p, 'n > 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_pow) = {
let rm_3b = fcsr[FRM];
let num_elem_vd = get_num_elem(0, SEW); /* vd regardless of LMUL setting */
Expand All @@ -40,14 +40,14 @@ function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_po
let 'd = num_elem_vd;
let 'm = SEW;

let vm_val : vector('n, bool) = read_vmask(num_elem_vs, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem_vs, vm, 0b00000);
let vd_val : vector('d, bits('m)) = read_vreg(num_elem_vd, SEW, 0, vd);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem_vs, SEW, LMUL_pow, vs2);
let mask : vector('n, bool) = init_masked_source(num_elem_vs, LMUL_pow, vm_val);
let mask : bits('n) = init_masked_source(num_elem_vs, LMUL_pow, vm_val);

var sum : bits('m) = read_single_element(SEW, 0, vs1); /* vs1 regardless of LMUL setting */
foreach (i from 0 to (num_elem_vs - 1)) {
if mask[i] then {
if mask[i] == bitone then {
sum = match funct6 {
/* currently ordered/unordered sum reductions do the same operations */
FVV_VFREDOSUM => fp_add(rm_3b, sum, vs2_val[i]),
Expand All @@ -66,7 +66,7 @@ function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_po
RETIRE_SUCCESS
}

val process_rfvv_widen: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
val process_rfvv_widen: forall 'n 'm 'p, 'n > 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
function process_rfvv_widen(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_pow) = {
let rm_3b = fcsr[FRM];
let SEW_widen = SEW * 2;
Expand All @@ -83,14 +83,14 @@ function process_rfvv_widen(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_pow
let 'm = SEW;
let 'o = SEW_widen;

let vm_val : vector('n, bool) = read_vmask(num_elem_vs, vm, 0b00000);
let vm_val : bits('n) = read_vmask(num_elem_vs, vm, 0b00000);
let vd_val : vector('d, bits('o)) = read_vreg(num_elem_vd, SEW_widen, 0, vd);
let vs2_val : vector('n, bits('m)) = read_vreg(num_elem_vs, SEW, LMUL_pow, vs2);
let mask : vector('n, bool) = init_masked_source(num_elem_vs, LMUL_pow, vm_val);
let mask : bits('n) = init_masked_source(num_elem_vs, LMUL_pow, vm_val);

var sum : bits('o) = read_single_element(SEW_widen, 0, vs1); /* vs1 regardless of LMUL setting */
foreach (i from 0 to (num_elem_vs - 1)) {
if mask[i] then {
if mask[i] == bitone then {
/* currently ordered/unordered sum reductions do the same operations */
sum = fp_add(rm_3b, sum, fp_widen(vs2_val[i]))
}
Expand Down
Loading
Loading