X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Factual_pinmux.py;h=ff6902af01399afefb559eb409c52687d0397d34;hb=11afcc66f875bfcf10642f8bab3812bfcf56e6d2;hp=fe16198e9afce110f65151beef3bcd59b05f956b;hpb=0833e8dea0960ef399dbe26c687d15f2da598f88;p=pinmux.git diff --git a/src/actual_pinmux.py b/src/actual_pinmux.py index fe16198..ff6902a 100644 --- a/src/actual_pinmux.py +++ b/src/actual_pinmux.py @@ -1,64 +1,95 @@ -from params import * +from parse import * from string import digits +try: + from string import maketrans +except ImportError: + maketrans = str.maketrans -## dictionary of properties of signals that are supported. -dictionary={ - "uart_rx":"input", - "uart_tx":"output", - "spi_sclk":"output", - "spi_mosi":"output", - "spi_ss": "output", - "spi_miso":"input" +# dictionary of properties of signals that are supported. +dictionary = { + "uart_rx" : "input", + "uart_tx" : "output", + "spi_sclk" : "output", + "spi_mosi" : "output", + "spi_ss" : "output", + "spi_miso" : "input", + "twi_sda" : "inout", + "twi_scl" : "inout", + "sd_clk": "output", + "sd_cmd": "output", + "sd_d": "inout", + "pwm": "output" } - -########### 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. + +# ============== common bsv templates ============ # +# 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=''' - rule assign_input_for_{2}(wrmux{0}=={1}); - wr{2}<=cell{0}_in; - endrule +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") -for lineno,line in enumerate(pinmap_file): - line1=line.split() - if(lineno>0): - if(lineno>N_IO): - print"ERROR: Parameter N_IO("+str(N_IO)+") is less than the pin number in line: "+str(lineno)+" of pinmap.txt" - exit(1) - ######## Mux each generic IO cell with the mapping###### - # provided in the pinmap file - pinmux=pinmux+" cell"+str(line1[0])+"_out=" - i=0 - while(i