From b3d256ab88c2c852659643a474d57e8ff3f32cde Mon Sep 17 00:00:00 2001 From: Neel Date: Mon, 19 Mar 2018 17:31:26 +0530 Subject: [PATCH] adding support for PWM. --- pinmap.txt | 2 +- src/actual_pinmux.py | 1 + src/interface_decl.py | 4 ++++ src/interface_def.py | 6 ++++++ src/parse.py | 1 + src/pinmux_generator.py | 13 +++++++++++++ src/wire_def.py | 9 ++++++++- 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/pinmap.txt b/pinmap.txt index 82f9ffe..a520d49 100644 --- a/pinmap.txt +++ b/pinmap.txt @@ -8,7 +8,7 @@ muxed 10 sd0_d0 sd1_d0 11 sd0_d1 sd1_d1 12 sd0_d2 sd1_d2 -13 sd0_d3 sd1_d3 +13 sd0_d3 sd1_d3 pwm0 dedicated 4 uart1_tx 5 uart1_rx diff --git a/src/actual_pinmux.py b/src/actual_pinmux.py index 2c1d76f..f24c976 100644 --- a/src/actual_pinmux.py +++ b/src/actual_pinmux.py @@ -15,6 +15,7 @@ dictionary = { "sd_clk": "output", "sd_cmd": "output", "sd_d": "inout", + "pwm": "output" } diff --git a/src/interface_decl.py b/src/interface_decl.py index 4569b4c..df54caf 100644 --- a/src/interface_decl.py +++ b/src/interface_decl.py @@ -64,4 +64,8 @@ jtaginterface_decl = ''' (*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); +''' # ======================================= # diff --git a/src/interface_def.py b/src/interface_def.py index 07d3b3f..6c20397 100644 --- a/src/interface_def.py +++ b/src/interface_def.py @@ -102,4 +102,10 @@ jtaginterface_def = ''' wrjtag{0}_tdo<=in; endmethod ''' + +pwminterface_def = ''' + method Action pwm{0}(Bit#(1) in); + wrpwm{0}<=in; + endmethod +''' # ============================================== # diff --git a/src/parse.py b/src/parse.py index babf31d..26ec3b4 100644 --- a/src/parse.py +++ b/src/parse.py @@ -8,6 +8,7 @@ N_SPI = 1 N_TWI = 2 N_SD = 2 N_JTAG = 2 +N_PWM = 1 Addressing = 'WORD' ADDR_WIDTH = 32 DATA_WIDTH = 32 diff --git a/src/pinmux_generator.py b/src/pinmux_generator.py index f52f803..3e216c2 100644 --- a/src/pinmux_generator.py +++ b/src/pinmux_generator.py @@ -118,6 +118,11 @@ for i in range(0, N_JTAG): bsv_file.write(''' // interface declaration between JTAG-{0} and pinmux'''.format(i)) bsv_file.write(jtaginterface_decl.format(i)) + +for i in range(0, N_PWM): + bsv_file.write(''' + // interface declaration between PWM-{0} and pinmux'''.format(i)) + bsv_file.write(pwminterface_decl.format(i)) # ============================================================== # ===== finish interface definition and start module definition======= @@ -176,6 +181,12 @@ for i in range(0, N_JTAG): '''\n // following wires capture signals to IO CELL if jtag-{0} is // allotted to it'''.format(i)) bsv_file.write(jtagwires.format(i)) + +for i in range(0, N_PWM): + bsv_file.write( + '''\n // following wires capture signals to IO CELL if pwm-{0} is + // allotted to it'''.format(i)) + bsv_file.write(pwmwires.format(i)) bsv_file.write("\n") # ==================================================================== # ========================= Actual pinmuxing ========================# @@ -210,6 +221,8 @@ for i in range(0, N_SD): bsv_file.write(sdinterface_def.format(i)) for i in range(0, N_JTAG): bsv_file.write(jtaginterface_def.format(i)) +for i in range(0, N_PWM): + bsv_file.write(pwminterface_def.format(i)) bsv_file.write(footer) print("BSV file successfully generated: bsv_src/pinmux.bsv") # ====================================================================== diff --git a/src/wire_def.py b/src/wire_def.py index 3982222..aca972b 100644 --- a/src/wire_def.py +++ b/src/wire_def.py @@ -102,7 +102,7 @@ jtagwires = ''' input_en:1, pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0, opendrain_en:0}}; GenericIOType jtag{0}_tdo_io=GenericIOType{{outputval:wrjtag{0}_tdo, - output_en:0, input_en:1, pullup_en:0, pulldown_en:0, + output_en:1, input_en:0, pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0, opendrain_en:0}}; GenericIOType jtag{0}_tms_io=GenericIOType{{outputval:0, output_en:0, input_en:1, pullup_en:0, pulldown_en:0, pushpull_en:0, @@ -114,4 +114,11 @@ jtagwires = ''' input_en:1, pullup_en:0, pulldown_en:0, pushpull_en:0, drivestrength:0, opendrain_en:0}}; ''' + +pwmwires = ''' + Wire#(Bit#(1)) wrpwm{0} <-mkDWire(0); + GenericIOType pwm{0}_io=GenericIOType{{outputval:wrpwm{0}, + output_en:1, input_en:0, pullup_en:0, pulldown_en:0, + pushpull_en:0, drivestrength:0, opendrain_en:0}}; +''' # =================================== # -- 2.30.2