+
+mkAssocElems ::
+ [(UnnamedSignal, SignalInfo)] -- | The signals in the current architecture
+ -> FApp UnnamedSignal -- | The application to look at.
+ -> Entity -- | The entity to map against.
+ -> [AST.AssocElem] -- | The resulting port maps
+
+mkAssocElems sigmap app entity =
+ -- Create the actual AssocElems
+ zipWith mkAssocElem ports sigs
+ where
+ -- Turn the ports and signals from a map into a flat list. This works,
+ -- since the maps must have an identical form by definition. TODO: Check
+ -- the similar form?
+ arg_ports = concat (map Foldable.toList (ent_args entity))
+ res_ports = Foldable.toList (ent_res entity)
+ arg_sigs = (concat (map Foldable.toList (appArgs app)))
+ res_sigs = Foldable.toList (appRes app)
+ -- Extract the id part from the (id, type) tuple
+ ports = (map fst (arg_ports ++ res_ports))
+ -- Translate signal numbers into names
+ sigs = (map (lookupSigName sigmap) (arg_sigs ++ res_sigs))
+
+-- | Look up a signal in the signal name map
+lookupSigName :: [(UnnamedSignal, SignalInfo)] -> UnnamedSignal -> String
+lookupSigName sigs sig = name