<?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>watchdog_timer</lsccip:name>
    <lsccip:display_name>Watchdog Timer</lsccip:display_name>
    <lsccip:version>1.6.1</lsccip:version>
    <lsccip:category>Processors_Controllers_and_Peripherals</lsccip:category>
    <lsccip:keywords>BusType_APB</lsccip:keywords>
    <lsccip:min_radiant_version>2.1</lsccip:min_radiant_version>
    <lsccip:min_esi_version>2.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              = "INTERFACE"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "string"
                    options         = "[('LMMI'), ('APB'), ('AHB-L'), ('None')]"
                    default         = "None"
                    title           = "Interface/Bus Selection"
                    group1          = "General"
    />
    -->
    <lsccip:setting id              = "APB_EN"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "bool"
                    default         = "False"
                    title           = "Enable APB"
                    group1          = "General"
    />
    
    <lsccip:setting id              = "WDT_MODE"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "string"
                    default         = "Cycle"
                    title           = "Mode"
                    options         = "[('Cycle'), ('Time')]"
                    group1          = "General"
    />
    <!--
    <lsccip:setting id              = "WDT2_EN"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "bool"
                    default         = "True"
                    hidden          = "True"
                    title           = "Enable Timer Stage 2"
                    group1          = "General"
    />
    -->
    <lsccip:setting id              = "UNIT"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    default         = "MHz"
                    value_type      = "string"
                    title           = "Frequency Unit"
                    options         = "[('kHz'), ('MHz')]"
                    hidden          = "WDT_MODE != 'Time'"
                    group1          = "General"
    />
    
    <lsccip:setting id              = "CLK_FREQ"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "int"
                    default         = "100"
                    value_range     = "(10, 999) if (UNIT == 'kHz') else (1, 150)" 
                    title           = "System Clock Frequency"
                    hidden          = "WDT_MODE != 'Time'"
                    group1          = "General"
    />
    
    <lsccip:setting id              = "CLK_FREQ_CALC"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "float"
                    value_expr      = "clk_freq_calc(CLK_FREQ, UNIT)" 
                    title           = "Input System Clock Frequency"
                    hidden          = "True"
                    group1          = "General"
    />
    
    <lsccip:setting id              = "NUM_CYCLE1"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "int"
                    default         = "5000"
                    value_range     = "(500, 75000000)" 
                    title           = "Timeout (number of cycles)"
                    value_expr      = "CALC_NUM_CYCLE1"
                    hidden          = "WDT_MODE != 'Cycle'"
                    group1          = "Timer Stage 1"
    />
    
    <lsccip:setting id              = "TIMEVAL1"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "int"
                    default         = "50"
                    options         = "time_opt()"
                    title           = "Timeout (ms)"
                    hidden          = "WDT_MODE != 'Time'"
                    group1          = "Timer Stage 1"
    />
    
    <lsccip:setting id              = "NUM_CYCLE2"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "int"
                    default         = "5000"
                    value_range     = "(500, 75000000)" 
                    title           = "Timeout (number of cycles)"
                    value_expr      = "CALC_NUM_CYCLE2"
                    hidden          = "WDT_MODE != 'Cycle'"
                    group1          = "Timer Stage 2"
    />
    
    <lsccip:setting id              = "TIMEVAL2"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "int"
                    default         = "50"
                    options         = "time_opt()"
                    title           = "Timeout (ms)"
                    hidden          = "WDT_MODE != 'Time'"
                    group1          = "Timer Stage 2"
    />
    
    <lsccip:setting id              = "CALC_NUM_CYCLE1"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "float"
                    title           = "Timeout S1 (number of cycles)"
                    value_expr      = "(1000*(CLK_FREQ_CALC*TIMEVAL1))"
                    hidden          = "True"
                    group1          = "Calculated"
    />
    
    <lsccip:setting id              = "CALC_NUM_CYCLE2"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "float"
                    title           = "Timeout S2 (number of cycles)"
                    value_expr      = "(1000*(CLK_FREQ_CALC*TIMEVAL2))"
                    hidden          = "True"
                    group1          = "Calculated"
    />
    
    <lsccip:setting id              = "FAMILY"
                    conn_mod        = "lscc_watchdog"
                    type            = "param"
                    value_type      = "string"
                    title           = "Device Architecture"
                    value_expr      = "get_device_name(1)"
                    hidden          = "True"
    />
    
  </lsccip:settings>

  <lsccip:ports>
    <lsccip:port name          = "clk_i"  
                 dir           = "in"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "clk_i"                                                     
    />
    
    <lsccip:port name          = "resetn_i"  
                 dir           = "in"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "resetn_i"                                                     
    />
    
    <lsccip:port name          = "kick_i"  
                 dir           = "in"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "kick_i"    
                 stick_low     = "APB_EN != 0"                 
    />
    
    <lsccip:port name          = "reset_o" 
                 dir           = "out"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "reset_o"                            
    />
    
    <lsccip:port name          = "nmi_o" 
                 dir           = "out"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "nmi_o"          
                 dangling      = "APB_EN != 0"       
    />
    
    <lsccip:port name          = "timer1_count_o" 
                 range         = "(26,0)"
                 dir           = "out"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "timer1_count_o"     
                 dangling      = "APB_EN != 0"                   
    />
    
    <lsccip:port name          = "timer2_count_o" 
                 range         = "(26,0)"
                 dir           = "out"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "timer2_count_o"     
                 dangling      = "APB_EN != 0"                  
    />
    
    <lsccip:port name          = "int_o" 
                 dir           = "out"  
                 conn_mod      = "lscc_watchdog" 
                 conn_port     = "int_o"             
                 dangling      = "APB_EN != 1"   
				 bus_interface = "INTR"
    />
    <lsccip:port
                name           = "apb_psel_i"
                dir            = "in"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_psel_i"    
                stick_low      = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_penable_i"
                dir            = "in"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_penable_i"    
                stick_low      = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_paddr_i"
                dir            = "in"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_paddr_i"
                range          = "(7, 0)"    
                 stick_low     = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_pwdata_i"
                dir            = "in"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_pwdata_i"
                range          = "(31, 0)"    
                stick_low      = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_pwrite_i"
                dir            = "in"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_pwrite_i"    
                 stick_low     = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_prdata_o"
                dir            = "out"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_prdata_o"
                range          = "(31, 0)"    
                dangling       = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_pready_o"
                dir            = "out"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_pready_o"    
                dangling       = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />
    <lsccip:port
                name           = "apb_pslverr_o"
                dir            = "out"
                conn_mod       = "lscc_watchdog"
                conn_port      = "apb_pslverr_o"    
                dangling       = "APB_EN != 1"  
                bus_interface  = "APB_S0"
    />

  </lsccip:ports>

        <!--Uncomment below if you have the following files in your package-->
        <xi:include href="bus_interface.xml" parse="xml" />
        <xi:include href="memory_map.xml" parse="xml" />
</lsccip:ip>


