Beispiel #1
0
 def subIdxs(self, idx, node, ctx):
     if isinstance(node, VecInit):
         return [(nIdx, elem) for i, n in enumerate(node.lst)
                 for nIdx, elem in node.subIdxs(
                     low_ir.SubIndex(idx, i, node.typ.mapToIR(ctx)), n, ctx)
                 ]
     else:
         return [(idx, node.mapToIR(ctx))]
Beispiel #2
0
    def mapToIR(self, ctx: EmitterContext):
        # Define Wire
        name = ctx.getName(self)
        typ = self.typ.mapToIR(ctx)
        wire = low_ir.DefWire(name, typ)
        ctx.appendFinalStatement(wire, self.scopeId)
        ref = low_ir.Reference(name, typ)
        ctx.updateRef(self, ref)

        # Connect Elements
        for i, node in enumerate(self.lst):
            for idx, elem in self.subIdxs(low_ir.SubIndex(ref, i, typ.typ),
                                          node, ctx):
                con = low_ir.Connect(idx, elem)
                ctx.appendFinalStatement(con, self.scopeId)

        return ref