X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fperipherals%2Fspi%2Fspi.bsv;h=f427e28c5f62415b539eeb6c65cb6d05a3c91d48;hb=11a667017572d577c18e1b595f41510efa600353;hp=45288745eea84b817fef7043b1a10e5427f59eec;hpb=8c4e46a09ff0f1c6719fff55722b9f29836e81f4;p=shakti-peripherals.git diff --git a/src/peripherals/spi/spi.bsv b/src/peripherals/spi/spi.bsv index 4528874..f427e28 100644 --- a/src/peripherals/spi/spi.bsv +++ b/src/peripherals/spi/spi.bsv @@ -31,15 +31,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package spi; + import AXI4_Lite_Types :: *; + import AXI4_Lite_Fabric :: *; + import GetPut::*; import qspi::*; + `include "instance_defines.bsv" + (*always_ready, always_enabled*) interface SPI_out; interface Get#(Bit#(1)) clk_o; - interface Get#(Bit#(1)) io_out; 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; @@ -58,7 +63,7 @@ package spi; Ifc_qspi qspi <- mkqspi(); - interface SPI_out out; + interface out = interface SPI_out method Bit#(9) io0_sdio_ctrl; return qspi.out.io0_sdio_ctrl; endmethod @@ -67,26 +72,33 @@ package spi; endmethod interface io_out = interface Get method ActionValue#(Bit#(2)) get; - return qspi.out.io_out[1:0]; + Bit#(2) temp; + temp[1] = qspi.out.io_out[1]; + temp[0] = qspi.out.io_out[0]; + return temp; endmethod endinterface; interface io_out_en = interface Get method ActionValue#(Bit#(2)) get; - return qspi.out.io_out_en[1:0]; + Bit#(2) temp; + temp[1] = qspi.out.io_out_en[1]; + temp[0] = qspi.out.io_out_en[0]; + return temp; endmethod endinterface; interface io_in = interface Put method Action put(Bit#(2) in); - Bit(#4) temp = { 0, 0, in[1], in[0] }; + Bit#(4) temp; + temp[3] = 0; + temp[2] = 0; + temp[1] = in[1]; + temp[0] = in[0]; qspi.out.io_in(temp); endmethod endinterface; interface clk_o = qspi.out.clk_o; - interface io_out = qspi.out.io_out; - interface io_out_en = qspi.out.io_out_en; - interface io_in = qspi.out.io_in; interface ncs_o = qspi.ncs_o; - endinterface + endinterface; interface slave = qspi.slave; @@ -95,4 +107,5 @@ package spi; return qspi.interripts; endmethod + endmodule endpackage