Pass structural constant string information to the ivl interface.

This patch adds code to the compiler so that a constant string
in a structural context can maintain the string property. This
is needed but not currently implemented in vvp (it's still
converted to a number). A pending patch for the vlog95 target
does use this new information.
This commit is contained in:
Cary R 2011-04-18 11:07:41 -07:00 committed by Stephen Williams
parent 12df29af55
commit 56b04891e0
5 changed files with 17 additions and 1 deletions

View File

@ -1876,6 +1876,7 @@ NetConst::NetConst(NetScope*s, perm_string n, verinum::V v)
pin(0).set_dir(Link::OUTPUT);
value_ = new verinum::V[1];
value_[0] = v;
is_string_ = false;
}
NetConst::NetConst(NetScope*s, perm_string n, const verinum&val)
@ -1886,6 +1887,7 @@ NetConst::NetConst(NetScope*s, perm_string n, const verinum&val)
for (unsigned idx = 0 ; idx < width_ ; idx += 1) {
value_[idx] = val.get(idx);
}
is_string_ = val.is_string();
}
NetConst::~NetConst()
@ -1904,6 +1906,11 @@ unsigned NetConst::width() const
return width_;
}
bool NetConst::is_string() const
{
return is_string_;
}
NetFuncDef::NetFuncDef(NetScope*s, NetNet*result, const svector<NetNet*>&po)
: scope_(s), statement_(0), result_sig_(result), ports_(po)
{

View File

@ -1969,6 +1969,7 @@ class NetConst : public NetNode {
verinum::V value(unsigned idx) const;
unsigned width() const;
bool is_string() const;
virtual bool emit_node(struct target_t*) const;
virtual void functor_node(Design*, functor_t*);
@ -1977,6 +1978,7 @@ class NetConst : public NetNode {
private:
unsigned width_;
verinum::V*value_;
bool is_string_;
};
/*

View File

@ -170,6 +170,7 @@ extern "C" const char*ivl_const_bits(ivl_net_const_t net)
case IVL_VT_BOOL:
case IVL_VT_LOGIC:
case IVL_VT_STRING:
if (net->width_ <= sizeof(net->b.bit_))
return net->b.bit_;
else

View File

@ -2164,7 +2164,10 @@ bool dll_target::net_const(const NetConst*net)
struct ivl_net_const_s *obj = new struct ivl_net_const_s;
obj->type = IVL_VT_BOOL;
if (net->is_string()) {
obj->type = IVL_VT_STRING;
assert((net->width() % 8) == 0);
} else obj->type = IVL_VT_BOOL;
assert(net->scope());
obj->scope = find_scope(des_, net->scope());
FILE_NAME(obj, net);
@ -2197,11 +2200,13 @@ bool dll_target::net_const(const NetConst*net)
if (obj->type == IVL_VT_BOOL)
obj->type = IVL_VT_LOGIC;
bits[idx] = 'x';
assert(! net->is_string());
break;
case verinum::Vz:
if (obj->type == IVL_VT_BOOL)
obj->type = IVL_VT_LOGIC;
bits[idx] = 'z';
assert(! net->is_string());
break;
}

View File

@ -385,6 +385,7 @@ static char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr)
switch (ivl_const_type(cptr)) {
case IVL_VT_LOGIC:
case IVL_VT_BOOL:
case IVL_VT_STRING:
if ((ivl_nexus_ptr_drive0(nptr) == IVL_DR_STRONG)
&& (ivl_nexus_ptr_drive1(nptr) == IVL_DR_STRONG)) {