From 18f230fc460145f1c78a158b73924ce8d2f7dfdc Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 26 Mar 2020 09:04:52 -0400 Subject: [PATCH 1/2] Changed the default string size for tmpstr in flattenInstancesOf from 200 to 1024. Probably this should be dynamically allocated and expanded as needed, as it is holding names that are of increasing length as a hierarchy is descended and the instance prefixes appended to the name. --- VERSION | 2 +- base/flatten.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 09a6fc1..8dcb446 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.144 +1.5.145 diff --git a/base/flatten.c b/base/flatten.c index bae43f5..b6c8a26 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -259,7 +259,7 @@ int flattenInstancesOf(char *name, int fnum, char *instance) struct nlist *ChildCell; struct objlist *tmp, *ob2, *ob3; int notdone, rnodenum; - char tmpstr[200]; + char tmpstr[1024]; int nextnode, oldmax, numflat = 0; #if !OLDPREFIX int prefixlength; From 36aa373fb2d0120e3f5ade1c561abf6641c80826 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 26 Mar 2020 11:53:52 -0400 Subject: [PATCH 2/2] Corrected an error in the verilog read to correctly assign signals to bus pins over an array of instances. Takes care of the three situations where the length of the signal bus equals the number of instances; where the length of the signal bus is a multiple of the number of instances; and where the number of instances is a multiple of the length of the signal bus. --- base/verilog.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/base/verilog.c b/base/verilog.c index c9e7a2c..d7b60fe 100644 --- a/base/verilog.c +++ b/base/verilog.c @@ -1565,19 +1565,40 @@ nextinst: // Check if net name is a wire bus or portion of a bus if (GetBus(scan->net, &wb) == 0) { int range; + + // This takes care of three situations: + // (1) The signal bus length matches the number of instances: + // apply one signal per instance. + // (2) The signal bus length is a multiple of the number of instances: + // apply a signal sub-bus to each instance. + // (3) The number of instances is a multiple of the signal bus length: + // apply the same signal to each instance. + if ((arrayend - arraystart) == (wb.end - wb.start)) { // Net is a bus, but net is split over arrayed instances Port(scan->name); } else if (wb.start > wb.end) { - range = wb.start - wb.end; + if ((arraystart - arrayend) > (wb.start - wb.end)) + range = (((arraystart - arrayend) + 1) / + ((wb.start - wb.end) + 1)) - 1; + else + range = (((wb.start - wb.end) + 1) / + ((arraystart - arrayend) + 1)) - 1; + for (i = range; i >= 0; i--) { sprintf(defport, "%s[%d]", scan->name, i); Port(defport); } } else { - range = wb.end - wb.start; + if ((arrayend - arraystart) > (wb.end - wb.start)) + range = (((arrayend - arraystart) + 1) / + ((wb.end - wb.start) + 1)) - 1; + else + range = (((wb.end - wb.start) + 1) / + ((arrayend - arraystart) + 1)) - 1; + for (i = 0; i <= range; i++) { sprintf(defport, "%s[%d]", scan->name, i); Port(defport);