adding support for PWM.
authorNeel <neelgala@gmail.com>
Mon, 19 Mar 2018 12:01:26 +0000 (17:31 +0530)
committerNeel <neelgala@gmail.com>
Mon, 19 Mar 2018 12:01:26 +0000 (17:31 +0530)
pinmap.txt
src/actual_pinmux.py
src/interface_decl.py
src/interface_def.py
src/parse.py
src/pinmux_generator.py
src/wire_def.py

index 82f9ffe395d04a0737dce25ca0f060d31442d81a..a520d497a7c167f38c2b1326f635044d9c82843a 100644 (file)
@@ -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
index 2c1d76f1584282269ac59ff0e9ef5f9571728dc6..f24c9764a136bb22ca677271d153060cefa7be60 100644 (file)
@@ -15,6 +15,7 @@ dictionary = {
     "sd_clk": "output",
     "sd_cmd": "output",
     "sd_d": "inout",
+    "pwm": "output"
 }
 
 
index 4569b4caf16e444f89795f9326dc1760775751fe..df54caf6834862ddfcd544a01dd10ec6a011f345 100644 (file)
@@ -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);
+'''
 # ======================================= #
index 07d3b3f580bdf6a89137dc1411e5cc85a5defd9f..6c2039777138dbd13bb284339b9dbc7015a25ccf 100644 (file)
@@ -102,4 +102,10 @@ jtaginterface_def = '''
         wrjtag{0}_tdo<=in;
       endmethod
 '''
+
+pwminterface_def = '''
+      method Action pwm{0}(Bit#(1) in);
+        wrpwm{0}<=in;
+      endmethod
+'''
 # ============================================== #
index babf31d469c8d70d6ed86ee7fe1cab528911ea92..26ec3b4f21ce3a817e15fef182db690750c0afd3 100644 (file)
@@ -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
index f52f8037a8d6a6459133ee10fa474dcd0d1882fc..3e216c2eba5d2ae76612a54f5df20b869416fbb1 100644 (file)
@@ -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")
 # ======================================================================
index 398222228bb87c7b5eda46df7dc47690a74598bd..aca972b3c5a7d9893e4b355801bceb9ea614b3f9 100644 (file)
@@ -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}};
+'''
 # =================================== #