From 0833e8dea0960ef399dbe26c687d15f2da598f88 Mon Sep 17 00:00:00 2001 From: Neel Date: Sun, 11 Mar 2018 22:13:31 +0530 Subject: [PATCH] automated the pinumxing logic Currently it only supports muxing between inputs and outputs. Handling of inouts will have to be done soon. --- pinmap.txt | 5 +++ src/actual_pinmux.py | 71 ++++++++++++++++++++++++++++++++++------- src/params.py | 4 +-- src/pinmux_generator.py | 6 ++++ src/wire_def.py | 8 ++--- 5 files changed, 76 insertions(+), 18 deletions(-) create mode 100644 pinmap.txt diff --git a/pinmap.txt b/pinmap.txt new file mode 100644 index 0000000..d3dc0fa --- /dev/null +++ b/pinmap.txt @@ -0,0 +1,5 @@ +muxed +0 uart0_tx spi0_sclk +1 uart0_rx spi0_mosi +2 uart1_tx spi0_ss +3 uart1_rx spi0_miso diff --git a/src/actual_pinmux.py b/src/actual_pinmux.py index 944a816..fe16198 100644 --- a/src/actual_pinmux.py +++ b/src/actual_pinmux.py @@ -1,17 +1,64 @@ from params import * -#== Actual pinmuxing ==# TODO: Need to get this as a templete -pinmux=''' - /*=============== THIS IS WHERE ACTUAL MUXING HAPPENS ==========*/ - cell0_out=wrmux0==0?uart0_rx_io:uart1_rx_io; - rule get_input_for_rx; - if(wrmux0==0) - wruart0_rx<=cell0_in; - else - wruart1_rx<=cell0_in; +from string import digits + + +## 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" +} + + +########### 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=''' + rule assign_input_for_{2}(wrmux{0}=={1}); + wr{2}<=cell{0}_in; endrule - cell1_out=wrmux1==0?uart0_tx_io:uart1_tx_io; - /*==============================================================*/ ''' -######################################################################## +######################################### +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