Back pointers in the nexus objects into the devices

that point to it.

 Collect threads into a list in the design.
This commit is contained in:
steve 2000-10-08 04:01:54 +00:00
parent 76e2c509d7
commit 8fe887ffe1
6 changed files with 203 additions and 31 deletions

View File

@ -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.17 2000/10/07 19:45:43 steve Exp $"
#ident "$Id: ivl_target.h,v 1.18 2000/10/08 04:01:54 steve Exp $"
#endif
#ifdef __cplusplus
@ -269,6 +269,14 @@ extern unsigned ivl_logic_pins(ivl_net_logic_t net);
extern const char* ivl_nexus_name(ivl_nexus_t net);
/* SCOPE
* Scopes of various sort have these properties. Use these methods to
* access them.
*/
extern const char* ivl_scope_name(ivl_scope_t net);
/* SIGNALS
* Signals are named things in the Verilog source, like wires and
* regs, and also named things that are preated as temporaries during
@ -281,6 +289,9 @@ extern const char* ivl_nexus_name(ivl_nexus_t net);
extern unsigned ivl_signal_pins(ivl_signal_t net);
extern ivl_signal_port_t ivl_signal_port(ivl_signal_t net);
extern ivl_signal_type_t ivl_signal_type(ivl_signal_t net);
extern const char* ivl_signal_name(ivl_signal_t net);
extern const char* ivl_signal_basename(ivl_signal_t net);
/*
* These functions get information about a process. A process is
@ -442,6 +453,12 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.18 2000/10/08 04:01:54 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.17 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*

View File

@ -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.10 2000/10/06 23:46:50 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.11 2000/10/08 04:01:54 steve Exp $"
#endif
# include "t-dll.h"
@ -38,7 +38,7 @@ extern "C" const char*ivl_get_flag(ivl_design_t des, const char*key)
extern "C" const char*ivl_get_root_name(ivl_design_t des)
{
return des->root_->self->basename();
return des->root_->name_;
}
extern "C" const char*ivl_const_bits(ivl_net_const_t net)
@ -171,8 +171,8 @@ extern "C" ivl_nexus_t ivl_logic_pin(ivl_net_logic_t net, unsigned pin)
extern "C" const char* ivl_nexus_name(ivl_nexus_t net)
{
const Nexus*nex = net->self;
return nex->name();
assert(net);
return net->name_;
}
extern "C" ivl_process_type_t ivl_process_type(ivl_process_t net)
@ -185,6 +185,25 @@ extern "C" ivl_statement_t ivl_process_stmt(ivl_process_t net)
return net->stmt_;
}
extern "C" const char* ivl_scope_name(ivl_scope_t net)
{
return net->name_;
}
extern "C" const char* ivl_signal_basename(ivl_signal_t net)
{
const char*nam = net->name_;
nam += strlen(ivl_scope_name(net->scope_));
assert(*nam == '.');
nam += 1;
return nam;
}
extern "C" const char* ivl_signal_name(ivl_signal_t net)
{
return net->name_;
}
extern "C" unsigned ivl_signal_pins(ivl_signal_t net)
{
return net->width_;
@ -321,6 +340,12 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.11 2000/10/08 04:01:54 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.10 2000/10/06 23:46:50 steve
* ivl_target updates, including more complete
* handling of ivl_nexus_t objects. Much reduced

View File

@ -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.8 2000/10/06 23:46:50 steve Exp $"
#ident "$Id: t-dll-proc.cc,v 1.9 2000/10/08 04:01:54 steve Exp $"
#endif
# include "target.h"
@ -63,17 +63,11 @@ bool dll_target::process(const NetProcTop*net)
obj->stmt_ = stmt_cur_;
stmt_cur_ = 0;
if (process_) {
int rc = (process_)(obj);
return rc == 0;
/* Save the process in the design. */
obj->next_ = des_.threads_;
des_.threads_ = obj;
} else {
cerr << dll_path_ << ": internal error: target DLL lacks "
<< "target_process function." << endl;
return false;
}
return false;
return true;
}
/*
@ -275,6 +269,12 @@ void dll_target::proc_while(const NetWhile*net)
/*
* $Log: t-dll-proc.cc,v $
* Revision 1.9 2000/10/08 04:01:54 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.8 2000/10/06 23:46:50 steve
* ivl_target updates, including more complete
* handling of ivl_nexus_t objects. Much reduced

110
t-dll.cc
View File

@ -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.12 2000/10/07 19:45:43 steve Exp $"
#ident "$Id: t-dll.cc,v 1.13 2000/10/08 04:01:55 steve Exp $"
#endif
# include "compiler.h"
@ -51,6 +51,41 @@ static ivl_scope_t find_scope(ivl_scope_t root, const NetScope*cur)
return 0;
}
static ivl_nexus_t nexus_sig_make(ivl_signal_t net, unsigned pin)
{
ivl_nexus_t tmp = new struct ivl_nexus_s;
tmp->nptr_ = 1;
tmp->ptrs_ = (struct __nexus_ptr*) malloc(sizeof(struct __nexus_ptr));
tmp->ptrs_[0].pin_ = pin;
tmp->ptrs_[0].type_ = __NEXUS_PTR_SIG;
tmp->ptrs_[0].l.sig = net;
return tmp;
}
static void nexus_sig_add(ivl_nexus_t nex, ivl_signal_t net, unsigned pin)
{
unsigned top = nex->nptr_ + 1;
nex->ptrs_ = (struct __nexus_ptr*)
realloc(nex->ptrs_, top * sizeof(struct __nexus_ptr));
nex->nptr_ = top;
nex->ptrs_[top-1].type_= __NEXUS_PTR_SIG;
nex->ptrs_[top-1].pin_ = pin;
nex->ptrs_[top-1].l.sig= net;
}
static void nexus_log_add(ivl_nexus_t nex, ivl_net_logic_t net, unsigned pin)
{
unsigned top = nex->nptr_ + 1;
nex->ptrs_ = (struct __nexus_ptr*)
realloc(nex->ptrs_, top * sizeof(struct __nexus_ptr));
nex->nptr_ = top;
nex->ptrs_[top-1].type_= __NEXUS_PTR_LOG;
nex->ptrs_[top-1].pin_ = pin;
nex->ptrs_[top-1].l.log= net;
}
void scope_add_logic(ivl_scope_t scope, ivl_net_logic_t net)
{
if (scope->nlog_ == 0) {
@ -80,7 +115,8 @@ bool dll_target::start_design(const Design*des)
// Initialize the design object.
des_.self = des;
des_.root_ = (ivl_scope_t)calloc(1, sizeof(struct ivl_scope_s));
des_.root_ = new struct ivl_scope_s;
des_.root_->name_ = strdup(des->find_root_scope()->name().c_str());
des_.root_->self = des->find_root_scope();
start_design_ = (start_design_f)dlsym(dll_, LU "target_start_design" TU);
@ -98,12 +134,34 @@ bool dll_target::start_design(const Design*des)
return true;
}
/*
* Here ivl is telling us that the design is scanned completely, and
* here is where we call the API to process the constructed design.
*/
void dll_target::end_design(const Design*)
{
if (process_) {
for (ivl_process_t idx = des_.threads_; idx; idx = idx->next_) {
process_(idx);
}
} else {
cerr << dll_path_ << ": internal error: target DLL lacks "
<< "target_process function." << endl;
}
(end_design_)(&des_);
dlclose(dll_);
}
/*
* Add a bufz object to the scope that contains it.
*
* Note that in the ivl_target API a BUFZ device is a special kind of
* ivl_net_logic_t device, so create an ivl_net_logic_t cookie to
* handle it.
*/
bool dll_target::bufz(const NetBUFZ*net)
{
struct ivl_net_logic_s *obj = new struct ivl_net_logic_s;
@ -115,11 +173,23 @@ bool dll_target::bufz(const NetBUFZ*net)
obj->npins_ = 2;
obj->pins_ = new ivl_nexus_t[2];
/* Get the ivl_nexus_t objects connected to the two pins.
(We know a priori that the ivl_nexus_t objects have been
allocated, because the signals have been scanned before
me. This saves me the trouble of allocating them.) */
assert(net->pin(0).nexus()->t_cookie());
obj->pins_[0] = (ivl_nexus_t) net->pin(0).nexus()->t_cookie();
nexus_log_add(obj->pins_[0], obj, 0);
assert(net->pin(1).nexus()->t_cookie());
obj->pins_[1] = (ivl_nexus_t) net->pin(1).nexus()->t_cookie();
nexus_log_add(obj->pins_[1], obj, 1);
/* Attach the logic device to the scope that contains it. */
assert(net->scope());
ivl_scope_t scope = find_scope(des_.root_, net->scope());
@ -174,12 +244,16 @@ void dll_target::logic(const NetLogic*net)
break;
}
/* Connect all the ivl_nexus_t objects to the pins of the
device. */
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();
nexus_log_add(obj->pins_[idx], obj, idx);
}
assert(net->scope());
@ -286,6 +360,7 @@ void dll_target::scope(const NetScope*net)
} else {
scope = new struct ivl_scope_s;
scope->self = net;
scope->name_ = strdup(net->name().c_str());
ivl_scope_t parent = find_scope(des_.root_, net->parent());
assert(parent != 0);
@ -300,7 +375,9 @@ 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));
ivl_signal_t obj = new struct ivl_signal_s;
obj->name_ = strdup(net->name());
/* Attach the signal to the ivl_scope_t object that contains
it. This involves growing the sigs_ array in the scope
@ -323,6 +400,13 @@ void dll_target::signal(const NetNet*net)
obj->scope_->sigs_[obj->scope_->nsigs_-1] = obj;
}
#ifndef NDEBUG
{ const char*scope_name = obj->scope_->self->name().c_str();
size_t name_len = strlen(scope_name);
assert(0 == strncmp(scope_name, obj->name_, name_len));
}
#endif
/* Save the privitive properties of the signal in the
ivl_signal_t object. */
@ -414,11 +498,11 @@ void dll_target::signal(const NetNet*net)
const Nexus*nex = net->pin(0).nexus();
if (nex->t_cookie()) {
obj->n.pin_ = (ivl_nexus_t)nex->t_cookie();
nexus_sig_add(obj->n.pin_, obj, 0);
} else {
ivl_nexus_t tmp = (ivl_nexus_t)
calloc(1, sizeof(struct ivl_nexus_s));
tmp->self = nex;
ivl_nexus_t tmp = nexus_sig_make(obj, 0);
tmp->name_ = strdup(nex->name());
nex->t_cookie(tmp);
obj->n.pin_ = tmp;
}
@ -433,11 +517,11 @@ void dll_target::signal(const NetNet*net)
const Nexus*nex = net->pin(idx).nexus();
if (nex->t_cookie()) {
obj->n.pins_[idx] = (ivl_nexus_t)nex->t_cookie();
nexus_sig_add(obj->n.pins_[idx], obj, idx);
} else {
ivl_nexus_t tmp = (ivl_nexus_t)
calloc(1, sizeof(struct ivl_nexus_s));
tmp->self = nex;
ivl_nexus_t tmp = nexus_sig_make(obj, idx);
tmp->name_ = strdup(nex->name());
nex->t_cookie(tmp);
obj->n.pins_[idx] = tmp;
}
@ -448,7 +532,7 @@ void dll_target::signal(const NetNet*net)
module, if it exists. */
if (net_signal_) {
int rc = (net_signal_)(net->name(), obj);
int rc = (net_signal_)(obj->name_, obj);
return;
} else {
@ -463,6 +547,12 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.13 2000/10/08 04:01:55 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.12 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*

36
t-dll.h
View File

@ -19,14 +19,18 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.10 2000/10/07 19:45:43 steve Exp $"
#ident "$Id: t-dll.h,v 1.11 2000/10/08 04:01:55 steve Exp $"
#endif
# include "target.h"
# include "ivl_target.h"
struct ivl_design_s {
ivl_scope_t root_;
ivl_process_t threads_;
const Design*self;
};
@ -161,8 +165,26 @@ struct ivl_net_logic_s {
};
/*
* The ivl_nexus_t is a single-bit link of some number of pins of
* devices. the __nexus_ptr structure is a helper that actually does
* the pointing.
*/
struct __nexus_ptr {
unsigned pin_ :24;
unsigned type_ : 8;
union {
ivl_signal_t sig; /* type 0 */
ivl_net_logic_t log; /* type 1 */
} l;
};
# define __NEXUS_PTR_SIG 0
# define __NEXUS_PTR_LOG 1
struct ivl_nexus_s {
const Nexus*self;
unsigned nptr_;
struct __nexus_ptr*ptrs_;
char*name_;
};
/*
@ -172,6 +194,8 @@ struct ivl_nexus_s {
struct ivl_process_s {
ivl_process_type_t type_;
ivl_statement_t stmt_;
ivl_process_t next_;
};
/*
@ -183,6 +207,7 @@ struct ivl_process_s {
struct ivl_scope_s {
ivl_scope_t child_, sibling_;
char* name_;
const NetScope*self;
unsigned nsigs_;
@ -205,6 +230,7 @@ struct ivl_signal_s {
unsigned width_ :24;
unsigned signed_ : 1;
char*name_;
ivl_scope_t scope_;
union {
@ -272,6 +298,12 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.11 2000/10/08 04:01:55 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.10 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*

View File

@ -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.9 2000/10/07 19:45:43 steve Exp $"
#ident "$Id: verilog.c,v 1.10 2000/10/08 04:01:55 steve Exp $"
#endif
/*
@ -115,11 +115,13 @@ int target_net_signal(const char*name, ivl_signal_t net)
switch (ivl_signal_type(net)) {
case IVL_SIT_REG:
fprintf(out, " reg [%u:0] %s;\n", cnt-1, name);
fprintf(out, " reg [%u:0] %s; // %s\n", cnt-1,
ivl_signal_basename(net), name);
break;
case IVL_SIT_WIRE:
fprintf(out, " wire [%u:0] %s;\n", cnt-1, name);
fprintf(out, " wire [%u:0] %s; // %s\n", cnt-1,
ivl_signal_basename(net), name);
break;
default:
@ -284,6 +286,12 @@ int target_process(ivl_process_t net)
/*
* $Log: verilog.c,v $
* Revision 1.10 2000/10/08 04:01:55 steve
* Back pointers in the nexus objects into the devices
* that point to it.
*
* Collect threads into a list in the design.
*
* Revision 1.9 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*