

mainmenu_option next_comment
comment 'Processor            '
  choice 'Select processor (Changes file list - requires "make distclean")' \
    "LEON3	CONFIG_LEON3 \
     LEON4	CONFIG_LEON4" LEON3
  int 'Number of processors' CONFIG_PROC_NUM 1
  choice 'Force values from example configuration (see help)' \
    "Minimal-configuration	CONFIG_LEON_MIN \
     General-purpose-cfg	CONFIG_LEON_GP \
     High-Performance-cfg	CONFIG_LEON_HP \
     Custom-configuration	CONFIG_LEON_CUSTOM" Custom-configuration
  if [ "$CONFIG_LEON_MIN" = "y" ]; then
    define_int  CONFIG_IU_NWINDOWS 8
    define_bool CONFIG_IU_V8MULDIV n
    define_bool CONFIG_IU_BP n
    define_bool CONFIG_IU_SVT y
    define_int  CONFIG_IU_LDELAY 1
    define_int  CONFIG_IU_WATCHPOINTS 0
    define_bool CONFIG_PWD n
    define_hex  CONFIG_IU_RSTADDR 00000
    define_bool CONFIG_FPU_ENABLE n
    define_bool CONFIG_ICACHE_ENABLE y
    define_bool CONFIG_ICACHE_ASSO1 y
    define_bool CONFIG_ICACHE_SZ2 y
    define_bool CONFIG_ICACHE_LZ16 y
    define_bool CONFIG_ICACHE_ALGORND y
    define_bool CONFIG_ICACHE_LOCK n
    define_bool CONFIG_DCACHE_ENABLE y
    define_bool CONFIG_DCACHE_ASSO1 y
    define_bool CONFIG_DCACHE_SZ2 y
    define_bool CONFIG_DCACHE_LZ16 y
    define_bool CONFIG_DCACHE_ALGORND y
    define_bool CONFIG_DCACHE_LOCK n
    define_bool CONFIG_DCACHE_SNOOP n
    define_bool CONFIG_MMU_ENABLE n
    define_bool CONFIG_DSU_ENABLE n
    define_bool CONFIG_NP_ASI n
    define_bool CONFIG_PWRPSR n
  fi
  if [ "$CONFIG_LEON_GP" = "y" ]; then
    define_int  CONFIG_IU_NWINDOWS 8
    define_bool CONFIG_IU_V8MULDIV y
    define_bool CONFIG_IU_MUL_LATENCY_5 y
    define_bool CONFIG_IU_MUL_MAC n
    define_bool CONFIG_IU_BP y
    define_bool CONFIG_IU_SVT y
    define_int  CONFIG_IU_LDELAY 1
    define_int  CONFIG_IU_WATCHPOINTS 2
    define_bool CONFIG_PWD y
    define_hex  CONFIG_IU_RSTADDR 00000
    define_bool CONFIG_FPU_ENABLE n
    define_bool CONFIG_ICACHE_ENABLE y
    define_bool CONFIG_ICACHE_ASSO2 y
    define_bool CONFIG_ICACHE_SZ4 y
    define_bool CONFIG_ICACHE_LZ16 y
    define_bool CONFIG_ICACHE_ALGORND y
    define_bool CONFIG_ICACHE_LOCK n
    define_bool CONFIG_ICACHE_LRAM n
    define_bool CONFIG_DCACHE_ENABLE y
    define_bool CONFIG_DCACHE_ASSO2 y
    define_bool CONFIG_DCACHE_SZ4 y
    define_bool CONFIG_DCACHE_LZ16 y
    define_bool CONFIG_DCACHE_ALGORND y
    define_bool CONFIG_DCACHE_LOCK n
    define_bool CONFIG_DCACHE_SNOOP y
    define_bool CONFIG_DCACHE_SNOOP_SEPTAG y
    define_bool CONFIG_DCACHE_SNOOP_SP n
    define_bool CONFIG_DCACHE_LRAM n
    define_bool CONFIG_MMU_ENABLE y
    define_bool CONFIG_MMU_SPLIT y
    define_bool CONFIG_MMU_REPARRAY y
    define_bool CONFIG_MMU_I8 y
    define_bool CONFIG_MMU_D8 y
    define_bool CONFIG_MMU_FASTWB y
    define_bool CONFIG_MMU_PAGE_4K y
    define_bool CONFIG_DSU_ENABLE y
    define_bool CONFIG_DSU_ITRACE y
    define_bool CONFIG_DSU_ITRACESZ4 y
    define_bool CONFIG_DSU_ATRACESZ4 y
    define_bool CONFIG_NP_ASI y
    define_bool CONFIG_PWRPSR y
  fi
  if [ "$CONFIG_LEON_HP" = "y" ]; then
    define_int  CONFIG_IU_NWINDOWS 8
    define_bool CONFIG_IU_V8MULDIV y
    define_bool CONFIG_IU_MUL_LATENCY_2 y
    define_bool CONFIG_IU_MUL_MAC n
    define_bool CONFIG_IU_BP y
    define_bool CONFIG_IU_SVT y
    define_int  CONFIG_IU_LDELAY 1
    define_int  CONFIG_IU_WATCHPOINTS 4
    define_bool CONFIG_PWD y
    define_hex  CONFIG_IU_RSTADDR 00000
    define_bool CONFIG_FPU_ENABLE y
    define_bool CONFIG_FPU_GRFPU y
    define_bool CONFIG_FPU_GRFPU_INFMUL y
    define_bool CONFIG_ICACHE_ENABLE y
    define_bool CONFIG_ICACHE_ASSO2 y
    define_bool CONFIG_ICACHE_SZ4 y
    define_bool CONFIG_ICACHE_LZ16 y
    define_bool CONFIG_ICACHE_ALGOLRU y
    define_bool CONFIG_ICACHE_LOCK n
    define_bool CONFIG_ICACHE_LRAM n
    define_bool CONFIG_DCACHE_ENABLE y
    define_bool CONFIG_DCACHE_ASSO2 y
    define_bool CONFIG_DCACHE_SZ4 y
    define_bool CONFIG_DCACHE_LZ16 y
    define_bool CONFIG_DCACHE_ALGOLRU y
    define_bool CONFIG_DCACHE_LOCK n
    define_bool CONFIG_DCACHE_SNOOP y
    define_bool CONFIG_DCACHE_SNOOP_SEPTAG y
    define_bool CONFIG_DCACHE_SNOOP_SP n
    define_bool CONFIG_DCACHE_LRAM n
    define_bool CONFIG_MMU_ENABLE y
    define_bool CONFIG_MMU_SPLIT y
    define_bool CONFIG_MMU_REPARRAY y
    define_bool CONFIG_MMU_I16 y
    define_bool CONFIG_MMU_D16 y
    define_bool CONFIG_MMU_FASTWB y
    define_bool CONFIG_MMU_PAGE_4K y
    define_bool CONFIG_DSU_ENABLE y
    define_bool CONFIG_DSU_ITRACE y
    define_bool CONFIG_DSU_ITRACESZ4 y
    define_bool CONFIG_DSU_ATRACESZ4 y
    define_bool CONFIG_NP_ASI y
    define_bool CONFIG_PWRPSR y
  fi

  if [ "$CONFIG_LEON_CUSTOM" = "y" ]; then
    mainmenu_option next_comment
      comment 'Integer unit                                           '
      int 'SPARC register windows' CONFIG_IU_NWINDOWS 8
      bool 'SPARC V8 MUL/DIV instructions' CONFIG_IU_V8MULDIV
      if [ "$CONFIG_IU_V8MULDIV" = "y" ]; then
        choice 'Hardware multiplier latency' \
	  "2-cycles		CONFIG_IU_MUL_LATENCY_2 \
	  4-cycles		CONFIG_IU_MUL_LATENCY_4 \
	  5-cycles		CONFIG_IU_MUL_LATENCY_5" 5-cycles
        if [ "$CONFIG_IU_MUL_LATENCY_4" = "y" -o "$CONFIG_IU_MUL_LATENCY_5" = "y" ]; then
          bool 'SPARC V8e SMAC/UMAC instructions     ' CONFIG_IU_MUL_MAC
        fi
        choice 'Multipler structure        ' \
	  "Inferred		CONFIG_IU_MUL_INFERRED \
	  NTNU_Modgen		CONFIG_IU_MUL_MODGEN \
	  TechSpec		CONFIG_IU_MUL_TECHSPEC \
	  Designware		CONFIG_IU_MUL_DW" Inferred
      fi
      bool 'Single-vector trapping' CONFIG_IU_SVT
      int 'Load delay' CONFIG_IU_LDELAY 1
      int 'Hardware watchpoints' CONFIG_IU_WATCHPOINTS 0
      bool 'Enable power-down mode ' CONFIG_PWD
      hex ' Reset start address (addr[31:12]) ' CONFIG_IU_RSTADDR 00000
      bool 'SPARC V8E non-privileged ASI access' CONFIG_NP_ASI
      bool 'SPARC V8E partial Write %psr (WRPSR)' CONFIG_WRPSR
      if [ "$CONFIG_LEON3" = "y" ]; then
           bool 'SPARC V8E AWP and regfile partitioning ' CONFIG_ALTWIN
      fi
      bool 'Enable LEON-REX extension' CONFIG_REX
    endmenu
    mainmenu_option next_comment
    comment 'Floating-point unit'
      bool 'Enable FPU                             ' CONFIG_FPU_ENABLE
      if [ "$CONFIG_FPU_ENABLE" = "y" ]; then
        choice 'FPU core' \
	  "GRFPU		CONFIG_FPU_GRFPU \
	   GRFPU-LITE	CONFIG_FPU_GRFPULITE" GRFPU
        if [ "$CONFIG_FPU_GRFPU" = "y" ]; then
	  choice 'GRFPU multiplier' \
	   "Inferred              CONFIG_FPU_GRFPU_INFMUL \
	    DW                    CONFIG_FPU_GRFPU_DWMUL \
	    ModGen                CONFIG_FPU_GRFPU_MODGEN \
   	    TechSpec              CONFIG_FPU_GRFPU_TECHSPEC" Inferred
        fi
        bool 'Shared GRFPU                      ' CONFIG_FPU_GRFPU_SH
        if [ "$CONFIG_FPU_GRFPULITE" = "y" ]; then
	  choice 'GRFPU-LITE controller' \
	   "Simple                CONFIG_FPU_GRFPC0 \
	    Data-forwarding       CONFIG_FPU_GRFPC1 \
	    Non-blocking          CONFIG_FPU_GRFPC2" Simple 	
        fi
        bool 'Use VHDL netlist          ' CONFIG_FPU_NETLIST
      fi
    endmenu
  fi
  mainmenu_option next_comment
  comment 'Cache system'
    if [ "$CONFIG_LEON_CUSTOM" = "y" ]; then
      bool 'Enable instruction cache       ' CONFIG_ICACHE_ENABLE
      if [ "$CONFIG_ICACHE_ENABLE" = "y" ]; then
        choice 'Associativity (ways)            ' \
	  "1		CONFIG_ICACHE_ASSO1 \
	  2		CONFIG_ICACHE_ASSO2 \
	  3		CONFIG_ICACHE_ASSO3 \
	  4		CONFIG_ICACHE_ASSO4" 1
        choice 'Way size (kbytes/way)' \
	  "1		CONFIG_ICACHE_SZ1 \
	  2		CONFIG_ICACHE_SZ2 \
	  4		CONFIG_ICACHE_SZ4 \
	  8		CONFIG_ICACHE_SZ8 \
	  16		CONFIG_ICACHE_SZ16 \
	  32		CONFIG_ICACHE_SZ32 \
	  64		CONFIG_ICACHE_SZ64 \
	  128		CONFIG_ICACHE_SZ128 \
	  256		CONFIG_ICACHE_SZ256" 4
        choice 'Line size (bytes/line)' \
	  "16		CONFIG_ICACHE_LZ16 \
	  32		CONFIG_ICACHE_LZ32" 32
        if [ "$CONFIG_ICACHE_ASSO1" != "y" ]; then
          choice 'Replacement alorithm' \
	   "Random		CONFIG_ICACHE_ALGORND \
	   LRU/Dynamic		CONFIG_ICACHE_ALGOLRU" Random
         if [ "$CONFIG_LEON3" = "y" ]; then
           bool 'Cache locking      ' CONFIG_ICACHE_LOCK
         fi
        fi
      fi
     if [ "$CONFIG_LEON3" = "y" ]; then
      if [ "$CONFIG_MMU_ENABLE" != "y" ]; then
        bool 'Enable local instruction RAM            ' CONFIG_ICACHE_LRAM
      fi
      if [ "$CONFIG_ICACHE_LRAM" = "y" ]; then
         choice 'Local data RAM size (kbytes)' \
  	"1		CONFIG_ICACHE_LRAM_SZ1 \
	2		CONFIG_ICACHE_LRAM_SZ2 \
	4		CONFIG_ICACHE_LRAM_SZ4 \
	8		CONFIG_ICACHE_LRAM_SZ8 \
	16		CONFIG_ICACHE_LRAM_SZ16 \
	32		CONFIG_ICACHE_LRAM_SZ32 \
	64		CONFIG_ICACHE_LRAM_SZ64 \
	128		CONFIG_ICACHE_LRAM_SZ128 \
	256		CONFIG_ICACHE_LRAM_SZ256" 4
          hex ' Local instruction RAM start address (8 MSB) ' CONFIG_ICACHE_LRSTART 8e
      fi
     fi
      bool 'Enable data cache       ' CONFIG_DCACHE_ENABLE
      if [ "$CONFIG_DCACHE_ENABLE" = "y" ]; then
        choice 'Associativity (ways)' \
	  "1		CONFIG_DCACHE_ASSO1 \
	  2		CONFIG_DCACHE_ASSO2 \
	  3		CONFIG_DCACHE_ASSO3 \
	  4		CONFIG_DCACHE_ASSO4" 1
        choice 'Way size (kbytes/ways)' \
	  "1		CONFIG_DCACHE_SZ1 \
	  2		CONFIG_DCACHE_SZ2 \
	  4		CONFIG_DCACHE_SZ4 \
	  8		CONFIG_DCACHE_SZ8 \
	  16		CONFIG_DCACHE_SZ16 \
	  32		CONFIG_DCACHE_SZ32 \
	  64		CONFIG_DCACHE_SZ64 \
	  128		CONFIG_DCACHE_SZ128 \
	  256		CONFIG_DCACHE_SZ256" 4
        if [ "$CONFIG_DCACHE_ENABLE" = "y" ]; then
          choice 'Line size (bytes/line)' \
	    "16		CONFIG_DCACHE_LZ16 \
	    32		CONFIG_DCACHE_LZ32" 16
        fi
        if [ "$CONFIG_DCACHE_ASSO1" != "y" ]; then
          choice 'Replacement alorithm' \
	  "Random		CONFIG_DCACHE_ALGORND \
	  LRU/Dynamic		CONFIG_DCACHE_ALGOLRU" Random
          bool 'Cache locking      ' CONFIG_DCACHE_LOCK
        fi
        bool 'AHB snooping       ' CONFIG_DCACHE_SNOOP
        if [ "$CONFIG_DCACHE_SNOOP" = "y" ]; then
            bool 'Separate physical/snoop tags  ' CONFIG_DCACHE_SNOOP_SEPTAG
            if [ "$CONFIG_LEON3" = "y" ]; then
              if [ "$CONFIG_DCACHE_SNOOP_SEPTAG" = "y" ]; then
                bool 'Use SP RAM for separate tags  ' CONFIG_DCACHE_SNOOP_SP
              fi
            fi
        fi
      fi
    fi
    hex 'Fixed cacheability map  ' CONFIG_CACHE_FIXED 0
#    if [ "$CONFIG_LEON4" = "y" ]; then
        hex '64/128-bit AHB bus map (only affects LEON4)    ' CONFIG_BWMASK 0000
        choice 'Cache and AHB data width (only affects LEON4)' \
        	"64-bit		CONFIG_CACHE_64BIT \
                	128-bit		CONFIG_CACHE_128BIT" 64-bit 
#    fi
    if [ "$CONFIG_LEON3" = "y" ]; then
     if [ "$CONFIG_MMU_ENABLE" != "y" ]; then
       bool 'Enable local data RAM            ' CONFIG_DCACHE_LRAM
     fi
     if [ "$CONFIG_DCACHE_LRAM" = "y" ]; then
         choice 'Local data RAM size (kbytes)' \
 	"1		CONFIG_DCACHE_LRAM_SZ1 \
 	2		CONFIG_DCACHE_LRAM_SZ2 \
 	4		CONFIG_DCACHE_LRAM_SZ4 \
 	8		CONFIG_DCACHE_LRAM_SZ8 \
 	16		CONFIG_DCACHE_LRAM_SZ16 \
 	32		CONFIG_DCACHE_LRAM_SZ32 \
 	64		CONFIG_DCACHE_LRAM_SZ64 \
 	128		CONFIG_DCACHE_LRAM_SZ128 \
 	256		CONFIG_DCACHE_LRAM_SZ256" 4
         hex ' Local data RAM start address (8 MSB) ' CONFIG_DCACHE_LRSTART 8f
     fi
    fi
  endmenu

  if [ "$CONFIG_LEON_CUSTOM" = "y" ]; then
    mainmenu_option next_comment
    comment 'MMU'
    bool 'Enable MMU       ' CONFIG_MMU_ENABLE
    if [ "$CONFIG_MMU_ENABLE" = "y" ]; then
      choice 'MMU type              ' \
	  "combined	CONFIG_MMU_COMBINED \
	   split		CONFIG_MMU_SPLIT" combined
      choice 'TLB replacement sheme              ' \
	  "LRU      	CONFIG_MMU_REPARRAY \
	   Increment	CONFIG_MMU_REPINCREMENT" Increment 
         choice 'Instruction (or combined) TLB entries' \
	  "2		CONFIG_MMU_I2 \
	  4		CONFIG_MMU_I4 \
	  8		CONFIG_MMU_I8 \
	  16		CONFIG_MMU_I16 \
	  32		CONFIG_MMU_I32 \
	  64		CONFIG_MMU_I64" 8
      if [ "$CONFIG_MMU_SPLIT" = "y" ]; then
         choice 'Data TLB entries' \
	  "2		CONFIG_MMU_D2 \
	  4		CONFIG_MMU_D4 \
	  8		CONFIG_MMU_D8 \
	  16		CONFIG_MMU_D16 \
	  32		CONFIG_MMU_D32 \
	  64		CONFIG_MMU_D64" 8
	  bool 'Fast writebuffer       ' CONFIG_MMU_FASTWB
      fi
      choice 'MMU page size' \
	  "4K		CONFIG_MMU_PAGE_4K \
	  8K		CONFIG_MMU_PAGE_8K \
	  16K		CONFIG_MMU_PAGE_16K \
	  32K		CONFIG_MMU_PAGE_32K \
	  Programmable	CONFIG_MMU_PAGE_PROG" 4K
    fi
    endmenu
  fi
  mainmenu_option next_comment
    comment 'Debug Support Unit        '
    bool 'Enable LEON Debug support unit    ' CONFIG_DSU_ENABLE
    if [ "$CONFIG_DSU_ENABLE" = "y" ]; then
      bool 'Instruction trace buffer' CONFIG_DSU_ITRACE
      if [ "$CONFIG_DSU_ITRACE" = "y" ]; then
        choice 'Instruction trace buffer size (kbytes)' \
	"1		CONFIG_DSU_ITRACESZ1 \
	2		CONFIG_DSU_ITRACESZ2 \
	4		CONFIG_DSU_ITRACESZ4 \
	8		CONFIG_DSU_ITRACESZ8 \
	16		CONFIG_DSU_ITRACESZ16" 1
        bool 'Enable two-port instruction trace buffer' CONFIG_DSU_ITRACE_2P
      fi
      bool 'AHB trace buffer' CONFIG_DSU_ATRACE
      if [ "$CONFIG_DSU_ATRACE" = "y" ]; then
        choice 'AHB trace buffer size (kbytes)' \
	"1		CONFIG_DSU_ATRACESZ1 \
	2		CONFIG_DSU_ATRACESZ2 \
	4		CONFIG_DSU_ATRACESZ4 \
	8		CONFIG_DSU_ATRACESZ8 \
	16		CONFIG_DSU_ATRACESZ16" 1
        bool 'Enable AHB trace buffer filters ' CONFIG_DSU_AFILT
        bool 'Enable statistics outputs       ' CONFIG_DSU_ASTAT
        choice 'AHB watchpoints' \
	"Pipelined	CONFIG_DSU_AHBWP2 \
	Enabled		CONFIG_DSU_AHBWP1 \
	Disabled	CONFIG_DSU_AHBWP0 " Pipelined
      fi
    fi
    bool 'Enable LEON Statistics Module       ' CONFIG_STAT_ENABLE
    if [ "$CONFIG_STAT_ENABLE" = "y" ]; then
      int 'Number of counters (1 - 64)           ' CONFIG_STAT_CNT 4
      int 'Number of accumulative counters       ' CONFIG_STAT_NMAX 0
    fi
  endmenu

  mainmenu_option next_comment
  comment 'Fault-tolerance  '
      choice 'IU Register file protection     ' \
	"None		CONFIG_IUFT_NONE \
	Parity		CONFIG_IUFT_PAR \
	PDMR 		CONFIG_IUFT_DMR \
	BCH  		CONFIG_IUFT_BCH \
	BCH-OTF		CONFIG_IUFT_BCHOTF \
	TechSpec	CONFIG_IUFT_TECHSPEC \
	TMR		CONFIG_IUFT_TMR" None
      if [ "$CONFIG_FPU_ENABLE" = "y" ]; then
        choice 'FPU Register file protection     ' \
	  "None		CONFIG_FPUFT_NONE \
	   Parity		CONFIG_FPUFT_PAR \
 	   PDMR 		CONFIG_FPUFT_DMR \
	   TMR		CONFIG_FPUFT_TMR" None
      fi
      bool 'Register file error injection' CONFIG_RF_ERRINJ
      choice 'Cache memory protection     ' \
	  "None		CONFIG_CACHE_FT_NONE \
	   Parity		CONFIG_CACHE_FT_EN \
 	   SECDEC-BCH 		CONFIG_CACHE_FT_BCH \
	   TechSpec		CONFIG_CACHE_FT_TECH" None
      int 'Cache memory error injection' CONFIG_CACHE_ERRINJ 0
  endmenu

  mainmenu_option next_comment
    comment 'VHDL debug settings       '
    bool 'Processor disassembly to console         ' CONFIG_IU_DISAS
    if [ "$CONFIG_IU_DISAS" = "y" ]; then
      bool 'Processor disassembly in netlist         ' CONFIG_IU_DISAS_NET
    fi
    bool '32-bit program counters       ' CONFIG_DEBUG_PC32
  endmenu
fi
endmenu

