Ejemplo n.º 1
0
def createHDLGlobalPortsFromSST(HDL, SST):

    # 0/ default assignments
    iCTR = 0
    oCTR = 0

    ## 1/ walk the SST to create intances
    print("INFO: Creating global ports from SST...", end="")
    for cNode in SST.listNode:

        # 1.1/ input ports
        if cNode.type == sst.typeNode.VARIABLE:
            newPort = dp.sornPort(HDL)
            newPort.name = cNode.name
            if not cNode.islValue:
                iCTR += 1
                newPort.isInput = True
            else:
                oCTR += 1
            newPort.isGlobal = True

    print("INFO: " + str(iCTR) + " input and " + str(oCTR) +
          " output global port(s) found")

    return HDL
Ejemplo n.º 2
0
def createToplevelInstance(env):

    # 1/ default assignments and preliminaries
    cPortNameDict = {}
    print("creating toplevel instance...", end="")
    HDL = dp.sornHDL(env.name)
    HDL.isToplevel = True
    print(env.name)
    # 2/ get input and output lists
    for cValue in env.HDL:
        for cPort in env.HDL[cValue].ports:
            if cPort.isGlobal:
                if not cPort.name in cPortNameDict:
                    cPortNameDict[cPort.name] = [cPort]
                else:
                    cPortNameDict[cPort.name].append(cPort)
    # 3/ get internally connected ports
    for cName in cPortNameDict:
        equalDirection = True
        cDirection = cPortNameDict[cName][0].isInput
        for cNode in cPortNameDict[cName]:
            if not (cNode.isInput == cDirection): equalDirection = False
        if equalDirection:
            cPortNameDict[cName] = [cPortNameDict[cName][0]]
    # 4/ set up ports
    for cName in cPortNameDict:
        if len(cPortNameDict[cName]) == 1:
            newPort = dp.sornPort(HDL)
            newPort.name = cName
            newPort.isGlobal = True
            newPort.isInput = cPortNameDict[cName][0].isInput
        else:
            newNet = dp.sornNet(HDL, cName)
    print("DONE! ")
    print(str(len(HDL.nets)) + " net(s) in total")
    env.HDL[env.name] = HDL
    return env.HDL
Ejemplo n.º 3
0
def createHDLInstancesFromSST(HDL, SST):

    ## 1/ walk the SST to create intances
    print("creating sorn instances from SST...", end="")
    for cNode in SST.listNode:

        # 1.1/ binary operator
        if cNode.type == sst.typeNode.BINOP:

            # 1.1.1/ create and configure new i/0 ports
            newInputPort0 = dp.sornPort(HDL)
            newInputPort0.isInput = True
            newInputPort0.name = "input0"

            if not (cNode.siblings[0].type == sst.typeNode.NUMERIC
                    or cNode.siblings[1].type == sst.typeNode.NUMERIC):
                newInputPort1 = dp.sornPort(HDL)
                newInputPort1.isInput = True
                newInputPort1.name = "input1"

            newOutputPort = dp.sornPort(HDL)
            newOutputPort.name = "output0"

            # 1.1.2/ create and configure new instance
            cInst = dp.sornInstance(HDL, cNode.name, cNode.function, [])
            cInst.nodeSST = cNode
            cInst.depth = cNode.depth
            cNode.instHDL = cInst
            # 1.1.4/ register instance to ports and vice versa
            dp.register(newInputPort0, cInst)
            if not (cNode.siblings[0].type == sst.typeNode.NUMERIC
                    or cNode.siblings[1].type == sst.typeNode.NUMERIC):
                dp.register(newInputPort1, cInst)
            dp.register(newOutputPort, cInst)

        # 1.2/ (function) call
        if cNode.type == sst.typeNode.FUNCTION:
            # 1.2.1/ create and configure new i/0 ports
            newInputPort = dp.sornPort(HDL)
            newInputPort.isInput = True
            newInputPort.name = "input0"

            newOutputPort = dp.sornPort(HDL)
            newOutputPort.name = "output0"

            # 1.2.2/ create and configure new instance
            cInst = dp.sornInstance(HDL, cNode.name, cNode.function, [])
            cInst.nodeSST = cNode
            cInst.depth = cNode.depth
            cNode.instHDL = cInst
            # 1.2.3/ register instance to ports and vice versa
            dp.register(newInputPort, cInst)
            dp.register(newOutputPort, cInst)

        # 1.3/ pipeline register
        if cNode.type == sst.typeNode.REGISTER:
            # 1.3.1/ create and configure new i/0 ports
            newInputPort = dp.sornPort(HDL)
            newInputPort.isInput = True
            newInputPort.name = "input0"

            newOutputPort = dp.sornPort(HDL)
            newOutputPort.name = "output0"

            # 1.3.2/ create and configure new instance
            cInst = dp.sornInstance(HDL, cNode.name, [], [])
            cInst.nodeSST = cNode
            cInst.depth = cNode.depth
            cNode.instHDL = cInst
            cInst.isRegister = True
            # 1.3.3/ register instance to ports and vice versa
            dp.register(newInputPort, cInst)
            dp.register(newOutputPort, cInst)

    print(str(len(HDL.instances)) + " instance(s) in total")

    return HDL