From e8bc5aefb4a1f3eaedc68d2a719b2377db003929 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 5 Dec 2008 12:09:00 -0800 Subject: [PATCH] V0.8: Get arrayed instance ports correct. This is a back port from development of the code to get the arrayed instance port order correct (MSB to LSB). --- elab_scope.cc | 6 +++++- elaborate.cc | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/elab_scope.cc b/elab_scope.cc index e4b538bc8..ceeab9157 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -448,7 +448,11 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const /* Stash the instance array of scopes into the parent scope. Later elaboration passes will use this vector to - further elaborate the array. */ + further elaborate the array. + + Note that the array is ordered from LSB to MSB. We will use + that fact in the main elaborate to connect things in the + correct order. */ sc->instance_arrays[get_name()] = instances; } diff --git a/elaborate.cc b/elaborate.cc index 9d59763af..ffd427aa2 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -663,7 +663,9 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const unsigned prts_pin_count = 0; for (unsigned inst = 0 ; inst < instance.count() ; inst += 1) { - NetScope*inst_scope = instance[inst]; + // Scan the instances from MSB to LSB. The port + // will be assembled in that order as well. + NetScope*inst_scope = instance[instance.count()-inst-1]; // Scan the module sub-ports for this instance... for (unsigned ldx = 0 ; ldx < mport.count() ; ldx += 1) {