From: Neel Date: Tue, 13 Mar 2018 06:24:19 +0000 (+0530) Subject: full support for dedicated pins. X-Git-Url: https://git.libre-soc.org/?p=pinmux.git;a=commitdiff_plain;h=b810d8d4e7fb0eb4f68b84692ce75c63bc016e64 full support for dedicated pins. --- diff --git a/src/actual_pinmux.py b/src/actual_pinmux.py index 29af14d..bedd567 100644 --- a/src/actual_pinmux.py +++ b/src/actual_pinmux.py @@ -16,15 +16,19 @@ dictionary = { # ============== common bsv templates ============ # -assign_cell = '''cell{0}_out=wrmux{0}=={1}?''' # first argument is the io-cell number being assigned. # second argument is the mux value. # Third argument is the signal from the pinmap file -input_wire = ''' +mux_wire = ''' rule assign_{2}_on_cell{0}(wrmux{0}=={1}); {2}<=cell{0}_in; endrule ''' +dedicated_wire = ''' + rule assign_{1}_on_cell{0}; + {1}<=cell{0}_in; + endrule +''' # ============================================================ pinmux = ''' ''' pinmap_file = open("./pinmap.txt", "r") @@ -35,6 +39,7 @@ for lineno, line in enumerate(pinmap_file): dedicated = False elif("dedicated" in line): dedicated = True + digits = str.maketrans(dict.fromkeys('0123456789')) # ==== Logic for muxed pins ==== # if(len(line1) > 1 and not(dedicated)): if(lineno > N_IO): @@ -47,7 +52,7 @@ for lineno, line in enumerate(pinmap_file): exit(1) # ==== Mux each generic IO cell with the mapping ===== # # provided in the pinmap file - pinmux = pinmux + " cell" + str(line1[0]) + "_out=" + pinmux = pinmux + " cell" + str(line1[0]) + "_out=" i = 0 while(i < len(line1) - 1): pinmux = pinmux + "wrmux" + \ @@ -66,7 +71,6 @@ for lineno, line in enumerate(pinmap_file): # since the interfaces are always standard and cannot change from # user-to-user. Plus this also reduces human-error as well :) for i in range(0, len(line1) - 1): - digits = str.maketrans(dict.fromkeys('0123456789')) temp = line1[i + 1].translate(digits) x = dictionary.get(temp) if(x is None): @@ -79,16 +83,24 @@ for lineno, line in enumerate(pinmap_file): exit(1) if(x == "input"): pinmux = pinmux + \ - input_wire.format(line1[0], i, "wr" + line1[i + 1]) + "\n" + mux_wire.format(line1[0], i, "wr" + line1[i + 1]) + "\n" elif(x == "inout"): pinmux = pinmux + \ - input_wire.format(line1[0], i, "wr" + line1[i + 1] + - "_in") + "\n" + mux_wire.format(line1[0], i, "wr" + line1[i + 1] + + "_in") + "\n" # ============================================================ # # ================== Logic for dedicated pins ========= # elif(len(line1) > 1 and dedicated): - pinmux = pinmux + " cell" + \ + pinmux = pinmux + " cell" + \ str(line1[0]) + "_out=" + line1[1] + "_io;\n" + temp = line1[1].translate(digits) + x = dictionary.get(temp) + if(x == "input"): + pinmux = pinmux + \ + dedicated_wire.format(line1[0], "wr" + line1[1]) + "\n" + elif(x == "inout"): + pinmux = pinmux + \ + dedicated_wire.format(line1[0], "wr" + line1[1] + "_in") + "\n" # ======================================================= # # ========================================================= diff --git a/src/params.py b/src/params.py index ea7a8a5..bba7fad 100644 --- a/src/params.py +++ b/src/params.py @@ -1,7 +1,7 @@ # == Parameters == # N_MUX = 1 # number of selection lines for the mux per io -N_IO = 6 +N_IO = 8 N_UART = 2 N_SPI = 1 -N_TWI = 1 +N_TWI = 2 # ================ # diff --git a/src/pinmux_generator.py b/src/pinmux_generator.py index 6dfa595..dbea8d5 100644 --- a/src/pinmux_generator.py +++ b/src/pinmux_generator.py @@ -33,21 +33,23 @@ if not os.path.exists("bsv_src"): bsv_file = open("./bsv_src/pinmux.bsv", "w") header = ''' /* - This BSV file has been generated by the PinMux tool available at: . + This BSV file has been generated by the PinMux tool available at: + https://bitbucket.org/casl/pinmux. + Authors: Neel Gala, Luke Date of generation: ''' + time.strftime("%c") + ''' */ package pinmux; typedef struct{ - Bit#(1) outputval; // output from core to pad bit7 + Bit#(1) outputval; // output from core to pad bit7 Bit#(1) output_en; // output enable from core to pad bit6 - Bit#(1) input_en; // input enable from core to io_cell bit5 - Bit#(1) pullup_en; // pullup enable from core to io_cell bit4 - Bit#(1) pulldown_en; // pulldown enable from core to io_cell bit3 - Bit#(1) drivestrength; // drivestrength from core to io_cell bit2 - Bit#(1) pushpull_en; // pushpull enable from core to io_cell bit1 - Bit#(1) opendrain_en; // opendrain enable form core to io_cell bit0 + Bit#(1) input_en; // input enable from core to io_cell bit5 + Bit#(1) pullup_en; // pullup enable from core to io_cell bit4 + Bit#(1) pulldown_en; // pulldown enable from core to io_cell bit3 + Bit#(1) drivestrength; // drivestrength from core to io_cell bit2 + Bit#(1) pushpull_en; // pushpull enable from core to io_cell bit1 + Bit#(1) opendrain_en; // opendrain enable form core to io_cell bit0 } GenericIOType deriving(Eq,Bits,FShow); interface Ifc_pinmux;