From: Luke Kenneth Casson Leighton Date: Mon, 23 Jul 2018 13:02:43 +0000 (+0100) Subject: convert i2c peripheral to get/put X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=78f772dcb06050b7a8d2602c440e2c2da4acb84b;p=shakti-peripherals.git convert i2c peripheral to get/put --- diff --git a/src/peripherals/i2c/I2C_top.bsv b/src/peripherals/i2c/I2C_top.bsv index 9b5977c..cd8bc37 100644 --- a/src/peripherals/i2c/I2C_top.bsv +++ b/src/peripherals/i2c/I2C_top.bsv @@ -19,6 +19,7 @@ I2C Controller top module which is compliant with UM10204 I2C Specification prov // ================================================ package I2C_top; // Bluespec Libraries +import GetPut ::*; import TriState ::*; import Counter ::*; // ================================================ @@ -45,7 +46,6 @@ import Semi_FIFOF ::*; (*always_enabled, always_ready*) interface I2C_out; - method Bit#(1) scl_out; method Bit#(1) i2c_DRV0; method Bit#(1) i2c_DRV1; method Bit#(1) i2c_DRV2; @@ -55,11 +55,12 @@ import Semi_FIFOF ::*; method Bit#(1) i2c_PUQ; method Bit#(1) i2c_PWRUPZHL; method Bit#(1) i2c_PWRUP_PULL_EN; - method Action scl_in(Bit#(1) in); - method Bool scl_out_en; - method Bit#(1) sda_out; - method Action sda_in(Bit#(1) in); - method Bool sda_out_en; + interface Get#(Bit#(1)) scl_out; + interface Put#(Bit#(1)) scl_in; + interface Get#(Bit#(1)) scl_out_en; + interface Get#(Bit#(1)) sda_out; + interface Put#(Bit#(1)) sda_in; + interface Get#(Bit#(1)) sda_out_en; endinterface @@ -865,9 +866,6 @@ Interrupt Generation And Documentation endinterface*/ interface I2C_out out; - method Bit#(1) scl_out; - return val_SCL; - endmethod method Bit#(1) i2c_DRV0; return drv0_rg[0]; endmethod @@ -895,21 +893,34 @@ Interrupt Generation And Documentation method Bit#(1) i2c_PWRUP_PULL_EN; return pwrup_pull_en_rg[0]; endmethod - method Action scl_in(Bit#(1) in); - val_SCL_in <= in; - endmethod - method Bool scl_out_en; - return (cOutEn && eso == 1'b1); + interface scl_out = interface Get + method ActionValue#(Bit#(1)) get; + return val_SCL; endmethod - method Bit#(1) sda_out; + interface scl_in = interface Put + method Action put(Bit#(1) in); + val_SCL_in <= in; + endmethod + endinterface; + interface scl_out_en = interface Get + method ActionValue#(Bit#(1)) get; + return pack(cOutEn && eso == 1'b1); + endmethod + endinterface; + interface sda_out = interface Get + method ActionValue#(Bit#(1)) get; return val_SDA; endmethod - method Action sda_in(Bit#(1) in); + interface sda_in = interface Put + method Action put(Bit#(1) in); val_SDA_in <= in; - endmethod - method Bool sda_out_en; - return (dOutEn && eso == 1'b1); - endmethod + endmethod + endinterface; + interface sda_out_en = interface Get + method ActionValue#(Bit#(1)) get; + return pack(dOutEn && eso == 1'b1); + endmethod + endinterface; endinterface //AXI-4 Interface