diff --git a/tgt-vvp/eval_vec4.c b/tgt-vvp/eval_vec4.c index 2274e5bae..51dbdc424 100644 --- a/tgt-vvp/eval_vec4.c +++ b/tgt-vvp/eval_vec4.c @@ -618,6 +618,18 @@ static void draw_select_vec4(ivl_expr_t expr) return; } + if (ivl_expr_value(subexpr)==IVL_VT_DARRAY) { + ivl_signal_t sig = ivl_expr_signal(subexpr); + assert(sig); + assert(ivl_signal_data_type(sig)==IVL_VT_DARRAY); + + assert(base); + draw_eval_expr_into_integer(base, 3); + fprintf(vvp_out, " %%load/dar/vec4 v%p_0;\n", sig); + + return; + } + draw_eval_vec4(subexpr, 0); draw_eval_vec4(base, 0); fprintf(vvp_out, " %%part/%c %u;\n", sign_suff, wid); diff --git a/tgt-vvp/stmt_assign.c b/tgt-vvp/stmt_assign.c index 906a77475..665feb4b3 100644 --- a/tgt-vvp/stmt_assign.c +++ b/tgt-vvp/stmt_assign.c @@ -941,16 +941,13 @@ static int show_stmt_assign_sig_darray(ivl_statement_t net) fprintf(vvp_out, " %%store/dar/str v%p_0;\n", var); } else if (mux) { - struct vector_info rvec = draw_eval_expr_wid(rval, ivl_lval_width(lval), - STUFF_OK_XZ); - /* The %set/dar expects the array index to be in index + draw_eval_vec4(rval, STUFF_OK_XZ); + + /* The %store/dar/vec4 expects the array index to be in index register 3. Calculate the index in place. */ draw_eval_expr_into_integer(mux, 3); - fprintf(vvp_out, " %%set/dar v%p_0, %u, %u;\n", - var, rvec.base, rvec.wid); - - if (rvec.base >= 4) clr_vector(rvec); + fprintf(vvp_out, " %%store/dar/vec4 v%p_0;\n", var); } else if (ivl_expr_type(rval) == IVL_EX_ARRAY_PATTERN) { /* There is no l-value mux, but the r-value is an array diff --git a/vvp/codes.h b/vvp/codes.h index ef7b3b6ed..4abf29152 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -141,10 +141,10 @@ extern bool of_LOAD_AV(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AVP0(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AVP0_S(vthread_t thr, vvp_code_t code); extern bool of_LOAD_AVX_P(vthread_t thr, vvp_code_t code); -extern bool of_LOAD_DAR(vthread_t thr, vvp_code_t code); extern bool of_LOAD_REAL(vthread_t thr, vvp_code_t code); extern bool of_LOAD_DAR_R(vthread_t thr, vvp_code_t code); extern bool of_LOAD_DAR_STR(vthread_t thr, vvp_code_t code); +extern bool of_LOAD_DAR_VEC4(vthread_t thr, vvp_code_t code); extern bool of_LOAD_OBJ(vthread_t thr, vvp_code_t code); extern bool of_LOAD_STR(vthread_t thr, vvp_code_t code); extern bool of_LOAD_STRA(vthread_t thr, vvp_code_t code); @@ -212,6 +212,7 @@ extern bool of_SHIFTR_S(vthread_t thr, vvp_code_t code); extern bool of_SPLIT_VEC4(vthread_t thr, vvp_code_t code); extern bool of_STORE_DAR_R(vthread_t thr, vvp_code_t code); extern bool of_STORE_DAR_STR(vthread_t thr, vvp_code_t code); +extern bool of_STORE_DAR_VEC4(vthread_t thr, vvp_code_t code); extern bool of_STORE_OBJ(vthread_t thr, vvp_code_t code); extern bool of_STORE_PROP_OBJ(vthread_t thr, vvp_code_t code); extern bool of_STORE_PROP_R(vthread_t thr, vvp_code_t code); diff --git a/vvp/compile.cc b/vvp/compile.cc index f9d1c6156..4710e9505 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -189,9 +189,9 @@ static const struct opcode_table_s opcode_table[] = { { "%load/avp0",of_LOAD_AVP0,3, {OA_BIT1, OA_ARR_PTR, OA_BIT2} }, { "%load/avp0/s",of_LOAD_AVP0_S,3,{OA_BIT1,OA_ARR_PTR, OA_BIT2} }, { "%load/avx.p",of_LOAD_AVX_P,3,{OA_BIT1, OA_ARR_PTR, OA_BIT2} }, - { "%load/dar",of_LOAD_DAR,3,{OA_BIT1, OA_FUNC_PTR, OA_BIT2} }, - { "%load/dar/r", of_LOAD_DAR_R, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE}}, - { "%load/dar/str",of_LOAD_DAR_STR, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, + { "%load/dar/r", of_LOAD_DAR_R, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE}}, + { "%load/dar/str",of_LOAD_DAR_STR, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, + { "%load/dar/vec4",of_LOAD_DAR_VEC4,1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%load/obj", of_LOAD_OBJ, 1,{OA_FUNC_PTR,OA_NONE, OA_NONE} }, { "%load/real", of_LOAD_REAL, 1,{OA_VPI_PTR, OA_NONE, OA_NONE} }, { "%load/str", of_LOAD_STR, 1,{OA_FUNC_PTR,OA_NONE, OA_NONE} }, @@ -256,10 +256,11 @@ static const struct opcode_table_s opcode_table[] = { { "%shiftl", of_SHIFTL, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, { "%shiftr", of_SHIFTR, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, { "%shiftr/s", of_SHIFTR_S, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, - { "%split/vec4", of_SPLIT_VEC4, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, - { "%store/dar/r", of_STORE_DAR_R, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, - { "%store/dar/str",of_STORE_DAR_STR, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, - { "%store/obj", of_STORE_OBJ, 1, {OA_FUNC_PTR,OA_NONE, OA_NONE} }, + { "%split/vec4", of_SPLIT_VEC4, 1,{OA_NUMBER, OA_NONE, OA_NONE} }, + { "%store/dar/r", of_STORE_DAR_R, 1,{OA_FUNC_PTR, OA_NONE, OA_NONE} }, + { "%store/dar/str", of_STORE_DAR_STR, 1,{OA_FUNC_PTR, OA_NONE, OA_NONE} }, + { "%store/dar/vec4",of_STORE_DAR_VEC4,1,{OA_FUNC_PTR, OA_NONE, OA_NONE} }, + { "%store/obj", of_STORE_OBJ, 1,{OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%store/prop/obj",of_STORE_PROP_OBJ,1, {OA_NUMBER, OA_NONE, OA_NONE} }, { "%store/prop/r", of_STORE_PROP_R, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, { "%store/prop/str",of_STORE_PROP_STR,1, {OA_NUMBER, OA_NONE, OA_NONE} }, diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index df1243750..dca25bb85 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -741,8 +741,7 @@ bit, and the is the selector for the bit to use. If is out of range, then x is loaded. The index value is incremented by one if it is defined (bit 4 is not 1). -* %load/dar , , -* %load/dar/r +* %load/dar , , (XXXX Old implementation) This instruction loads an array word from a dynamic array. The