import os
import sys
import time
+import math
# project module imports
from interface_decl import *
from interface_def import *
-from params import *
+from parse import *
from wire_def import *
from actual_pinmux import *
os.makedirs("bsv_src")
bsv_file = open("./bsv_src/pinmux.bsv", "w")
+
+
header = '''
/*
This BSV file has been generated by the PinMux tool available at:
// of muxes happening per IO. For now we have a generalized width
// where each IO will have the same number of muxes.''')
-for i in range(0, N_IO):
- bsv_file.write(mux_interface.format(i))
+for cell in muxed_cells:
+ bsv_file.write(mux_interface.format(cell[0],
+ int(math.log(len(cell) - 1, 2))))
bsv_file.write('''
bsv_file.write('''
// interface declaration between TWI-{0} and pinmux'''.format(i))
bsv_file.write(twiinterface_decl.format(i))
+
+for i in range(0, N_SD):
+ bsv_file.write('''
+ // interface declaration between SD-{0} and pinmux'''.format(i))
+ bsv_file.write(sdinterface_decl.format(i))
# ==============================================================
# ===== finish interface definition and start module definition=======
// the followins wires capture the pin-mux selection
// values for each mux assigned to a CELL
''')
-for i in range(0, N_IO):
- bsv_file.write(muxwire.format(i))
+for cell in muxed_cells:
+ bsv_file.write(muxwire.format(cell[0], int(math.log(len(cell) - 1, 2))))
bsv_file.write(
'''\n // following wires capture signals to IO CELL if twi-{0} is
// allotted to it'''.format(i))
bsv_file.write(twiwires.format(i))
+
+for i in range(0, N_SD):
+ bsv_file.write(
+ '''\n // following wires capture signals to IO CELL if sd-{0} is
+ // allotted to it'''.format(i))
+ bsv_file.write(sdwires.format(i))
bsv_file.write("\n")
# ====================================================================
# ========================= Actual pinmuxing ========================#
''')
# ====================================================================
# ================= interface definitions for each method =============#
-for i in range(0, N_IO):
- bsv_file.write(mux_interface_def.format(i))
+for cell in muxed_cells:
+ bsv_file.write(mux_interface_def.format(cell[0],
+ int(math.log(len(cell) - 1, 2))))
for i in range(0, N_IO):
bsv_file.write(io_interface_def.format(i))
for i in range(0, N_UART):
bsv_file.write(spiinterface_def.format(i))
for i in range(0, N_TWI):
bsv_file.write(twiinterface_def.format(i))
+for i in range(0, N_SD):
+ bsv_file.write(sdinterface_def.format(i))
bsv_file.write(footer)
print("BSV file successfully generated: bsv_src/pinmux.bsv")
# ======================================================================
+bsv_file.close()