Description
I am using SVUnit for my unit test framework that makes use of *.svh files for a lot of the framework, but including the path where these files are located seems to not do anything.
Steps to Reproduce
- Install/Download SVUnit
- Create
add.sv
`timescale 1ns/1ps
module add#(
parameter integer DWIDTH = 8
) (
input clk, resetn,
input [DWIDTH-1:0] a, b,
output reg [DWIDTH-1:0] sum,
output reg overflow
);
always@(posedge clk) begin
if(~resetn) begin
sum <= {DWIDTH{1'b0}};
overflow <= 0;
end
else begin
{overflow, sum} <= a + b;
end
end
endmodule
- Create
add_unit_test.sv
`include "svunit_defines.svh"
module add_unit_test;
import svunit_pkg::svunit_testcase;
string name = "add_ut";
svunit_testcase svunit_ut;
localparam DWIDTH = 8;
localparam CLK_PERIOD = 10;
localparam ITERATIONS = 5;
localparam SYSTEM_DELAY = 2;
localparam OFFSET = 7;
localparam SCALAR_VALUE = 36;
localparam RESET_CYCLES = 2;
//===================================
// This is the UUT that we're
// running the Unit Tests on
//===================================
logic clk, resetn, overflow;
logic [DWIDTH-1:0] a, b;
logic [DWIDTH-1:0] sum;
add #(
.DWIDTH(DWIDTH)
) my_add (
.clk(clk),
.resetn(resetn),
.a(a),
.b(b),
.sum(sum),
.overflow(overflow)
);
//===================================
// Build
//===================================
function void build();
svunit_ut = new(name);
endfunction
//===================================
// Setup for running the Unit Tests
//===================================
task setup();
svunit_ut.setup();
/* Place Setup Code Here */
resetn = 1;
clk = 1;
// Keep this as unknowns so we can see if the reset works
a = {DWIDTH{1'bx}};
b = {DWIDTH{1'bx}};
endtask
//===================================
// Here we deconstruct anything we
// need after running the Unit Tests
//===================================
task teardown();
svunit_ut.teardown();
/* Place Teardown Code Here */
endtask
task reset();
resetn = 1;
@(posedge clk);
resetn = 0;
repeat(RESET_CYCLES) @(posedge clk);
resetn = 1;
endtask
function logic [DWIDTH-1:0] summation (logic [DWIDTH-1:0] a,b);
summation = a+b;
endfunction
// Clock Generator
`SVUNIT_CLK_GEN(clk, (CLK_PERIOD/2))
//===================================
// All tests are defined between the
// SVUNIT_TESTS_BEGIN/END macros
//
// Each individual test must be
// defined between `SVTEST(_NAME_)
// `SVTEST_END;
//
// i.e.
// `SVTEST(mytest)
// <test code>
// `SVTEST_END
//===================================
`SVUNIT_TESTS_BEGIN
// These tests will be done in order with a delay
// between each test
`SVTEST(reset_test)
// Should start off as unknown
`FAIL_UNLESS_EQUAL(sum, {DWIDTH{1'bx}})
repeat(SYSTEM_DELAY) @(posedge clk);
reset();
`FAIL_UNLESS_EQUAL(sum, {DWIDTH{1'b0}})
`SVTEST_END
`SVTEST(core_function)
repeat(1) begin
a = $urandom_range(0, (1<<DWIDTH)-1);
b = $urandom_range(0, (1<<DWIDTH)-1);
repeat(SYSTEM_DELAY) @(posedge clk);
$display("%d : %d", summation(a,b), sum);
`FAIL_UNLESS_EQUAL(sum, summation(a,b))
end
`SVTEST_END
`SVUNIT_TESTS_END
endmodule
- Run
svlint --include <path_to_svunit>/svunit_base add.sv add_unit_test.sv
- You should get the following error:
Error: failed to include 'svunit_defines.svh'
Description
I am using SVUnit for my unit test framework that makes use of
*.svhfiles for a lot of the framework, but including the path where these files are located seems to not do anything.Steps to Reproduce
add.svadd_unit_test.svsvlint --include <path_to_svunit>/svunit_base add.sv add_unit_test.sv