Commit bee78070 authored by Patricia Lopez Cueva's avatar Patricia Lopez Cueva
Browse files

SENER integration

parent 7ecf74c8
......@@ -194,20 +194,20 @@ class FromVHDLToASN1SCC(RecursiveMapperGeneric[List[int], str]): # pylint: disa
if isSequenceVariable(node):
panicWithCallStack("OCTET STRING (in %s) must have a fixed SIZE constraint !" % node.Location()) # pragma: no cover
if node._range[-1] % 4 != 0: # TODO
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
register = srcVHDL[0] + srcVHDL[1]
lines = [] # type: List[str]
lines.append("{\n")
lines.append(" unsigned int tmp, i;\n")
lines.append(" for(i=0; i<%d; i++) {\n" % int(node._range[-1] / 4))
lines.append(" tmp = 0;\n")
lines.append(" rmap_tgt_read(R_RMAP_BASEADR + %s + (i*4), &tmp, 4, R_RMAP_DSTADR);\n" % hex(register))
lines.append(" rmap_tgt_read(R_RMAP_BASEADR + %s + (i*4), &tmp, 4, R_RMAP_DSTADR);\n" % hex(register))
lines.append(" memcpy(%s.arr + (i*4), (unsigned char*)&tmp, sizeof(unsigned int));\n" % destVar)
lines.append(" }\n")
lines.append("}\n")
srcVHDL[0] += node._range[-1]
return lines
......@@ -333,7 +333,7 @@ class FromASN1SCCtoVHDL(RecursiveMapperGeneric[str, List[int]]): # pylint: disa
lines.append(" for(i=0; i<%d; i++) {\n" % int(node._range[-1] / 4))
lines.append(" tmp = 0;\n")
lines.append(" tmp = *(unsigned int*)(%s.arr + (i*4));\n" % srcVar)
lines.append(" rmap_tgt_write(R_RMAP_BASEADR + %s + (i*4), &tmp, 4, R_RMAP_DSTADR);\n" % hex(register))
lines.append(" rmap_tgt_write(R_RMAP_BASEADR + %s + (i*4), &tmp, 4, R_RMAP_DSTADR);\n" % hex(register))
lines.append(" }\n")
lines.append("}\n")
......@@ -495,7 +495,7 @@ static long long bswap64(long long x)
#endif
uint32_t count;
unsigned int count;
#include "rmap123.h"
......@@ -537,7 +537,7 @@ uint32_t count;
def ExecuteBlock(self, unused_modelingLanguage: str, unused_asnFile: str, sp: ApLevelContainer, unused_subProgramImplementation: str, maybeFVname: str) -> None:
self.C_SourceFile.write(" unsigned int flag = 0;\n\n")
self.C_SourceFile.write(" // Now that the parameters are passed inside the FPGA, run the processing logic\n")
self.C_SourceFile.write(' unsigned int okstart = 1;\n')
self.C_SourceFile.write(' if (rmap_tgt_write(R_RMAP_BASEADR + %s, &okstart, 4, R_RMAP_DSTADR)) {\n' %
hex(int(VHDL_Circuit.lookupSP[sp._id]._offset)))
......@@ -709,7 +709,7 @@ class MapASN1ToVHDLreadinputdata(RecursiveMapperGeneric[List[int], str]): # pyl
if len(node._range) > 1 and node._range[0] != node._range[1]:
panicWithCallStack("VHDL OCTET STRING (in %s) must have a fixed SIZE constraint !" % node.Location()) # pragma: no cover
if node._range[-1] % 4 != 0: # TODO
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
maxlen = len(str(node._range[-1]))
lines = [] # type: List[str]
for i in range(node._range[-1]):
......@@ -783,7 +783,7 @@ class MapASN1ToVHDLwriteoutputdata(RecursiveMapperGeneric[List[int], str]): # p
if len(node._range) > 1 and node._range[0] != node._range[1]:
panicWithCallStack("VHDL OCTET STRING (in %s) must have a fixed SIZE constraint !" % node.Location()) # pragma: no cover
if node._range[-1] % 4 != 0: # TODO
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
panicWithCallStack("OCTET STRING (in %s) is not a multiple of 4 bytes (this is not yet supported)." % node.Location())
maxlen = len(str(node._range[-1]))
lines = [] # type: List[str]
for i in range(node._range[-1]):
......@@ -1090,7 +1090,7 @@ def OnFinal() -> None:
AddToStr('circuits', ' reset_%s : in std_logic\n' % c._spCleanName)
AddToStr('circuits', ' );\n')
AddToStr('circuits', ' end component;\n\n')
skeleton = []
skeleton.append(' entity bambu_%s is\n' % c._spCleanName)
skeleton.append(' port (\n')
......@@ -1122,7 +1122,7 @@ def OnFinal() -> None:
AddToStr('reset', " %(pi)s_StartCalculationsInternal <= '0';\n" % {'pi': c._spCleanName})
AddToStr('reset', " --%(pi)s_inp <= (others => '0');\n" % {'pi': c._spCleanName})
AddToStr('reset', " %(pi)s_StartCalculationsPulse <= '0';\n" % {'pi': c._spCleanName})
AddToStr('reset', " %(pi)s_StartCalculationsInternalOld <= '0';\n" % {'pi': c._spCleanName})
AddToStr('reset', " %(pi)s_StartCalculationsInternalOld <= '0';\n" % {'pi': c._spCleanName})
AddToStr('updateStartStopPulses',
' %(pi)s_StartCalculationsPulse <= %(pi)s_StartCalculationsInternal xor %(pi)s_StartCalculationsInternalOld;\n' % {'pi': c._spCleanName})
AddToStr('updateStartStopPulses',
......@@ -1209,11 +1209,11 @@ def computeBambuDeclarations(node: AsnNode, asnTypename: str, prefix: str, names
return lines
elif isinstance(node, AsnOctetString):
if not node._range:
panicWithCallStack("need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
panicWithCallStack("need a SIZE constraint or else we can't generate C code (%s)!\n" % node.Location()) # pragma: no cover
lines = [] # type: List[str]
for i in range(0, node._range[-1]):
lines.extend(["unsigned char" + " " + prefix + "_elem_%d" % i])
return lines
return lines
else:
panicWithCallStack("Unsupported type: " + str(node.__class__))
......@@ -1262,7 +1262,7 @@ def computeBambuInputAssignmentsForSimulink(sp: ApLevelContainer, node: AsnNode,
return lines
else:
panicWithCallStack("Unsupported type: " + str(node.__class__))
def readInputsAsBambuWantsForC(param: Param, names: AST_Lookup, leafTypeDict: AST_Leaftypes):
prefixVHDL = param._id
prefixC = "IN_" + param._id
......@@ -1296,10 +1296,10 @@ def computeBambuInputAssignmentsForC(node: AsnNode, asnTypename: str, prefixC: s
lines = [] # type: List[str]
for i in range(0, node._range[-1]):
lines.extend([prefixC + ".arr[%d] = " % i + prefixVHDL + "_elem_%d" % i])
return lines
return lines
else:
panicWithCallStack("Unsupported type: " + str(node.__class__))
def writeOutputsAsBambuWantsForSimulink(sp: ApLevelContainer, param: Param, names: AST_Lookup, leafTypeDict: AST_Leaftypes):
prefixVHDL = "*" + param._id
......@@ -1380,7 +1380,7 @@ def computeBambuOutputAssignmentsForC(node: AsnNode, asnTypename: str, prefixC:
lines = [] # type: List[str]
for i in range(0, node._range[-1]):
lines.extend([prefixVHDL + "_elem_%d = " % i + prefixC + ".arr[%d]" % i])
return lines
return lines
else:
panicWithCallStack("Unsupported type: " + str(node.__class__))
......@@ -1390,9 +1390,9 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, subProgramImplementation: str)
leafTypeDict = asnParser.g_leafTypeDict
outputCsourceFilename = vhdlBackend.CleanNameAsToolWants(sp._id) + "_bambu.c"
bambuFile = open(os.path.dirname(vhdlBackend.C_SourceFile.name) + '/' + outputCsourceFilename, 'w')
bambuFile.write("#include \"%s.h\" // Space certified compiler generated\n" % vhdlBackend.asn_name)
bambuFile.write("#include \"%s.h\"\n" % vhdlBackend.CleanNameAsToolWants(sp._id))
bambuFile.write("#include \"%s_types.h\"\n\n" % vhdlBackend.CleanNameAsToolWants(sp._id))
......@@ -1409,7 +1409,7 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, subProgramImplementation: str)
bambuFile.write(
'%s%s' % (",\n " if idx != 0 else "", line))
bambuFile.write(') {\n')
initStr = """
static int initialized = 0;
......@@ -1428,7 +1428,7 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, subProgramImplementation: str)
for idx, line in enumerate(lines):
bambuFile.write(
'%s%s;' % ("\n ", line))
stepStr = """
#ifndef rtmGetStopRequested
......@@ -1441,7 +1441,7 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, subProgramImplementation: str)
#endif
""" % (sp._id, sp._id, sp._id, sp._id, sp._id)
bambuFile.write(stepStr)
lines = []
for param in sp._params:
if isinstance(param, OutParam):
......@@ -1449,8 +1449,8 @@ def EmitBambuSimulinkBridge(sp: ApLevelContainer, subProgramImplementation: str)
writeOutputsAsBambuWantsForSimulink(sp, param, names, leafTypeDict))
for idx, line in enumerate(lines):
bambuFile.write(
'%s%s;' % ("\n ", line))
'%s%s;' % ("\n ", line))
bambuFile.write('\n}\n\n')
......@@ -1460,13 +1460,13 @@ def EmitBambuCBridge(sp: ApLevelContainer, subProgramImplementation: str):
leafTypeDict = asnParser.g_leafTypeDict
outputCsourceFilename = vhdlBackend.CleanNameAsToolWants(sp._id) + "_bambu.c"
bambuFile = open(os.path.dirname(vhdlBackend.C_SourceFile.name) + '/' + outputCsourceFilename, 'w')
functionBlocksName = os.path.dirname(vhdlBackend.C_SourceFile.name)[4:] # not elegant but not sure how to get the Function Block's name from here
bambuFile.write("#include \"%s.h\" // Space certified compiler generated\n" % vhdlBackend.asn_name)
bambuFile.write("#include \"%s.h\"\n" % functionBlocksName)
bambuFile.write("#include \"%s.h\"\n" % functionBlocksName)
bambuFile.write('\nvoid bambu_%s(\n ' % sp._id)
# List flattened PI parameters
lines = []
......@@ -1477,7 +1477,7 @@ def EmitBambuCBridge(sp: ApLevelContainer, subProgramImplementation: str):
bambuFile.write(
'%s%s' % (",\n " if idx != 0 else "", line))
bambuFile.write(') {\n')
# Declare PI params
lines = []
for param in sp._params:
......@@ -1522,6 +1522,6 @@ def EmitBambuCBridge(sp: ApLevelContainer, subProgramImplementation: str):
writeOutputsAsBambuWantsForC(param, names, leafTypeDict))
for idx, line in enumerate(lines):
bambuFile.write(
'%s%s;' % ("\n ", line))
'%s%s;' % ("\n ", line))
bambuFile.write('\n}\n\n')
......@@ -314,13 +314,9 @@ project.addFiles('top_lib', ['rdhc_bb.vhd'])
project.setOptions({'UseNxLibrary': 'Yes',
'MergeRegisterToPad': 'Always',
'MultiplierToDSPMapThreshold': '1',
'ManageUnconnectedOutputs': 'Ground',
'ManageUnconnectedSignals': 'Ground',
'AdderToDSPMapThreshold': '0',
'DefaultRAMMapping': 'RAM',
'MappingEffort': 'Low', 'ManageAsynchronousReadPort': 'No',
'TimingDriven': 'Yes'})
'DefaultRAMMapping': 'RAM'})
project.addMappingDirective('getModels(.*regfile_3p.*)', 'RAM', 'RF')
#=======================================================================================================
# Assigning timing constraints
......
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