diff --git a/tgt-vvp/stmt_assign.c b/tgt-vvp/stmt_assign.c index d729d8efc..44af922ca 100644 --- a/tgt-vvp/stmt_assign.c +++ b/tgt-vvp/stmt_assign.c @@ -1015,6 +1015,7 @@ static int show_stmt_assign_sig_cobject(ivl_statement_t net) ivl_lval_t lval = ivl_stmt_lval(net, 0); ivl_expr_t rval = ivl_stmt_rval(net); ivl_signal_t sig= ivl_lval_sig(lval); + unsigned lwid = ivl_lval_width(lval); int prop_idx = ivl_lval_property_idx(lval); @@ -1031,8 +1032,8 @@ static int show_stmt_assign_sig_cobject(ivl_statement_t net) fprintf(vvp_out, " %%cast2;\n"); fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); - fprintf(vvp_out, " %%store/prop/v %d; Store in bool property %s\n", - prop_idx, ivl_type_prop_name(sig_type, prop_idx)); + fprintf(vvp_out, " %%store/prop/v %d, %u; Store in bool property %s\n", + prop_idx, lwid, ivl_type_prop_name(sig_type, prop_idx)); fprintf(vvp_out, " %%pop/obj 1, 0;\n"); } else if (ivl_type_base(prop_type) == IVL_VT_LOGIC) { @@ -1042,8 +1043,8 @@ static int show_stmt_assign_sig_cobject(ivl_statement_t net) draw_eval_vec4(rval, STUFF_OK_XZ); fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); - fprintf(vvp_out, " %%store/prop/v %d; Store in logic property %s\n", - prop_idx, ivl_type_prop_name(sig_type, prop_idx)); + fprintf(vvp_out, " %%store/prop/v %d, %u; Store in logic property %s\n", + prop_idx, lwid, ivl_type_prop_name(sig_type, prop_idx)); fprintf(vvp_out, " %%pop/obj 1, 0;\n"); } else if (ivl_type_base(prop_type) == IVL_VT_REAL) { diff --git a/vvp/compile.cc b/vvp/compile.cc index 6ad278995..3ccd97d68 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -270,10 +270,10 @@ static const struct opcode_table_s opcode_table[] = { { "%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/obja", of_STORE_OBJA, 2, {OA_ARR_PTR, OA_BIT1, OA_NONE} }, - { "%store/prop/obj",of_STORE_PROP_OBJ,1, {OA_NUMBER, OA_NONE, OA_NONE} }, + { "%store/prop/obj",of_STORE_PROP_OBJ,2, {OA_NUMBER, OA_BIT1, 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} }, - { "%store/prop/v", of_STORE_PROP_V, 1, {OA_NUMBER, OA_NONE, OA_NONE} }, + { "%store/prop/v", of_STORE_PROP_V, 2, {OA_NUMBER, OA_BIT1, OA_NONE} }, { "%store/qb/r", of_STORE_QB_R, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%store/qb/str", of_STORE_QB_STR, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%store/qf/r", of_STORE_QF_R, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index b9b0da07c..078526c07 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1230,10 +1230,10 @@ variable given by the label. See also %load/obj. -* %store/prop/obj -* %store/prop/r -* %store/prop/str -* %store/prop/v +* %store/prop/obj , +* %store/prop/r +* %store/prop/str +* %store/prop/v , The %store/prop/r pops a real value from the real stack and stores it into the the property number of a cobject in the top of the @@ -1246,6 +1246,10 @@ is the index register to select an element. If the property is an array, this selects the element. If is 0, then use the value 0 instead of index register zero. Use 0 for non-array properties. +The %store/prop/v pops a vector from the vec4 stack and stores it into +the property of the cobject in the top of the object stack. The +vector is truncated to bits, and the cobject is NOT popped. + * %store/real * %store/reala , diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 03b1bec13..2d90abdfc 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -2186,6 +2186,10 @@ bool of_CMPU(vthread_t thr, vvp_code_t cp) vvp_vector4_t rval = thr->pop_vec4(); vvp_vector4_t lval = thr->pop_vec4(); + if (rval.size() != lval.size()) { + cerr << "VVP ERROR: %cmp/u operand width mismatch: lval=" << lval + << ", rval=" << rval << endl; + } assert(rval.size() == lval.size()); unsigned wid = lval.size(); @@ -5256,7 +5260,7 @@ bool of_PROP_STR(vthread_t thr, vvp_code_t cp) /* * %prop/v * - * Load a property from the cobject on the top of the stack into + * Load a property from the cobject on the top of the stack into * the vector space at . */ bool of_PROP_V(vthread_t thr, vvp_code_t cp) @@ -6181,15 +6185,21 @@ bool of_STORE_PROP_STR(vthread_t thr, vvp_code_t cp) } /* - * %store/prop/v + * %store/prop/v , * - * Store vector value into property of cobject in the top of the stack. + * Store vector value into property of cobject in the top of the + * stack. Do NOT pop the object stack. */ bool of_STORE_PROP_V(vthread_t thr, vvp_code_t cp) { size_t pid = cp->number; + unsigned wid = cp->bit_idx[0]; + vvp_vector4_t val = thr->pop_vec4(); + assert(val.size() >= wid); + val.resize(wid); + vvp_object_t&obj = thr->peek_object(); vvp_cobject*cobj = obj.peek(); assert(cobj);