Archived
1
0

Merge pull request #7 from cryham/check

Added check for too small stateWordSize (default 8) showing: Over 255…
This commit is contained in:
Jacob Alexander 2016-05-08 17:16:41 -07:00
commit 034927e13b

View File

@ -119,11 +119,14 @@ class Backend( BackendBase ):
## Defines ## ## Defines ##
self.fill_dict['Defines'] = "" self.fill_dict['Defines'] = ""
stateWordSize = ""
# Iterate through defines and lookup the variables # Iterate through defines and lookup the variables
for define in variables.defines.keys(): for define in variables.defines.keys():
if define in variables.overallVariables.keys(): if define in variables.overallVariables.keys():
self.fill_dict['Defines'] += "\n#define {0} {1}".format( variables.defines[ define ], variables.overallVariables[ define ].replace( '\n', ' \\\n' ) ) self.fill_dict['Defines'] += "\n#define {0} {1}".format( variables.defines[ define ], variables.overallVariables[ define ].replace( '\n', ' \\\n' ) )
if define == "stateWordSize":
stateWordSize = variables.overallVariables[ define ]
else: else:
print( "{0} '{1}' not defined...".format( WARNING, define ) ) print( "{0} '{1}' not defined...".format( WARNING, define ) )
@ -215,6 +218,8 @@ class Backend( BackendBase ):
self.fill_dict['ResultMacroList'] += "\tDefine_RM( {0} ),\n".format( result ) self.fill_dict['ResultMacroList'] += "\tDefine_RM( {0} ),\n".format( result )
self.fill_dict['ResultMacroList'] += "};" self.fill_dict['ResultMacroList'] += "};"
results_count = len( macros.resultsIndexSorted );
## Result Macro Record ## ## Result Macro Record ##
self.fill_dict['ResultMacroRecord'] = "ResultMacroRecord ResultMacroRecordList[ ResultMacroNum ];" self.fill_dict['ResultMacroRecord'] = "ResultMacroRecord ResultMacroRecordList[ ResultMacroNum ];"
@ -224,6 +229,7 @@ class Backend( BackendBase ):
self.fill_dict['TriggerMacros'] = "" self.fill_dict['TriggerMacros'] = ""
# Iterate through each of the trigger macros # Iterate through each of the trigger macros
triggers_count = len( macros.triggersIndexSorted );
for trigger in range( 0, len( macros.triggersIndexSorted ) ): for trigger in range( 0, len( macros.triggersIndexSorted ) ):
self.fill_dict['TriggerMacros'] += "Guide_TM( {0} ) = {{ ".format( trigger ) self.fill_dict['TriggerMacros'] += "Guide_TM( {0} ) = {{ ".format( trigger )
@ -249,6 +255,14 @@ class Backend( BackendBase ):
self.fill_dict['TriggerMacros'] += "0 };\n" self.fill_dict['TriggerMacros'] += "0 };\n"
self.fill_dict['TriggerMacros'] = self.fill_dict['TriggerMacros'][ :-1 ] # Remove last newline self.fill_dict['TriggerMacros'] = self.fill_dict['TriggerMacros'][ :-1 ] # Remove last newline
# check for too small stateWordSize
if stateWordSize == "8" and (triggers_count > 255 or results_count > 255):
print ("{0} Over 255 trigger or result macros, changing stateWordSize from {1} to 16.".format( WARNING, stateWordSize ) )
print( "Results count: ", results_count )
print( "Triggers count:", triggers_count )
stateWordSize == "16"
self.fill_dict['Defines'] = self.fill_dict['Defines'].replace("StateWordSize_define 8", "StateWordSize_define 16")
#print (self.fill_dict['Defines'])
## Trigger Macro List ## ## Trigger Macro List ##
self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n" self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n"