-
Notifications
You must be signed in to change notification settings - Fork 10
/
top.v
49 lines (42 loc) · 1.33 KB
/
top.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// DESCRIPTION: Verilator: Verilog example module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2003 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// ======================================================================
module top
(input logic clk,
input logic reset);
// Create 100 cycles of example stimulus
reg [31:0] count_c;
always_ff @ (posedge clk) begin
//$display("[%0t] clk=%b reset=%b", $time, clk, reset);
if (reset) begin
count_c <= 0;
end
else begin
count_c <= count_c + 1;
if (count_c >= 99) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
end
// Example coverage analysis
cover property (@(posedge clk) count_c == 30); // Hit
cover property (@(posedge clk) count_c == 300); // Not covered
// Example toggle analysis
wire count_hit_50; // Hit
wire count_hit_500; // Not covered
assign count_hit_50 = (count_c == 50);
assign count_hit_500 = (count_c == 500);
// Example line and block coverage
always_comb begin
if (count_hit_50) begin // Hit
$write("[%0t] got 50\n", $time); // Hit
end
if (count_hit_500) begin // Not covered
$write("[%0t] got 600\n", $time); // Not covered
end
end
endmodule