Commit 02d81ca7 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

GMV/Tiago and GMV/Laura: Appeasing mypy.

parent eba64e8c
Pipeline #2887 failed with stage
in 2 minutes and 36 seconds
......@@ -118,6 +118,7 @@ def RegistersAllocated(node_or_str: Union[str, AsnNode]) -> int:
retValue = RegistersAllocated(names[node._containedType])
else: # pragma: no cover
panicWithCallStack("unsupported %s (%s)" % (str(node.__class__), node.Location())) # pragma: no cover
assert retValue is not None
return retValue
......@@ -976,41 +977,49 @@ def OnStartup(modelingLanguage: str, asnFile: str, subProgram: ApLevelContainer,
def OnBasic(nodeTypename: str, node: AsnBasicNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnBasic(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnBasic(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequence(nodeTypename: str, node: AsnSequence, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnSequence(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnSequence(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSet(nodeTypename: str, node: AsnSet, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
vhdlBackend.OnSet(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
if vhdlBackend:
vhdlBackend.OnSet(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnEnumerated(nodeTypename: str, node: AsnEnumerated, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnEnumerated(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnEnumerated(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequenceOf(nodeTypename: str, node: AsnSequenceOf, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnSequenceOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnSequenceOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSetOf(nodeTypename: str, node: AsnSetOf, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
vhdlBackend.OnSetOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
if vhdlBackend:
vhdlBackend.OnSetOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnChoice(nodeTypename: str, node: AsnChoice, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnChoice(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnChoice(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnShutdown(modelingLanguage: str, asnFile: str, sp: ApLevelContainer, subProgramImplementation: str, maybeFVname: str) -> None:
vhdlBackend.OnShutdown(modelingLanguage, asnFile, sp, subProgramImplementation, maybeFVname)
if vhdlBackend:
vhdlBackend.OnShutdown(modelingLanguage, asnFile, sp, subProgramImplementation, maybeFVname)
if subProgramImplementation.lower() == "simulink":
EmitBambuSimulinkBridge(sp, subProgramImplementation)
elif subProgramImplementation.lower() == "c":
......@@ -1022,6 +1031,7 @@ def AddToStr(s: str, d: str) -> None:
def OnFinal() -> None:
assert vhdlBackend is not None
circuitMapper = MapASN1ToVHDLCircuit()
ioRegisterMapper = MapASN1ToVHDLregisters()
readinputdataMapper = MapASN1ToVHDLreadinputdata()
......@@ -1206,6 +1216,8 @@ def getTypeAndVarsAsBambuWantsThem(param: Param, names: AST_Lookup, leafTypeDict
def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1232,7 +1244,7 @@ def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuDeclarations(
......@@ -1245,7 +1257,7 @@ def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuDeclarations] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(["unsigned char" + " " + prefix + "_elem_%0*d" % (maxlen, i)])
......@@ -1263,6 +1275,8 @@ def readInputsAsBambuWantsForSimulink(sp: ApLevelContainer, param: Param, names:
def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode, unused_asnTypename: str, prefixSimulink: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1291,7 +1305,7 @@ def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode,
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuInputAssignmentsForSimulink(
......@@ -1306,7 +1320,7 @@ def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode,
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForSimulink] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([clean(sp._id) + "_U." + prefixSimulink + ".element_data[%d] = " % i + prefixVHDL + "_elem_%0*d" % (maxlen, i)])
......@@ -1324,6 +1338,8 @@ def readInputsAsBambuWantsForC(param: Param, names: AST_Lookup, leafTypeDict: AS
def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, prefixC: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1350,7 +1366,7 @@ def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pre
elif isinstance(node, (AsnSequenceOf, AsnSetOf)):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(
......@@ -1365,7 +1381,7 @@ def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pre
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixC + ".arr[%d] = " % i + prefixVHDL + "_elem_%0*d" % (maxlen, i)])
......@@ -1383,6 +1399,8 @@ def writeOutputsAsBambuWantsForSimulink(sp: ApLevelContainer, param: Param, name
def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode, unused_asnTypename: str, prefixSimulink: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1411,7 +1429,7 @@ def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuOutputAssignmentsForSimulink(
......@@ -1426,7 +1444,7 @@ def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForSimulink] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixVHDL + "_elem_%0*d = " % (maxlen, i) + clean(sp._id) + "_Y." + prefixSimulink + ".element_data[%d]" % i])
......@@ -1444,6 +1462,8 @@ def writeOutputsAsBambuWantsForC(param: Param, names: AST_Lookup, leafTypeDict:
def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, prefixC: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1470,7 +1490,7 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
elif isinstance(node, (AsnSequenceOf, AsnSetOf)):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(
......@@ -1485,7 +1505,7 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixVHDL + "_elem_%0*d = " % (maxlen, i) + prefixC + ".arr[%d]" % i])
......@@ -1495,6 +1515,8 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
def EmitBambuSimulinkBridge(sp: ApLevelContainer, unused_subProgramImplementation: str):
assert vhdlBackend is not None
# Parameter access is much faster in Python - cache these two globals
names = asnParser.g_names
leafTypeDict = asnParser.g_leafTypeDict
......@@ -1565,6 +1587,8 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, unused_subProgramImplementatio
def EmitBambuCBridge(sp: ApLevelContainer, unused_subProgramImplementation: str):
assert vhdlBackend is not None
# Parameter access is much faster in Python - cache these two globals
names = asnParser.g_names
leafTypeDict = asnParser.g_leafTypeDict
......
......@@ -120,6 +120,7 @@ def RegistersAllocated(node_or_str: Union[str, AsnNode]) -> int:
retValue = RegistersAllocated(names[node._containedType])
else: # pragma: no cover
panicWithCallStack("unsupported %s (%s)" % (str(node.__class__), node.Location())) # pragma: no cover
assert retValue is not None
return retValue
......@@ -1233,41 +1234,49 @@ def OnStartup(modelingLanguage: str, asnFile: str, subProgram: ApLevelContainer,
def OnBasic(nodeTypename: str, node: AsnBasicNode, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnBasic(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnBasic(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequence(nodeTypename: str, node: AsnSequence, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnSequence(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnSequence(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSet(nodeTypename: str, node: AsnSet, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
vhdlBackend.OnSet(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
if vhdlBackend:
vhdlBackend.OnSet(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnEnumerated(nodeTypename: str, node: AsnEnumerated, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnEnumerated(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnEnumerated(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSequenceOf(nodeTypename: str, node: AsnSequenceOf, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnSequenceOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnSequenceOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnSetOf(nodeTypename: str, node: AsnSetOf, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
vhdlBackend.OnSetOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
if vhdlBackend:
vhdlBackend.OnSetOf(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pragma: nocover
def OnChoice(nodeTypename: str, node: AsnChoice, subProgram: ApLevelContainer, subProgramImplementation: str, param: Param, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
Common(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
vhdlBackend.OnChoice(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
if vhdlBackend:
vhdlBackend.OnChoice(nodeTypename, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
def OnShutdown(modelingLanguage: str, asnFile: str, sp: ApLevelContainer, subProgramImplementation: str, maybeFVname: str) -> None:
vhdlBackend.OnShutdown(modelingLanguage, asnFile, sp, subProgramImplementation, maybeFVname)
if vhdlBackend:
vhdlBackend.OnShutdown(modelingLanguage, asnFile, sp, subProgramImplementation, maybeFVname)
if subProgramImplementation.lower() == "simulink":
EmitBambuSimulinkBridge(sp, subProgramImplementation)
elif subProgramImplementation.lower() == "c":
......@@ -1279,6 +1288,8 @@ def AddToStr(s: str, d: str) -> None:
def OnFinal() -> None:
assert vhdlBackend is not None
circuitMapper = MapASN1ToVHDLCircuit()
ioRegisterMapper = MapASN1ToVHDLregisters()
inputDeclarationMapper = MapASN1ToVHDLinput()
......@@ -1502,6 +1513,7 @@ def getTypeAndVarsAsBambuWantsThem(param: Param, names: AST_Lookup, leafTypeDict
def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1524,7 +1536,7 @@ def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuDeclarations(
......@@ -1537,7 +1549,7 @@ def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuDeclarations] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(["unsigned char" + " " + prefix + "_elem_%0*d" % (maxlen, i)])
......@@ -1555,6 +1567,7 @@ def readInputsAsBambuWantsForSimulink(sp: ApLevelContainer, param: Param, names:
def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode, unused_asnTypename: str, prefixSimulink: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1583,7 +1596,7 @@ def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode,
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuInputAssignmentsForSimulink(
......@@ -1598,7 +1611,7 @@ def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode,
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForSimulink] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([clean(sp._id) + "_U." + prefixSimulink + ".element_data[%d] = " % i + prefixVHDL + "_elem_%0*d" % (maxlen, i)])
......@@ -1616,6 +1629,7 @@ def readInputsAsBambuWantsForC(param: Param, names: AST_Lookup, leafTypeDict: AS
def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, prefixC: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1638,7 +1652,7 @@ def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pre
elif isinstance(node, (AsnSequenceOf, AsnSetOf)):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(
......@@ -1653,7 +1667,7 @@ def computeBambuInputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pre
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuInputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixC + ".arr[%d] = " % i + prefixVHDL + "_elem_%0*d" % (maxlen, i)])
......@@ -1671,6 +1685,7 @@ def writeOutputsAsBambuWantsForSimulink(sp: ApLevelContainer, param: Param, name
def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode, unused_asnTypename: str, prefixSimulink: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1699,7 +1714,7 @@ def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode
leafTypeDict))
return lines
elif isinstance(node, (AsnSequence, AsnSet)):
lines = [] # type: List[str]
lines = []
for child in node._members:
lines.extend(
computeBambuOutputAssignmentsForSimulink(
......@@ -1714,7 +1729,7 @@ def computeBambuOutputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForSimulink] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixVHDL + "_elem_%0*d = " % (maxlen, i) + clean(sp._id) + "_Y." + prefixSimulink + ".element_data[%d]" % i])
......@@ -1732,6 +1747,7 @@ def writeOutputsAsBambuWantsForC(param: Param, names: AST_Lookup, leafTypeDict:
def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, prefixC: str, prefixVHDL: str, names: AST_Lookup, leafTypeDict: AST_Leaftypes) -> List[str]:
assert vhdlBackend is not None
clean = vhdlBackend.CleanNameAsToolWants
while isinstance(node, AsnMetaMember):
node = names[node._containedType]
......@@ -1758,7 +1774,7 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
elif isinstance(node, (AsnSequenceOf, AsnSetOf)):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend(
......@@ -1773,7 +1789,7 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("[computeBambuOutputAssignmentsForC] need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
lines = []
maxlen = len(str(node._range[-1]))
for i in range(0, node._range[-1]):
lines.extend([prefixVHDL + "_elem_%0*d = " % (maxlen, i) + prefixC + ".arr[%d]" % i])
......@@ -1783,6 +1799,8 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, unused_asnTypename: str, pr
def EmitBambuSimulinkBridge(sp: ApLevelContainer, unused_subProgramImplementation: str):
assert vhdlBackend is not None
# Parameter access is much faster in Python - cache these two globals
names = asnParser.g_names
leafTypeDict = asnParser.g_leafTypeDict
......@@ -1854,6 +1872,8 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, unused_subProgramImplementatio
def EmitBambuCBridge(sp: ApLevelContainer, unused_subProgramImplementation: str):
assert vhdlBackend is not None
# Parameter access is much faster in Python - cache these two globals
names = asnParser.g_names
leafTypeDict = asnParser.g_leafTypeDict
......
......@@ -402,7 +402,7 @@ def ProcessCustomBackends(
# Taking list of tuples made of (spName, sp_impl, language, maybeFVname)
asnFile: Optional[str],
useOSS: bool,
SystemsAndImplementations: List[Tuple[str, str, str, str]]) -> None:
SystemsAndImplementations: List[Tuple[str, str, str, str, str]]) -> None:
# The code generators for GUIs, Python mappers and VHDL mappers are different: they need access to
# both ASN.1 types and SP params.
......@@ -559,7 +559,7 @@ def main() -> None:
commonPy.configMT.fpga_mapper = os.path.normpath(sys.argv[idx + 1])
except: # pragma: no cover
panic('Usage: %s [-v] [-verbose] [-useOSS] [-fpga <BRAVE|ZESTSC1|ZYNQZC706>] [-o dirname] input1.aadl [input2.aadl] ...\n' % sys.argv[0]) # pragma: no cover
if commonPy.configMT.fpga_mapper is None or commonPy.configMT.fpga_mapper not in ['BRAVE', 'ZESTSC1', 'ZYNQZC706']:
if commonPy.configMT.fpga_mapper == '' or commonPy.configMT.fpga_mapper not in ['BRAVE', 'ZESTSC1', 'ZYNQZC706']:
panic('Usage: %s [-v] [-verbose] [-useOSS] [-fpga <BRAVE|ZESTSC1|ZYNQZC706>] [-o dirname] input1.aadl [input2.aadl] ...\n' % sys.argv[0]) # pragma: no cover
del sys.argv[idx]
del sys.argv[idx]
......
......@@ -41,9 +41,9 @@ from typing import Tuple, Union, Dict, Any, List # NOQA pylint: disable=unused-
g_apLevelContainers = {} # type: Dict[str, ApLevelContainer]
g_subProgramImplementations = [] # type: List[Tuple[str,str,str,str]]
g_processImplementations = [] # type: List[Tuple[str,str,str,str]]
g_threadImplementations = [] # type: List[Tuple[str,str,str,str]]
g_subProgramImplementations = [] # type: List[Tuple[str,str,str,str,str]]
g_processImplementations = [] # type: List[Tuple[str,str,str,str,str]]
g_threadImplementations = [] # type: List[Tuple[str,str,str,str,str]]
# AST classes
......@@ -199,6 +199,7 @@ class ApLevelContainer:
self._params = [] # type: List[Param]
self._connections = [] # type: List[Connection]
self._language: str
self._fpgaConfigurations: str
def AddConnection(self, srcUniquePortId: UniquePortIdentifier, destUniquePortId: UniquePortIdentifier) -> None:
if srcUniquePortId._componentId is None:
......
......@@ -43,4 +43,4 @@ debugParser = False
verbose = False
showCode = False
outputDir = "." + os.sep
fpga_mapper = None
fpga_mapper = ''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment