Add functions for targets to scan disciplines.

The disciplines are, from the perspective of the ivl target, collected
into the design. Add functions for the target to scan the disciplines
in the design.

In the process, also clean up the handlng of design constants.
This commit is contained in:
Stephen Williams 2008-11-23 21:29:54 -08:00
parent 6185556ef5
commit d8ec6fc42a
7 changed files with 65 additions and 32 deletions

View File

@ -2,6 +2,8 @@ EXPORTS
ivl_design_const
ivl_design_consts
ivl_design_discipline
ivl_design_disciplines
ivl_design_flag
ivl_design_process
ivl_design_root

View File

@ -510,6 +510,9 @@ extern int ivl_design_time_precision(ivl_design_t des);
extern unsigned ivl_design_consts(ivl_design_t des);
extern ivl_net_const_t ivl_design_const(ivl_design_t, unsigned idx);
extern unsigned ivl_design_disciplines(ivl_design_t des);
extern ivl_discipline_t ivl_design_discipline(ivl_design_t des, unsigned idx);
/* LITERAL CONSTANTS
* Literal constants are nodes with no input and a single constant
* output. The form of the output depends on the type of the node.

View File

@ -19,8 +19,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "ivl_target.h"
# include <inttypes.h>
# include <vector>
# include <valarray>
/*
* This header has declarations related to the ivl_target.h API that
@ -33,6 +35,29 @@
* should gradually be moved over to this header file.)
*/
/*
* This is the root of a design, from the ivl_target point of few. The
* ivl_target API uses this as the root for getting at everything else
* in the design.
*/
struct ivl_design_s {
int time_precision;
ivl_process_t threads_;
ivl_scope_t *roots_;
unsigned nroots_;
// Keep an array of constants objects.
std::valarray<ivl_net_const_t> consts;
// Keep a handy array of all of the disciplines in the design.
std::valarray<ivl_discipline_t> disciplines;
const class Design*self;
};
struct ivl_branch_s {
ivl_nexus_t pins[2];
};
@ -43,10 +68,8 @@ struct ivl_branch_s {
* have disciplines and do not belong to islands.
*/
class ivl_discipline_s;
struct ivl_island_s {
ivl_discipline_s*discipline;
ivl_discipline_t discipline;
// user accessible flags. They are initially false, always.
std::vector<bool> flags;
};

View File

@ -73,15 +73,28 @@ extern "C" int ivl_design_time_precision(ivl_design_t des)
extern "C" unsigned ivl_design_consts(ivl_design_t des)
{
return des->nconsts;
return des->consts.size();
}
extern "C" ivl_net_const_t ivl_design_const(ivl_design_t des, unsigned idx)
{
assert(idx < des->nconsts);
assert(idx < des->consts.size());
return des->consts[idx];
}
extern "C" unsigned ivl_design_disciplines(ivl_design_t des)
{
assert(des);
return des->disciplines.size();
}
extern "C" ivl_discipline_t ivl_design_discipline(ivl_design_t des, unsigned idx)
{
assert(des);
assert(idx < des->disciplines.size());
return des->disciplines[idx];
}
extern "C" ivl_dis_domain_t ivl_discipline_domain(ivl_discipline_t net)
{
return net->domain();

View File

@ -26,6 +26,7 @@
# include "compiler.h"
# include "t-dll.h"
# include "netmisc.h"
# include "discipline.h"
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
@ -616,14 +617,20 @@ bool dll_target::start_design(const Design*des)
des_.nroots_ = 0;
des_.roots_ = NULL;
des_.disciplines.resize(disciplines.size());
unsigned idx = 0;
for (map<perm_string,ivl_discipline_t>::const_iterator cur = disciplines.begin()
; cur != disciplines.end() ; cur ++) {
des_.disciplines[idx] = cur->second;
idx += 1;
}
assert(idx == des_.disciplines.size());
root_scopes = des->find_root_scopes();
for (list<NetScope*>::const_iterator scop = root_scopes.begin();
scop != root_scopes.end(); scop++)
add_root(des_, *scop);
des_.consts = (ivl_net_const_t*)
malloc(sizeof(ivl_net_const_t));
des_.nconsts = 0;
target_ = (target_design_f)ivl_dlsym(dll_, LU "target_design" TU);
if (target_ == 0) {
@ -2263,11 +2270,8 @@ bool dll_target::net_const(const NetConst*net)
obj->pin_ = nex->t_cookie();
nexus_con_add(obj->pin_, obj, 0, drv0, drv1);
des_.nconsts += 1;
des_.consts = (ivl_net_const_t*)
realloc(des_.consts, des_.nconsts * sizeof(ivl_net_const_t));
des_.consts[des_.nconsts-1] = obj;
des_.consts.resize( des_.consts.size() + 1 );
des_.consts[des_.consts.size()-1] = obj;
make_const_delays_(obj, net);
@ -2295,10 +2299,8 @@ bool dll_target::net_literal(const NetLiteral*net)
obj->pin_ = nex->t_cookie();
nexus_con_add(obj->pin_, obj, 0, drv0, drv1);
des_.nconsts += 1;
des_.consts = (ivl_net_const_t*)
realloc(des_.consts, des_.nconsts * sizeof(ivl_net_const_t));
des_.consts[des_.nconsts-1] = obj;
des_.consts.resize( des_.consts.size() + 1 );
des_.consts[des_.consts.size()-1] = obj;
make_const_delays_(obj, net);

15
t-dll.h
View File

@ -39,21 +39,6 @@ typedef shl_t ivl_dll_t;
# error No DLL stub support for this target.
#endif
struct ivl_design_s {
int time_precision;
ivl_scope_t *roots_;
unsigned nroots_;
ivl_process_t threads_;
ivl_net_const_t*consts;
unsigned nconsts;
const Design*self;
};
/*
* The DLL target type loads a named object file to handle the process
* of scanning the netlist. When it is time to start the design, I

View File

@ -1654,6 +1654,11 @@ int target_design(ivl_design_t des)
return -2;
}
for (idx = 0 ; idx < ivl_design_disciplines(des) ; idx += 1) {
ivl_discipline_t dis = ivl_design_discipline(des,idx);
fprintf(out, "discipline %s\n", ivl_discipline_name(dis));
}
ivl_design_roots(des, &root_scopes, &nroot);
for (idx = 0 ; idx < nroot ; idx += 1) {