@@ -80,8 +80,8 @@ class ModuleDependencyFinder(mainModuleName : Identifier) extends ASTAnalyzer(
8080}
8181
8282object ModuleInstantiatorPass {
83- sealed abstract class InstanceVarRenaming (val ident : Identifier , val typ : Type )
84- case class BoundInput (id : Identifier , t : Type , expr : Expr ) extends InstanceVarRenaming (id , t)
83+ sealed abstract class InstanceVarRenaming (val expr : Expr , val typ : Type )
84+ case class BoundInput (exp : Expr , t : Type ) extends InstanceVarRenaming (exp , t)
8585 case class UnboundInput (id : Identifier , t : Type ) extends InstanceVarRenaming (id, t)
8686 case class BoundOutput (lhs : Lhs , t : Type ) extends InstanceVarRenaming (lhs.ident, t)
8787 case class UnboundOutput (id : Identifier , t : Type ) extends InstanceVarRenaming (id, t)
@@ -111,11 +111,11 @@ object ModuleInstantiatorPass {
111111 }
112112 }
113113
114- // Convert a RewriteMap into a VarMap
114+ // Convert a VarMap into a RewriteMap.
115115 def toRewriteMap (varMap : VarMap , instVarMap : InstVarMap ) : RewriteMap = {
116116 val empty : RewriteMap = Map .empty
117117 val rewriteMap1 = varMap.foldLeft(empty) {
118- (acc, mapping) => acc + (mapping._1 -> mapping._2.ident )
118+ (acc, mapping) => acc + (mapping._1 -> mapping._2.expr )
119119 }
120120 val rewriteMap2 = instVarMap.foldLeft(rewriteMap1) {
121121 (acc, mapping) => {
@@ -146,8 +146,11 @@ class ModuleInstantiatorPass(module : Module, inst : InstanceDecl, targetModule
146146 // map each input
147147 val idMap1 = targetModule.inputs.foldLeft(idMap0) {
148148 (mapAcc, inp) => {
149+ logger.debug(" inp is %s" .format(inp.toString))
149150 inst.argMap.get(inp._1) match {
150- case Some (expr) => mapAcc + (inp._1 -> MIP .BoundInput (NameProvider .get(inp._1.toString + " _bound_input" ), inp._2, expr))
151+ case Some (expr) =>
152+ logger.debug(" expr is %s" .format(expr.toString))
153+ mapAcc + (inp._1 -> MIP .BoundInput (expr, inp._2))
151154 case None => mapAcc + (inp._1 -> MIP .UnboundInput (NameProvider .get(inp._1.toString + " _unbound_input" ), inp._2))
152155 }
153156 }
@@ -192,11 +195,18 @@ class ModuleInstantiatorPass(module : Module, inst : InstanceDecl, targetModule
192195 val instVarMap1 = varMap.foldLeft(Map .empty[List [Identifier ], Identifier ]) {
193196 (instVarMap, renaming) => {
194197 renaming._2 match {
195- case MIP .BoundInput (_, _, _) | MIP .UnboundInput (_, _) |
198+ case MIP .BoundInput (_, _) =>
199+ if (renaming._2.expr.isInstanceOf [Identifier ])
200+ {
201+ instVarMap + (List (inst.instanceId, renaming._1) -> renaming._2.expr.asInstanceOf [Identifier ])
202+ }
203+ else
204+ instVarMap
205+ case MIP .UnboundInput (_, _) |
196206 MIP .BoundOutput (_, _) | MIP .UnboundOutput (_, _) |
197207 MIP .StateVariable (_, _) | MIP .SharedVariable (_, _) |
198208 MIP .Constant (_, _) =>
199- instVarMap + (List (inst.instanceId, renaming._1) -> renaming._2.ident )
209+ instVarMap + (List (inst.instanceId, renaming._1) -> renaming._2.expr. asInstanceOf [ Identifier ] )
200210 case _ =>
201211 instVarMap
202212 }
@@ -228,7 +238,7 @@ class ModuleInstantiatorPass(module : Module, inst : InstanceDecl, targetModule
228238 varMap.map {
229239 v => {
230240 v._2 match {
231- case MIP .BoundInput (id, t, _) => fixPosition( Some ( StateVarsDecl ( List (id), t)), id.position)
241+ case MIP .BoundInput (_, _) => None
232242 case MIP .UnboundOutput (id, t) => fixPosition(Some (StateVarsDecl (List (id), t)), id.position)
233243 case MIP .StateVariable (id, t) => fixPosition(Some (StateVarsDecl (List (id), t)), id.position)
234244 case MIP .Constant (id, t) => fixPosition(Some (ConstantsDecl (List (id), t)), id.position)
@@ -244,7 +254,7 @@ class ModuleInstantiatorPass(module : Module, inst : InstanceDecl, targetModule
244254 v => {
245255 v._2 match {
246256 case MIP .UnboundInput (id, t) => fixPosition(Some (InputVarsDecl (List (id), t)), id.position)
247- case MIP .BoundInput (_, _, _ ) | MIP .BoundOutput (_, _) |
257+ case MIP .BoundInput (_, _) | MIP .BoundOutput (_, _) |
248258 MIP .UnboundOutput (_, _) | MIP .StateVariable (_, _) |
249259 MIP .SharedVariable (_, _) | MIP .Constant (_, _) | MIP .Function (_, _) =>
250260 None
@@ -253,18 +263,7 @@ class ModuleInstantiatorPass(module : Module, inst : InstanceDecl, targetModule
253263 }.toList.flatten
254264 }
255265
256- def createNextInputAssignments (varMap : VarMap ) : List [Statement ] = {
257- varMap.map {
258- v => {
259- v._2 match {
260- case MIP .BoundInput (id, _, expr) =>
261- fixPosition(Some (AssignStmt (List (LhsId (id)), List (expr))), id.position)
262- case _ =>
263- None
264- }
265- }
266- }.toList.flatten
267- }
266+ def createNextInputAssignments (varMap : VarMap ) : List [Statement ] = { List () }
268267
269268 val (varMap, externalSymbolMap) = createVarMap()
270269 val targetInstVarMap = targetModule.getAnnotation[InstanceVarMapAnnotation ].get.iMap
0 commit comments