diff --git a/design_dump.cc b/design_dump.cc index 758505417..a6cf069d1 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: design_dump.cc,v 1.98 2000/09/26 01:35:42 steve Exp $" +#ident "$Id: design_dump.cc,v 1.99 2000/10/06 23:46:50 steve Exp $" #endif /* @@ -74,8 +74,8 @@ void NetNet::dump_net(ostream&o, unsigned ind) const if (local_flag_) o << " (local)"; o << " (eref=" << get_eref() << ")"; - if (scope_) - o << " scope=" << scope_->name(); + if (scope()) + o << " scope=" << scope()->name(); o << " #(" << rise_time() << "," << fall_time() << "," << decay_time() << ") init="; for (unsigned idx = pin_count() ; idx > 0 ; idx -= 1) @@ -971,6 +971,11 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.99 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.98 2000/09/26 01:35:42 steve * Remove the obsolete NetEIdent class. * diff --git a/ivl_target.h b/ivl_target.h index 38852288d..3d29b541e 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: ivl_target.h,v 1.15 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: ivl_target.h,v 1.16 2000/10/06 23:46:50 steve Exp $" #endif #ifdef __cplusplus @@ -78,7 +78,9 @@ _BEGIN_DECL * or always statements from the verilog source. * * ivl_scope_t - * Elaborated scopes within a design are represented by this type. + * Elaborated scopes within a design are represented by this + * type. Objects of this type also act as containers for scoped + * objects such as signals. * * ivl_statement_t * Statements within processes are represented by one of these. The @@ -91,6 +93,10 @@ _BEGIN_DECL * that returns a "char*". The latter is a pointer to the least * significant bit value. Bit values are represented by the characters * '0', '1', 'x' and 'z'. Strengths are stored elsewhere. + * + * -- A Note About Names -- + * The names of objects are complete, hierarchical names. That is, + * they include the instance name of the module that contains them. */ typedef struct ivl_design_s *ivl_design_t; typedef struct ivl_expr_s *ivl_expr_t; @@ -234,7 +240,7 @@ extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net); extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net); /* any expression */ extern int ivl_expr_signed(ivl_expr_t net); - /* */ + /* IVL_EX_STRING */ extern const char* ivl_expr_string(ivl_expr_t net); /* any expression */ extern unsigned ivl_expr_width(ivl_expr_t net); @@ -318,12 +324,16 @@ extern ivl_statement_t ivl_stmt_cond_false(ivl_statement_t net); extern ivl_statement_t ivl_stmt_cond_true(ivl_statement_t net); /* IVL_ST_DELAY */ extern unsigned long ivl_stmt_delay_val(ivl_statement_t net); + /* IVL_ST_ASSIGN */ +extern unsigned ivl_stmt_lwidth(ivl_statement_t net); /* IVL_ST_STASK */ extern const char* ivl_stmt_name(ivl_statement_t net); /* IVL_ST_STASK */ extern ivl_expr_t ivl_stmt_parm(ivl_statement_t net, unsigned idx); /* IVL_ST_STASK */ extern unsigned ivl_stmt_parm_count(ivl_statement_t net); + /* IVL_ST_ASSIGN */ +extern ivl_expr_t ivl_stmt_rval(ivl_statement_t net); /* IVL_ST_DELAY, IVL_ST_WAIT, IVL_ST_WHILE */ extern ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net); @@ -433,6 +443,11 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.16 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.15 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/net_link.cc b/net_link.cc index bbb87d164..e2295a051 100644 --- a/net_link.cc +++ b/net_link.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_link.cc,v 1.3 2000/08/26 00:54:03 steve Exp $" +#ident "$Id: net_link.cc,v 1.4 2000/10/06 23:46:50 steve Exp $" #endif # include "netlist.h" @@ -200,6 +200,7 @@ Nexus::Nexus() { name_ = 0; list_ = 0; + t_cookie_ = 0; } Nexus::~Nexus() @@ -274,6 +275,18 @@ const Link* Nexus::first_nlink() const return list_; } +void* Nexus::t_cookie() const +{ + return t_cookie_; +} + +void* Nexus::t_cookie(void*val)const +{ + void*tmp = t_cookie_; + t_cookie_ = val; + return tmp; +} + const char* Nexus::name() const { if (name_) @@ -337,6 +350,11 @@ const char* Nexus::name() const /* * $Log: net_link.cc,v $ + * Revision 1.4 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.3 2000/08/26 00:54:03 steve * Get at gate information for ivl_target interface. * diff --git a/net_scope.cc b/net_scope.cc index a01759800..4b61a3868 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_scope.cc,v 1.9 2000/08/27 15:51:50 steve Exp $" +#ident "$Id: net_scope.cc,v 1.10 2000/10/06 23:46:50 steve Exp $" #endif # include "netlist.h" @@ -233,7 +233,7 @@ void NetScope::add_signal(NetNet*net) void NetScope::rem_signal(NetNet*net) { - assert(net->scope_ == this); + assert(net->scope() == this); if (signals_ == net) signals_ = net->sig_prev_; @@ -355,6 +355,11 @@ string NetScope::local_symbol() /* * $Log: net_scope.cc,v $ + * Revision 1.10 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.9 2000/08/27 15:51:50 steve * t-dll iterates signals, and passes them to the * target module. diff --git a/netlist.cc b/netlist.cc index cf9ec7f65..7f8d8548c 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.cc,v 1.140 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: netlist.cc,v 1.141 2000/10/06 23:46:50 steve Exp $" #endif # include @@ -163,7 +163,20 @@ Link* find_next_output(Link*lnk) } NetObj::NetObj(const string&n, unsigned np) -: npins_(np), delay1_(0), delay2_(0), delay3_(0) +: scope_(0), npins_(np), delay1_(0), delay2_(0), delay3_(0) +{ + name_ = new char[n.length()+1]; + strcpy(name_, n.c_str()); + + pins_ = new Link[npins_]; + for (unsigned idx = 0 ; idx < npins_ ; idx += 1) { + pins_[idx].node_ = this; + pins_[idx].pin_ = idx; + } +} + +NetObj::NetObj(NetScope*s, const string&n, unsigned np) +: scope_(s), npins_(np), delay1_(0), delay2_(0), delay3_(0) { name_ = new char[n.length()+1]; strcpy(name_, n.c_str()); @@ -181,6 +194,16 @@ NetObj::~NetObj() delete[]pins_; } +NetScope* NetObj::scope() +{ + return scope_; +} + +const NetScope* NetObj::scope() const +{ + return scope_; +} + void NetObj::set_attributes(const map&attr) { assert(attributes_.size() == 0); @@ -272,11 +295,11 @@ NetNode* NetNode::next_node() } NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins) -: NetObj(n, npins), sig_next_(0), sig_prev_(0), scope_(s), +: NetObj(s, n, npins), sig_next_(0), sig_prev_(0), type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0), local_flag_(false), eref_count_(0) { - assert(scope_); + assert(s); verinum::V init_value = verinum::Vz; switch (t) { @@ -294,16 +317,16 @@ NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins) pin(idx).set_init(init_value); } - scope_->add_signal(this); + scope()->add_signal(this); } NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls) -: NetObj(n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0), - sig_prev_(0), scope_(s), type_(t), +: NetObj(s, n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0), + sig_prev_(0), type_(t), port_type_(NOT_A_PORT), msb_(ms), lsb_(ls), local_flag_(false), eref_count_(0) { - assert(scope_); + assert(s); verinum::V init_value = verinum::Vz; switch (t) { @@ -321,19 +344,14 @@ NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls) pin(idx).set_init(init_value); } - scope_->add_signal(this); + s->add_signal(this); } NetNet::~NetNet() { assert(eref_count_ == 0); - if (scope_) - scope_->rem_signal(this); -} - -NetScope* NetNet::scope() -{ - return scope_; + if (scope()) + scope()->rem_signal(this); } NetNet::Type NetNet::type() const @@ -361,11 +379,6 @@ long NetNet::msb() const return msb_; } -const NetScope* NetNet::scope() const -{ - return scope_; -} - unsigned NetNet::sb_to_idx(long sb) const { if (msb_ >= lsb_) @@ -2423,6 +2436,11 @@ bool NetUDP::sequ_glob_(string input, char output) /* * $Log: netlist.cc,v $ + * Revision 1.141 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.140 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/netlist.h b/netlist.h index 13cd5ee00..5ecca336a 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.h,v 1.171 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: netlist.h,v 1.172 2000/10/06 23:46:50 steve Exp $" #endif /* @@ -74,8 +74,12 @@ class NetObj { public: public: explicit NetObj(const string&n, unsigned npins); + explicit NetObj(NetScope*s, const string&n, unsigned npins); virtual ~NetObj(); + NetScope* scope(); + const NetScope* scope() const; + const char* name() const { return name_; } unsigned pin_count() const { return npins_; } @@ -103,6 +107,7 @@ class NetObj { void dump_obj_attr(ostream&, unsigned) const; private: + NetScope*scope_; char* name_; Link*pins_; const unsigned npins_; @@ -220,6 +225,10 @@ class Link { * The links in a nexus are grouped into a singly linked list, with * the nexus pointing to the first Link. Each link in turn points to * the next link in the nexus, with the last link pointing to 0. + * + * The t_cookie() is a void* that targets can use to store information + * in a Nexus. ivl guarantees that the t_cookie will be 0 when the + * target is invoked. */ class Nexus { @@ -236,12 +245,16 @@ class Nexus { Link*first_nlink(); const Link* first_nlink()const; + void* t_cookie() const; + void* t_cookie(void*) const; + private: Link*list_; void unlink(Link*); void relink(Link*); mutable char* name_; /* Cache the calculated name for the Nexus. */ + mutable void* t_cookie_; private: // not implemented Nexus(const Nexus&); @@ -309,9 +322,6 @@ class NetNet : public NetObj, public LineInfo { virtual ~NetNet(); - NetScope* scope(); - const NetScope* scope() const; - Type type() const; PortType port_type() const; @@ -347,7 +357,6 @@ class NetNet : public NetObj, public LineInfo { NetNet*sig_next_, *sig_prev_; private: - NetScope*scope_; Type type_; PortType port_type_; @@ -2796,6 +2805,11 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.172 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.171 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/t-dll-api.cc b/t-dll-api.cc index ba9753c8a..e6e8b23fd 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll-api.cc,v 1.9 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: t-dll-api.cc,v 1.10 2000/10/06 23:46:50 steve Exp $" #endif # include "t-dll.h" @@ -44,7 +44,20 @@ extern "C" const char*ivl_get_root_name(ivl_design_t des) extern "C" const char*ivl_const_bits(ivl_net_const_t net) { assert(net); - return net->bits_; + if (net->width_ <= sizeof(char*)) + return net->b.bit_; + else + return net->b.bits_; +} + +extern "C" ivl_nexus_t ivl_const_pin(ivl_net_const_t net, unsigned idx) +{ + assert(net); + assert(idx < net->width_); + if (net->width_ == 1) + return net->n.pin_; + else + return net->n.pins_[idx]; } extern "C" unsigned ivl_const_pins(ivl_net_const_t net) @@ -142,31 +155,23 @@ extern "C" unsigned ivl_expr_width(ivl_expr_t net) extern "C" ivl_logic_t ivl_logic_type(ivl_net_logic_t net) { - switch (net->dev_->type()) { - case NetLogic::AND: - return IVL_LO_AND; - case NetLogic::OR: - return IVL_LO_OR; - case NetLogic::XOR: - return IVL_LO_XOR; - } - assert(0); - return IVL_LO_NONE; + return net->type_; } extern "C" unsigned ivl_logic_pins(ivl_net_logic_t net) { - return net->dev_->pin_count(); + return net->npins_; } extern "C" ivl_nexus_t ivl_logic_pin(ivl_net_logic_t net, unsigned pin) { - return (ivl_nexus_t) (net->dev_->pin(pin).nexus()); + assert(pin < net->npins_); + return net->pins_[pin]; } extern "C" const char* ivl_nexus_name(ivl_nexus_t net) { - const Nexus*nex = (const Nexus*)net; + const Nexus*nex = net->self; return nex->name(); } @@ -182,71 +187,17 @@ extern "C" ivl_statement_t ivl_process_stmt(ivl_process_t net) extern "C" unsigned ivl_signal_pins(ivl_signal_t net) { - const NetNet*sig = (const NetNet*)net; - return sig->pin_count(); + return net->width_; } extern "C" ivl_signal_port_t ivl_signal_port(ivl_signal_t net) { - const NetNet*sig = (const NetNet*)net; - - switch (sig->port_type()) { - - case NetNet::PINPUT: - return IVL_SIP_INPUT; - - case NetNet::POUTPUT: - return IVL_SIP_OUTPUT; - - case NetNet::PINOUT: - return IVL_SIP_INOUT; - } - - return IVL_SIP_NONE; + return net->port_; } extern "C" ivl_signal_type_t ivl_signal_type(ivl_signal_t net) { - const NetNet*sig = (const NetNet*)net; - switch (sig->type()) { - - case NetNet::REG: - case NetNet::INTEGER: - return IVL_SIT_REG; - - case NetNet::SUPPLY0: - return IVL_SIT_SUPPLY0; - - case NetNet::SUPPLY1: - return IVL_SIT_SUPPLY1; - - case NetNet::TRI: - return IVL_SIT_TRI; - - case NetNet::TRI0: - return IVL_SIT_TRI0; - - case NetNet::TRI1: - return IVL_SIT_TRI1; - - case NetNet::TRIAND: - return IVL_SIT_TRIAND; - - case NetNet::TRIOR: - return IVL_SIT_TRIOR; - - case NetNet::WAND: - return IVL_SIT_WAND; - - case NetNet::WIRE: - case NetNet::IMPLICIT: - return IVL_SIT_WIRE; - - case NetNet::WOR: - return IVL_SIT_WOR; - } - - return IVL_SIT_NONE; + return net->type_; } extern "C" ivl_statement_type_t ivl_statement_type(ivl_statement_t net) @@ -298,6 +249,12 @@ extern "C" unsigned long ivl_stmt_delay_val(ivl_statement_t net) return net->u_.delay_.delay_; } +extern "C" unsigned ivl_stmt_lwidth(ivl_statement_t net) +{ + assert(net->type_ == IVL_ST_ASSIGN); + return net->u_.assign_.lwidth_; +} + extern "C" const char* ivl_stmt_name(ivl_statement_t net) { switch (net->type_) { @@ -334,6 +291,18 @@ extern "C" unsigned ivl_stmt_parm_count(ivl_statement_t net) return 0; } +extern "C" ivl_expr_t ivl_stmt_rval(ivl_statement_t net) +{ + switch (net->type_) { + case IVL_ST_ASSIGN: + return net->u_.assign_.rval_; + default: + assert(0); + } + + return 0; +} + extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) { switch (net->type_) { @@ -352,6 +321,11 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net) /* * $Log: t-dll-api.cc,v $ + * Revision 1.10 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.9 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 4a859fa9e..d8db68393 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll-proc.cc,v 1.7 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: t-dll-proc.cc,v 1.8 2000/10/06 23:46:50 steve Exp $" #endif # include "target.h" @@ -76,8 +76,7 @@ bool dll_target::process(const NetProcTop*net) return false; } -/*XXXX - * Currently, this doesn't do anything really, so stub it out. +/* */ void dll_target::proc_assign(const NetAssign*net) { @@ -85,6 +84,13 @@ void dll_target::proc_assign(const NetAssign*net) assert(stmt_cur_->type_ == IVL_ST_NONE); stmt_cur_->type_ = IVL_ST_ASSIGN; + + stmt_cur_->u_.assign_.lwidth_ = net->lwidth(); + + assert(expr_ == 0); + net->rval()->expr_scan(this); + stmt_cur_->u_.assign_.rval_ = expr_; + expr_ = 0; } @@ -212,10 +218,10 @@ void dll_target::proc_stask(const NetSTask*net) calloc(nparms, sizeof(ivl_expr_t)); for (unsigned idx = 0 ; idx < nparms ; idx += 1) { - expr_ = 0; if (net->parm(idx)) net->parm(idx)->expr_scan(this); stmt_cur_->u_.stask_.parms_[idx] = expr_; + expr_ = 0; } } @@ -269,6 +275,11 @@ void dll_target::proc_while(const NetWhile*net) /* * $Log: t-dll-proc.cc,v $ + * Revision 1.8 2000/10/06 23:46:50 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.7 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/t-dll.cc b/t-dll.cc index 0dbc55f70..d40bdba73 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.cc,v 1.10 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: t-dll.cc,v 1.11 2000/10/06 23:46:51 steve Exp $" #endif # include "compiler.h" @@ -43,8 +43,8 @@ bool dll_target::start_design(const Design*des) des_.root_ = (ivl_scope_t)calloc(1, sizeof(struct ivl_scope_s)); des_.root_->self = des->find_root_scope(); - start_design_ = (start_design_f)dlsym(dll_, "target_start_design"); - end_design_ = (end_design_f) dlsym(dll_, "target_end_design"); + start_design_ = (start_design_f)dlsym(dll_, LU "target_start_design" TU); + end_design_ = (end_design_f) dlsym(dll_, LU "target_end_design" TU); net_bufz_ = (net_bufz_f) dlsym(dll_, LU "target_net_bufz" TU); net_const_ = (net_const_f) dlsym(dll_, LU "target_net_const" TU); @@ -95,11 +95,37 @@ void dll_target::event(const NetEvent*net) void dll_target::logic(const NetLogic*net) { - struct ivl_net_logic_s obj; - obj.dev_ = net; + struct ivl_net_logic_s *obj = new struct ivl_net_logic_s; + + switch (net->type()) { + case NetLogic::AND: + obj->type_ = IVL_LO_AND; + break; + case NetLogic::BUF: + obj->type_ = IVL_LO_BUF; + break; + case NetLogic::OR: + obj->type_ = IVL_LO_OR; + break; + case NetLogic::XOR: + obj->type_ = IVL_LO_XOR; + break; + default: + assert(0); + obj->type_ = IVL_LO_NONE; + break; + } + + obj->npins_ = net->pin_count(); + obj->pins_ = new ivl_nexus_t[obj->npins_]; + for (unsigned idx = 0 ; idx < obj->npins_ ; idx += 1) { + const Nexus*nex = net->pin(idx).nexus(); + assert(nex->t_cookie()); + obj->pins_[idx] = (ivl_nexus_t) nex->t_cookie(); + } if (net_logic_) { - (net_logic_)(net->name(), &obj); + (net_logic_)(net->name(), obj); } else { cerr << dll_path_ << ": internal error: target DLL lacks " @@ -112,27 +138,53 @@ void dll_target::logic(const NetLogic*net) bool dll_target::net_const(const NetConst*net) { unsigned idx; - ivl_net_const_t obj = (ivl_net_const_t) - calloc(1, sizeof(struct ivl_net_const_s)); + char*bits; + + struct ivl_net_const_s *obj = new struct ivl_net_const_s; obj->width_ = net->pin_count(); - obj->bits_ = (char*)malloc(obj->width_); + if (obj->width_ <= sizeof(char*)) { + bits = obj->b.bit_; + + } else { + obj->b.bits_ = (char*)malloc(obj->width_); + bits = obj->b.bits_; + } + for (idx = 0 ; idx < obj->width_ ; idx += 1) switch (net->value(idx)) { case verinum::V0: - obj->bits_[idx] = '0'; + bits[idx] = '0'; break; case verinum::V1: - obj->bits_[idx] = '1'; + bits[idx] = '1'; break; case verinum::Vx: - obj->bits_[idx] = 'x'; + bits[idx] = 'x'; break; case verinum::Vz: - obj->bits_[idx] = 'z'; + bits[idx] = 'z'; break; } + /* Connect to all the nexus objects. Note that the one-bit + case can be handled more efficiently without allocating + array space. */ + if (obj->width_ == 1) { + const Nexus*nex = net->pin(0).nexus(); + assert(nex->t_cookie()); + obj->n.pin_ = (ivl_nexus_t) nex->t_cookie(); + + } else { + obj->n.pins_ = new ivl_nexus_t[obj->width_]; + for (unsigned idx = 0 ; idx < obj->width_ ; idx += 1) { + const Nexus*nex = net->pin(idx).nexus(); + assert(nex->t_cookie()); + obj->n.pins_[idx] = (ivl_nexus_t) nex->t_cookie(); + } + } + + /* All done, call the target_net_const function if it exists. */ if (net_const_) { int rc = (net_const_)(net->name(), obj); return rc == 0; @@ -161,6 +213,11 @@ void dll_target::net_probe(const NetEvProbe*net) return; } +/* + * This function locates an ivl_scope_t object that matches the + * NetScope object. The search works by looking for the parent scope, + * then scanning the parent scope for the NetScope object. + */ static ivl_scope_t find_scope(ivl_scope_t root, const NetScope*cur) { ivl_scope_t parent, tmp; @@ -205,8 +262,155 @@ void dll_target::scope(const NetScope*net) void dll_target::signal(const NetNet*net) { + ivl_signal_t obj = (ivl_signal_t)calloc(1, sizeof(struct ivl_signal_s)); + + /* Attach the signal to the ivl_scope_t object that contains + it. This involves growing the sigs_ array in the scope + object, or creating the sigs_ array if this is the first + signal. */ + obj->scope_ = find_scope(des_.root_, net->scope()); + assert(obj->scope_); + + if (obj->scope_->nsigs_ == 0) { + assert(obj->scope_->sigs_ == 0); + obj->scope_->nsigs_ = 1; + obj->scope_->sigs_ = (ivl_signal_t*)malloc(sizeof(ivl_signal_t)); + + } else { + assert(obj->scope_->sigs_); + obj->scope_->nsigs_ += 1; + obj->scope_->sigs_ = (ivl_signal_t*) + realloc(obj->scope_->sigs_, + obj->scope_->nsigs_*sizeof(ivl_signal_t)); + obj->scope_->sigs_[obj->scope_->nsigs_-1] = obj; + } + + /* Save the privitive properties of the signal in the + ivl_signal_t object. */ + + obj->width_ = net->pin_count(); + obj->signed_= 0; + + switch (net->port_type()) { + + case NetNet::PINPUT: + obj->port_ = IVL_SIP_INPUT; + break; + + case NetNet::POUTPUT: + obj->port_ = IVL_SIP_OUTPUT; + break; + + case NetNet::PINOUT: + obj->port_ = IVL_SIP_INOUT; + break; + + default: + obj->port_ = IVL_SIP_NONE; + break; + } + + switch (net->type()) { + + case NetNet::REG: + case NetNet::INTEGER: + obj->type_ = IVL_SIT_REG; + break; + + case NetNet::SUPPLY0: + obj->type_ = IVL_SIT_SUPPLY0; + break; + + case NetNet::SUPPLY1: + obj->type_ = IVL_SIT_SUPPLY1; + break; + + case NetNet::TRI: + obj->type_ = IVL_SIT_TRI; + break; + + case NetNet::TRI0: + obj->type_ = IVL_SIT_TRI0; + break; + + case NetNet::TRI1: + obj->type_ = IVL_SIT_TRI1; + break; + + case NetNet::TRIAND: + obj->type_ = IVL_SIT_TRIAND; + break; + + case NetNet::TRIOR: + obj->type_ = IVL_SIT_TRIOR; + break; + + case NetNet::WAND: + obj->type_ = IVL_SIT_WAND; + break; + + case NetNet::WIRE: + case NetNet::IMPLICIT: + obj->type_ = IVL_SIT_WIRE; + break; + + case NetNet::WOR: + obj->type_ = IVL_SIT_WOR; + break; + + default: + obj->type_ = IVL_SIT_NONE; + break; + } + + /* Get the nexus objects for all the pins of the signal. If + the signal has only one pin, then write the single + ivl_nexus_t object into n.pin_. Otherwise, make an array of + ivl_nexus_t cookies. + + When I create an ivl_nexus_t object, store it in the + t_cookie of the Nexus object so that I find it again when I + next encounter the nexus. */ + + if (obj->width_ == 1) { + const Nexus*nex = net->pin(0).nexus(); + if (nex->t_cookie()) { + obj->n.pin_ = (ivl_nexus_t)nex->t_cookie(); + + } else { + ivl_nexus_t tmp = (ivl_nexus_t) + calloc(1, sizeof(struct ivl_nexus_s)); + tmp->self = nex; + nex->t_cookie(tmp); + obj->n.pin_ = tmp; + } + + } else { + unsigned idx; + + obj->n.pins_ = (ivl_nexus_t*) + calloc(obj->width_, sizeof(ivl_nexus_t)); + + for (idx = 0 ; idx < obj->width_ ; idx += 1) { + const Nexus*nex = net->pin(idx).nexus(); + if (nex->t_cookie()) { + obj->n.pins_[idx] = (ivl_nexus_t)nex->t_cookie(); + + } else { + ivl_nexus_t tmp = (ivl_nexus_t) + calloc(1, sizeof(struct ivl_nexus_s)); + tmp->self = nex; + nex->t_cookie(tmp); + obj->n.pins_[idx] = tmp; + } + } + } + + /* Invoke the target_net_signal function of the loaded target + module, if it exists. */ + if (net_signal_) { - int rc = (net_signal_)(net->name(), (ivl_signal_t)net); + int rc = (net_signal_)(net->name(), obj); return; } else { @@ -221,6 +425,11 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.11 2000/10/06 23:46:51 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.10 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/t-dll.h b/t-dll.h index d98aa86d8..5e9650c3f 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.h,v 1.8 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: t-dll.h,v 1.9 2000/10/06 23:46:51 steve Exp $" #endif # include "target.h" @@ -132,25 +132,83 @@ struct ivl_expr_s { } u_; }; +/* + * This object represents a vector constant, possibly signed, in a + * structural context. + */ struct ivl_net_const_s { unsigned width_ :24; unsigned signed_ : 1; - char *bits_; + + union { + char bit_[sizeof(char*)]; + char *bits_; + } b; + + union { + ivl_nexus_t pin_; + ivl_nexus_t*pins_; + } n; }; +/* + * Logic gates (just about everything that has a single output) are + * represented structurally by instances of this object. + */ struct ivl_net_logic_s { - const NetLogic*dev_; + ivl_logic_t type_; + unsigned npins_; + ivl_nexus_t*pins_; }; + +struct ivl_nexus_s { + const Nexus*self; +}; + +/* + * All we know about a process it its type (initial or always) and the + * single statement that is it. + */ struct ivl_process_s { ivl_process_type_t type_; ivl_statement_t stmt_; }; +/* + * Scopes are kept in a tree. Each scope points to its first child, + * and also to any siblings. Thus a parent can scan all its children + * by following its child pointer then following sibling pointers from + * there. + */ struct ivl_scope_s { ivl_scope_t child_, sibling_; const NetScope*self; + + unsigned nsigs_; + ivl_signal_t*sigs_; +}; + +/* + * A signal is a think like a wire, a reg, or whatever. It has a type, + * and if it is a port is also has a directory. Signals are collected + * into scopes (which also point back to me) and have pins that + * connect to the rest of the netlist. + */ +struct ivl_signal_s { + ivl_signal_type_t type_; + ivl_signal_port_t port_; + + unsigned width_ :24; + unsigned signed_ : 1; + + ivl_scope_t scope_; + + union { + ivl_nexus_t pin_; + ivl_nexus_t*pins_; + } n; }; /* @@ -161,6 +219,11 @@ struct ivl_scope_s { struct ivl_statement_s { enum ivl_statement_type_e type_; union { + struct { /* IVL_ST_ASSIGN */ + unsigned lwidth_ :24; + ivl_expr_t rval_; + } assign_; + struct { /* IVL_ST_BLOCK */ struct ivl_statement_s*stmt_; unsigned nstmt_; @@ -207,6 +270,11 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.9 2000/10/06 23:46:51 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.8 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 50ebf7de0..563939968 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: stub.c,v 1.13 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: stub.c,v 1.14 2000/10/06 23:46:51 steve Exp $" #endif /* @@ -73,7 +73,11 @@ int target_net_const(const char*name, ivl_net_const_t net) for (idx = 0 ; idx < wid ; idx += 1) fprintf(out, "%c", bits[wid-1-idx]); - fprintf(out, "\n"); + fprintf(out, " (%s", ivl_nexus_name(ivl_const_pin(net, 0))); + for (idx = 1 ; idx < wid ; idx += 1) + fprintf(", %s", ivl_nexus_name(ivl_const_pin(net, idx))); + + fprintf(out, ")\n"); return 0; } @@ -92,6 +96,10 @@ int target_net_logic(const char*name, ivl_net_logic_t net) fprintf(out, "and %s (%s", name, ivl_nexus_name(ivl_logic_pin(net, 0))); break; + case IVL_LO_BUF: + fprintf(out, "buf %s (%s", name, + ivl_nexus_name(ivl_logic_pin(net, 0))); + break; case IVL_LO_OR: fprintf(out, "or %s (%s", name, ivl_nexus_name(ivl_logic_pin(net, 0))); @@ -202,7 +210,9 @@ static void show_statement(ivl_statement_t net, unsigned ind) switch (code) { case IVL_ST_ASSIGN: - fprintf(out, "%*sASSIGN: ? = ?\n", ind, ""); + fprintf(out, "%*sASSIGN \n", ind, "", + ivl_stmt_lwidth(net)); + show_expression(ivl_stmt_rval(net), ind+4); break; case IVL_ST_BLOCK: { @@ -291,6 +301,11 @@ int target_process(ivl_process_t net) /* * $Log: stub.c,v $ + * Revision 1.14 2000/10/06 23:46:51 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.13 2000/10/05 05:03:01 steve * xor and constant devices. * diff --git a/tgt-verilog/verilog.c b/tgt-verilog/verilog.c index b1f77b7d7..1addd6f82 100644 --- a/tgt-verilog/verilog.c +++ b/tgt-verilog/verilog.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: verilog.c,v 1.7 2000/10/05 05:03:02 steve Exp $" +#ident "$Id: verilog.c,v 1.8 2000/10/06 23:46:51 steve Exp $" #endif /* @@ -82,6 +82,10 @@ int target_net_logic(const char*name, ivl_net_logic_t net) fprintf(out, " and %s (%s", name, ivl_nexus_name(ivl_logic_pin(net, 0))); break; + case IVL_LO_BUF: + fprintf(out, " buf %s (%s", name, + ivl_nexus_name(ivl_logic_pin(net, 0))); + break; case IVL_LO_OR: fprintf(out, " or %s (%s", name, ivl_nexus_name(ivl_logic_pin(net, 0))); @@ -180,7 +184,9 @@ static void show_statement(ivl_statement_t net, unsigned ind) switch (code) { case IVL_ST_ASSIGN: - fprintf(out, "%*s? = ?;\n", ind, ""); + fprintf(out, "%*s? = ", ind, ""); + show_expression(ivl_stmt_rval(net)); + fprintf(out, ";\n"); break; case IVL_ST_BLOCK: { @@ -274,6 +280,11 @@ int target_process(ivl_process_t net) /* * $Log: verilog.c,v $ + * Revision 1.8 2000/10/06 23:46:51 steve + * ivl_target updates, including more complete + * handling of ivl_nexus_t objects. Much reduced + * dependencies on pointers to netlist objects. + * * Revision 1.7 2000/10/05 05:03:02 steve * xor and constant devices. *