Verilog format
This commit is contained in:
parent
7f0be8a072
commit
e238a2ca5e
|
|
@ -19,7 +19,9 @@ module t;
|
||||||
class XorTest;
|
class XorTest;
|
||||||
rand bit [7:0] data[];
|
rand bit [7:0] data[];
|
||||||
rand bit [7:0] result;
|
rand bit [7:0] result;
|
||||||
function new(); data = new[4]; endfunction
|
function new();
|
||||||
|
data = new[4];
|
||||||
|
endfunction
|
||||||
constraint c_size {data.size() == 4;}
|
constraint c_size {data.size() == 4;}
|
||||||
constraint c_xor {result == data.xor();}
|
constraint c_xor {result == data.xor();}
|
||||||
endclass
|
endclass
|
||||||
|
|
@ -27,7 +29,9 @@ module t;
|
||||||
class SumTest;
|
class SumTest;
|
||||||
rand bit [7:0] data[];
|
rand bit [7:0] data[];
|
||||||
rand bit [7:0] result;
|
rand bit [7:0] result;
|
||||||
function new(); data = new[4]; endfunction
|
function new();
|
||||||
|
data = new[4];
|
||||||
|
endfunction
|
||||||
constraint c_size {data.size() == 4;}
|
constraint c_size {data.size() == 4;}
|
||||||
constraint c_sum {result == data.sum();}
|
constraint c_sum {result == data.sum();}
|
||||||
endclass
|
endclass
|
||||||
|
|
@ -35,7 +39,9 @@ module t;
|
||||||
class AndTest;
|
class AndTest;
|
||||||
rand bit [7:0] data[];
|
rand bit [7:0] data[];
|
||||||
rand bit [7:0] result;
|
rand bit [7:0] result;
|
||||||
function new(); data = new[4]; endfunction
|
function new();
|
||||||
|
data = new[4];
|
||||||
|
endfunction
|
||||||
constraint c_size {data.size() == 4;}
|
constraint c_size {data.size() == 4;}
|
||||||
constraint c_and {result == data.and();}
|
constraint c_and {result == data.and();}
|
||||||
endclass
|
endclass
|
||||||
|
|
@ -43,7 +49,9 @@ module t;
|
||||||
class OrTest;
|
class OrTest;
|
||||||
rand bit [7:0] data[];
|
rand bit [7:0] data[];
|
||||||
rand bit [7:0] result;
|
rand bit [7:0] result;
|
||||||
function new(); data = new[4]; endfunction
|
function new();
|
||||||
|
data = new[4];
|
||||||
|
endfunction
|
||||||
constraint c_size {data.size() == 4;}
|
constraint c_size {data.size() == 4;}
|
||||||
constraint c_or {result == data.or();}
|
constraint c_or {result == data.or();}
|
||||||
endclass
|
endclass
|
||||||
|
|
@ -51,7 +59,9 @@ module t;
|
||||||
class ProductTest;
|
class ProductTest;
|
||||||
rand bit [7:0] data[];
|
rand bit [7:0] data[];
|
||||||
rand bit [7:0] result;
|
rand bit [7:0] result;
|
||||||
function new(); data = new[4]; endfunction
|
function new();
|
||||||
|
data = new[4];
|
||||||
|
endfunction
|
||||||
constraint c_size {data.size() == 4;}
|
constraint c_size {data.size() == 4;}
|
||||||
constraint c_prod {result == data.product();}
|
constraint c_prod {result == data.product();}
|
||||||
endclass
|
endclass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
%Warning-CONSTRAINTIGN: t/t_constraint_func_call_unsup.v:18:23: Unsupported: complex function in constraint, treating as state
|
%Warning-CONSTRAINTIGN: t/t_constraint_func_call_unsup.v:16:22: Unsupported: complex function in constraint, treating as state
|
||||||
18 | constraint c { x <= complex_func(y); }
|
16 | constraint c {x <= complex_func(y);}
|
||||||
| ^~~~~~~~~~~~
|
| ^~~~~~~~~~~~
|
||||||
... For warning description see https://verilator.org/warn/CONSTRAINTIGN?v=latest
|
... For warning description see https://verilator.org/warn/CONSTRAINTIGN?v=latest
|
||||||
... Use "/* verilator lint_off CONSTRAINTIGN */" and lint_on around source to disable this message.
|
... Use "/* verilator lint_off CONSTRAINTIGN */" and lint_on around source to disable this message.
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,8 @@ class Cls;
|
||||||
rand bit [7:0] y;
|
rand bit [7:0] y;
|
||||||
|
|
||||||
function bit [7:0] complex_func(bit [7:0] m);
|
function bit [7:0] complex_func(bit [7:0] m);
|
||||||
if (m > 128)
|
if (m > 128) return m;
|
||||||
return m;
|
else return m + 1;
|
||||||
else
|
|
||||||
return m + 1;
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
constraint c {x <= complex_func(y);}
|
constraint c {x <= complex_func(y);}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ interface Iface;
|
||||||
endinterface
|
endinterface
|
||||||
|
|
||||||
module rvlab_tests (
|
module rvlab_tests (
|
||||||
Iface ifc);
|
Iface ifc
|
||||||
|
);
|
||||||
task test_idcode();
|
task test_idcode();
|
||||||
bit [31:0] idcode_read;
|
bit [31:0] idcode_read;
|
||||||
ifc.tsk(idcode_read, '0);
|
ifc.tsk(idcode_read, '0);
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
// DESCRIPTION: Verilator: Verilog Test module
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
//
|
//
|
||||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
||||||
// any use, without warranty, 2026 by Antmicro Ltd.
|
// SPDX-FileCopyrightText: 2026 Antmicro Ltd
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
module t;
|
module t;
|
||||||
initial fork
|
initial
|
||||||
|
fork
|
||||||
#0 $write("This should be last\n");
|
#0 $write("This should be last\n");
|
||||||
begin
|
begin
|
||||||
fork $write("This should be second\n"); join_none
|
fork
|
||||||
|
$write("This should be second\n");
|
||||||
|
join_none
|
||||||
$write("This should be first\n");
|
$write("This should be first\n");
|
||||||
end
|
end
|
||||||
join_none
|
join_none
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// DESCRIPTION: Verilator: Verilog Test module
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
//
|
//
|
||||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
||||||
// any use, without warranty, 2026 by Antmicro Ltd.
|
// SPDX-FileCopyrightText: 2026 Antmicro Ltd
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
module test;
|
module test;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// DESCRIPTION: Verilator: Verilog Test module
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
//
|
//
|
||||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
||||||
// any use, without warranty, 2026 by Antmicro Ltd.
|
// SPDX-FileCopyrightText: 2026 Antmicro Ltd
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
class events_holder;
|
class events_holder;
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
// SPDX-FileCopyrightText: 2024 Antmicro
|
// SPDX-FileCopyrightText: 2024 Antmicro
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
module subsub
|
module subsub #(
|
||||||
#(
|
|
||||||
`include "t_hier_block_import.vh"
|
`include "t_hier_block_import.vh"
|
||||||
)
|
) (
|
||||||
(output bit [31:0] out); /*verilator hier_block*/
|
output bit [31:0] out
|
||||||
|
); /*verilator hier_block*/
|
||||||
assign out = pt.PARAM_VALUE;
|
assign out = pt.PARAM_VALUE;
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@
|
||||||
|
|
||||||
module detail_code (
|
module detail_code (
|
||||||
input clk,
|
input clk,
|
||||||
input reset_l);
|
input reset_l
|
||||||
|
);
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module sub_top (
|
module sub_top (
|
||||||
input clk,
|
input clk,
|
||||||
input reset_l);
|
input reset_l
|
||||||
|
);
|
||||||
|
|
||||||
detail_code u0 (
|
detail_code u0 (
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@
|
||||||
// SPDX-FileCopyrightText: 2026 Wilson Snyder
|
// SPDX-FileCopyrightText: 2026 Wilson Snyder
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
interface ifc #(parameter int width)(input logic [width-1:0] b);
|
interface ifc #(
|
||||||
|
parameter int width
|
||||||
|
) (
|
||||||
|
input logic [width-1:0] b
|
||||||
|
);
|
||||||
logic [width-1:0] a;
|
logic [width-1:0] a;
|
||||||
typedef logic [width-1:0] type_t;
|
typedef logic [width-1:0] type_t;
|
||||||
always_comb a = type_t'(b);
|
always_comb a = type_t'(b);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ module submod(
|
||||||
always_ff @(posedge clk or posedge rst) begin
|
always_ff @(posedge clk or posedge rst) begin
|
||||||
if (rst) begin
|
if (rst) begin
|
||||||
out_signal <= 1'b0;
|
out_signal <= 1'b0;
|
||||||
end else begin
|
end
|
||||||
|
else begin
|
||||||
out_signal <= ~out_signal;
|
out_signal <= ~out_signal;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
||||||
module submod(/*AUTOARG*/
|
module submod (
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic rst,
|
input logic rst,
|
||||||
output logic out_signal
|
output logic out_signal
|
||||||
|
|
@ -13,7 +13,8 @@ module submod(/*AUTOARG*/
|
||||||
always_ff @(posedge clk or posedge rst) begin
|
always_ff @(posedge clk or posedge rst) begin
|
||||||
if (rst) begin
|
if (rst) begin
|
||||||
out_signal <= 1'b0;
|
out_signal <= 1'b0;
|
||||||
end else begin
|
end
|
||||||
|
else begin
|
||||||
out_signal <= ~out_signal;
|
out_signal <= ~out_signal;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ endclass
|
||||||
class Caller;
|
class Caller;
|
||||||
rand bit [7:0] own_value;
|
rand bit [7:0] own_value;
|
||||||
function int do_rand(DataItem item);
|
function int do_rand(DataItem item);
|
||||||
return item.randomize() with { this.value > 8'd30; this.value < 8'd40; };
|
return item.randomize() with {
|
||||||
|
this.value > 8'd30;
|
||||||
|
this.value < 8'd40;
|
||||||
|
};
|
||||||
endfunction
|
endfunction
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
|
@ -35,18 +38,28 @@ module t;
|
||||||
automatic int rand_ok;
|
automatic int rand_ok;
|
||||||
|
|
||||||
// Test 1: 'this.member' in inline constraint from module-level code
|
// Test 1: 'this.member' in inline constraint from module-level code
|
||||||
rand_ok = item.randomize() with { this.value > 8'd10; this.value < 8'd50; };
|
rand_ok = item.randomize() with {
|
||||||
|
this.value > 8'd10;
|
||||||
|
this.value < 8'd50;
|
||||||
|
};
|
||||||
`checkd(rand_ok, 1)
|
`checkd(rand_ok, 1)
|
||||||
`check_range(item.value, 11, 49)
|
`check_range(item.value, 11, 49)
|
||||||
`check_range(item.limit, 50, 200)
|
`check_range(item.limit, 50, 200)
|
||||||
|
|
||||||
// Test 2: multiple 'this.member' references
|
// Test 2: multiple 'this.member' references
|
||||||
rand_ok = item.randomize() with { this.value > 8'd20; this.value < 8'd30; };
|
rand_ok = item.randomize() with {
|
||||||
|
this.value > 8'd20;
|
||||||
|
this.value < 8'd30;
|
||||||
|
};
|
||||||
`checkd(rand_ok, 1)
|
`checkd(rand_ok, 1)
|
||||||
`check_range(item.value, 21, 29)
|
`check_range(item.value, 21, 29)
|
||||||
|
|
||||||
// Test 3: mix of 'this.member' and unqualified member
|
// Test 3: mix of 'this.member' and unqualified member
|
||||||
rand_ok = item.randomize() with { this.value > 8'd5; this.value < 8'd100; limit > 8'd150; };
|
rand_ok = item.randomize() with {
|
||||||
|
this.value > 8'd5;
|
||||||
|
this.value < 8'd100;
|
||||||
|
limit > 8'd150;
|
||||||
|
};
|
||||||
`checkd(rand_ok, 1)
|
`checkd(rand_ok, 1)
|
||||||
`check_range(item.value, 6, 99)
|
`check_range(item.value, 6, 99)
|
||||||
`check_range(item.limit, 151, 200)
|
`check_range(item.limit, 151, 200)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue