add I2C master to ls180
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 23 Sep 2020 10:43:53 +0000 (11:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 23 Sep 2020 10:43:53 +0000 (11:43 +0100)
src/soc/litex/florent/libresoc/ls180.py
src/soc/litex/florent/ls180soc.py

index ce99735ef424f7537899634edbba70afdcf752a0..17b8772598244ae906087f10497f83e3d1e12a8f 100644 (file)
@@ -11,6 +11,9 @@ conceptually similar to the following:
 * https://github.com/enjoy-digital/liteeth/blob/master/liteeth/gen.py
 * https://github.com/enjoy-digital/litepcie/blob/master/litepcie/gen.py
 
+Total I/O pins: 84.
+Fits in a JEDEC QFP-100
+
 """
 
 from migen.fhdl.structure import _Fragment
@@ -22,9 +25,11 @@ import os
 # IOs ----------------------------------------------------------------------------------------------
 
 _io = [
+    # CLK/RST: 2 pins
     ("sys_clk", 0, Pins("G2"), IOStandard("LVCMOS33")),
     ("sys_rst",   0, Pins("R1"), IOStandard("LVCMOS33")),
 
+    # JTAG0: 4 pins
     ("jtag", 0,
         Subsignal("tms", Pins("Z1"), IOStandard("LVCMOS33")),
         Subsignal("tck", Pins("Z2"), IOStandard("LVCMOS33")),
@@ -32,16 +37,25 @@ _io = [
         Subsignal("tdo", Pins("Z4"), IOStandard("LVCMOS33")),
     ),
 
+    # I2C0: 2 pins
+    ("i2c", 0,
+        Subsignal("scl", Pins("L4"), IOStandard("LVCMOS33")),
+        Subsignal("sda", Pins("M1"), IOStandard("LVCMOS33"))
+    ),
+
+    # UART0: 2 pins
     ("serial", 0,
         Subsignal("tx", Pins("L4"), IOStandard("LVCMOS33")),
         Subsignal("rx", Pins("M1"), IOStandard("LVCMOS33"))
     ),
 
+    # UART1: 2 pins
     ("serial", 1,
         Subsignal("tx", Pins("L4"), IOStandard("LVCMOS33")),
         Subsignal("rx", Pins("M1"), IOStandard("LVCMOS33"))
     ),
 
+    # SPI0: 4 pins
     ("spi_master", 0,
         Subsignal("clk",  Pins("J1")),
         Subsignal("mosi", Pins("J3"), Misc("PULLMODE=UP")),
@@ -51,6 +65,7 @@ _io = [
         IOStandard("LVCMOS33"),
     ),
 
+    # SPICARD0: 4 pins
     ("spisdcard", 0,
         Subsignal("clk",  Pins("J1")),
         Subsignal("mosi", Pins("J3"), Misc("PULLMODE=UP")),
@@ -60,6 +75,7 @@ _io = [
         IOStandard("LVCMOS33"),
     ),
 
+    # SDCARD0: 6 pins
     ("sdcard", 0,
         Subsignal("clk",  Pins("J1")),
         Subsignal("cmd",  Pins("J3"), Misc("PULLMODE=UP")),
@@ -68,6 +84,7 @@ _io = [
         IOStandard("LVCMOS33"),
     ),
 
+    # SDRAM: 39 pins
     ("sdram_clock", 0, Pins("F19"), IOStandard("LVCMOS33")),
     ("sdram", 0,
         Subsignal("a",     Pins(
@@ -87,6 +104,7 @@ _io = [
         Misc("SLEWRATE=FAST"),
     ),
 
+    # PWM: 2 pins
     ("pwm", 0, Pins("P1"), IOStandard("LVCMOS33")),
     ("pwm", 1, Pins("P2"), IOStandard("LVCMOS33")),
 ]
@@ -110,11 +128,12 @@ for i in range(8):
 pinsin = ' '.join(pinsin)
 pinsout = ' '.join(pinsout)
 
-# 8 GPIO in, 8 GPIO out
+# GPIO in: 8 pins
 _io.append( ("gpio_in", 8, Pins(pinsin), IOStandard("LVCMOS33")) )
+# GPIO out: 8 pins
 _io.append( ("gpio_out", 8, Pins(pinsout), IOStandard("LVCMOS33")) )
 
-# 3 External INT wires
+# EINT: 3 pins
 _io.append( ("eint", 3, Pins("E0 E1 E2"), IOStandard("LVCMOS33")) )
 
 # Platform -----------------------------------------------------------------------------------------
index 877abf020f6d4e059b9ff6e6cedb68688024b11b..72b23a6683fc15f9e55ae6723a9ad895ed3f0f87 100755 (executable)
@@ -23,6 +23,7 @@ from litedram.phy.gensdrphy import GENSDRPHY, HalfRateGENSDRPHY
 from litex.soc.cores.gpio import GPIOInOut, GPIOIn, GPIOOut#, GPIOTristate
 from litex.soc.cores.spi import SPIMaster
 from litex.soc.cores.pwm import PWM
+from litex.soc.cores.bitbang import I2CMaster
 
 from litex.tools.litex_sim import sdram_module_nphases, get_sdram_phy_settings
 
@@ -205,6 +206,9 @@ class LibreSoCSim(SoCCore):
             setattr(self.submodules, name, PWM(platform.request("pwm", i)))
             self.add_csr(name)
 
+        # I2C Master
+        self.submodules.i2c = I2CMaster(platform.request("i2c"))
+        self.add_csr("i2c")
 
         # Debug ---------------------------------------------------------------
         if not debug: