.. -----------------------------------------------------------------------------
   ..
   ..  Filename       : index.rst
   ..  Author         : Huang Leilei
   ..  Status         : draft
   ..  Created        : 2026-03-03
   ..  Description    : about simulation
   ..
.. -----------------------------------------------------------------------------

About Simulation
================

   Directory *simulation* contains **two** different kinds of simulation environments.

*  :rtl: simulation environments for RTL-level inputs
*  :netlist: simulation environments netlist-level inputs

RTL-Level Simulation ENV
------------------------

   TO BE ADDED


Netlist-Level Simulation ENV
----------------------------

   TO BE ADDED


Existing Environments
---------------------

   Information on several existing environments is listed below.

rtl_calc_add_knl
````````````````

*  Function

   #. elaborate RTL design *calc_add_knl*
   #. check RTL design *calc_add_knl*
   #. simulate RTL design *calc_add_knl*
   #. collect coverage of RTL design *calc_add_knl*
   #. do simulation regression on RTL design *calc_add_knl*
   #. do coverage regression on RTL design *calc_add_knl*

*  Dependency

   .. table::
      :align: left
      :widths: auto

      =========== ============
       item        my version
      =========== ============
       make        3.82
       ncverilog   15.20-s083
       verdi       2019.06-SP2
       simvision   2019.06-SP2
       imc         21.09-s005
      =========== ============

*  Content

   .. table::
      :align: left
      :widths: auto

      ===================================== =========================================== ============
       item                                  description                                 postscript
      ===================================== =========================================== ============
       script/makefile.mk                    mother makefile
       script/uniqFileList.pl                script to *uniq* file lists
       script/regression.sh                  regression script
       rtl_calc_add_knl/makefile             daughter makefile
       rtl_calc_add_knl/sim_calc_add_knl.f   simulation files lists
       rtl_calc_add_knl/sim_calc_add_knl.v   mother testbench
       rtl_calc_add_knl/sub_bench            directory for daughter testbench
       rtl_calc_add_knl/check_data           directory for test vectors
       rtl_calc_add_knl/simul_data           directory for simulation or coverage data   generated by command *make sim* or *make cov*
       rtl_calc_add_knl/simul_data_regr      directory for regression data               generated by command *make sim_regr* or *make cov_regr*
      ===================================== =========================================== ============

*  Usage

      |  In WSL environment, change directory to *simulation/rtl/rtl_calc_add_knl*,
      |  then you can

   #. view help with

      ::

         make

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make.png
         :width: 870

   #. view elaboration results with

      ::

         make com_view

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_com_view_1.png
         :width: 710

      \

      .. image:: make_com_view_2.png
         :width: 710

   #. simulate and dump waveform with

      ::

         make sim SIM_KNOB_WAVEFORM=1

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_sim.png
         :width: 705

   #. view simulation results (waveform) with

      ::

         make sim_view

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_sim_view.png
         :width: 800

      if gtkwave cannot be opened due to DISPLAY related issues, it may be solved by updating WSL:
      open PowerShell and enter:

      ::

         wsl --update

   #. do simulation regression with

      ::

         make sim_regr T_V_CSTR_DIR="../../../reference_model/xkcalc/dump_calc_add_knl"

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_sim_regr_1.png
         :width: 1080

      \

      .. image:: make_sim_regr_2.png
         :width: 1080

      Since 2 correct cases and 2 wrong cases are "regressioned", run/skip/error/all number 4/0/2/4 is reported.

   #. view simulation regression results with

      ::

         make sim_regr_view

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_sim_regr_view.png
         :width: 910

      You can run correct cases with:

      ::

         make sim_regr T_V_CSTR_DIR="../../../reference_model/xkcalc/dump_calc_add_knl" T_V_CSTR_PATTERN="*correct"

      then you will get

      .. image:: make_sim_regr_3.png
         :width: 1080

   #. view configuration value with

      ::

         make cfg_view

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_cfg_view.png
         :width: 720

   #. clean files with

      ::

         make clean

      or

      ::

         make clean_all

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_clean.png
         :width: 650

      |  On Linux server (with related EDA tools), change directory to *simulation/rtl/rtl_calc_add_knl*,
      |  then you can
      |  (**Relevant environment needed; not required for this course.**)

   1. view check results with

      ::

         make chk_view EDA_CSTR_TOOL=syn

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_chk_view.png
         :width: 990


   #. collect coverage with

      ::

         make cov EDA_CSTR_TOOL=cds

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_cov.png
         :width: 980

   #. view coverage results with

      ::

         make cov_view EDA_CSTR_TOOL=cds

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_cov_view.png
         :width: 1725

      Since only one saturation mode (FLAG_SAT==1) is tested, the coverage grade is less than 100%.

   #. do coverage regression with

      ::

         make cov_regr EDA_CSTR_TOOL=cds

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_cov_regr.png
         :width: 1110

      Since only correct cases are "regressioned" thanks to *T_V_CSTR_PATTERN*, run/skip/error/all number 2/0/0/2 is reported.

   #. view coverage regression results with

      ::

         make cov_regr_view EDA_CSTR_TOOL=cds

      then you will get

      .. +++++++++++++++++++ uncommented to help the decision of width

      .. image:: make_cov_regr_view.png
         :width: 1720

      Since both saturation modes (FLAG_SAT==0 and FLAG_SAT==1) are tested, the coverage grade is 100%.


net_calc_add_knl
````````````````

   TO BE ADDED
