verilator/test_regress/t/t_covergroup_coverpoint_met...

40 lines
891 B
Systemverilog
Raw Permalink Normal View History

2025-06-27 21:47:13 +02:00
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2025 Wilson Snyder
2025-06-27 21:47:13 +02:00
// SPDX-License-Identifier: CC0-1.0
2026-03-08 23:26:40 +01:00
module t (
input clk
);
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
logic [3:0] a;
int b;
int cyc = 0;
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
always @(posedge clk) begin
cyc <= cyc + 1;
end
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
covergroup cg @(posedge clk);
coverpoint a;
coverpoint b {bins the_bins[5] = {[0 : 20]};}
endgroup
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
cg the_cg = new;
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
assign a = cyc[3:0];
assign b = cyc;
2025-06-27 21:47:13 +02:00
2026-03-08 23:26:40 +01:00
always @(posedge clk) begin
if (cyc == 14) begin
$display("coverage a = %f", the_cg.a.get_inst_coverage());
$display("coverage b = %f", the_cg.b.get_inst_coverage());
if (the_cg.a.get_inst_coverage() != 15 / 16.0) $stop();
if (the_cg.b.get_inst_coverage() != 4 / 5.0) $stop();
$write("*-* All Finished *-*\n");
$finish;
2025-06-27 21:47:13 +02:00
end
2026-03-08 23:26:40 +01:00
end
2025-06-27 21:47:13 +02:00
endmodule