From 7898f4e40283c21b3ff68b150f2fe63d3bfcd925 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 1 Jun 2008 14:29:27 -0700 Subject: [PATCH] Account for swithes linked to nexus in ivl_target.h API. Switches can connect to a nexus too, so add the missing nexus support for that in the ivl_target.h API. --- ivl.def | 1 + ivl_target.h | 6 ++++-- net_tran.cc | 2 +- t-dll-api.cc | 14 ++++++++++++++ tgt-stub/stub.c | 6 ++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ivl.def b/ivl.def index 17dcc0c49..78064e569 100644 --- a/ivl.def +++ b/ivl.def @@ -115,6 +115,7 @@ ivl_nexus_ptr_pin ivl_nexus_ptr_lpm ivl_nexus_ptr_log ivl_nexus_ptr_sig +ivl_nexus_ptr_switch ivl_parameter_basename ivl_parameter_expr diff --git a/ivl_target.h b/ivl_target.h index 715fcd4c8..8391ce89c 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -1327,6 +1327,7 @@ extern unsigned ivl_nexus_ptr_pin(ivl_nexus_ptr_t net); extern ivl_net_const_t ivl_nexus_ptr_con(ivl_nexus_ptr_t net); extern ivl_net_logic_t ivl_nexus_ptr_log(ivl_nexus_ptr_t net); extern ivl_lpm_t ivl_nexus_ptr_lpm(ivl_nexus_ptr_t net); +extern ivl_switch_t ivl_nexus_ptr_switch(ivl_nexus_ptr_t net); extern ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net); /* PARAMETER @@ -1867,6 +1868,7 @@ extern ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net); * match. The enable must be a scalar. */ extern ivl_switch_type_t ivl_switch_type(ivl_switch_t net); +extern ivl_scope_t ivl_switch_scope(ivl_switch_t net); extern const char*ivl_switch_basename(ivl_switch_t net); extern ivl_nexus_t ivl_switch_a(ivl_switch_t net); extern ivl_nexus_t ivl_switch_b(ivl_switch_t net); @@ -1875,10 +1877,10 @@ extern ivl_nexus_t ivl_switch_enable(ivl_switch_t net); /* Not implemented yet extern unsigned ivl_switch_attr_cnt(ivl_switch_t net); extern ivl_attribute_t ivl_switch_attr_val(ivl_switch_t net, unsigned idx); - +*** */ extern const char* ivl_switch_file(ivl_switch_t net); extern unsigned ivl_switch_lineno(ivl_switch_t net); -*** */ + #if defined(__MINGW32__) || defined (__CYGWIN32__) # define DLLEXPORT __declspec(dllexport) #else diff --git a/net_tran.cc b/net_tran.cc index 88067769b..c2acf4787 100644 --- a/net_tran.cc +++ b/net_tran.cc @@ -42,7 +42,7 @@ static bool has_enable(ivl_switch_type_t tt) } NetTran::NetTran(NetScope*scope, perm_string n, ivl_switch_type_t tt) -: NetNode(scope, n, has_enable(tt)? 3 : 2) + : NetNode(scope, n, has_enable(tt)? 3 : 2), type_(tt) { pin(0).set_dir(Link::PASSIVE); pin(0).set_name(perm_string::literal("A"), 0); pin(1).set_dir(Link::PASSIVE); pin(1).set_name(perm_string::literal("B"), 0); diff --git a/t-dll-api.cc b/t-dll-api.cc index cbfbf7e84..30a4274af 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -1338,6 +1338,15 @@ extern "C" ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net) return net->l.sig; } +extern "C" ivl_switch_t ivl_nexus_ptr_switch(ivl_nexus_ptr_t net) +{ + if (net == 0) + return 0; + if (net->type_ != __NEXUS_PTR_SWI) + return 0; + return net->l.swi; +} + extern "C" const char* ivl_parameter_basename(ivl_parameter_t net) { assert(net); @@ -2162,6 +2171,11 @@ extern "C" const char*ivl_switch_basename(ivl_switch_t net) return net->name; } +extern "C" ivl_scope_t ivl_switch_scope(ivl_switch_t net) +{ + return net->scope; +} + extern "C" ivl_switch_type_t ivl_switch_type(ivl_switch_t net) { return net->type; diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 5d390800f..7571fc123 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1059,6 +1059,7 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex) ivl_net_logic_t log; ivl_lpm_t lpm; ivl_signal_t sig; + ivl_switch_t swt; ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, idx); const char*dr0 = str_tab[ivl_nexus_ptr_drive0(ptr)]; @@ -1092,6 +1093,11 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex) ivl_scope_name(ivl_lpm_scope(lpm)), ivl_lpm_basename(lpm), dr0, dr1); + } else if ((swt = ivl_nexus_ptr_switch(ptr))) { + fprintf(out, " SWITCH %s.%s\n", + ivl_scope_name(ivl_switch_scope(swt)), + ivl_switch_basename(swt)); + } else if ((con = ivl_nexus_ptr_con(ptr))) { signal_nexus_const(net, ptr, con);