Implicit crop of vectors assigned to vector properties.
The %store/prop/v takes a width so that it is guaranteed that all assignments to a vector property will get the size right.
This commit is contained in:
parent
a98f21aa65
commit
9964d67e5e
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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} },
|
||||
|
|
|
|||
|
|
@ -1230,10 +1230,10 @@ variable given by the label.
|
|||
|
||||
See also %load/obj.
|
||||
|
||||
* %store/prop/obj <index>
|
||||
* %store/prop/r <index>
|
||||
* %store/prop/str <index>
|
||||
* %store/prop/v <index>
|
||||
* %store/prop/obj <pid>, <idx>
|
||||
* %store/prop/r <pid>
|
||||
* %store/prop/str <pid>
|
||||
* %store/prop/v <pid>, <wid>
|
||||
|
||||
The %store/prop/r pops a real value from the real stack and stores it
|
||||
into the the property number <pid> 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 <idx> 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 <pid> of the cobject in the top of the object stack. The
|
||||
vector is truncated to <wid> bits, and the cobject is NOT popped.
|
||||
|
||||
* %store/real <var-label>
|
||||
* %store/reala <var-label>, <index>
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <pid>
|
||||
*
|
||||
* Load a property <id> from the cobject on the top of the stack into
|
||||
* Load a property <pid> from the cobject on the top of the stack into
|
||||
* the vector space at <base>.
|
||||
*/
|
||||
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 <id>
|
||||
* %store/prop/v <pid>, <wid>
|
||||
*
|
||||
* Store vector value into property <id> of cobject in the top of the stack.
|
||||
* Store vector value into property <id> 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<vvp_cobject>();
|
||||
assert(cobj);
|
||||
|
|
|
|||
Loading…
Reference in New Issue