Convert entire OpenRAM to use python3. Works with Python 3.6.

Major changes:
Remove mpmath library and use numpy instead.
Convert bytes to new bytearrays.
Fix class name check for duplicate gds instances.
Add explicit integer conversion from floats.
Fix importlib reload from importlib library
Fix new key/index syntax issues.
Fix filter and map conversion to lists.
Fix deprecation warnings.
Fix Circuits vs Netlist in Magic LVS results.
Fix file closing warnings.
This commit is contained in:
Matt Guthaus
2018-05-14 16:15:45 -07:00
parent 58628d7867
commit f34c4eb7dc
179 changed files with 803 additions and 42105 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
import unittest
from testutils import header,openram_test
@@ -58,11 +58,12 @@ def check_file_format_tab(file_name):
f = open(file_name, "r+b")
key_positions = []
for num, line in enumerate(f, 1):
if '\t' in line:
if b'\t' in line:
key_positions.append(num)
if len(key_positions) > 0:
debug.info(0, '\nFound ' + str(len(key_positions)) + ' tabs in ' +
str(file_name) + ' (line ' + str(key_positions[0]) + ')')
f.close()
return len(key_positions)
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python2.7
"Run a regresion test the library cells for DRC"
#!/usr/bin/env python3
"Run a regression test the library cells for DRC"
import unittest
from testutils import header,openram_test
import sys,os,re
sys.path.append(os.path.join(sys.path[0],".."))
#sys.path.append(os.path.join(sys.path[0],".."))
import globals
from globals import OPTS
import debug
+3 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test the library cells for LVS"
#!/usr/bin/env python3
"Run a regression test the library cells for LVS"
import unittest
from testutils import header,openram_test
@@ -38,7 +38,7 @@ def setup_files():
sp_dir = OPTS.openram_tech + "/sp_lib"
files = os.listdir(gds_dir)
nametest = re.compile("\.gds$", re.IGNORECASE)
gds_files = filter(nametest.search, files)
gds_files = list(filter(nametest.search, files))
files = os.listdir(sp_dir)
nametest = re.compile("\.sp$", re.IGNORECASE)
sp_files = filter(nametest.search, files)
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test for DRC on basic contacts of different array sizes"
#!/usr/bin/env python3
"Run a regression test for DRC on basic contacts of different array sizes"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic path"
#!/usr/bin/env python3
"Run a regression test on a basic path"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic parameterized transistors"
#!/usr/bin/env python3
"Run a regression test on a basic parameterized transistors"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
"Run a regresion test on a basic wire"
#!/usr/bin/env python3
"Run a regression test on a basic wire"
import unittest
from testutils import header,openram_test
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regresion tests on a parameterized inverter
Run regression tests on a parameterized inverter
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regresion tests on a parameterized inverter
Run regression tests on a parameterized inverter
"""
import unittest
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regression tests on a parameterized inverter
"""
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regresion tests on a parameterized inverter
Run regression tests on a parameterized inverter
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a 2-row buffer cell
Run a regression test on a 2-row buffer cell
"""
import unittest
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regression tests on a parameterized nand 2. This module doesn't
generate a multi_finger 2-input nand gate. It generates only a minimum
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regresion tests on a parameterized pnand3.
Run regression tests on a parameterized pnand3.
This module doesn't generate a multi-finger 3-input nand gate.
It generates only a minimum size 3-input nand gate.
"""
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run regression tests on a parameterized nor 2. This module doesn't
generate a multi_finger 2-input nor gate. It generates only a minimum
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a precharge cell
Run a regression test on a precharge cell
"""
import unittest
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a wordline_driver array
Run a regression test on a wordline_driver array
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a basic array
Run a regression test on a basic array
"""
import unittest
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a hierarchical_decoder.
Run a regression test on a hierarchical_decoder.
"""
import unittest
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a hierarchical_predecode2x4.
Run a regression test on a hierarchical_predecode2x4.
"""
import unittest
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a hierarchical_predecode3x8.
Run a regression test on a hierarchical_predecode3x8.
"""
import unittest
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a single transistor column_mux.
Run a regression test on a single transistor column_mux.
"""
from testutils import header,openram_test,unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a precharge array
Run a regression test on a precharge array
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a wordline_driver array
Run a regression test on a wordline_driver array
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a sense amp array
Run a regression test on a sense amp array
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a write driver array
Run a regression test on a write driver array
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_array.
Run a regression test on a dff_array.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_array.
Run a regression test on a dff_array.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_buf.
Run a regression test on a dff_buf.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_array.
Run a regression test on a dff_array.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_inv.
Run a regression test on a dff_inv.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a dff_array.
Run a regression test on a dff_array.
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a tri_gate_array.
Run a regression test on a tri_gate_array.
"""
import unittest
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a test on a delay chain
"""
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a test on a delay chain
"""
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a control_logic
Run a regression test on a control_logic
"""
import unittest
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
+6 -6
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -22,19 +22,19 @@ class multi_bank_test(openram_test):
import bank
debug.info(1, "No column mux")
a = bank.bank(word_size=4, num_words=16, words_per_row=1, num_banks=2, name="bank1")
a = bank.bank(word_size=4, num_words=16, words_per_row=1, num_banks=2, name="bank1_multi")
self.local_check(a)
debug.info(1, "Two way column mux")
a = bank.bank(word_size=4, num_words=32, words_per_row=2, num_banks=2, name="bank2")
a = bank.bank(word_size=4, num_words=32, words_per_row=2, num_banks=2, name="bank2_multi")
self.local_check(a)
debug.info(1, "Four way column mux")
a = bank.bank(word_size=4, num_words=64, words_per_row=4, num_banks=2, name="bank3")
a = bank.bank(word_size=4, num_words=64, words_per_row=4, num_banks=2, name="bank3_multi")
self.local_check(a)
debug.info(1, "Eight way column mux")
a = bank.bank(word_size=2, num_words=128, words_per_row=8, num_banks=2, name="bank4")
a = bank.bank(word_size=2, num_words=128, words_per_row=8, num_banks=2, name="bank4_multi")
self.local_check(a)
OPTS.check_lvsdrc = True
+6 -6
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -22,20 +22,20 @@ class single_bank_test(openram_test):
import bank
debug.info(1, "No column mux")
a = bank.bank(word_size=4, num_words=16, words_per_row=1, num_banks=1, name="bank1")
a = bank.bank(word_size=4, num_words=16, words_per_row=1, num_banks=1, name="bank1_single")
self.local_check(a)
debug.info(1, "Two way column mux")
a = bank.bank(word_size=4, num_words=32, words_per_row=2, num_banks=1, name="bank2")
a = bank.bank(word_size=4, num_words=32, words_per_row=2, num_banks=1, name="bank2_single")
self.local_check(a)
debug.info(1, "Four way column mux")
a = bank.bank(word_size=4, num_words=64, words_per_row=4, num_banks=1, name="bank3")
a = bank.bank(word_size=4, num_words=64, words_per_row=4, num_banks=1, name="bank3_single")
self.local_check(a)
# Eight way has a short circuit of one column mux select to gnd rail
debug.info(1, "Eight way column mux")
a = bank.bank(word_size=2, num_words=128, words_per_row=8, num_banks=1, name="bank4")
a = bank.bank(word_size=2, num_words=128, words_per_row=8, num_banks=1, name="bank4_single")
self.local_check(a)
OPTS.check_lvsdrc = True
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a 1 bank SRAM
Run a regression test on a 1 bank SRAM
"""
import unittest
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a 2 bank SRAM
Run a regression test on a 2 bank SRAM
"""
import unittest
@@ -11,6 +11,7 @@ import globals
from globals import OPTS
import debug
@unittest.skip("Multibank is not working yet.")
class sram_2bank_test(openram_test):
def runTest(self):
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on a 4 bank SRAM
Run a regression test on a 4 bank SRAM
"""
import unittest
@@ -11,6 +11,7 @@ import globals
from globals import OPTS
import debug
@unittest.skip("Multibank is not working yet.")
class sram_4bank_test(openram_test):
def runTest(self):
+4 -3
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -20,6 +20,7 @@ class timing_sram_test(openram_test):
OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import delay
@@ -66,7 +67,7 @@ class timing_sram_test(openram_test):
'delay_lh': [0.6538954],
'read0_power': [9.7622],
'read1_power': [9.589],
'write1_power': [10.2578],
'write1_power': [10.8],
'write0_power': [6.928400000000001],
'slew_hl': [0.8321625],
'min_period': 2.344,
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -20,6 +20,7 @@ class timing_setup_test(openram_test):
OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import setup_hold
+4 -3
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -20,6 +20,7 @@ class timing_sram_test(openram_test):
OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import delay
@@ -67,7 +68,7 @@ class timing_sram_test(openram_test):
'write1_power': [11.718020000000001],
'write0_power': [8.250219],
'slew_hl': [0.8273725],
'min_period': 2.734,
'min_period': 34,
'delay_hl': [1.085861],
'slew_lh': [0.5730144]}
else:
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -20,6 +20,7 @@ class timing_setup_test(openram_test):
OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import setup_hold
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regression test on an extracted SRAM to ensure functionality.
"""
+3 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Run a regresion test on various srams
Run a regression test on various srams
"""
import unittest
@@ -20,6 +20,7 @@ class sram_func_test(openram_test):
OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import delay
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Check the .lib file for an SRAM
"""
+2 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Check the .lib file for an SRAM with pruning
"""
@@ -21,6 +21,7 @@ class lib_test(openram_test):
OPTS.trim_netlist = True
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import lib
+2 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Check the .lib file for an SRAM
"""
@@ -21,6 +21,7 @@ class lib_test(openram_test):
OPTS.trim_netlist = False
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import lib
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Check the LEF file for an SRMA
"""
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
Check the .v file for an SRAM
"""
+4 -4
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
"""
This tests the top-level executable. It checks that it generates the
appropriate files: .lef, .lib, .sp, .gds, .v. It DOES NOT, however,
@@ -29,10 +29,10 @@ class openram_test(openram_test):
self.assertEqual(os.path.exists(out_path),False)
try:
os.makedirs(out_path, 0750)
os.makedirs(out_path, 0o0750)
except OSError as e:
if e.errno == 17: # errno.EEXIST
os.chmod(out_path, 0750)
os.chmod(out_path, 0o0750)
# specify the same verbosity for the system call
verbosity = ""
@@ -42,7 +42,7 @@ class openram_test(openram_test):
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
cmd = "python2.7 {0}/openram.py -n -o {1} -p {2} {3} config_20_{4}.py 2>&1 > {5}/output.log".format(OPENRAM_HOME,
cmd = "python3 {0}/openram.py -n -o {1} -p {2} {3} config_20_{4}.py 2>&1 > {5}/output.log".format(OPENRAM_HOME,
out_file,
out_path,
verbosity,
+2 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
import re
import unittest
@@ -17,7 +17,7 @@ files = os.listdir(sys.path[0])
# assume any file that ends in "test.py" in it is a regression test
nametest = re.compile("test\.py$", re.IGNORECASE)
tests = filter(nametest.search, files)
tests = list(filter(nametest.search, files))
tests.sort()
# import all of the modules
+14 -13
View File
@@ -1,7 +1,6 @@
import unittest,warnings
import sys,os,glob
sys.path.append(os.path.join(sys.path[0],".."))
import globals
from globals import OPTS
import debug
@@ -27,20 +26,22 @@ class openram_test(unittest.TestCase):
a.gds_write(tempgds)
import verify
result=verify.run_drc(a.name, tempgds)
self.reset()
try:
self.assertTrue(verify.run_drc(a.name, tempgds)==0)
self.assertTrue(result==0)
except:
self.reset()
self.fail("DRC failed: {}".format(a.name))
result=verify.run_lvs(a.name, tempgds, tempspice, final_verification)
self.reset()
try:
self.assertTrue(verify.run_lvs(a.name, tempgds, tempspice, final_verification)==0)
self.assertTrue(result==0)
except:
self.reset()
self.fail("LVS mismatch: {}".format(a.name))
self.reset()
if OPTS.purge_temp:
self.cleanup()
@@ -159,12 +160,12 @@ class openram_test(unittest.TestCase):
def header(filename, technology):
tst = "Running Test for:"
print "\n"
print " ______________________________________________________________________________ "
print "|==============================================================================|"
print "|=========" + tst.center(60) + "=========|"
print "|=========" + technology.center(60) + "=========|"
print "|=========" + filename.center(60) + "=========|"
print("\n")
print(" ______________________________________________________________________________ ")
print("|==============================================================================|")
print("|=========" + tst.center(60) + "=========|")
print("|=========" + technology.center(60) + "=========|")
print("|=========" + filename.center(60) + "=========|")
from globals import OPTS
print "|=========" + OPTS.openram_temp.center(60) + "=========|"
print "|==============================================================================|"
print("|=========" + OPTS.openram_temp.center(60) + "=========|")
print("|==============================================================================|")