Modified the liberty library generator to allow a header file to be specified, since liberty libraries can't just be made by concatenating cell entries together. Revised the GF180MCU Makefile to add the header files, which I recently added to the Google repositories for the standard cells and the I/O library. The current version is writing out the first cell's header, which should be cleaned up, but it is producing valid liberty libraries.
diff --git a/VERSION b/VERSION index 0688620..c873388 100644 --- a/VERSION +++ b/VERSION
@@ -1 +1 @@ -1.0.324 +1.0.325
diff --git a/common/create_lib_library.py b/common/create_lib_library.py index a066094..83daf87 100755 --- a/common/create_lib_library.py +++ b/common/create_lib_library.py
@@ -30,6 +30,7 @@ print(' <destlib> is the root name of the library file') print(' -compile-only remove the indidual files if specified') print(' -excludelist= is a comma-separated list of files to ignore') + print(' -header= is the name of a file containing header information') print('') #---------------------------------------------------------------------------- @@ -41,11 +42,28 @@ # voltage. #---------------------------------------------------------------------------- -def create_lib_library(destlibdir, destlib, do_compile_only=False, excludelist=[]): +def create_lib_library(destlibdir, destlib, do_compile_only=False, excludelist=[], + headerfile=None): # destlib should not have a file extension destlibroot = os.path.splitext(destlib)[0] + # If a header file is specified, read it first. If the header file + # name is the same as the library name (typical), the file will be + # destroyed before being rebuilt, so save the header file contents. + + hlines = [] + if headerfile: + try: + with open(destlibdir + '/' + headerfile, 'r') as ifile: + htext = ifile.read() + hlines = htext.splitlines() + except: + print('Error reading liberty header file ' + headerfile) + headerfile = None + else: + headerseen = True + alllibname = destlibdir + '/' + destlibroot + '.lib' if os.path.isfile(alllibname): os.remove(alllibname) @@ -79,6 +97,14 @@ if len(llist) > 1: print('New file is: ' + alllibname) with open(alllibname, 'w') as ofile: + + # If a header file is specified, write that to the output first + if headerfile: + for hline in hlines: + if not hline.startswith('}'): + print(hline, file=ofile) + print('\n', file=ofile) + headerdone = False for lfile in llist: if not os.path.exists(lfile): @@ -101,6 +127,10 @@ headerdone = True print('/*--------EOF---------*/\n', file=ofile) + if headerfile: + # Finish the header file + print('}', file=ofile) + if do_compile_only == True: print('Compile-only: Removing individual LEF files') for lfile in llist: @@ -122,6 +152,7 @@ # Defaults do_compile_only = False excludelist = [] + headerfile = None # Break arguments into groups where the first word begins with "-". # All following words not beginning with "-" are appended to the @@ -142,6 +173,11 @@ excludelist = keyval[1].trim('"').split(',') else: print("No items in exclude list (ignoring).") + elif keyval[0] == 'header': + if len(keyval) > 0: + headerfile = keyval[1].trim('"') + else: + print("No value for header file (ignoring).") else: print("Unknown option '" + keyval[0] + "' (ignoring).") else: @@ -168,7 +204,7 @@ print(file) print('') - create_lib_library(destlibdir, destlib, do_compile_only, excludelist) + create_lib_library(destlibdir, destlib, do_compile_only, excludelist, headerfile) print('Done.') sys.exit(0)
diff --git a/common/foundry_install.py b/common/foundry_install.py index 99123b4..cb93cda 100755 --- a/common/foundry_install.py +++ b/common/foundry_install.py
@@ -118,6 +118,14 @@ # contains a directory path, then patterns are added from # files in the specified directory instead of the source. # +# header : Followed by "=" and an alternative name. When compiling +# a library file, use this file as a header. Required for +# liberty format; optional for others. Behavior is format- +# dependent; e.g., for liberty headers, the cell entries +# will be inserted before the final closing brace. The name +# may be wildcarded, but if so, there must only be a single +# matching file. +# # rename : Followed by "=" and an alternative name. For any # file that is a single entry, change the name of # the file in the target directory to this (To-do: @@ -854,6 +862,15 @@ if len(includelist) > 0: print('Including files: ' + (',').join(includelist)) + # Option 'header' has an argument + headerfile = None + try: + headerfile = list(item.split('=')[1] for item in option if item.startswith('header'))[0] + except IndexError: + headerfile = None + else: + print('Header file is: ' + headerfile) + # Option 'rename' has an argument try: newname = list(item.split('=')[1] for item in option if item.startswith('rename'))[0] @@ -1048,10 +1065,23 @@ destfilelist.append(os.path.split(targname)[1]) + # If headerfile is non-null, then copy this file, too. Do not add + # it to "destfilelist", as it is handled separately. Recast + # headerfile as the name of the file without the path. + + if headerfile: + headerpath = substitute(sourcedir + '/' + headerfile, library[1]) + headerlist = glob.glob(headerpath) + if len(headerlist) == 1: + libname = headerlist[0] + destfile = os.path.split(libname)[1] + targname = destlibdir + destpath + '/' + destfile + shutil.copy(libname, targname) + headerfile = destfile + # Add names from "include" list to destfilelist before writing # filelist.txt for library file compiling. - includenames = [] for incname in includelist: if '/' in incname: # Names come from files in a path that is not the source @@ -1105,7 +1135,7 @@ # then compile one, because one does not want to have to have # an include line for every single cell used in a design. - create_lib_library(destlibdir, compname, do_compile_only, excludelist) + create_lib_library(destlibdir, compname, do_compile_only, excludelist, headerfile) elif option[0] == 'spice' or option[0] == 'spi': # If there is not a single file with all SPICE subcircuits in it,
diff --git a/gf180mcu/Makefile.in b/gf180mcu/Makefile.in index 8f78f7a..c543511 100644 --- a/gf180mcu/Makefile.in +++ b/gf180mcu/Makefile.in
@@ -721,34 +721,49 @@ rename=gf180mcu_fd_sc_mcu9t5v0.tlef \ -cdl cells/*/*.cdl compile-only noconvert \ -liberty cells/*/*_ff_125C_1v98.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_125C_1v98.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ff_125C_1v98 \ -liberty cells/*/*_ff_n40C_1v98.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_n40C_1v98.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ff_n40C_1v98 \ - -liberty cells/*/*_ff_125C_3p6v.lib compile-only \ - rename=gf180mcu_fd_sc_mcu9t5v0__ff_125C_3p6v \ - -liberty cells/*/*_ff_n40C_3p6v.lib compile-only \ - rename=gf180mcu_fd_sc_mcu9t5v0__ff_n40C_3p6v \ + -liberty cells/*/*_ff_125C_3v60.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_125C_3v60.lib \ + rename=gf180mcu_fd_sc_mcu9t5v0__ff_125C_3v60 \ + -liberty cells/*/*_ff_n40C_3v60.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_n40C_3v60.lib \ + rename=gf180mcu_fd_sc_mcu9t5v0__ff_n40C_3v60 \ -liberty cells/*/*_ff_125C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_125C_5v50.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ff_125C_5v50 \ -liberty cells/*/*_ff_n40C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ff_n40C_5v50.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ff_n40C_5v50 \ -liberty cells/*/*_ss_125C_1v62.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_125C_1v62.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_125C_1v62 \ -liberty cells/*/*_ss_n40C_1v62.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_n40C_1v62.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_n40C_1v62 \ -liberty cells/*/*_ss_125C_3v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_125C_3v00.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_125C_3v00 \ -liberty cells/*/*_ss_n40C_3v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_n40C_3v00.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_n40C_3v00 \ -liberty cells/*/*_ss_125C_4v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_125C_4v50.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_125C_4v50 \ -liberty cells/*/*_ss_n40C_4v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__ss_n40C_4v50.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__ss_n40C_4v50 \ -liberty cells/*/*_tt_025C_1v80.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__tt_025C_1v80.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__tt_025C_1v80 \ -liberty cells/*/*_tt_025C_3v30.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__tt_025C_3v30.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__tt_025C_3v30 \ -liberty cells/*/*_tt_025C_5v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu9t5v0__tt_025C_5v00.lib \ rename=gf180mcu_fd_sc_mcu9t5v0__tt_025C_5v00 \ -gds cells/*/*.gds compile-only \ -lef cells/*/*.lef compile-only \ @@ -764,34 +779,49 @@ rename=gf180mcu_fd_sc_mcu7t5v0.tlef \ -cdl cells/*/*.cdl compile-only noconvert \ -liberty cells/*/*_ff_125C_1v98.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_125C_1v98.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ff_125C_1v98 \ -liberty cells/*/*_ff_n40C_1v98.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_n40C_1v98.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ff_n40C_1v98 \ - -liberty cells/*/*_ff_125C_3p6v.lib compile-only \ - rename=gf180mcu_fd_sc_mcu7t5v0__ff_125C_3p6v \ - -liberty cells/*/*_ff_n40C_3p6v.lib compile-only \ - rename=gf180mcu_fd_sc_mcu7t5v0__ff_n40C_3p6v \ + -liberty cells/*/*_ff_125C_3v60.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_125C_3v60.lib \ + rename=gf180mcu_fd_sc_mcu7t5v0__ff_125C_3v60 \ + -liberty cells/*/*_ff_n40C_3v60.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_n40C_3v60.lib \ + rename=gf180mcu_fd_sc_mcu7t5v0__ff_n40C_3v60 \ -liberty cells/*/*_ff_125C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_125C_5v50.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ff_125C_5v50 \ -liberty cells/*/*_ff_n40C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ff_n40C_5v50.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ff_n40C_5v50 \ -liberty cells/*/*_ss_125C_1v62.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_125C_1v62.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_125C_1v62 \ -liberty cells/*/*_ss_n40C_1v62.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_n40C_1v62.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_n40C_1v62 \ -liberty cells/*/*_ss_125C_3v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_125C_3v00.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_125C_3v00 \ -liberty cells/*/*_ss_n40C_3v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_n40C_3v00.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_n40C_3v00 \ -liberty cells/*/*_ss_125C_4v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_125C_4v50.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_125C_4v50 \ -liberty cells/*/*_ss_n40C_4v50.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__ss_n40C_4v50.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__ss_n40C_4v50 \ -liberty cells/*/*_tt_025C_1v80.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__tt_025C_1v80.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__tt_025C_1v80 \ -liberty cells/*/*_tt_025C_3v30.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__tt_025C_3v30.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__tt_025C_3v30 \ -liberty cells/*/*_tt_025C_5v00.lib compile-only \ + header=liberty/gf180mcu_fd_sc_mcu7t5v0__tt_025C_5v00.lib \ rename=gf180mcu_fd_sc_mcu7t5v0__tt_025C_5v00 \ -gds cells/*/*.gds compile-only \ -lef cells/*/*.lef compile-only \ @@ -809,28 +839,40 @@ -target ${STAGING_PATH}/${GF180MCU$*} \ -cdl cells/*/*.cdl compile-only noconvert \ -liberty cells/*/*_ff_125C_2v75.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_125C_2v75.lib \ rename=gf180mcu_fd_io__ff_125C_2v75 \ -liberty cells/*/*_ff_n40C_2v75.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_n40C_2v75.lib \ rename=gf180mcu_fd_io__ff_n40C_2v75 \ -liberty cells/*/*_ff_125C_3v63.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_125C_3v63.lib \ rename=gf180mcu_fd_io__ff_125C_3v63 \ -liberty cells/*/*_ff_n40C_3v63.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_n40C_3v63.lib \ rename=gf180mcu_fd_io__ff_n40C_3v63 \ -liberty cells/*/*_ff_125C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_125C_5v50.lib \ rename=gf180mcu_fd_io__ff_125C_5v50 \ -liberty cells/*/*_ff_n40C_5v50.lib compile-only \ + header=liberty/gf180mcu_fd_io__ff_n40C_5v50.lib \ rename=gf180mcu_fd_io__ff_n40C_5v50 \ -liberty cells/*/*_ss_125C_2v50.lib compile-only \ + header=liberty/gf180mcu_fd_io__ss_125C_2v50.lib \ rename=gf180mcu_fd_io__ss_125C_2v50 \ -liberty cells/*/*_ss_125C_2v97.lib compile-only \ + header=liberty/gf180mcu_fd_io__ss_125C_2v97.lib \ rename=gf180mcu_fd_io__ss_125C_2v97 \ -liberty cells/*/*_ss_125C_4v50.lib compile-only \ + header=liberty/gf180mcu_fd_io__ss_125C_4v50.lib \ rename=gf180mcu_fd_io__ss_125C_4v50 \ -liberty cells/*/*_tt_025C_2v50.lib compile-only \ + header=liberty/gf180mcu_fd_io__tt_025C_2v50.lib \ rename=gf180mcu_fd_io__tt_025C_2v50 \ -liberty cells/*/*_tt_025C_3v30.lib compile-only \ + header=liberty/gf180mcu_fd_io__tt_025C_3v30.lib \ rename=gf180mcu_fd_io__tt_025C_3v30 \ -liberty cells/*/*_tt_025C_5v00.lib compile-only \ + header=liberty/gf180mcu_fd_io__tt_025C_5v00.lib \ rename=gf180mcu_fd_io__tt_025C_5v00 \ -gds cells/*/*_${$*_STACK}.gds compile-only \ options=custom/scripts/gds_import_io.tcl \