<lsccip:ip 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>io_intf</lsccip:name>
        <lsccip:display_name>I/O Interface</lsccip:display_name>
        <lsccip:version>1.1.1</lsccip:version>
        <lsccip:category>Processors_Controllers_and_Peripherals</lsccip:category>
        <lsccip:min_radiant_version>2024.2</lsccip:min_radiant_version>
        <lsccip:min_esi_version>2024.2</lsccip:min_esi_version>
        <lsccip:supported_products>
            <lsccip:supported_family name="*"/>
        </lsccip:supported_products>
        <lsccip:supported_platforms>
            <lsccip:supported_platform name="esi"/>
            <lsccip:supported_platform name="radiant"/>
        </lsccip:supported_platforms>
    </lsccip:general>
    <lsccip:settings>
        <lsccip:setting id="FAMILY"
                        type="param"
                        value_type="string"
                        conn_mod="lscc_io_module"
                        title="Device Architecture"
                        default="LFCPNX"
                        value_expr="runtime_info.device_info.architecture(1)"
                        editable="False"
                        hidden="True"
                        group1="General"
                       />
        <!-- <lsccip:setting id="DEVICE"
                        type="param"
                        value_type="string"
                        conn_mod="lscc_io_module"
                        title="Device"
                        value_expr="runtime_info.device_info.device(1)"
                        editable="False"
                        hidden="True"
                        group1="General"
                       />        -->
        <lsccip:setting id="INTR_MACRO"
                        type="verilog_macro"
                        macro_name="value"
                        conn_mod="lscc_io_module"
                        value_type="string"
                        title="Interface"
                        options="['AHBL', 'AXI4L']"
                        group1="Interface Setting"
                       />
        <lsccip:setting id="INTR"
                        type="param"
                        value_type="string"
                        conn_mod="lscc_io_module"
                        options="['AHBL' if INTR_MACRO=='AHBL' else 'AXI4L']"
                        hidden="True"
                       />
        <lsccip:setting id="GPI_EN"
                        type="param"
                        value_type="bool"
                        conn_mod="lscc_io_module"
                        title="GPI Enable"
                        default="False"
                        group1="General Pin Settings"
                       />
        <lsccip:setting id="GPI_NUM"
                        type="param"
                        value_type="int"
                        conn_mod="lscc_io_module"
                        title="Number of GPI Bits:"
                        default="1"
                        editable="GPI_EN"
                        value_range="1, 128"
                        group1="General Pin Settings"
                       />
        <lsccip:setting id="GPO_EN"
                        type="param"
                        value_type="bool"
                        conn_mod="lscc_io_module"
                        title="GPO Enable"
                        default="False"
                        group1="General Pin Settings"
                       />
        <lsccip:setting id="GPO_NUM"
                        type="param"
                        value_type="int"
                        conn_mod="lscc_io_module"
                        title="Number of GPO Bits:"
                        default="1"
                        editable="GPO_EN"
                        value_range="1, 128"
                        group1="General Pin Settings"
                       />
        <lsccip:setting id="IO_BUS_SIZE"
                        type="param"
                        value_type="int"
                        conn_mod="lscc_io_module"
                        title="I/O Bus Map Size (KiB)"
                        options="get_tgt_mem_range(1) if (GPI_EN | GPO_EN) else get_tgt_mem_range(0)"
                        default="1"
                        group1="Address Map Setting"
                       />
        <lsccip:setting id="TOTAL_IP_ADDR"
                        type="param"
                        value_type="int"
                        conn_mod="lscc_io_module"
                        title="Total IP Map Size (KiB)"
                        value_expr="total_mem_size(IO_BUS_SIZE, (GPI_EN|GPO_EN))"
                        default = "1"
                        editable="False"
                        group1="Address Map Setting"
                       />
        <lsccip:setting id="ADDR_WIDTH"
                        type="param"
                        value_type="int"
                        conn_mod="lscc_io_module"
                        title="Address Width"
                        value_expr="ext_clog2(IO_BUS_SIZE)+10"
                        default = "10"
                        hidden= "True"
                        editable="False"
                        group1="Address Map Setting"
                       />
    </lsccip:settings>
    <lsccip:ports>
        <lsccip:port name="clk_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                    />
        <lsccip:port name="rst_n_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                    />

<!-- AHB-Lite Subordinate Interface -->
        <lsccip:port name="ahbl_hsel_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_haddr_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hsize_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(2,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hburst_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(2,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_htrans_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(1,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hwdata_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hwrite_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hready_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hmastlock_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     stick_low="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hprot_i"
                     dir="in"
                     range="(3,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     stick_low="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hrdata_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hready_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
        <lsccip:port name="ahbl_hresp_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AHBL_S0"
                     dangling="INTR!='AHBL'"
                    />
<!-- AXI4-Lite Subordinate Interface -->
        <lsccip:port name="axil_awready_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_awvalid_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_awaddr_i"
                     dir="in"
                     range="(31,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_awprot_i"
                     dir="in"
                     range="(2,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_wready_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_wvalid_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_wdata_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_wstrb_i"
                     dir="in"
                     range="(3,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_bready_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_bvalid_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_bresp_o"
                     dir="out"
                     range="(1,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_arready_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_arvalid_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_araddr_i"
                     dir="in"
                     range="(31,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_arprot_i"
                     dir="in"
                     range="(2,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_rready_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_rvalid_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_rdata_o"
                     dir="out"
                     range="(31,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
        <lsccip:port name="axil_rresp_o"
                     dir="out"
                     range="(1,0)"
                     conn_mod="lscc_io_module"
                     bus_interface="AXI4L_S0"
                     dangling="INTR!='AXI4L'"
                    />
<!-- GPIO Ports -->
        <lsccip:port name="gpi"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(GPI_NUM-1,0)"
                     dangling="True if(GPI_EN==False) else False"
                    />
        <lsccip:port name="gpo"
                     dir="out"
                     conn_mod="lscc_io_module"
                     range="(GPO_NUM-1,0)"
                     dangling="True if(GPO_EN==False) else False"
                    />
<!-- I/O Bus Ports -->

        <lsccip:port name="io_read_data_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                    />
        <lsccip:port name="io_ready_i"
                     dir="in"
                     conn_mod="lscc_io_module"
                    />
        <!-- <lsccip:port name="io_addr_stb_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                    /> -->
        <lsccip:port name="io_addr_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     range="(ADDR_WIDTH-1,0)"
                    />
        <lsccip:port name="io_byte_en_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     range="(3,0)"
                    />
        <lsccip:port name="io_read_stb_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                    />
        <lsccip:port name="io_write_data_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                     range="(31,0)"
                    />
        <lsccip:port name="io_write_stb_o"
                     dir="out"
                     conn_mod="lscc_io_module"
                    />
    </lsccip:ports>

  <lsccip:outFileConfigs>
        <lsccip:fileConfig name="wrapper" file_suffix="sv" file_description="top_level_system_verilog"></lsccip:fileConfig>
    </lsccip:outFileConfigs>

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