# default module imports
import os
+import os.path
import sys
import time
import math
from actual_pinmux import init
from bus_transactors import axi4_lite
-p = Parse()
-init(p)
-ifaces = Interfaces()
-ifaces.ifaceadd('io', p.N_IO, io_interface, 0)
-
-if not os.path.exists("bsv_src"):
- os.makedirs("bsv_src")
-
copyright = '''
/*
This BSV file has been generated by the PinMux tool available at:
endpackage
'''
-def pinmuxgen():
+def pinmuxgen(pth=None, verify=True):
""" populating the file with the code
"""
+ p = Parse(pth, verify)
+ init(p)
+ ifaces = Interfaces()
+ ifaces.ifaceadd('io', p.N_IO, io_interface, 0)
+
+ bp = 'bsv_src'
+ if pth:
+ bp = os.path.join(pth, bp)
+ if not os.path.exists(bp):
+ os.makedirs(bp)
+
+ pmp = os.path.join(bp, 'pinmux.bsv')
+ ptp = os.path.join(bp, 'PinTop.bsv')
+ bvp = os.path.join(bp, 'bus.bsv')
+
# package and interface declaration followed by
# the generic io_cell definition
- with open("./bsv_src/pinmux.bsv", "w") as bsv_file:
+ with open(pmp, "w") as bsv_file:
bsv_file.write(header)
bsv_file.write('''\
print("BSV file successfully generated: bsv_src/pinmux.bsv")
# ======================================================================
- with open('bsv_src/PinTop.bsv', 'w') as bsv_file:
+ with open(ptp, 'w') as bsv_file:
bsv_file.write(copyright + '''
package PinTop;
import pinmux::*;
''')
# ######## Generate bus transactors ################
- with open('bsv_src/bus.bsv', 'w') as bsv_file:
+ with open(bvp, 'w') as bsv_file:
bsv_file.write(axi4_lite.format(p.ADDR_WIDTH, p.DATA_WIDTH))
# ##################################################
-pinmuxgen()
+if __name__ == '__main__':
+ pinmuxgen()