<?xml version="1.0"?>
<lsccip:ip version="1.0"
    xmlns:lsccip="http://www.latticesemi.com/XMLSchema/Radiant/ip"
    xmlns:xi="http://www.w3.org/2001/XInclude">

  <lsccip:general>
    <lsccip:vendor>latticesemi.com</lsccip:vendor>
    <lsccip:library>ip</lsccip:library>
    <lsccip:name>i2c_target</lsccip:name>
    <lsccip:display_name>I2C Target</lsccip:display_name>
    <lsccip:version>2.6.0</lsccip:version>
    <lsccip:category>Processors_Controllers_and_Peripherals</lsccip:category>
    <lsccip:keywords>BusType_APB</lsccip:keywords>
    <lsccip:min_radiant_version>3.1</lsccip:min_radiant_version>
    <lsccip:supported_products>
	<lsccip:supported_family name="LIFCL">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LFD2NX">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LFCPNX">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LFMXO5">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LATG1">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="UT24C">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="UT24CP">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LAV-AT">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="kr6a00">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LKH-CT">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LKH-MH">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LN2-CT">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LN2-MH">
	   </lsccip:supported_family>
	   <lsccip:supported_family name="LFMXO4">
	   </lsccip:supported_family>
	  </lsccip:supported_products>
    <lsccip:supported_platforms>
      <lsccip:supported_platform name="radiant"/>
      <lsccip:supported_platform name="esi"/>
    </lsccip:supported_platforms>
  </lsccip:general>

  <lsccip:settings>
    <!-- General -->
    <lsccip:setting id                 = "APB_ENABLE"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "bool"
                    title              = "APB Mode Enable"
                    default            = "True"
                    group1             = "General"
    />
    <lsccip:setting id                 = "REMOVE_TRISTATE"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "bool"
                    title              = "Remove Tristate Buffers"
                    default            = "False"
                    group1             = "General"
    />

    <lsccip:setting id                 = "ADDR_MODE"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "Addressing Mode"
                    options            = "[('7-bit', 7), ('10-bit', 10)]"
                    default            = "7"
                    group1             = "General"
    />

    <lsccip:setting id                 = "FAMILY"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "string"
                    default            = "LIFCL"
                    value_expr         = "runtime_info.device_info.architecture(1)"
                    editable           = "False"
                    hidden             = "True"
                    title              = "Device Architecture"
                    group1             = "General"
    />
    
    <lsccip:setting id                 = "SLAVE_ADDR_INPUT"
                    type               = "input"
                    value_type         = "string"
                    conn_mod           = "lscc_i2c_slave"
                    default            = "51"
                    output_formatter   = "nostr"
                    drc                = "check_hex_format(ADDR_MODE,SLAVE_ADDR_INPUT)"
                    title              = "I2C Target Address: 0x"
                    group1             = "General"
    />

    <lsccip:setting id                 = "SLAVE_ADDR"
                    type               = "param"
                    value_type         = "string"
                    conn_mod           = "lscc_i2c_slave"
                    default            = "51"
                    editable           = "False"
                    hidden             = "True"
                    output_formatter   = "nostr"
                    value_expr         = "calc_initial_value(ADDR_MODE, SLAVE_ADDR_INPUT)"
                    title              = "Actual SLAVE_ADDR"
                    group1             = "General"
    />

    <lsccip:setting id                 = "STOP_DET_MODE"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "STOP Condition Detected Interrupt Assertion"
                    options            = "[('STOP Condition addressed to IP', 0),
                                           ('All STOP condition detected on bus', 1)]"
                    default            = "0"
                    group1             = "General"
    />

    <!-- Clock -->
    <lsccip:setting id                 = "SYS_CLOCK_FREQ"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "System Clock Frequency (MHz)"
                    value_range        = "(40, 100)"
                    editable           = "True"
                    default            = "50"
                    group1             = "General"
    />

    <lsccip:setting id                 = "SDA_REG_DEPTH"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "I2C SDA Register Depth"
                    value_range        = "(0, 2)"
                    default            = "0"
                    group1             = "Timing Adjustment"
    />

    <!-- FIFO -->
    <lsccip:setting id                 = "FIFO_WIDTH"
                    type               = "input"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "FIFO Width"
                    value_expr         = "8"
                    editable           = "False"
                    group1             = "FIFO"
    />

    <lsccip:setting id                 = "FIFO_DEPTH"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "FIFO Depth"
                    options            = "[16, 32, 64, 128, 256]"
                    default            = "16"
                    group1             = "FIFO"
    />

    <lsccip:setting id                 = "FIFO_IMPL"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "string"
                    title              = "Implementation of FIFO"
                    options            = "['EBR', 'LUT']"
                    default            = "LUT"
                    group1             = "FIFO"
    />

    <lsccip:setting id                 = "TX_FIFO_AE_FLAG"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "TX FIFO Almost Empty Flag"
                    value_range        = "(1, 256)"
                    drc                = "ext_check_flag(TX_FIFO_AE_FLAG, FIFO_DEPTH)"
                    default            = "2"
                    group1             = "FIFO"
    />

    <lsccip:setting id                 = "RX_FIFO_AF_FLAG"
                    type               = "param"
                    conn_mod           = "lscc_i2c_slave"
                    value_type         = "int"
                    title              = "RX FIFO Almost Full Flag"
                    value_range        = "(1, 256)"
                    drc                = "ext_check_flag(RX_FIFO_AF_FLAG, FIFO_DEPTH)"
                    default            = "14"
                    group1             = "FIFO"
    />
  </lsccip:settings>

  <lsccip:ports>
<!-- I2C Signals -->
    <lsccip:port name          = "scl_io"
                 dir           = "inout"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "scl_io"
                 dangling      = "REMOVE_TRISTATE"
    />
    <lsccip:port name          = "scl_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "scl_i"
                 stick_low     = "not REMOVE_TRISTATE"
    />
    <lsccip:port name          = "scl_oe_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "scl_oe_o"
                 dangling      = "not REMOVE_TRISTATE"
    />
    <lsccip:port name          = "scl_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "scl_o"
                 dangling      = "not REMOVE_TRISTATE"
    />
    <lsccip:port name          = "sda_io"
                 dir           = "inout"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "sda_io"
                 dangling      = "REMOVE_TRISTATE"
    />
    <lsccip:port name          = "sda_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "sda_i"
                 stick_low     = "not REMOVE_TRISTATE"
    />
    <lsccip:port name          = "sda_oe_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "sda_oe_o"
                 dangling      = "not REMOVE_TRISTATE"
    />
    <lsccip:port name          = "sda_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "sda_o"
                 dangling      = "not REMOVE_TRISTATE"
    />
    <!-- Clock and Reset in    puts -->
    <lsccip:port name          = "clk_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "clk_i"
    />

    <lsccip:port name          = "rst_n_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "rst_n_i"
    />
    <!-- LMMI inputs -->
    <lsccip:port name          = "lmmi_request_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_request_i"
                 stick_low     = "APB_ENABLE == 1"
    />

    <lsccip:port name          = "lmmi_wr_rdn_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_wr_rdn_i"
                 stick_low     = "APB_ENABLE == 1"
    />

    <lsccip:port name          = "lmmi_offset_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_offset_i"
                 range         = "(3, 0)"
                 stick_low     = "APB_ENABLE == 1"
    />

    <lsccip:port name          = "lmmi_wdata_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_wdata_i"
                 range         = "(7, 0)"
                 stick_low     = "APB_ENABLE == 1"
    />

    <!-- LMMI outputs -->
    <lsccip:port name          = "lmmi_rdata_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_rdata_o"
                 range         = "(7, 0)"
                 dangling      = "APB_ENABLE == 1"
    />

    <lsccip:port name          = "lmmi_rdata_valid_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_rdata_valid_o"
                 dangling      = "APB_ENABLE == 1"
    />

    <lsccip:port name          = "lmmi_ready_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "lmmi_ready_o"
                 dangling      = "APB_ENABLE == 1"
    />

    <!-- LINTR output -->
    <lsccip:port name          = "int_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "int_o"
                 bus_interface = "INTR"
    />
    <!-- APB inputs -->

    <lsccip:port name          = "apb_penable_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_penable_i"
                 stick_low     = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_psel_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_psel_i"
                 stick_low     = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_pwrite_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_pwrite_i"
                 stick_low     = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_paddr_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_paddr_i"
                 range         = "(5, 0)"
                 stick_low     = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_pwdata_i"
                 dir           = "in"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_pwdata_i"
                 range         = "(31, 0)"
                 stick_low     = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <!-- APB outputs -->
    <lsccip:port name          = "apb_pready_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_pready_o"
                 dangling      = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_pslverr_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_pslverr_o"
                 dangling      = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />

    <lsccip:port name          = "apb_prdata_o"
                 dir           = "out"
                 conn_mod      = "lscc_i2c_slave"
                 conn_port     = "apb_prdata_o"
                 range         = "(31, 0)"
                 dangling      = "not APB_ENABLE"
                 bus_interface = "APB_S0"
    />
  </lsccip:ports>

    <xi:include href="bus_interface.xml" parse="xml" />
    <xi:include href="memory_map.xml" parse="xml" />

  <lsccip:componentGenerators>
    <lsccip:componentGenerator>
      <lsccip:name>create_constraint_file</lsccip:name>
      <lsccip:generatorExe>eval/create_constraint.py</lsccip:generatorExe>
    </lsccip:componentGenerator>
  </lsccip:componentGenerators>

</lsccip:ip>
