diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..cea4308de097ee382150e03ff5490cfce605a9a7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests/svunit"] + path = tests/svunit + url = https://github.com/svunit/svunit.git diff --git a/README.md b/README.md index 78b0b0905f672b53362d84911f42eccb6240bc76..8150894da3f96730ee86f626f27c8ef451af5f11 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,72 @@ -# fpga_groups_project +# fpga project - Arria10 SoC DevKit board version +### <ins>Useful information:</ins> +[Arria10 SoC DevKit board](https://www.intel.com/content/www/us/en/products/details/fpga/development-kits/arria/10-sx.html) -## Getting started -Choose the appropriate branch to clone project for selected board: -* de0-nano SoC -* arria10 SoC +[PeakRDL - control & status register (CSR) generator toolchain](https://peakrdl.readthedocs.io/en/latest/index.html) + +[SVUnit verification framework](https://docs.svunit.org/en/stable/) + +[IntelÂŽ ArriaÂŽ 10 Hard Processor System Technical Reference Manual](https://www.intel.com/content/www/us/en/docs/programmable/683711/21-2/hard-processor-system-technical-reference.html) + +[IntelÂŽ ArriaÂŽ 10 HPS Register Address Map and Definitions](https://www.intel.com/content/www/us/en/programmable/hps/arria-10/hps.html) + +[AMBA AXI and ACE Protocol Specification](https://developer.arm.com/documentation/ihi0022/e) + +### <ins>Update Submodules:</ins> +#### After changing branches, run the following command to update all submodules to the commit specified by the branch: + + git submodule update --init --recursive + +### <ins>Generate Verilog from rdl:</ins> +#### 1. Go to rdl directory: + + cd rdl + +#### 2. Generate Verilog from rdl file: -### Generate Verilog from rdl file (run from rdl folder): peakrdl regblock registers.rdl -o outputs/ --cpuif axi4-lite-flat -### Output files generation: -1. Open quartus from folder quartus: - `quartus soc_system.qpf` +### <ins>Simulate design</ins> +#### 1. Go to test directory: + + cd tests/modul_studenta_unit_test + +#### 2. Run test in gui mode: + + ./run_svunit_gui.sh + +#### 3. Run test in console mode: + + ./run_svunit.sh + +### <ins>FPGA bitstream files generation from command line:</ins> +#### 1. Go to quartus directory: + + cd quartus + +#### 2. Run quartus compilation: + + quartus_sh --flow compile soc_system -2. Run "Compile Design" +### <ins>FPGA bitstream files generation from Quartus GUI (alternative method):</ins> +#### 1. Go to quartus directory: -### .rbf file generation: -1. Go to quartus/output_files -2. run command: + cd quartus -* de0-nano: - - `quartus_cpf -o bitstream_compression=on -c soc_system.sof soc_system.rbf` +#### 2. Open quartus: -* arria10: + quartus soc_system.qpf & - `quartus_cpf --hps -o bitstream_compression=on -c soc_system.sof soc_system.rbf` +#### 2. Run "Compile Design" -### Updating image on SDMMC -#### De0 Nano Board: -1. Copy .wic image to sdmmc: use Win32DiskImage or any other available tool +### <ins>FPGA bitstream files generated by Quartus:</ins> -2. Copy soc_system.rbf to sdmmc + quartus/output_files/soc_system.sof + quartus/output_files/soc_system.core.rbf + quartus/output_files/soc_system.periph.rbf -#### Arria10 SoC DevKit Board: +### Updating image on SDMMC for Arria10 SoC DevKit Board: 1. Create `fit_spl_fpga.its` file with the following content: ``` @@ -71,8 +104,8 @@ Choose the appropriate branch to clone project for selected board: 2. Make image for U-boot: `mkimage -E -f fit_spl_fpga.its fit_spl_fpga.itb` -3. Copy .wic image to sdmmc: use Win32DiskImage or any other available tool +3. Copy [yocto](https://git.pg.edu.pl/ksti-projekty-grupowe-fpga/yocto) image (.wic) for Arria10 SoC DevKit board to SDMCC: use Win32DiskImage or any other available tool -4. Copy 3 files to sdmmc: `fit_spl_fpga.itb`, `soc_system.core.rbf` and `soc_system.periph.rbf` +4. Copy 3 files to SDMMC: `fit_spl_fpga.itb`, `soc_system.core.rbf` and `soc_system.periph.rbf` 5. Rename `a10soc-devkit.dtb` to `socfpga_arria10_socdk_sdmmc.dtb` diff --git a/axi_lite/axi4_lite_driver_slave.svh b/axi4_lite/axi4_lite_driver_slave.svh similarity index 100% rename from axi_lite/axi4_lite_driver_slave.svh rename to axi4_lite/axi4_lite_driver_slave.svh diff --git a/axi_lite/axi4_lite_if.sv b/axi4_lite/axi4_lite_if.sv similarity index 100% rename from axi_lite/axi4_lite_if.sv rename to axi4_lite/axi4_lite_if.sv diff --git a/axi_lite/axi4_lite_pkg.sv b/axi4_lite/axi4_lite_pkg.sv similarity index 100% rename from axi_lite/axi4_lite_pkg.sv rename to axi4_lite/axi4_lite_pkg.sv diff --git a/axi_lite/modport.svh b/axi4_lite/modport.svh similarity index 100% rename from axi_lite/modport.svh rename to axi4_lite/modport.svh diff --git a/axi_lite/unit_test_pkg.sv b/axi4_lite/unit_test_pkg.sv similarity index 100% rename from axi_lite/unit_test_pkg.sv rename to axi4_lite/unit_test_pkg.sv diff --git a/rtl/modul_studenta.sv b/rtl/modul_studenta.sv index 1344299ad5b57af25ce09cfc46226059f6376228..07a1081436898de3ff0865f9184c79e8987ccd92 100644 --- a/rtl/modul_studenta.sv +++ b/rtl/modul_studenta.sv @@ -37,7 +37,7 @@ registers u_registers ( .s_axil_awready (s_axil_awready), .s_axil_awvalid (s_axil_awvalid), - .s_axil_awaddr (s_axil_awaddr[8:0]), + .s_axil_awaddr (s_axil_awaddr[REGISTERS_MIN_ADDR_WIDTH-1:0]), .s_axil_awprot (s_axil_awprot), .s_axil_wready (s_axil_wready), @@ -51,7 +51,7 @@ registers u_registers ( .s_axil_arready (s_axil_arready), .s_axil_arvalid (s_axil_arvalid), - .s_axil_araddr (s_axil_araddr[8:0]), + .s_axil_araddr (s_axil_araddr[REGISTERS_MIN_ADDR_WIDTH-1:0]), .s_axil_arprot (s_axil_arprot), .s_axil_rready (s_axil_rready), diff --git a/tests/modul_studenta_unit_test/modul_studenta_unit_test.do b/tests/modul_studenta_unit_test/modul_studenta_unit_test.do new file mode 100644 index 0000000000000000000000000000000000000000..b703bbeb2639d8311382385cc5f6de5c31b02dc7 --- /dev/null +++ b/tests/modul_studenta_unit_test/modul_studenta_unit_test.do @@ -0,0 +1,47 @@ +transcript on + +add wave -position insertpoint \ +sim:/testrunner/__ts/modul_studenta_ut/dut/rst \ +sim:/testrunner/__ts/modul_studenta_ut/dut/clk \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_awready \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_awvalid \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_awaddr \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_awprot \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_wready \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_wvalid \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_wdata \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_wstrb \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_bready \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_bvalid \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_bresp \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_arready \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_arvalid \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_araddr \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_arprot \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_rready \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_rvalid \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_rdata \ +sim:/testrunner/__ts/modul_studenta_ut/dut/s_axil_rresp \ +sim:/testrunner/__ts/modul_studenta_ut/dut/hwif_out + +view structure +view signals + +TreeUpdate [SetDefaultTree] +quietly wave cursor active 1 +configure wave -namecolwidth 150 +configure wave -valuecolwidth 80 +configure wave -justifyvalue left +configure wave -signalnamewidth 1 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update + +log -r /* \ No newline at end of file diff --git a/tests/modul_studenta_unit_test/modul_studenta_unit_test.sv b/tests/modul_studenta_unit_test/modul_studenta_unit_test.sv index a5dec880d1fed0d488e51e2dfc0fdd20cfe5382a..54222b5e642699e3491f432ac3ef13d2f38f614f 100644 --- a/tests/modul_studenta_unit_test/modul_studenta_unit_test.sv +++ b/tests/modul_studenta_unit_test/modul_studenta_unit_test.sv @@ -1,6 +1,6 @@ `timescale 1 ns / 1 ns -`include "../svunit_base/svunit_defines.svh" +`include "../svunit/svunit_base/svunit_defines.svh" module modul_studenta_unit_test; import svunit_pkg::svunit_testcase; @@ -167,7 +167,7 @@ module modul_studenta_unit_test; request.data[1] = 8'h00; request.data[2] = 8'h00; request.data[3] = 8'h00; - request.address = 21'h0000_0004; + request.address = 21'h4; request.byte_enable = 4'b0001; request.access = axi4_lite_pkg::DEFAULT_DATA_ACCESS; @@ -193,7 +193,7 @@ module modul_studenta_unit_test; request_t request; axi4_lite_pkg::response_t expected_response = RESPONSE_OKAY; - request.address = 21'h0000_0000; + request.address = 21'h0; request.access = axi4_lite_pkg::DEFAULT_DATA_ACCESS; fork @@ -204,10 +204,13 @@ module modul_studenta_unit_test; request_t captured; axi4_slave_drv.read_response(captured.data, captured.response); + $display("Captured ID = 0x%0x%0x%0x%0x", captured.data[3], captured.data[2], captured.data[1], captured.data[0]); `FAIL_UNLESS_EQUAL(expected_response, captured.response) `FAIL_UNLESS_EQUAL(captured.data, 32'hABCD_1234) end join + + repeat(100) axi4_slave_drv.aclk_posedge(); `SVTEST_END `SVUNIT_TESTS_END diff --git a/tests/modul_studenta_unit_test/modul_studenta_unit_test_runner.sv b/tests/modul_studenta_unit_test/modul_studenta_unit_test_runner.sv deleted file mode 100644 index 81b8a5c7fe8b12a01c15a6316c1aa0bd160f417d..0000000000000000000000000000000000000000 --- a/tests/modul_studenta_unit_test/modul_studenta_unit_test_runner.sv +++ /dev/null @@ -1,43 +0,0 @@ -module modul_studenta_unit_test_runner; - logic test_passed = 0; - - import svunit_pkg::svunit_testrunner; - import svunit_pkg::svunit_testsuite; - - svunit_testrunner svunit_tr; - svunit_testsuite svunit_ts; - - modul_studenta_unit_test ut(); - - initial begin - build(); - run(); - - unique case (svunit_tr.get_results()) - svunit_pkg::PASS: begin - test_passed = 1; - $finish; - end - svunit_pkg::FAIL: begin - test_passed = 0; - $fatal(1); - end - endcase - end - - function void build(); - svunit_tr = new ("testrunner"); - svunit_ts = new ("testsuite"); - - ut.build(); - svunit_ts.add_testcase(ut.svunit_ut); - svunit_tr.add_testsuite(svunit_ts); - endfunction - - task run(); - svunit_ts.run(); - ut.run(); - svunit_ts.report(); - svunit_tr.report(); - endtask -endmodule \ No newline at end of file diff --git a/tests/modul_studenta_unit_test/run.do b/tests/modul_studenta_unit_test/run.do deleted file mode 100755 index 1c622a6c71791a9f4c0555482fe8bb085290364f..0000000000000000000000000000000000000000 --- a/tests/modul_studenta_unit_test/run.do +++ /dev/null @@ -1,51 +0,0 @@ -transcript on - -vlib work -vmap work - -vlog -sv -work work {../../rdl/outputs/registers_pkg.sv} -vlog -sv -work work {../../rdl/outputs/registers.sv} - -vlog -sv -work work {../../axi_lite/axi4_lite_pkg.sv} -vlog -sv -work work {../../axi_lite/axi4_lite_if.sv} - -vlog -sv -work work {../../axi_lite/unit_test_pkg.sv} - -vlog -sv -work work {../../rtl/axi_ram/svunit_base/svunit_pkg.sv} - -vlog -sv -work work {./modul_studenta_unit_test.sv} - -vlog -sv -work work {./modul_studenta_unit_test_runner.sv} - -vlog -sv -work work {../../rtl/modul_studenta.sv} - -vsim -suppress 12003,8386,8440 -t 1ps -L altera_ver -L lpm_ver -L sgate_ver -L altera_mf_ver -L altera_lnsim_ver -L fiftyfivenm_ver -L work -sv_seed random -voptargs="+acc" modul_studenta_unit_test_runner - -add wave -position insertpoint \ -sim:/modul_studenta_unit_test_runner/ut/dut/clk \ -sim:/modul_studenta_unit_test_runner/ut/dut/rst \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_awready \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_awvalid \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_awaddr \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_awprot \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_wready \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_wvalid \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_wdata \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_wstrb \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_bready \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_bvalid \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_bresp \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_arready \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_arvalid \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_araddr \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_arprot \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_rready \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_rvalid \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_rdata \ -sim:/modul_studenta_unit_test_runner/ut/dut/s_axil_rresp \ -sim:/modul_studenta_unit_test_runner/ut/dut/hwif_out \ - - -view structure -view signals -run -all \ No newline at end of file diff --git a/tests/modul_studenta_unit_test/run_svunit.sh b/tests/modul_studenta_unit_test/run_svunit.sh new file mode 100755 index 0000000000000000000000000000000000000000..600108f2e0a97d7818efb9ad8eabc5ff39ca5b87 --- /dev/null +++ b/tests/modul_studenta_unit_test/run_svunit.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Get the directory of the script +SCRIPT_DIR=$(dirname "$(realpath "$0")") + +# Change to the script's directory +cd "$SCRIPT_DIR" +# Source the Setup.bsh script from the ../svunit/ directory +cd ../svunit/ && source Setup.bsh +# Change to the script's directory +cd "$SCRIPT_DIR" + +# To run all unit test templates within a given parent directory +# runSVUnit -s questa -o tmp_svunit -r "-suppress 12003,8386" -r "-voptargs=+acc" -r "-sv_seed random" "$@" + +# To run specific unit test template within a given parent directory +runSVUnit -s questa -o tmp_svunit -r "-suppress 12003,8386" -r "-voptargs=+acc" -r "-sv_seed random" -t modul_studenta_unit_test.sv -r "-do ../modul_studenta_unit_test.do" "$@" + +# Example of run in GUI +# ./run_svunit.sh -r -gui + +# Example of run and define set +# ./run_svunit.sh -d MY_DEFINE=1 \ No newline at end of file diff --git a/tests/modul_studenta_unit_test/run_svunit_gui.sh b/tests/modul_studenta_unit_test/run_svunit_gui.sh new file mode 100755 index 0000000000000000000000000000000000000000..c03ea7025928a6821464e86a6f8d23aaf4df150f --- /dev/null +++ b/tests/modul_studenta_unit_test/run_svunit_gui.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Run SVUnit in GUI +./run_svunit.sh -r -gui "$@" + +# Example of SVUnit run in GUI and define set +# ./run_svunit_gui.sh -d MY_DEFINE=1 \ No newline at end of file diff --git a/tests/modul_studenta_unit_test/svunit.f b/tests/modul_studenta_unit_test/svunit.f new file mode 100644 index 0000000000000000000000000000000000000000..f00904a1a5402a292d891feea1807376ab3f91f1 --- /dev/null +++ b/tests/modul_studenta_unit_test/svunit.f @@ -0,0 +1,6 @@ +../../../rdl/outputs/registers_pkg.sv +../../../rdl/outputs/registers.sv +../../../axi4_lite/axi4_lite_pkg.sv +../../../axi4_lite/axi4_lite_if.sv +../../../axi4_lite/unit_test_pkg.sv +../../../rtl/modul_studenta.sv diff --git a/tests/svunit b/tests/svunit new file mode 160000 index 0000000000000000000000000000000000000000..6a5023d36c725cdf2d3dc59e2a9a883d0f15bc04 --- /dev/null +++ b/tests/svunit @@ -0,0 +1 @@ +Subproject commit 6a5023d36c725cdf2d3dc59e2a9a883d0f15bc04 diff --git a/tests/svunit_base/svunit_base.sv b/tests/svunit_base/svunit_base.sv deleted file mode 100644 index 0baf491ba9d0be6847825b04b3d6b815ca6c2b76..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_base.sv +++ /dev/null @@ -1,87 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -/* - Class: svunit_base - Base svunit class -*/ -class svunit_base; - - /* - String: name - Name of class instance - */ - protected string name; - - /* - Variable: success - Contains Pass or Fail for success of the Test - */ - protected results_t success = PASS; - - /* - Interface - */ - extern function new(string name); - extern function string get_name(); - extern function results_t get_results(); - - extern virtual function void report(); - -endclass - - -/* - Constructor: name - Initializes the test - - Parameters: - name - instance name of the unit test -*/ -function svunit_base::new(string name); - this.name = name; -endfunction - - -/* - Function: get_name - Returns instance name of the unit test -*/ -function string svunit_base::get_name(); - return name; -endfunction - - -/* - Method: report - This task reports the result for the test -*/ -function void svunit_base::report(); - string str = (success)? "PASSED":"FAILED"; - `INFO($sformatf("%0s::%0s", name, str)); -endfunction - - -/* - Function: get_results - Returns success of the unit test case -*/ -function results_t svunit_base::get_results(); - return success; -endfunction - diff --git a/tests/svunit_base/svunit_defines.svh b/tests/svunit_base/svunit_defines.svh deleted file mode 100644 index e1331eedc3469251206d4332740947cfd671a4e9..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_defines.svh +++ /dev/null @@ -1,207 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -/* - Assertion Macros -*/ -`ifndef FAIL_IF -`define FAIL_IF(exp) \ - if (svunit_pkg::current_tc.fail(`"fail_if`", (exp), `"exp`", `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_IF_LOG -`define FAIL_IF_LOG(exp,msg) \ - if (svunit_pkg::current_tc.fail(`"fail_if`", (exp), `"exp`", `__FILE__, `__LINE__, msg)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_IF_EQUAL -`define FAIL_IF_EQUAL(a,b) \ - if (svunit_pkg::current_tc.fail(`"fail_if_equal`", ((a)===(b)), `"(a) === (b)`", `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_UNLESS -`define FAIL_UNLESS(exp) \ - if (svunit_pkg::current_tc.fail(`"fail_unless`", !(exp), `"exp`", `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_UNLESS_LOG -`define FAIL_UNLESS_LOG(exp,msg) \ - if (svunit_pkg::current_tc.fail(`"fail_unless`", !(exp), `"exp`", `__FILE__, `__LINE__, msg)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_UNLESS_EQUAL -`define FAIL_UNLESS_EQUAL(a,b) \ - if (svunit_pkg::current_tc.fail(`"fail_unless_equal`", ((a)!==(b)), `"(a) !== (b)`", `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end -`endif - -`ifndef FAIL_IF_STR_EQUAL -`define FAIL_IF_STR_EQUAL(a,b) \ - begin \ - string stra; \ - string strb; \ - stra = a; \ - strb = b; \ - if (svunit_pkg::current_tc.fail(`"fail_if_str_equal`", stra.compare(strb)==0, $sformatf(`"\"%s\" == \"%s\"`",stra,strb), `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end \ - end -`endif - -`ifndef FAIL_UNLESS_STR_EQUAL -`define FAIL_UNLESS_STR_EQUAL(a,b) \ - begin \ - string stra; \ - string strb; \ - stra = a; \ - strb = b; \ - if (svunit_pkg::current_tc.fail(`"fail_unless_str_equal`", stra.compare(strb)!=0, $sformatf(`"\"%s\" != \"%s\"`",stra,strb), `__FILE__, `__LINE__)) begin \ - if (svunit_pkg::current_tc.is_running()) svunit_pkg::current_tc.give_up(); \ - end \ - end -`endif - - -/* - Macro: `INFO - Displays info message to screen and in log file - - Parameters: - msg - string to display -*/ -`define INFO(msg) \ - $display("INFO: [%0t][%0s]: %s", $time, name, msg) - - -/* - Macro: `ERROR - Displays error message to screen and in log file - - Parameters: - msg - string to display -*/ -`define ERROR(msg) \ - $display("ERROR: [%0t][%0s]: %s", $time, name, msg) - - -/* - Macro: `LF - Displays a blank line in log file -*/ -`define LF $display(""); - - -/* - Macro: `SVUNIT_TESTS_BEGIN - START a block of unit tests -*/ -`define SVUNIT_TESTS_BEGIN \ - task automatic run(); \ - `INFO("RUNNING"); - -/* - Macro: `SVUNIT_TESTS_END - END a block of unit tests -*/ -`define SVUNIT_TESTS_END endtask - - -/* - Macro: `SVTEST - START an svunit test within an SVUNIT_TEST_BEGIN/END block - - REQUIRES ACCESS TO error_count -*/ -`define SVTEST(_NAME_) \ - begin : _NAME_ \ - string _testName = `"_NAME_`"; \ - integer local_error_count = svunit_ut.get_error_count(); \ - string fileName; \ - int lineNumber; \ -\ - `INFO($sformatf(`"%s::RUNNING`", _testName)); \ - svunit_pkg::current_tc = svunit_ut; \ - svunit_ut.start(); \ - setup(); \ - fork \ - begin \ - fork \ - begin - -/* - Macro: `SVTEST_END - END an svunit test within an SVUNIT_TEST_BEGIN/END block -*/ -`define SVTEST_END \ - end \ - begin \ - if (svunit_ut.get_error_count() == local_error_count) begin \ - svunit_ut.wait_for_error(); \ - end \ - end \ - `SVUNIT_FUSE \ - join_any \ - #0; \ - disable fork; \ - end \ - join \ - svunit_ut.stop(); \ - teardown(); \ - if (svunit_ut.get_error_count() == local_error_count) \ - `INFO($sformatf(`"%s::PASSED`", _testName)); \ - else \ - `INFO($sformatf(`"%s::FAILED`", _testName)); \ - svunit_ut.update_exit_status(); \ - end - -`define SVUNIT_FUSE \ -`ifdef SVUNIT_TIMEOUT \ -begin \ - bit svunit_timeout = 1; \ - #(`SVUNIT_TIMEOUT); \ - `FAIL_IF(svunit_timeout) \ -end \ -`endif - -/* - Macro: `SVUNIT_CLK_GEN(_clk_variable, _half_period) - Generate a clock that runs only while this unit test - is running. -*/ -`define SVUNIT_CLK_GEN(_clk_variable, _half_period) \ - initial begin \ - _clk_variable = 0; \ - wait(svunit_ut != null); \ - forever begin \ - if( svunit_ut.is_running() ) \ - #_half_period _clk_variable = !_clk_variable; \ - else \ - wait( svunit_ut.is_running() ); \ - end \ - end diff --git a/tests/svunit_base/svunit_filter.svh b/tests/svunit_base/svunit_filter.svh deleted file mode 100644 index caf90939785f69fbbf104307817d6227894ba9d8..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_filter.svh +++ /dev/null @@ -1,180 +0,0 @@ -//########################################################################### -// -// Copyright 2021-2022 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - - -/** - * The filter expression that controls which tests should run. - */ -class filter; - - /* local */ typedef class filter_for_single_pattern; - - /* local */ typedef filter_for_single_pattern array_of_filters[]; - /* local */ typedef string array_of_string[]; - - /* local */ typedef struct { - string positive; - string negative; - } filter_expression_parts; - - - local static const string error_msg = "Expected the filter to be of the type '<test_case>.<test>[:<test_case>.<test>]'"; - local static filter single_instance; - - local const filter_for_single_pattern positive_subfilters[]; - local const filter_for_single_pattern negative_subfilters[]; - - - static function filter get(); - if (single_instance == null) - single_instance = new(); - return single_instance; - endfunction - - - local function new(); - string raw_filter = get_filter_value_from_run_script(); - filter_expression_parts parts = get_filter_expression_parts(raw_filter); - positive_subfilters = get_subfilters(parts.positive); - if (parts.negative != "") - negative_subfilters = get_subfilters(parts.negative); - endfunction - - - local function string get_filter_value_from_run_script(); - string result; - if (!$value$plusargs("SVUNIT_FILTER=%s", result)) - $fatal(0, "Expected to receive a plusarg called 'SVUNIT_FILTER'"); - return result; - endfunction - - - local function filter_expression_parts get_filter_expression_parts(string raw_filter); - string parts[]; - - if (raw_filter[0] == "-") - raw_filter = { "*", raw_filter }; - - parts = string_utils::split_by_char("-", raw_filter); - if (parts.size() > 2) - $fatal(0, "Expected at most a single '-' character."); - - if (parts.size() == 1) - return '{ parts[0], "" }; - return '{ parts[0], parts[1] }; - endfunction - - - local function array_of_filters get_subfilters(string raw_filter); - filter_for_single_pattern result[$]; - string patterns[]; - - if (raw_filter == "*") begin - filter_for_single_pattern filter_that_always_matches = new("*.*"); - return '{ filter_that_always_matches }; - end - - patterns = string_utils::split_by_char(":", raw_filter); - foreach (patterns[i]) - result.push_back(get_subfilter_from_non_trivial_expr(patterns[i])); - return result; - endfunction - - - local function filter_for_single_pattern get_subfilter_from_non_trivial_expr(string pattern); - filter_for_single_pattern result; - result = new(pattern); - return result; - endfunction - - - function bit is_selected(svunit_testcase tc, string test_name); - foreach (negative_subfilters[i]) - if (negative_subfilters[i].is_selected(tc, test_name)) - return 0; - - foreach (positive_subfilters[i]) - if (positive_subfilters[i].is_selected(tc, test_name)) - return 1; - - return 0; - endfunction - - - class filter_for_single_pattern; - - local const string testcase; - local const string test; - - function new(string pattern); - int unsigned dot_idx = get_dot_idx(pattern); - - testcase = pattern.substr(0, dot_idx-1); - disallow_partial_wildcards("testcase", testcase); - - test = pattern.substr(dot_idx+1, pattern.len()-1); - disallow_partial_wildcards("test", test); - endfunction - - local function int unsigned get_dot_idx(string filter); - int unsigned first_dot_idx = get_first_dot_idx(filter); - ensure_no_more_dots(filter, first_dot_idx); - return first_dot_idx; - endfunction - - local function int unsigned get_first_dot_idx(string filter); - for (int i = 0; i < filter.len(); i++) - if (filter[i] == ".") - return i; - $fatal(0, error_msg); - endfunction - - local function void ensure_no_more_dots(string filter, int unsigned first_dot_idx); - for (int i = first_dot_idx+1; i < filter.len(); i++) - if (filter[i] == ".") - $fatal(0, error_msg); - endfunction - - local function void disallow_partial_wildcards(string field_name, string field_value); - if (field_value != "*") - if (str_contains_char(field_value, "*")) - $fatal(0, $sformatf("Partial wildcards in %s names aren't currently supported", field_name)); - endfunction - - local static function bit str_contains_char(string s, string c); - if (c.len() != 1) - $fatal(0, "Expected a single character"); - foreach (s[i]) - if (s[i] == c[0]) - return 1; - return 0; - endfunction - - virtual function bit is_selected(svunit_testcase tc, string test_name); - if (is_match(this.testcase, tc.get_name()) && is_match(this.test, test_name)) - return 1; - return 0; - endfunction - - local function bit is_match(string filter_val, string val); - return (filter_val == "*") || (filter_val == val); - endfunction - - endclass - -endclass diff --git a/tests/svunit_base/svunit_globals.svh b/tests/svunit_base/svunit_globals.svh deleted file mode 100644 index bcc24db95a397f16424b5f5f9ab00cf759c1c9c3..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_globals.svh +++ /dev/null @@ -1,20 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -// The current testcase that is being executed. -svunit_testcase current_tc; diff --git a/tests/svunit_base/svunit_pkg.sv b/tests/svunit_base/svunit_pkg.sv deleted file mode 100644 index 2c67e8b806c6af54c5a6d463b44215d83574907d..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_pkg.sv +++ /dev/null @@ -1,35 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`include "svunit_defines.svh" - -package svunit_pkg; - -`ifdef SVUNIT_VERSION - const string svunit_version = `SVUNIT_VERSION; -`else - const string svunit_version = "For SVUnit Version info, see: $SVUNIT_INSTALL/VERSION.txt"; -`endif - - `include "svunit_types.svh" - `include "svunit_base.sv" - `include "svunit_testcase.sv" - `include "svunit_testsuite.sv" - `include "svunit_testrunner.sv" - `include "svunit_globals.svh" -endpackage diff --git a/tests/svunit_base/svunit_testcase.sv b/tests/svunit_base/svunit_testcase.sv deleted file mode 100644 index e49b27faee33b0832f957aa8303fce7449bf3036..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_testcase.sv +++ /dev/null @@ -1,210 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -/* - Class: svunit_testcase - Base class for the unit test case -*/ -class svunit_testcase extends svunit_base; - - /* - uint: test_count - Counter for number of tests - */ - local int unsigned test_count = 0; - - - /* - uint: error_count - Counter for number of errors - */ - local int unsigned error_count = 0; - - - /* - Variable: running - 1 is somewhere between setup and teardown, 0 otherwise - */ - local bit running = 0; - - - /* - Interface - */ - extern function new(string name); - - extern task wait_for_error(); - extern function integer get_error_count(); - extern task give_up(); - - extern function bit fail(string c, bit b, string s, string f, int l, string d = ""); - - extern function void start(); - extern function void stop(); - extern function bit is_running(); - - extern function void update_exit_status(); - extern function void report(); - - extern virtual task setup(); - extern virtual task teardown(); - -endclass - - -/* - Constructor: new - Initializes the test case - - Parameters: - name - instance name of the test case - -*/ -function svunit_testcase::new(string name); - super.new(name); -endfunction - - -/* - Method: wait_for_error - Blocks until the error_count changes -*/ -task svunit_testcase::wait_for_error(); - @(error_count); -endtask - - -/* - Method: get_error_count - Returns the error count -*/ -function integer svunit_testcase::get_error_count(); - return error_count; -endfunction - - -/* - Method: give_up - Blocks indefinitely (Should only be called by `FAIL_IF) -*/ -task svunit_testcase::give_up(); - event never; - @(never); -endtask - - -/* - Method: fail - If expression fails, increments error count, displays a message - and returns the results - - Parameters: - c - calling function - b - evaluation of expression (0 - false, 1 - true) - s - string to pass to pass or fail task - f - file name of the failure - l - line number of the failure - d - user specified debug info - - return 1 if fail else 0 -*/ -function bit svunit_testcase::fail(string c, bit b, string s, string f, int l, string d = ""); - string _d; - if (b) begin - error_count++; - if (d != "") begin - $sformat(_d, "[ %s ] ", d); - end - `ERROR($sformatf("%s: %s %s(at %s line:%0d)",c,s,_d,f,l)); - return 1; - end - else begin - return 0; - end -endfunction - - -/* - Method: start - Changes the execution status of the test to running and increment the test count -*/ -function void svunit_testcase::start(); - running = 1; - test_count++; -endfunction - - -/* - Method: stop - Changes the execution status of the test to stopped -*/ -function void svunit_testcase::stop(); - running = 0; -endfunction - - -/* - Method: is_running - Returns the execution status of the test -*/ -function bit svunit_testcase::is_running(); - return running; -endfunction - - -/* - Methos: update_exit_status - Updates the results of this testcase -*/ -function void svunit_testcase::update_exit_status(); - if (error_count == 0) - success = PASS; - else - success = FAIL; -endfunction - - -/* - Method: report - This task reports the results for the unit tests -*/ -function void svunit_testcase::report(); - string success_str = (success)? "PASSED":"FAILED"; - - `INFO($sformatf("%0s (%0d of %0d tests passing)", - success_str, - test_count-error_count, - test_count)); -endfunction - - -/* - Method: setup - Only required if using VCS since pure virtual functions are not implemented -*/ -task svunit_testcase::setup(); -endtask - - -/* - Method: teardown - House cleaning after each test -*/ -task svunit_testcase::teardown(); -endtask - diff --git a/tests/svunit_base/svunit_testrunner.sv b/tests/svunit_base/svunit_testrunner.sv deleted file mode 100644 index ee59988919a92bb919470e4ab2567edd7535e787..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_testrunner.sv +++ /dev/null @@ -1,95 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -/* - Class: svunit_testrunner - Base class for the test runner -*/ -class svunit_testrunner extends svunit_base; - - /* - Array: list_of_svunits - Queue List of Test Suites to include in the Test Runner - */ - local svunit_testsuite list_of_suites[$]; - - - /* - Interface - */ - extern function new(string name); - extern function void add_testsuite(svunit_testsuite suite); - - extern function void report(); - -endclass - - -/* - Constructor: name - Initializes the test runner - - Parameters: - name - instance name of the unit test runner -*/ -function svunit_testrunner::new(string name); - super.new(name); -endfunction - - -/* - Method: add_testsuite - Adds single testsuite to list of suites - - Parameters: - suite - test suite to add to the list of test suites -*/ -function void svunit_testrunner::add_testsuite(svunit_testsuite suite); - `INFO($sformatf("Registering Test Suite %0s", suite.get_name())); - list_of_suites.push_back(suite); -endfunction - - -/* - Method: report - This task reports the results for the test suites -*/ -function void svunit_testrunner::report(); - int pass_cnt; - string success_str; - - begin - svunit_testsuite match[$] = list_of_suites.find() with (item.get_results() == PASS); - pass_cnt = match.size(); - end - - if (pass_cnt == list_of_suites.size()) begin - success_str = "PASSED"; - success = PASS; - end else begin - success_str = "FAILED"; - success = FAIL; - end - - `LF; - `INFO($sformatf("%0s (%0d of %0d suites passing) [%s]", - success_str, - pass_cnt, - list_of_suites.size(), - svunit_version)); -endfunction diff --git a/tests/svunit_base/svunit_testsuite.sv b/tests/svunit_base/svunit_testsuite.sv deleted file mode 100644 index d6f23a8f70b73a9a0b6eb56bf641d93b678c7fa7..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_testsuite.sv +++ /dev/null @@ -1,107 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -/* - Class: svunit_testsuite - Base class for the unit test suite -*/ -class svunit_testsuite extends svunit_base; - - /* - Array: list_of_testcases - Queue list of Unit Testcases to include for this Test Suite - */ - local svunit_testcase list_of_testcases[$]; - - - /* - Interface - */ - extern function new(string name); - extern function void add_testcase(svunit_testcase svunit); - extern task run(); - - extern function void report(); - -endclass - - -/* - Constructor: new - Initializes the test suite - - Parameters: - name - instance name of the unit test suite -*/ -function svunit_testsuite::new(string name); - super.new(name); -endfunction - - -/* - Method: add_testcase - Adds a testcase to list of tests - - Parameters: - svunit - unit test to add to the list of unit tests -*/ -function void svunit_testsuite::add_testcase(svunit_testcase svunit); - `INFO($sformatf("Registering Unit Test Case %s", svunit.get_name())); - list_of_testcases.push_back(svunit); -endfunction - - -/* - Method: run - Main Run Task of the Test Suite -*/ -task svunit_testsuite::run(); - `INFO("RUNNING"); -endtask - - -/* - Method: report - This task reports the results for the unit tests -*/ -function void svunit_testsuite::report(); - int pass_cnt; - string success_str; - - foreach(list_of_testcases[i]) - list_of_testcases[i].report(); - - begin - svunit_testcase match[$] = list_of_testcases.find() with (item.get_results() == PASS); - pass_cnt = match.size(); - end - - if (pass_cnt == list_of_testcases.size()) begin - success_str = "PASSED"; - success = PASS; - end else begin - success_str = "FAILED"; - success = FAIL; - end - - `LF; - `INFO($sformatf("%0s (%0d of %0d testcases passing)", - success_str, - pass_cnt, - list_of_testcases.size())); -endfunction diff --git a/tests/svunit_base/svunit_types.svh b/tests/svunit_base/svunit_types.svh deleted file mode 100644 index 35c12661805ffb46796bbba2da314c47147ecba3..0000000000000000000000000000000000000000 --- a/tests/svunit_base/svunit_types.svh +++ /dev/null @@ -1,35 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`ifndef SVUNIT_TYPES -`define SVUNIT_TYPES - - /* - Enum: results_t - enumerated type containing PASS/FAIL - */ - typedef enum {PASS=1, FAIL=0} results_t; - - - /* - Enum: boolean_t - enumerated type containing TRUE/FALSE - */ - typedef enum {TRUE=1, FALSE=0} boolean_t; - -`endif diff --git a/tests/svunit_base/util/clk_and_reset.svh b/tests/svunit_base/util/clk_and_reset.svh deleted file mode 100644 index 419d10b8c2e6fdaba7111495590baf97b76213a5..0000000000000000000000000000000000000000 --- a/tests/svunit_base/util/clk_and_reset.svh +++ /dev/null @@ -1,46 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`define CLK_RESET_FIXTURE(CLK_HPERIOD,RST_PERIOD) \ -parameter clkHPeriod = CLK_HPERIOD; \ -logic clk; \ -logic rst_n; \ -initial begin \ - clk = 1; \ - rst_n = 1; \ -end \ -task automatic step(int size = 1); \ - repeat (size) begin \ - int step_size = clkHPeriod - $time % (clkHPeriod); \ - #(step_size) clk <= ~clk; \ - #(clkHPeriod) clk <= ~clk; \ - end \ -endtask \ -task nextSamplePoint(); \ - if ($time%(clkHPeriod) == 0) #1; \ - else repeat (2) #0; \ -endtask \ -task reset(); \ - rst_n = 0; \ - step(RST_PERIOD); \ - rst_n = 1; \ - step(1); \ -endtask \ -task pause(); \ - #0; \ -endtask diff --git a/tests/svunit_base/uvm-mock/svunit_idle_uvm_domain.sv b/tests/svunit_base/uvm-mock/svunit_idle_uvm_domain.sv deleted file mode 100644 index 671d57a7b44ea53c0ba92a5e776a970648f87752..0000000000000000000000000000000000000000 --- a/tests/svunit_base/uvm-mock/svunit_idle_uvm_domain.sv +++ /dev/null @@ -1,115 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`ifndef __SVUNIT_UVM_DOMAIN_SV__ -`define __SVUNIT_UVM_DOMAIN_SV__ - -import uvm_pkg::*; - -typedef class svunit_idle_uvm_component; -typedef class svunit_idle_uvm_domain; - - -//---------------------------------------------------- -// global helper functions to activate and deactivate -// components -//---------------------------------------------------- -function void svunit_activate_uvm_component(uvm_component c); - c.set_domain(uvm_domain::get_uvm_domain(), 1); -endfunction - -function void svunit_deactivate_uvm_component(uvm_component c); - c.set_domain(svunit_idle_uvm_domain::get_svunit_domain(), 1); -endfunction - -//--------------------------------------------------- -// this is the idle domain that where components are -// assigned for deactivation -//--------------------------------------------------- - -class svunit_idle_uvm_domain extends uvm_domain; - //------------------------------------------- - // new svunit domain and scheduler instances - //------------------------------------------- - static local uvm_domain m_svunit_domain; - static local uvm_phase m_svunit_schedule; - - //-------------------------------------------- - // override the get_common_domain to register - // the svunit_domain - //-------------------------------------------- - static function uvm_domain get_common_domain(); - uvm_domain common; - uvm_domain domain; - - common = uvm_domain::get_common_domain(); - - domain = get_svunit_domain(); - common.add(domain, - .with_phase(common.find(uvm_run_phase::get()))); - - return common; - endfunction - - //---------------------------------------------- - // static function that returns a handle to the - // new svunit domain - //---------------------------------------------- - static function uvm_domain get_svunit_domain(); - if (m_svunit_domain == null) begin - svunit_idle_uvm_component master_idle_component; - - m_svunit_domain = new("svunit_domain"); - m_svunit_schedule = new("svunit_sched", UVM_PHASE_SCHEDULE); - add_uvm_phases(m_svunit_schedule); - m_svunit_domain.add(m_svunit_schedule); - - master_idle_component = svunit_idle_uvm_component::type_id::create("svunit_idle_uvm_component", null); - master_idle_component.set_domain(m_svunit_domain); - end - return m_svunit_domain; - endfunction - - function new(string name); - super.new(name); - endfunction -endclass - -const uvm_domain _idle_domain = svunit_idle_uvm_domain::get_svunit_domain(); - -//--------------------------------------------------------- -// the purpose of this component is to raise an objections -// at pre_reset so that other components registered to the -// same domain never proceed beyond that point -//--------------------------------------------------------- -class svunit_idle_uvm_component extends uvm_component; - `uvm_component_utils(svunit_idle_uvm_component) - - function new(string name = "", uvm_component parent = null); - super.new(name, parent); - endfunction - - function void phase_started(uvm_phase phase); - if (phase.get_name() == "pre_reset") begin - phase.raise_objection(null); - end - endfunction -endclass - - -`endif diff --git a/tests/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv b/tests/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv deleted file mode 100644 index e543a8d02678a635e8891f8db2eca14a479b911d..0000000000000000000000000000000000000000 --- a/tests/svunit_base/uvm-mock/svunit_uvm_mock_pkg.sv +++ /dev/null @@ -1,34 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`ifndef SVUNIT_UVM_MOCK_PKG -`define SVUNIT_UVM_MOCK_PKG - -package svunit_uvm_mock_pkg; - import uvm_pkg::*; - import svunit_pkg::*; - - `include "uvm_macros.svh" - - `include "svunit_idle_uvm_domain.sv" - `include "svunit_uvm_report_mock_types.svh" - `include "svunit_uvm_report_mock.sv" - `include "svunit_uvm_test.sv" -endpackage - -`endif diff --git a/tests/svunit_base/uvm-mock/svunit_uvm_report_mock.sv b/tests/svunit_base/uvm-mock/svunit_uvm_report_mock.sv deleted file mode 100644 index 8dcac756e5ab0a49b590f94fe6787b9d33fd5746..0000000000000000000000000000000000000000 --- a/tests/svunit_base/uvm-mock/svunit_uvm_report_mock.sv +++ /dev/null @@ -1,51 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -class uvm_report_mock; - static svunit_uvm_report_mock_expected_actual_container reports = new(); - - static function void setup(); - reports.delete(); - endfunction - - static function int expected_cnt(); - return reports.expected.size(); - endfunction - - static function int actual_cnt(); - return reports.actual.size(); - endfunction - - `define EXPECT_SEVERITY(NAME, SEV) \ - static function void expect_``NAME(string id="", \ - string message=""); \ - reports.expected.push_back('{id, message, SEV}); \ - endfunction - - `EXPECT_SEVERITY(warning, UVM_WARNING) - `EXPECT_SEVERITY(error, UVM_ERROR) - `EXPECT_SEVERITY(fatal, UVM_FATAL) - - static function bit verify_complete(); - return reports.verify_complete(); - endfunction - - static function string dump(); - return reports.dump(); - endfunction -endclass diff --git a/tests/svunit_base/uvm-mock/svunit_uvm_report_mock_types.svh b/tests/svunit_base/uvm-mock/svunit_uvm_report_mock_types.svh deleted file mode 100644 index 055196e9b51db768ccb01f797a27b63f54b91f32..0000000000000000000000000000000000000000 --- a/tests/svunit_base/uvm-mock/svunit_uvm_report_mock_types.svh +++ /dev/null @@ -1,129 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -class svunit_uvm_report_mock_expected_actual_container extends uvm_report_catcher; -`ifdef UVM_VERSION_1_2 - typedef uvm_severity uvm_severity_type; -`endif - - typedef struct { - string id; - string msg; - uvm_severity sev; - } catch_t; - - catch_t expected[$]; - catch_t actual[$]; - - function new(string name=""); - super.new(name); - endfunction - - function void delete(); - expected.delete(); - actual.delete(); - endfunction - - function action_e catch(); - uvm_severity_type sev_t = uvm_severity_type'(get_severity()); - - if (sev_t == UVM_INFO) return THROW; - - actual.push_back('{get_id(), get_message(), get_severity()}); - // prevent the message from being displayed - return CAUGHT; - endfunction - - local function bit match_at_idx(int i); - bit match = 0; - if (expected[i].id == "") match = 1; - else match = (expected[i].id == actual[i].id); - if (expected[i].msg == "") match &= 1; - else match &= (expected[i].msg == actual[i].msg); - match &= (expected[i].sev == actual[i].sev); - return match; - endfunction - - function bit verify_complete(); - if (expected.size() != actual.size()) begin - $display("%s", dump()); - return 0; - end - - foreach (expected[i]) begin - if (!match_at_idx(i)) begin - $display("%s", dump()); - return 0; - end - end - - return 1; - endfunction - - function string dump(); - string id; - string msg; - uvm_severity_type sev; - string s_sev; - int i_max = (expected.size() > actual.size()) ? expected.size() : actual.size(); - - dump = "uvm_report_mock::dump\n"; - for (int i=0; i<i_max; i+=1) begin - if (i <= expected.size()-1) begin - if (expected[i].id != "") $sformat(id, "\"%s\"", expected[i].id); - else id = "\"*\""; - id = truncate(id); - if (expected[i].msg != "") $sformat(msg, "\"%s\"", expected[i].msg); - else msg = "\"*\""; - sev = uvm_severity_type'(expected[i].sev); - $sformat(s_sev, "%s", sev.name()); - end - else none_reported(id, msg, s_sev); - - $sformat(dump, "%s%0d: EXPECTED => %14s %22s %s\n", dump, i, s_sev, id, msg); - - - if (i <= actual.size()-1) begin - $sformat(id, "\"%s\"", actual[i].id);; - id = truncate(id); - $sformat(msg, "\"%s\"", actual[i].msg);; - sev = uvm_severity_type'(actual[i].sev); - $sformat(s_sev, "%s", sev.name()); - end - else none_reported(id, msg, s_sev); - - $sformat(dump, "%s ACTUAL => %14s %22s %s\n", dump, s_sev, id, msg); - end - endfunction - - local function void none_reported(ref string id, - string msg, - string s_sev); - id = ""; - msg = ""; - s_sev = "None reported"; - endfunction - - local function string truncate(string s, int len = 22); - if (s.len() > len) begin - s = s.substr(0,len-1); - s[s.len()-1] = "\""; - end - return s; - endfunction -endclass diff --git a/tests/svunit_base/uvm-mock/svunit_uvm_test.sv b/tests/svunit_base/uvm-mock/svunit_uvm_test.sv deleted file mode 100644 index d26ff77c0a56924bb4e967ef7505cfe6eec1b94b..0000000000000000000000000000000000000000 --- a/tests/svunit_base/uvm-mock/svunit_uvm_test.sv +++ /dev/null @@ -1,171 +0,0 @@ -//########################################################################### -// -// Copyright 2011 The SVUnit Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//########################################################################### - -`ifndef __SVUNIT_UVM_TEST_SV__ -`define __SVUNIT_UVM_TEST_SV__ - -//`include "uvm_macros.svh" -`include "svunit_idle_uvm_domain.sv" - - -import uvm_pkg::*; - -//------------------------------------------------------------ -// this test sets up the jump from post_shutdown to pre_reset -// and defines the static methods used to gate the progress -// at pre_reset (start) and main (finish) -//------------------------------------------------------------ -class svunit_uvm_test extends uvm_test; - - `uvm_component_utils(svunit_uvm_test) - - static local event m_start; - static local bit m_start_e; - - static local event m_finish; - static local bit m_finish_e; - - static local bit m_in_pre_reset; - static local bit m_in_main; - - function new(string name = "", uvm_component parent = null); - super.new(name, parent); - - m_start_e = 0; - m_finish_e = 0; - endfunction - - static function void start(); - -> m_start; - m_start_e = 1; - endfunction - - static function void finish(); - -> m_finish; - m_finish_e = 1; - endfunction - - - static function bit is_ready(); - return m_in_pre_reset; - endfunction - - static task wait_for_ready(); - @(posedge m_in_pre_reset); - endtask - - static function bit is_running(); - return m_in_main; - endfunction - - static task wait_for_running(); - @(posedge m_in_main); - endtask - - task pre_reset_phase(uvm_phase phase); - phase.raise_objection(null); - m_in_pre_reset = 1; - if (!m_start_e) @m_start; - m_start_e = 0; - phase.drop_objection(null); - m_in_pre_reset = 0; - endtask - - task main_phase(uvm_phase phase); - phase.raise_objection(null); - m_in_main = 1; - if (!m_finish_e) @m_finish; - m_finish_e = 0; - phase.drop_objection(null); - m_in_main = 0; - endtask - - task post_shutdown_phase(uvm_phase phase); - //------------------------------------------------ - // mask the PH_JUMP message because it's annoying - //------------------------------------------------ - uvm_root top; - top = uvm_root::get(); - top.m_rh.set_severity_id_action(UVM_INFO, "PH_JUMP", UVM_NO_ACTION); - - //------------- - // do the jump - //------------- - phase.jump(uvm_pre_reset_phase::get()); - endtask -endclass - - -//------------------------------------------------------ -// global help methods for calling start and finish for -// the svunit_uvm_test -//------------------------------------------------------ -bit svunit_uvm_test_running = 0; -task svunit_uvm_test_start(); - if (!svunit_uvm_test_running) begin - fork - begin - #1; - if (!svunit_uvm_test_running) begin - `uvm_fatal("svunit_uvm_test_start", "You're running svunit with uvm without defining RUN_SVUNIT_WITH_UVM. Please add '+define+RUN_SVUNIT_WITH_UVM' to your svunit.f file."); - end - end - join_none - end - - // wait for the svunit_test to get to the pre_reset_phase - if (!svunit_uvm_test::is_ready()) svunit_uvm_test::wait_for_ready(); - - svunit_uvm_test::start(); -endtask - -task svunit_uvm_test_finish(); - // wait for the svunit_test to get to the main_phase - if (!svunit_uvm_test::is_running()) svunit_uvm_test::wait_for_running(); - - svunit_uvm_test::finish(); -endtask - - -//------------------------------------------------------------ -// global to instantiate and invoke the test. only happens on -// the initial call. for subsequent calls, nothing happens. -//------------------------------------------------------------ -task svunit_uvm_test_inst(string test_name = "svunit_uvm_test"); - if (!svunit_uvm_test_running) begin - svunit_uvm_test_running = 1; - fork - begin - uvm_root top; - - top = uvm_root::get(); - void'(svunit_idle_uvm_domain::get_common_domain()); - - //-------------------------------------------------------------------------------------- - // if no test is running yet (i.e this is the first call to svunit_uvm_test_inst), setup - // the svunit_idle_uvm_domain and invoke the svunit_uvm_test. Breeze by this otherwise. - //-------------------------------------------------------------------------------------- - if (!top.has_child("uvm_test_top")) begin - top.run_test("svunit_uvm_test"); - end - end - join_none - end -endtask - -`endif