evalsoc.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. .. _design_soc_evalsoc:
  2. Nuclei Eval SoC
  3. ===============
  4. .. note::
  5. Nuclei CPU IP now with iregion feature will use totally new evaluation SoC,
  6. this SoC is different from previous Demo SoC, please take care.
  7. Nuclei DemoSoC is now removed in 0.5.0 release, and please use evalsoc now.
  8. Nuclei Eval SoC is an evaluation FPGA SoC from Nuclei
  9. for customer to evaluate Nuclei RISC-V Process Core, and it is a successor for Demo SoC.
  10. .. _design_soc_evalsoc_overview:
  11. Overview
  12. --------
  13. To easy user to evaluate Nuclei Processor Core, the prototype
  14. SoC (called Nuclei Eval SoC) is provided for evaluation purpose.
  15. This prototype SoC includes:
  16. * Processor Core, it can be Nuclei N class, NX class or UX class Processor Core.
  17. * On-Chip SRAMs for instruction and data.
  18. * The SoC buses.
  19. * The basic peripherals, such as UART, SPI etc.
  20. With this prototype SoC, user can run simulations, map it into the FPGA board,
  21. and run with real embedded application examples.
  22. If you want to learn more about this evaluation SoC, please get the
  23. ``<Nuclei_Eval_SoC_Intro.pdf>`` from `Nuclei`_.
  24. .. _design_soc_evalsoc_boards:
  25. Supported Boards
  26. ----------------
  27. In Nuclei SDK, we support the following boards based on **Nuclei Evaluation SoC**, see:
  28. * :ref:`design_board_nuclei_fpga_eval`, default Board when this SoC selected.
  29. .. _design_soc_evalsoc_usage:
  30. Usage
  31. -----
  32. .. note::
  33. To ensure compatibility when using Nuclei EvalSoC(FPGA), please verify with our Application Engineer (AE) the specific CPU configuration to confirm if the EvalSoC's CPU possesses the features you intend to test.
  34. You can utilize the :ref:`design_app_cpuinfo` application to determine the available CPU features on your system and cross-reference this information with the Nuclei ISA specifications.
  35. .. note::
  36. In latest CPU RTL generation flow, it will also generate an Nuclei SDK to match CPU
  37. and EvalSoC RTL configuration, please use the generated Nuclei SDK to evaluate your
  38. CPU and EvalSoC feature.
  39. The generated Nuclei SDK by **nuclei_gen** will do the following tasks:
  40. - Generate ``SoC/evalsoc/cpufeature.mk``: which will define **CORE**, **ARCH_EXT**, **QEMU_SOCCFG** or **SIMULATION** default value.
  41. - Generate ``SoC/evalsoc/Common/Include/cpufeature.h``: which will define current cpu feature macros.
  42. - Generate ``SoC/evalsoc/evalsoc.json``: which will define current qemu soc configuration according to the evalsoc and cpu configuration.
  43. - Generate ``SoC/evalsoc/Board/nuclei_fpga_eval/Source/GCC/evalsoc.memory``: which will define the ilm/dlm/flash/ddr/sram base address and size.
  44. - Modify ``SoC/evalsoc/Board/nuclei_fpga_eval/openocd_evalsoc.cfg``: Mainly change ``workmem_base/workmem_size/flashxip_base/xipnuspi_base`` to adapt the evalsoc configuration.
  45. If you want to use the generated Nuclei SDK by **nuclei_gen** In Nuclei Studio IDE, you need to zip it first,
  46. and then **import** it using ``RV-Tools -> NPK Package Management`` in Nuclei Studio IDE's menu, and when
  47. creating a IDE project using ``New Nuclei RISC-V C/C++ Project``, please select the correct sdk and version which
  48. you can check it in the ``<SDK>/npk.yml`` file, and in the project example configuration wizard window, you should
  49. configure the **Nuclei RISC-V Core** and **ARCH Extensions**, **Nuclei Cache Extensions**
  50. according to your configured CPU ISA, and CPU feature defined in generated ``cpufeature.h``.
  51. **WARNING**: Currently you still need to modify IAR linker script(``*.icf``) by yourself, it is not automatically modified.
  52. If you want to use this **Nuclei Evaluation SoC** in Nuclei SDK, you need to set the
  53. :ref:`develop_buildsystem_var_soc` Makefile variable to ``evalsoc``.
  54. .. note::
  55. IAR support is done by prebuilt IAR projects not through Makefile based build system, please check https://github.com/Nuclei-Software/nuclei-sdk/blob/master/ideprojects/iar/README.md for detailed usage.
  56. Extra make variables supported only in this SoC and used internally only by Nuclei, not designed for widely used:
  57. * **RUNMODE**: it is used internally by Nuclei, used to control ILM/DLM/ICache/DCache enable or disable
  58. via make variable, please check ``SoC/evalsoc/runmode.mk`` for details. It is not functional by default,
  59. unless you set a non-empty variable to this ``RUNMODE`` variable, it can be used with different **ILM_EN/DLM_EN/IC_EN/DC_EN/CCM_EN**.
  60. * **L2_EN**: it is used internally by Nuclei, used to control L2 cache enable or disable, introduced in 0.6.0 release.
  61. * **LDSPEC_EN**: it is used internally by Nuclei, used to control load speculative enable or disable, introduced in 0.6.0 release.
  62. * **BPU_EN**: it is used internally by Nuclei, used to control branch prediction unit enable or disable, introduced in 0.6.0 release.
  63. * **ECC_EN**: it is used internally by Nuclei, used to control (ilm/dlm/L1 I/Dcache)ecc unit enable or disable, introduced in 0.7.0 release.
  64. * **XLCFG_xxx** make variables such as **XLCFG_CIDU**, **XLCFG_CCM**, **XLCFG_TEE** and **XLCFG_SMPU** which are used to overwrite default macros defined in ``cpufeature.h`` which will affect **XXX_PRESENT** macros in ``evalsoc.h``, introduced in 0.7.0 release.
  65. * **CODESIZE**: it is used to control whether remove all template routine code for interrupt and exception and banner print code to measure basic code size requirement for evalsoc when ``CODESIZE=1``
  66. * **SYSCLK**: it is used together with ``CODESIZE=1`` to overwrite default ``SYSTEM_CLOCK`` macro value for different bitstream, eg. ``SYSCLK=50000000 CODESIZE=1``, it will set default SYSTEM_CLOCK to 50000000.
  67. * **QEMU_MC_EXTOPT** is used to pass extra options to Nuclei Qemu ``-M`` machine options for evalsoc,
  68. please dont pass any extra ``,`` to this make variable, you can pass such as ``QEMU_MC_EXTOPT=debug=1`` but not pass ``QEMU_MC_EXTOPT=,debug=1``
  69. * **QEMU_CPU_EXTOPT** is used to pass extra options to Nuclei Qemu ``-cpu`` cpu options for evalsoc,
  70. please dont pass any extra ``,`` to this make variable, you can pass such as ``QEMU_CPU_EXTOPT=vlen=512`` but
  71. not pass ``QEMU_CPU_EXTOPT=,vlen=512``
  72. * **XLCFG_ECLIC**: it is used to control ECLIC configuration, when ``XLCFG_ECLIC=0`` it will undefine ``CFG_HAS_CLIC``, when ``XLCFG_ECLIC=1`` it will define ``CFG_HAS_CLIC``, and when ``XLCFG_ECLIC=2`` it will define both ``CFG_HAS_ECLICV2`` and ``CFG_HAS_CLIC`` for ECLICv2 support, introduced in 0.9.0 release.
  73. * **ECLIC_HWCTX**: it is used to enable ECLIC hardware context auto-save feature, when ``ECLIC_HWCTX=1`` it will define ``ECLIC_HW_CTX_AUTO`` macro, introduced in 0.9.0 release.
  74. .. code-block:: shell
  75. # Choose SoC to be evalsoc
  76. # the following command will build application
  77. # using default evalsoc SoC based board
  78. # defined in Build System and application Makefile
  79. make SOC=evalsoc info # you can check current working SDK configuration information
  80. make SOC=evalsoc clean
  81. make SOC=evalsoc all
  82. .. _design_soc_evalsoc_eclicv2:
  83. ECLICv2 Support
  84. ---------------
  85. Starting from version 0.9.0, Nuclei EvalSoC provides support for ECLICv2 with hardware context auto-save feature.
  86. **Features:**
  87. * Hardware context auto-save/restore for non-vector interrupt and exception handlers
  88. * Automatic task stack pointer switching
  89. * Support for both M-mode and S-mode operation
  90. * Conditional compilation for backward compatibility
  91. **Configuration:**
  92. To enable ECLICv2 support with hardware context auto-save:
  93. * **MUST**: Nuclei RISC-V CPU must have ECLICv2 feature configured
  94. * Set ``XLCFG_ECLIC=2`` to enable ECLICv2 configuration or ``cpufeature.h`` contains ``CFG_HAS_ECLICV2`` macro
  95. * Set ``ECLIC_HWCTX=1`` to enable hardware context auto-save feature
  96. * When both options are enabled, the hardware will automatically save/restore context and handle stack pointer switching
  97. **Example:**
  98. .. code-block:: shell
  99. # Enable ECLICv2 with hardware context auto-save
  100. # eg. you are running on Nuclei N300 RISC-V CPU with ECLICv2 feature present
  101. # Test baremetal eclic v2 auto-save/restore feature, trap sp auto switch not enabled
  102. cd application/baremetal/demo_eclic
  103. # Test freertos eclic v2 auto-save/restore feature, trap sp auto switch enabled, since interrupt/exception need seperated stack besides task stack
  104. # cd application/freertos/demo
  105. make SOC=evalsoc CORE=n300 XLCFG_ECLIC=2 ECLIC_HWCTX=1 clean
  106. make SOC=evalsoc CORE=n300 XLCFG_ECLIC=2 ECLIC_HWCTX=1 all
  107. .. _design_soc_evalsoc_ecc:
  108. ECC Error Injection
  109. -------------------
  110. The ECC (Error Checking and Correction) mechanism supports:
  111. - Detection and correction of **single-bit errors**,
  112. - Raising an exception upon detection of a **double-bit error**,
  113. - **No guarantee** of correct behavior when **three or more bits** are corrupted.
  114. To verify ECC functionality, ECC error injection is used to simulate memory errors.
  115. This technique bypasses the hardware-generated ECC code and instead writes a deliberately
  116. corrupted ECC code into memory.
  117. Depending on the hardware implementation, **only one** of the following two injection methods is
  118. supported. This choice is **fixed in hardware** and **not configurable by software**.
  119. Therefore, before performing ECC error injection tests, you must determine which method your target
  120. hardware supports.
  121. **Supported Injection Modes:**
  122. 1. **Direct Write Mode (Legacy)**
  123. Manually compute the full ECC code, including intentional errors, and write the complete data+ECC word directly to memory.
  124. 2. **XOR Mode (New)**
  125. Provide an **ECC mask** instead of a full ECC code. The hardware automatically XORs this mask with the correct (golden) ECC code to flip the specified bits, thereby injecting errors.
  126. **Configuration:**
  127. To run applications with appropriate injection mode:
  128. - Use **Direct Write Mode** if: ``XLCFG_ECC=1`` is set, **or** ``cpufeature.h`` defines ``CFG_HAS_ECC`` but **does not define** ``CFG_ECC_CODE_XOR``.
  129. - Use **XOR Mode** if: ``XLCFG_ECC=2`` is set, **or** ``cpufeature.h`` defines both ``CFG_HAS_ECC`` and ``CFG_ECC_CODE_XOR``.
  130. **Example:**
  131. For more information, refer to the :ref:`design_app_demo_ecc` application.
  132. .. code-block:: shell
  133. # change to application/baremetal/demo_ecc
  134. cd application/baremetal/demo_ecc
  135. # Example 1: Test ECC error injection on ILM/DLM using Direct Write Mode
  136. # (e.g., N300 core with legacy ECC support)
  137. make SOC=evalsoc BOARD=nuclei_fpga_eval CORE=n300 DOWNLOAD=ilm XLCFG_ECC=1 clean
  138. make SOC=evalsoc BOARD=nuclei_fpga_eval CORE=n300 DOWNLOAD=ilm XLCFG_ECC=1 all
  139. # Example 2: Test ECC error injection on cache using XOR Mode
  140. # (e.g., UX900 core with modern ECC support)
  141. make SOC=evalsoc BOARD=nuclei_fpga_eval CORE=ux900 DOWNLOAD=ddr CCM_EN=1 XLCFG_ECC=2 clean
  142. make SOC=evalsoc BOARD=nuclei_fpga_eval CORE=ux900 DOWNLOAD=ddr CCM_EN=1 XLCFG_ECC=2 all
  143. .. _Nuclei: https://nucleisys.com/