mirror of https://github.com/efabless/caravel.git
Merge pull request #542 from d-m-bailey/gpio-fix
Requires testing after merge. Moving in DEV branch.
This commit is contained in:
commit
3cacfeae5b
|
@ -152,8 +152,10 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if os.path.isfile(user_defines_path):
|
if os.path.isfile(user_defines_path):
|
||||||
with open(user_defines_path, 'r') as ifile:
|
with open(user_defines_path, 'r') as ifile:
|
||||||
infolines = ifile.read().splitlines()
|
raw_data = ifile.read()
|
||||||
for line in infolines:
|
comment_pattern = r'//.*|/\*[\s\S]*?\*/'
|
||||||
|
data_without_comments = re.sub(comment_pattern, '', raw_data)
|
||||||
|
for line in data_without_comments.splitlines():
|
||||||
tokens = line.split()
|
tokens = line.split()
|
||||||
if len(tokens) >= 3:
|
if len(tokens) >= 3:
|
||||||
if tokens[0] == '`define':
|
if tokens[0] == '`define':
|
||||||
|
@ -219,14 +221,24 @@ if __name__ == '__main__':
|
||||||
print('No configuration specified for GPIO ' + str(i) + '; skipping.')
|
print('No configuration specified for GPIO ' + str(i) + '; skipping.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
valid_value = r"^13'h[0-9a-fA-F]{4}$"
|
||||||
|
value_match = re.match(valid_value, config_value)
|
||||||
|
if not value_match:
|
||||||
|
print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping')
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
default_str = config_value[-4:]
|
default_str = config_value[-4:]
|
||||||
binval = '{:013b}'.format(int(default_str, 16))
|
binval = '{:013b}'.format(int(default_str, 16))
|
||||||
|
if len(binval) > 13:
|
||||||
|
print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping')
|
||||||
|
continue
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping')
|
print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cell_name = 'gpio_defaults_block_' + default_str
|
cell_name = 'gpio_defaults_block_' + default_str.lower()
|
||||||
mag_file = magpath + '/' + cell_name + '.mag'
|
mag_file = magpath + '/' + cell_name + '.mag'
|
||||||
cellsused[i] = cell_name
|
cellsused[i] = cell_name
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue