mbits-mirafra / axi4_avip

MIT License
22 stars 25 forks source link

Learn about files inside svunit/bin area #84

Open Gopalsuthar2308 opened 1 year ago

Gopalsuthar2308 commented 1 year ago

The idea here is to understand

muneebullashariff commented 1 year ago

When we runSVUnit for the first time, the below hidden files are created:

image
muneebullashariff commented 1 year ago

1. The contents of .svunit.f for NON-UVM runs: runSVUnit -s questa

+incdir+/hwetools/work_area/frontend/muneeb_new/test/test_section
+incdir+/hwetools/svunit/svunit_base/junit-xml
/hwetools/svunit/svunit_base/junit-xml/junit_xml.sv
+incdir+/hwetools/svunit/svunit_base
/hwetools/svunit/svunit_base/svunit_pkg.sv
/hwetools/work_area/frontend/muneeb_new/test/test_section/./uut_unit_test.sv
+incdir+/hwetools/work_area/frontend/muneeb_new/test/test_section/.
.__testsuite.sv
.testrunner.sv

2. The contents of .svunit.f for UVM runs: runSVUnit -s questa -uvm

+incdir+/hwetools/work_area/frontend/muneeb_new/test/test_design
+incdir+/hwetools/svunit/svunit_base/junit-xml
/hwetools/svunit/svunit_base/junit-xml/junit_xml.sv
+incdir+/hwetools/svunit/svunit_base
/hwetools/svunit/svunit_base/svunit_pkg.sv
/hwetools/svunit/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv
+incdir+/hwetools/svunit/svunit_base/uvm-mock
/hwetools/svunit/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv
/hwetools/work_area/frontend/muneeb_new/test/test_design/./uut_unit_test.sv
+incdir+/hwetools/work_area/frontend/muneeb_new/test/test_design/.
.__testsuite.sv
.testrunner.sv
image

3. The contents of .svunit.f for with SVMock : runSVUnit -s questa -uvm

+incdir+/hwetools/work_area/frontend/muneeb_new/test_svmock/bedrock
+incdir+/hwetools/svunit/svunit_base/junit-xml
/hwetools/svunit/svunit_base/junit-xml/junit_xml.sv
+incdir+/hwetools/svunit/svunit_base
/hwetools/svunit/svunit_base/svunit_pkg.sv
/hwetools/svunit/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv
+incdir+/hwetools/svunit/svunit_base/uvm-mock
/hwetools/svunit/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv
-f /hwetools/work_area/frontend/muneeb_new/test_svmock/bedrock/./svunit.f    (This line)
/hwetools/work_area/frontend/muneeb_new/test_svmock/bedrock/./bedrock_unit_test.sv
+incdir+/hwetools/work_area/frontend/muneeb_new/test_svmock/bedrock/.
.__testsuite.sv
.testrunner.sv

As shown, user-defined svunit.f will also be included in the hidden .svunit.f file contents:

image

Note: Only if the user-defined name is svunit.f then it'll be included. If the name is different it won't be included and we need to give the below command:

runSVUnit -s questa -uvm -f muneeb.f

muneebullashariff commented 1 year ago

Contents of .testrunner.sv


`ifdef RUN_SVUNIT_WITH_UVM
  import uvm_pkg::*;
`endif

module testrunner();
  import svunit_pkg::svunit_testrunner;
`ifdef RUN_SVUNIT_WITH_UVM
  import svunit_uvm_mock_pkg::svunit_uvm_test_inst;
  import svunit_uvm_mock_pkg::uvm_report_mock;
`endif

  string name = "testrunner";
  svunit_testrunner svunit_tr;

  //==================================
  // These are the test suites that we
  // want included in this testrunner
  //==================================
  __testsuite __ts();

  //===================================
  // Main
  //===================================
  initial
  begin

    `ifdef RUN_SVUNIT_WITH_UVM_REPORT_MOCK
      uvm_report_cb::add(null, uvm_report_mock::reports);
    `endif

    build();

    `ifdef RUN_SVUNIT_WITH_UVM
      svunit_uvm_test_inst("svunit_uvm_test");
    `endif

    run();
    $finish();
  end

  //===================================
  // Build
  //===================================
  function void build();
    svunit_tr = new(name);
    __ts.build();
    svunit_tr.add_testsuite(__ts.svunit_ts);
  endfunction

  //===================================
  // Run
  //===================================
  task run();
    __ts.run();
    svunit_tr.report();
  endtask

endmodule
muneebullashariff commented 1 year ago

Contents of .__testsuite.sv for single testcase

module __testsuite;
  import svunit_pkg::svunit_testsuite;

  string name = "__ts";
  svunit_testsuite svunit_ts;

  //===================================
  // These are the unit tests that we
  // want included in this testsuite
  //===================================
  test_unit_test test_ut();

  //===================================
  // Build
  //===================================
  function void build();
    test_ut.build();
    svunit_ts = new(name);
    svunit_ts.add_testcase(test_ut.svunit_ut);
  endfunction

  //===================================
  // Run
  //===================================
  task run();
    svunit_ts.run();
    test_ut.run();
    svunit_ts.report();
  endtask

endmodule
muneebullashariff commented 1 year ago

Contents of .__testsuite.sv for multiple testcases

module __testsuite;
  import svunit_pkg::svunit_testsuite;

  string name = "__ts";
  svunit_testsuite svunit_ts;

  //===================================
  // These are the unit tests that we
  // want included in this testsuite
  //===================================
  apb_coverage_agent_unit_test apb_coverage_agent_ut();
  apb_coverage_unit_test apb_coverage_ut();
  apb_if_unit_test apb_if_ut();
  apb_mon_unit_test apb_mon_ut();

  //===================================
  // Build
  //===================================
  function void build();
    apb_coverage_agent_ut.build();
    apb_coverage_ut.build();
    apb_if_ut.build();
    apb_mon_ut.build();
    svunit_ts = new(name);
    svunit_ts.add_testcase(apb_coverage_agent_ut.svunit_ut);
    svunit_ts.add_testcase(apb_coverage_ut.svunit_ut);
    svunit_ts.add_testcase(apb_if_ut.svunit_ut);
    svunit_ts.add_testcase(apb_mon_ut.svunit_ut);
  endfunction

  //===================================
  // Run
  //===================================
  task run();
    svunit_ts.run();
    apb_coverage_agent_ut.run();
    apb_coverage_ut.run();
    apb_if_ut.run();
    apb_mon_ut.run();
    svunit_ts.report();
  endtask

endmodule 
muneebullashariff commented 1 year ago
image image