add quart wrapper
[shakti-peripherals.git] / src / peripherals / uart / quart.bsv
index 56a0965a520d7aef98b182ec2cbee56e7e24846a..2dc6c7ee50e260e9c97dc766bb2b67210a41c4df 100644 (file)
@@ -29,84 +29,84 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 --------------------------------------------------------------------
 */
 
-package spi;
+package quart;
 
     import AXI4_Lite_Types   :: *;
     import AXI4_Lite_Fabric  :: *;
        import GetPut::*;
-       import qspi::*;
+       import Uart16550::*;
     `include "instance_defines.bsv"
 
-
     (*always_ready, always_enabled*)
-    interface SPI_out;
-        interface Get#(Bit#(1)) clk_o;
-        method Bit#(9) io0_sdio_ctrl;
-        method Bit#(9) io1_sdio_ctrl;
-        // index 0 is MOSI, index 1 is MISO.
-        interface Get#(Bit#(2)) io_out;
-        interface Get#(Bit#(2)) io_out_en;
-        interface Put#(Bit#(2)) io_in;
-        interface Get#(Bit#(1)) ncs_o;
+    interface QUART_out;
+        interface Put#(Bit#(1)) srx_in;
+        interface Put#(Bit#(1)) cts_in;
+        interface Get#(Bit#(1)) stx_out;
+        interface Get#(Bit#(1)) rts_out;
     endinterface
 
-    interface Ifc_spi;
-        interface SPI_out out;
+    interface QUART_AXI4_Lite_Ifc;
+        interface QUART_out out;
                interface AXI4_Lite_Slave_IFC#(`PADDR,`Reg_width,`USERSPACE) slave;
-        // 0=TOF, 1=SMF, 2=Threshold, 3=TCF, 4=TEF 5 = request_ready
-               method Bit#(6) interrupts; 
+        (* always_ready, always_enabled *) method Bit#(1) irq;
        endinterface
 
-
        (*synthesize*)
-       module mkspi(Ifc_spi);
-       
-    Ifc_qspi qspi <- mkqspi();
-
-    interface out = interface SPI_out
-       method Bit#(9) io0_sdio_ctrl;
-               return qspi.out.io0_sdio_ctrl;
-       endmethod
-       method Bit#(9) io1_sdio_ctrl;
-               return qspi.out.io1_sdio_ctrl;
-       endmethod
-      interface io_out = interface Get
-        method ActionValue#(Bit#(2)) get;
-            let temp2 <- qspi.out.io_out.get;
-            Bit#(2) temp;
-            temp[0] = temp2[0];
-            temp[1] = temp2[1];
+    module mkQUART#(Clock core_clock, Reset core_reset)
+                                        (QUART_AXI4_Lite_Ifc);
+
+    Uart16550_AXI4_Lite_Ifc uart <- mkUart16550(core_clock, core_reset);
+    //uart.pin_dsr_sync <= in; 
+    //uart.pin_ri_sync  <= in; 
+    //uart.pin_dcd_sync <= in; 
+    Bit#(1) v1 = 1;
+    Bit#(1) v0 = 1;
+    let dsr_in = uart.coe_rs232.dsr_in.put;
+    dsr_in = v1;
+    let dcd_in = uart.coe_rs232.dcd_in.put;
+    dcd_in = v1;
+    let ri_in = uart.coe_rs232.ri_in.put;
+    ri_in = v0;
+
+    let temp2 <- uart.coe_rs232.dtr_out.get;
+    Bit#(1) temp = temp2;
+    uart.coe_rs232.dtr_out.get(temp);
+
+    interface out = interface QUART_out
+        interface srx_in = interface Put
+          method Action put(Bit#(1) in);
+            uart.coe_rs232.srx_in.put(in); // RX Input
+          endmethod
+        endinterface;
+
+        interface cts_in = interface Put
+          method Action put(Bit#(1) in);
+            uart.coe_rs232.cts_in.put(in); // CTS Input
+          endmethod
+        endinterface;
+
+        interface stx_out = interface Get
+          method ActionValue#(Bit#(1)) get;
+            let temp2 <- uart.coe_rs232.stx_out.get;
+            Bit#(1) temp = temp2;
             return temp;
-        endmethod
-      endinterface;
-      interface io_out_en = interface Get
-        method ActionValue#(Bit#(2)) get;
-            let temp2 <- qspi.out.io_out_en.get;
-            Bit#(2) temp;
-            temp[0] = temp2[0];
-            temp[1] = temp2[1];
+          endmethod
+        endinterface;
+
+        interface rts_out = interface Get
+          method ActionValue#(Bit#(1)) get;
+            let temp2 <- uart.coe_rs232.rts_out.get;
+            Bit#(1) temp = temp2;
             return temp;
-        endmethod
-      endinterface;
-      interface io_in = interface Put
-        method Action put(Bit#(2) in);
-            Bit#(4) temp;
-            temp[3] = 0;
-            temp[2] = 0;
-            temp[1] = in[1];
-            temp[0] = in[0];
-            qspi.out.io_in.put(temp);
-        endmethod
-      endinterface;
-      interface clk_o = qspi.out.clk_o;
-      interface ncs_o = qspi.out.ncs_o;
+          endmethod
+        endinterface;
+
     endinterface;
 
-    interface slave = qspi.slave;
+    interface slave = uart.slave_axi_uart;
 
-  // 0=TOF, 1=SMF, 2=Threshold, 3=TCF, 4=TEF 5=request_ready
-       method Bit#(6) interrupts;
-               return qspi.interrupts;
+       method Bit#(1) irq;
+               return uart.irq;
        endmethod
 
   endmodule