mirror of https://github.com/efabless/caravel.git
Remove uncompress dependencies for set_user_id and gpio_defaults
- set_user_id had no dependencies - gen_gpio_defaults had a dependency for caravan_core.mag, but added a smart_open routine to natively open an uncompressed or compressed file based on the suffix. No need to recompress.
This commit is contained in:
parent
48965172f8
commit
c868e1c96e
4
Makefile
4
Makefile
|
@ -1100,7 +1100,7 @@ __final:
|
|||
@rm -rf ./mag/tmp
|
||||
|
||||
.PHONY: set_user_id
|
||||
set_user_id: check-env check-uid uncompress uncompress-caravel
|
||||
set_user_id: check-env check-uid
|
||||
$(MAKE) -f $(CARAVEL_ROOT)/Makefile __set_user_id
|
||||
@echo "Set user ID completed." 2>&1 | tee -a ./signoff/build/set_user_id.out
|
||||
|
||||
|
@ -1115,7 +1115,7 @@ __set_user_id:
|
|||
python3 $(CARAVEL_ROOT)/scripts/set_user_id.py $(USER_ID) $(shell pwd) 2>&1 | tee ./signoff/build/set_user_id.out
|
||||
|
||||
.PHONY: gpio_defaults
|
||||
gpio_defaults: check-env uncompress uncompress-caravel
|
||||
gpio_defaults: check-env
|
||||
$(MAKE) -f $(CARAVEL_ROOT)/Makefile __gpio_defaults
|
||||
@echo "GPIO defaults completed." 2>&1 | tee -a ./signoff/build/__gpio_defaults.out
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import sys
|
|||
import re
|
||||
import glob
|
||||
import subprocess
|
||||
import gzip
|
||||
|
||||
def usage():
|
||||
print('Usage:')
|
||||
|
@ -81,6 +82,22 @@ def usage():
|
|||
print(' <path_to_project>.')
|
||||
return 0
|
||||
|
||||
def smart_open(filename, mode="rt"):
|
||||
"""
|
||||
Opens a file normally if uncompressed, or with gzip if it’s a .gz file.
|
||||
|
||||
Args:
|
||||
filename (str): Path to the file.
|
||||
mode (str): File mode ('rt' for text, 'rb' for binary, etc.).
|
||||
|
||||
Returns:
|
||||
File object (either normal open or gzip open).
|
||||
"""
|
||||
if filename.endswith(".gz"):
|
||||
return gzip.open(filename, mode)
|
||||
else:
|
||||
return open(filename, mode)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# Coordinate pairs in microns for the zero position on each bit
|
||||
|
@ -351,14 +368,15 @@ if __name__ == '__main__':
|
|||
print('Test only: Caravel core layout:')
|
||||
|
||||
# Check for compressed layout
|
||||
is_compressed = False
|
||||
if not os.path.isfile(caravel_path + '/mag/caravel_core.mag'):
|
||||
if os.path.isfile(caravel_path + '/mag/caravel_core.mag.gz'):
|
||||
is_compressed = True
|
||||
print('Uncompressing caravel_core.mag')
|
||||
subprocess.run(['gunzip', caravel_path + '/mag/caravel_core.mag.gz'])
|
||||
if os.path.isfile(caravel_path + '/mag/caravel_core.mag'):
|
||||
caravel_core_magfile = caravel_path + '/mag/caravel_core.mag'
|
||||
elif os.path.isfile(caravel_path + '/mag/caravel_core.mag.gz'):
|
||||
caravel_core_magfile = caravel_path + '/mag/caravel_core.mag.gz'
|
||||
else:
|
||||
print(f' Could not find {caravel_path}/mag/caravel_core.mag[.gz]')
|
||||
sys.exit(2)
|
||||
|
||||
with open(caravel_path + '/mag/caravel_core.mag', 'r') as ifile:
|
||||
with smart_open(caravel_core_magfile, 'rt') as ifile:
|
||||
maglines = ifile.read().splitlines()
|
||||
outlines = []
|
||||
for magline in maglines:
|
||||
|
@ -392,11 +410,6 @@ if __name__ == '__main__':
|
|||
for outline in outlines:
|
||||
print(outline, file=ofile)
|
||||
|
||||
if is_compressed:
|
||||
print('Compressing caravel_core.mag')
|
||||
subprocess.run(['gzip', '-n', '--best', caravel_path +
|
||||
'/mag/caravel_core.mag'])
|
||||
|
||||
# Do the same to the core gate-level verilog
|
||||
|
||||
inst1rex = re.compile('[ \t]*(gpio_defaults_block_?[0-1]?[0-9A-Fa-f]*)[ \t]+.?gpio_defaults_block_([0-9]+).([0-9]+)')
|
||||
|
@ -439,7 +452,17 @@ if __name__ == '__main__':
|
|||
|
||||
if testmode:
|
||||
print('Test only: Caravan layout:')
|
||||
with open(caravel_path + '/mag/caravan_core.mag', 'r') as ifile:
|
||||
|
||||
# Check for compressed layout
|
||||
if os.path.isfile(caravel_path + '/mag/caravan_core.mag'):
|
||||
caravan_core_magfile = caravel_path + '/mag/caravan_core.mag'
|
||||
elif os.path.isfile(caravel_path + '/mag/caravan_core.mag.gz'):
|
||||
caravan_core_magfile = caravel_path + '/mag/caravan_core.mag.gz'
|
||||
else:
|
||||
print(f' Could not find {caravel_path}/mag/caravan_core.mag[.gz]')
|
||||
sys.exit(2)
|
||||
|
||||
with smart_open(caravan_core_magfile, 'rt') as ifile:
|
||||
maglines = ifile.read().splitlines()
|
||||
outlines = []
|
||||
for magline in maglines:
|
||||
|
|
Loading…
Reference in New Issue