From: Luke Kenneth Casson Leighton Date: Tue, 20 Mar 2018 17:17:53 +0000 (+0000) Subject: remove hard-coded interface definitions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=783acd63efb6b84e4ea505576116e38acd914944;p=pinmux.git remove hard-coded interface definitions --- diff --git a/src/interface_decl.py b/src/interface_decl.py index e476bd8..3648272 100644 --- a/src/interface_decl.py +++ b/src/interface_decl.py @@ -1,75 +1,3 @@ -# ========= Interface declarations ================ # -mux_interface = ''' - method Action cell{0}_mux(Bit#({1}) in);''' - -io_interface = ''' - (*always_ready*) method Bit#(1) io_outputval_{0}; - (*always_ready*) method Bit#(1) io_output_en_{0}; - (*always_ready*) method Bit#(1) io_input_en_{0}; - (*always_ready*) method Bit#(1) io_pullup_en_{0}; - (*always_ready*) method Bit#(1) io_pulldown_en_{0}; - (*always_ready*) method Bit#(1) io_drivestrength_{0}; - (*always_ready*) method Bit#(1) io_pushpull_en_{0}; - (*always_ready*) method Bit#(1) io_opendrain_en_{0}; - (*always_ready,always_enabled,result="io"*) - method Action io_inputval_{0}(Bit#(1) in); -''' -# == Peripheral Interface definitions == # -# these are the interface of the peripherals to the pin mux -# Outputs from the peripherals will be inputs to the pinmux -# module. Hence the change in direction for most pins - -uartinterface_decl = ''' - (*always_ready,always_enabled*) method Action tx_{0}(Bit#(1) in); - (*always_ready,always_enabled*) method Bit#(1) rx_{0}; -''' - -spiinterface_decl = ''' - (*always_ready,always_enabled*) method Action sclk_{0} (Bit#(1) in); - (*always_ready,always_enabled*) method Action mosi_{0} (Bit#(1) in); - (*always_ready,always_enabled*) method Action ss_{0} (Bit#(1) in); - (*always_ready,always_enabled*) method Bit#(1) miso_{0}; -''' - -twiinterface_decl = ''' - (*always_ready,always_enabled*) method Action sda{0}_out (Bit#(1) in); - (*always_ready,always_enabled*) method Action sda{0}_outen (Bit#(1) in); - (*always_ready,always_enabled*) method Bit#(1) sda{0}_in; - (*always_ready,always_enabled*) method Action scl{0}_out (Bit#(1) in); - (*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; -''' - -jtaginterface_decl = ''' - (*always_ready,always_enabled*) method Bit#(1) jtag{0}_tdi; - (*always_ready,always_enabled*) method Bit#(1) jtag{0}_tms; - (*always_ready,always_enabled*) method Bit#(1) jtag{0}_tclk; - (*always_ready,always_enabled*) method Bit#(1) jtag{0}_trst; - (*always_ready,always_enabled*) method Action jtag{0}_tdo(Bit#(1) in); -''' - -pwminterface_decl = ''' - (*always_ready,always_enabled*) method Action pwm{0}(Bit#(1) in); -''' -# ======================================= # - class Pin(object): """ pin interface declaration. @@ -163,64 +91,56 @@ if __name__ == '__main__': p = _pinmunge(p, " ", " ") return p - pwm = Interface([{'name': "pwm{0}", 'action': True}]) - print pwm - print - assert pinmunge(str(pwm)) == pinmunge(pwminterface_decl) +# ========= Interface declarations ================ # - jtag = Interface([{'name': 'jtag{0}_tdi'}, - {'name': 'jtag{0}_tms'}, - {'name': 'jtag{0}_tclk'}, - {'name': 'jtag{0}_trst'}, - {'name': 'jtag{0}_tdo', 'action': True}]) - print jtag - print - assert pinmunge(str(jtag)) == pinmunge(jtaginterface_decl) +mux_interface = ''' + method Action cell{0}_mux(Bit#({1}) in);''' - sd = Interface([{'name': 'sd{0}_clk', 'action': True}, - {'name': 'sd{0}_cmd', 'action': True}, - {'name': 'sd{0}_d0', 'outen': True}, - {'name': 'sd{0}_d1', 'outen': True}, - {'name': 'sd{0}_d2', 'outen': True}, - {'name': 'sd{0}_d3', 'outen': True} +io_interface = Interface([{'name': 'io_outputval_{0}', 'enabled': False}, + {'name': 'io_output_en_{0}', 'enabled': False}, + {'name': 'io_input_en_{0}', 'enabled': False}, + {'name': 'io_pullup_en_{0}', 'enabled': False}, + {'name': 'io_pulldown_en_{0}', 'enabled': False}, + {'name': 'io_drivestrength_{0}', 'enabled': False}, + {'name': 'io_pushpull_en_{0}', 'enabled': False}, + {'name': 'io_opendrain_en_{0}', 'enabled': False}, + {'name': 'io_inputval_{0}', 'action': True, 'io': True}, ]) - print sd - print - assert pinmunge(str(sd)) == pinmunge(sdinterface_decl) - twi = Interface([{'name': 'sda{0}', 'outen': True}, - {'name': 'scl{0}', 'outen': True}, - ]) - print twi - print - assert pinmunge(str(twi)) == pinmunge(twiinterface_decl) +# == Peripheral Interface definitions == # +# these are the interface of the peripherals to the pin mux +# Outputs from the peripherals will be inputs to the pinmux +# module. Hence the change in direction for most pins - spi = Interface([{'name': 'sclk_{0}', 'action': True}, +uartinterface_decl = Interface([{'name': 'tx_{0}', 'action': True}, + {'name': 'rx_{0}'}, + ]) + +spiinterface_decl = Interface([{'name': 'sclk_{0}', 'action': True}, {'name': 'mosi_{0}', 'action': True}, {'name': 'ss_{0}', 'action': True}, {'name': 'miso_{0}'}, ]) - print spi - print - assert pinmunge(str(spi)) == pinmunge(spiinterface_decl) - uart = Interface([{'name': 'tx_{0}', 'action': True}, - {'name': 'rx_{0}'}, - ]) - print uart - print - assert pinmunge(str(uart)) == pinmunge(uartinterface_decl) +twiinterface_decl = Interface([{'name': 'sda{0}', 'outen': True}, + {'name': 'scl{0}', 'outen': True}, + ]) - io = Interface([{'name': 'io_outputval_{0}', 'enabled': False}, - {'name': 'io_output_en_{0}', 'enabled': False}, - {'name': 'io_input_en_{0}', 'enabled': False}, - {'name': 'io_pullup_en_{0}', 'enabled': False}, - {'name': 'io_pulldown_en_{0}', 'enabled': False}, - {'name': 'io_drivestrength_{0}', 'enabled': False}, - {'name': 'io_pushpull_en_{0}', 'enabled': False}, - {'name': 'io_opendrain_en_{0}', 'enabled': False}, - {'name': 'io_inputval_{0}', 'action': True, 'io': True}, +sdinterface_decl = Interface([{'name': 'sd{0}_clk', 'action': True}, + {'name': 'sd{0}_cmd', 'action': True}, + {'name': 'sd{0}_d0', 'outen': True}, + {'name': 'sd{0}_d1', 'outen': True}, + {'name': 'sd{0}_d2', 'outen': True}, + {'name': 'sd{0}_d3', 'outen': True} ]) - print io - print - assert pinmunge(str(io)) == pinmunge(io_interface) + +jtaginterface_decl = Interface([{'name': 'jtag{0}_tdi'}, + {'name': 'jtag{0}_tms'}, + {'name': 'jtag{0}_tclk'}, + {'name': 'jtag{0}_trst'}, + {'name': 'jtag{0}_tdo', 'action': True}]) + +pwminterface_decl = Interface([{'name': "pwm{0}", 'action': True}]) + +# ======================================= # +