From f29d09dcbe12296f400dea183cb8c3f6ca7329ee Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 12 Aug 2010 11:21:36 -0700 Subject: [PATCH] Add uwire support/functionality to the stub and vvp back ends This patch adds a check in the vvp back end that a uwire has at most one driver. Previously this was just converted (with a warning message) to a wire just after elaboration. --- ivl_target.h | 3 ++- main.cc | 2 +- t-dll.cc | 8 +++++--- tgt-stub/stub.c | 3 +++ tgt-vvp/draw_net_input.c | 25 +++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ivl_target.h b/ivl_target.h index 68cf57d61..759b69157 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -353,7 +353,8 @@ typedef enum ivl_signal_type_e { IVL_SIT_TRI0 = 5, IVL_SIT_TRI1 = 6, IVL_SIT_TRIAND = 7, - IVL_SIT_TRIOR = 8 + IVL_SIT_TRIOR = 8, + IVL_SIT_UWIRE = 9 } ivl_signal_type_t; /* This is the type code for ivl_statement_t objects. */ diff --git a/main.cc b/main.cc index fa462dc24..a411b79e3 100644 --- a/main.cc +++ b/main.cc @@ -1105,7 +1105,7 @@ int main(int argc, char*argv[]) if (int emit_rc = des->emit(&dll_target_obj)) { if (emit_rc > 0) { cerr << "error: Code generation had " - << emit_rc << " errors." + << emit_rc << " error(s)." << endl; return 1; } diff --git a/t-dll.cc b/t-dll.cc index 9f2b49a55..f5d2771e9 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -2384,10 +2384,12 @@ void dll_target::signal(const NetNet*net) assert(0); break; + /* We will convert this to a TRI after we check that there + is only one driver. */ case NetNet::UWIRE: - cerr << net->get_fileline() - << ": warning: uwire is not currently supported, converting " - "it to a wire!" << endl; + obj->type_ = IVL_SIT_UWIRE; + break; + case NetNet::TRI: case NetNet::WIRE: case NetNet::IMPLICIT: diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index a00693874..2d6d0ed4a 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1224,6 +1224,9 @@ static void show_signal(ivl_signal_t net) case IVL_SIT_TRI1: type = "tri1"; break; + case IVL_SIT_UWIRE: + type = "uwire"; + break; default: break; } diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index ab9bd2905..d0bdbfcbb 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -47,6 +47,7 @@ static ivl_signal_type_t signal_type_of_nexus(ivl_nexus_t nex) continue; if (stype == IVL_SIT_NONE) continue; + if (stype == IVL_SIT_UWIRE) return IVL_SIT_UWIRE; out = stype; } @@ -572,6 +573,7 @@ static void draw_net_input_x(ivl_nexus_t nex, res = signal_type_of_nexus(nex); switch (res) { case IVL_SIT_TRI: + case IVL_SIT_UWIRE: resolv_type = "tri"; break; case IVL_SIT_TRI0: @@ -660,6 +662,7 @@ static void draw_net_input_x(ivl_nexus_t nex, tmp += strlen(tmp); switch (res) { case IVL_SIT_TRI: + case IVL_SIT_UWIRE: for (jdx = 0 ; jdx < wid ; jdx += 1) *tmp++ = 'z'; break; @@ -698,6 +701,28 @@ static void draw_net_input_x(ivl_nexus_t nex, return; } + /* A uwire is a tri with only one driver. */ + if (res == IVL_SIT_UWIRE) { + if (ndrivers > 1) { + unsigned uidx; + ivl_signal_t usig; + /* Find the uwire signal. */ + for (uidx = 0 ; uidx < ivl_nexus_ptrs(nex) ; uidx += 1) { + ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, uidx); + usig = ivl_nexus_ptr_sig(ptr); + if (usig != 0) break; + } + assert(usig); + + fprintf(stderr, "%s:%u: vvp.tgt error: uwire \"%s\" must " + "have a single driver, found (%u).\n", + ivl_signal_file(usig), + ivl_signal_lineno(usig), + ivl_signal_basename(usig), ndrivers); + vvp_errors += 1; + } + res = IVL_SIT_TRI; + } /* If the nexus has exactly one driver, then simply draw it. Note that this will *not* work if the nexus is not a