muxed
0 uart0_tx spi0_sclk uart2_tx uart3_tx
1 uart0_rx spi0_mosi uart2_rx uart3_rx
-2 twi0_sda spi0_ss
+2 twi0_sda spi0_ss
3 twi0_scl spi0_miso
+8 sd0_clk sd1_clk
+9 sd0_cmd sd1_cmd
+10 sd0_d0 sd1_d0
+11 sd0_d1 sd1_d1
+12 sd0_d2 sd1_d2
+13 sd0_d3 sd1_d3
dedicated
4 uart1_tx
5 uart1_rx
"spi_ss" : "output",
"spi_miso" : "input",
"twi_sda" : "inout",
- "twi_scl" : "inout"
+ "twi_scl" : "inout",
+ "sd_clk": "output",
+ "sd_cmd": "output",
+ "sd_d": "inout",
}
x = dictionary.get(temp)
if(x is None):
print(
- "Error: The signal : " +
+ "ERROR: The signal : " +
str(cell[i + 1]) +
- " in lineno: " +
- str(lineno) + "of pinmap.txt isn't present in the \
- current dictionary.\nUpdate dictionary or fix-typo.")
+ " of pinmap.txt isn't present in the current dictionary.\
+ \nUpdate dictionary or fix-typo.")
exit(1)
if(x == "input"):
pinmux = pinmux + \
(*always_ready,always_enabled*) method Action scl{0}_outen (Bit#(1) in);
(*always_ready,always_enabled*) method Bit#(1) scl{0}_in;
'''
+
+sdinterface_decl = '''
+ (*always_ready,always_enabled*) method Action sd{0}_clk (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_cmd (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_d0_out (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_d0_outen (Bit#(1) in);
+ (*always_ready,always_enabled*) method Bit#(1) sd{0}_d0_in;
+ (*always_ready,always_enabled*) method Action sd{0}_d1_out (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_d1_outen (Bit#(1) in);
+ (*always_ready,always_enabled*) method Bit#(1) sd{0}_d1_in;
+ (*always_ready,always_enabled*) method Action sd{0}_d2_out (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_d2_outen (Bit#(1) in);
+ (*always_ready,always_enabled*) method Bit#(1) sd{0}_d2_in;
+ (*always_ready,always_enabled*) method Action sd{0}_d3_out (Bit#(1) in);
+ (*always_ready,always_enabled*) method Action sd{0}_d3_outen (Bit#(1) in);
+ (*always_ready,always_enabled*) method Bit#(1) sd{0}_d3_in;
+'''
# ======================================= #
method scl{0}_in=wrtwi{0}_scl_in;
'''
+
+sdinterface_def = '''
+ method Action sd{0}_clk (Bit#(1) in);
+ wrsd{0}_clk<=in;
+ endmethod
+ method Action sd{0}_cmd (Bit#(1) in);
+ wrsd{0}_cmd<=in;
+ endmethod
+ method Action sd{0}_d0_out (Bit#(1) in);
+ wrsd{0}_d0_out<=in;
+ endmethod
+ method Action sd{0}_d0_outen (Bit#(1) in);
+ wrsd{0}_d0_outen<=in;
+ endmethod
+ method sd{0}_d0_in=wrsd{0}_d0_in;
+ method Action sd{0}_d1_out (Bit#(1) in);
+ wrsd{0}_d1_out<=in;
+ endmethod
+ method Action sd{0}_d1_outen (Bit#(1) in);
+ wrsd{0}_d1_outen<=in;
+ endmethod
+ method sd{0}_d1_in=wrsd{0}_d1_in;
+ method Action sd{0}_d2_out (Bit#(1) in);
+ wrsd{0}_d2_out<=in;
+ endmethod
+ method Action sd{0}_d2_outen (Bit#(1) in);
+ wrsd{0}_d2_outen<=in;
+ endmethod
+ method sd{0}_d2_in=wrsd{0}_d2_in;
+ method Action sd{0}_d3_out (Bit#(1) in);
+ wrsd{0}_d3_out<=in;
+ endmethod
+ method Action sd{0}_d3_outen (Bit#(1) in);
+ wrsd{0}_d3_outen<=in;
+ endmethod
+ method sd{0}_d3_in=wrsd{0}_d3_in;
+'''
# ============================================== #
N_UART = 4
N_SPI = 1
N_TWI = 2
+N_SD = 2
# ================ #
dedicated_cells.append(line1)
if(len(line1) > 2):
muxed_cells.append(line1)
+pinnumbers = sorted(pinnumbers)
# ============================================= #
# ======= Multiple checks to see if the user has not screwed ======#
missing_pins = missing_numbers(pinnumbers)
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=======
'''\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 ========================#
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")
# ======================================================================
pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
opendrain_en:0}};
'''
+
+sdwires = '''
+ Wire#(Bit#(1)) wrsd{0}_clk <-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_cmd <-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d0_out<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d0_outen<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d0_in<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d1_out<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d1_outen<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d1_in<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d2_out<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d2_outen<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d2_in<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d3_out<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d3_outen<-mkDWire(0);
+ Wire#(Bit#(1)) wrsd{0}_d3_in<-mkDWire(0);
+ GenericIOType sd{0}_clk_io = GenericIOType{{outputval:wrsd{0}_clk,
+ output_en:1, input_en:0,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+ GenericIOType sd{0}_cmd_io = GenericIOType{{outputval:wrsd{0}_cmd,
+ output_en:1, input_en:0,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+ GenericIOType sd{0}_d0_io = GenericIOType{{outputval:wrsd{0}_d0_out,
+ output_en:wrsd{0}_d0_outen, input_en:~wrsd{0}_d0_outen,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+ GenericIOType sd{0}_d1_io = GenericIOType{{outputval:wrsd{0}_d1_out,
+ output_en:wrsd{0}_d1_outen, input_en:~wrsd{0}_d1_outen,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+ GenericIOType sd{0}_d2_io = GenericIOType{{outputval:wrsd{0}_d2_out,
+ output_en:wrsd{0}_d2_outen, input_en:~wrsd{0}_d2_outen,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+ GenericIOType sd{0}_d3_io = GenericIOType{{outputval:wrsd{0}_d3_out,
+ output_en:wrsd{0}_d3_outen, input_en:~wrsd{0}_d3_outen,
+ pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0,
+ opendrain_en:0}};
+'''
# =================================== #