Add support for logic vector properties in classes.
This is similar to but not the same as bit(bool) vector properties in classes.
This commit is contained in:
parent
fbc5557a10
commit
637d43fb5a
|
|
@ -872,7 +872,23 @@ static int show_stmt_assign_sig_cobject(ivl_statement_t net)
|
|||
struct vector_info val = draw_eval_expr_wid(rval, wid, STUFF_OK_XZ);
|
||||
|
||||
fprintf(vvp_out, " %%load/obj v%p_0;\n", sig);
|
||||
fprintf(vvp_out, " %%store/prop/v %d, %u, %u;\n", prop_idx, val.base, val.wid);
|
||||
fprintf(vvp_out, " %%store/prop/v %d, %u, %u; Store in bool property %s\n",
|
||||
prop_idx, val.base, val.wid,
|
||||
ivl_type_prop_name(sig_type, prop_idx));
|
||||
fprintf(vvp_out, " %%pop/obj 1;\n");
|
||||
clr_vector(val);
|
||||
|
||||
} else if (ivl_type_base(prop_type) == IVL_VT_LOGIC) {
|
||||
assert(ivl_type_packed_dimensions(prop_type) == 1);
|
||||
assert(ivl_type_packed_msb(prop_type,0) >= ivl_type_packed_lsb(prop_type, 0));
|
||||
int wid = ivl_type_packed_msb(prop_type,0) - ivl_type_packed_lsb(prop_type,0) + 1;
|
||||
|
||||
struct vector_info val = draw_eval_expr_wid(rval, wid, STUFF_OK_XZ);
|
||||
|
||||
fprintf(vvp_out, " %%load/obj v%p_0;\n", sig);
|
||||
fprintf(vvp_out, " %%store/prop/v %d, %u, %u; Store in logic property %s\n",
|
||||
prop_idx, val.base, val.wid,
|
||||
ivl_type_prop_name(sig_type, prop_idx));
|
||||
fprintf(vvp_out, " %%pop/obj 1;\n");
|
||||
clr_vector(val);
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,31 @@ class property_bit : public class_property_t {
|
|||
size_t wid_;
|
||||
};
|
||||
|
||||
class property_logic : public class_property_t {
|
||||
public:
|
||||
inline property_logic(size_t wid): wid_(wid) { }
|
||||
~property_logic() { }
|
||||
|
||||
size_t instance_size() const { return sizeof(vvp_vector4_t); }
|
||||
|
||||
public:
|
||||
void construct(char*buf) const
|
||||
{ new (buf+offset_) vvp_vector4_t (0, wid_); }
|
||||
|
||||
void destruct(char*buf) const
|
||||
{ vvp_vector4_t*tmp = reinterpret_cast<vvp_vector4_t*>(buf+offset_);
|
||||
tmp->~vvp_vector4_t();
|
||||
}
|
||||
|
||||
void set_vec4(char*buf, const vvp_vector4_t&val);
|
||||
void get_vec4(char*buf, vvp_vector4_t&val);
|
||||
|
||||
void copy(char*dst, char*src);
|
||||
|
||||
private:
|
||||
size_t wid_;
|
||||
};
|
||||
|
||||
template <class T> class property_real : public class_property_t {
|
||||
public:
|
||||
inline explicit property_real(void) { }
|
||||
|
|
@ -278,6 +303,25 @@ void property_bit::copy(char*dst, char*src)
|
|||
*dst_obj = *src_obj;
|
||||
}
|
||||
|
||||
void property_logic::set_vec4(char*buf, const vvp_vector4_t&val)
|
||||
{
|
||||
vvp_vector4_t*obj = reinterpret_cast<vvp_vector4_t*> (buf+offset_);
|
||||
*obj = val;
|
||||
}
|
||||
|
||||
void property_logic::get_vec4(char*buf, vvp_vector4_t&val)
|
||||
{
|
||||
vvp_vector4_t*obj = reinterpret_cast<vvp_vector4_t*> (buf+offset_);
|
||||
val = *obj;
|
||||
}
|
||||
|
||||
void property_logic::copy(char*dst, char*src)
|
||||
{
|
||||
vvp_vector4_t*dst_obj = reinterpret_cast<vvp_vector4_t*> (dst+offset_);
|
||||
vvp_vector4_t*src_obj = reinterpret_cast<vvp_vector4_t*> (src+offset_);
|
||||
*dst_obj = *src_obj;
|
||||
}
|
||||
|
||||
template <class T> void property_real<T>::set_real(char*buf, double val)
|
||||
{
|
||||
T*tmp = reinterpret_cast<T*>(buf+offset_);
|
||||
|
|
@ -373,6 +417,9 @@ void class_type::set_property(size_t idx, const string&name, const string&type)
|
|||
else if (type[0] == 'b') {
|
||||
size_t wid = strtoul(type.c_str()+1, 0, 0);
|
||||
properties_[idx].type = new property_bit(wid);
|
||||
} else if (type[0] == 'L') {
|
||||
size_t wid = strtoul(type.c_str()+1,0,0);
|
||||
properties_[idx].type = new property_logic(wid);
|
||||
} else {
|
||||
properties_[idx].type = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue