2008-12-12 20:34:02 +00:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
// any use, without warranty, 2008 by Wilson Snyder.
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
module t (/*AUTOARG*/
|
|
|
|
// Inputs
|
2024-02-08 01:11:27 +00:00
|
|
|
clk, check_real, check_array_real, check_string
|
2008-12-12 20:34:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
input clk;
|
2021-01-10 17:40:03 +00:00
|
|
|
input real check_real; // Check issue #2741
|
2024-02-08 01:11:27 +00:00
|
|
|
input real check_array_real [1:0];
|
2021-01-25 12:33:38 +00:00
|
|
|
input string check_string; // Check issue #2766
|
2008-12-12 20:34:02 +00:00
|
|
|
|
2013-10-30 00:15:01 +00:00
|
|
|
typedef struct packed {
|
|
|
|
union packed {
|
2022-05-01 14:10:00 +00:00
|
|
|
logic ua;
|
|
|
|
logic ub;
|
2013-10-30 00:15:01 +00:00
|
|
|
} u;
|
|
|
|
logic b;
|
|
|
|
} str_t;
|
|
|
|
|
2022-05-01 14:10:00 +00:00
|
|
|
reg toggle; initial toggle='0;
|
2013-10-30 00:15:01 +00:00
|
|
|
|
|
|
|
str_t stoggle; initial stoggle='0;
|
|
|
|
|
2024-02-08 02:03:32 +00:00
|
|
|
union {
|
|
|
|
real val1; // TODO use bit [7:0] here
|
|
|
|
real val2; // TODO use bit [3:0] here
|
|
|
|
} utoggle;
|
|
|
|
|
2013-11-01 02:39:26 +00:00
|
|
|
const reg aconst = '0;
|
|
|
|
|
2013-10-30 00:15:01 +00:00
|
|
|
reg [1:0][1:0] ptoggle; initial ptoggle=0;
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
integer cyc; initial cyc=1;
|
|
|
|
wire [7:0] cyc_copy = cyc[7:0];
|
|
|
|
wire toggle_up;
|
|
|
|
|
2024-02-08 13:44:27 +00:00
|
|
|
typedef struct {
|
|
|
|
int q[$];
|
|
|
|
} str_queue_t;
|
|
|
|
str_queue_t str_queue;
|
|
|
|
|
2008-12-12 20:34:02 +00:00
|
|
|
alpha a1 (/*AUTOINST*/
|
2022-05-01 14:10:00 +00:00
|
|
|
// Outputs
|
|
|
|
.toggle_up (toggle_up),
|
|
|
|
// Inputs
|
|
|
|
.clk (clk),
|
|
|
|
.toggle (toggle),
|
|
|
|
.cyc_copy (cyc_copy[7:0]));
|
2008-12-12 20:34:02 +00:00
|
|
|
alpha a2 (/*AUTOINST*/
|
2022-05-01 14:10:00 +00:00
|
|
|
// Outputs
|
|
|
|
.toggle_up (toggle_up),
|
|
|
|
// Inputs
|
|
|
|
.clk (clk),
|
|
|
|
.toggle (toggle),
|
|
|
|
.cyc_copy (cyc_copy[7:0]));
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
beta b1 (/*AUTOINST*/
|
2022-05-01 14:10:00 +00:00
|
|
|
// Inputs
|
|
|
|
.clk (clk),
|
|
|
|
.toggle_up (toggle_up));
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
off o1 (/*AUTOINST*/
|
2022-05-01 14:10:00 +00:00
|
|
|
// Inputs
|
|
|
|
.clk (clk),
|
|
|
|
.toggle (toggle));
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
reg [1:0] memory[121:110];
|
|
|
|
|
2021-03-29 22:54:51 +00:00
|
|
|
wire [1023:0] largeish = {992'h0, cyc};
|
2008-12-12 20:34:02 +00:00
|
|
|
// CHECK_COVER_MISSING(-1)
|
|
|
|
|
|
|
|
always @ (posedge clk) begin
|
2024-02-08 13:44:27 +00:00
|
|
|
if (cyc != 0) begin
|
2022-05-01 14:10:00 +00:00
|
|
|
cyc <= cyc + 1;
|
|
|
|
memory[cyc + 'd100] <= memory[cyc + 'd100] + 2'b1;
|
|
|
|
toggle <= '0;
|
|
|
|
stoggle.u <= toggle;
|
|
|
|
stoggle.b <= toggle;
|
2024-02-08 02:03:32 +00:00
|
|
|
utoggle.val1 <= real'(cyc[7:0]);
|
2022-05-01 14:10:00 +00:00
|
|
|
ptoggle[0][0] <= toggle;
|
2024-02-08 13:44:27 +00:00
|
|
|
if (cyc == 3) begin
|
|
|
|
str_queue.q.push_back(1);
|
2022-05-01 14:10:00 +00:00
|
|
|
toggle <= '1;
|
|
|
|
end
|
2024-02-08 13:44:27 +00:00
|
|
|
if (cyc == 4) begin
|
|
|
|
if (str_queue.q.size() != 1) $stop;
|
2022-05-01 14:10:00 +00:00
|
|
|
toggle <= '0;
|
|
|
|
end
|
2024-02-08 13:44:27 +00:00
|
|
|
else if (cyc == 10) begin
|
2022-05-01 14:10:00 +00:00
|
|
|
$write("*-* All Finished *-*\n");
|
|
|
|
$finish;
|
|
|
|
end
|
2008-12-12 20:34:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
module alpha (/*AUTOARG*/
|
|
|
|
// Outputs
|
|
|
|
toggle_up,
|
|
|
|
// Inputs
|
|
|
|
clk, toggle, cyc_copy
|
|
|
|
);
|
|
|
|
|
|
|
|
// t.a1 and t.a2 collapse to a count of 2
|
|
|
|
|
|
|
|
input clk;
|
|
|
|
|
|
|
|
input toggle;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.a*",4)
|
2008-12-12 20:34:02 +00:00
|
|
|
// 2 edges * (t.a1 and t.a2)
|
|
|
|
|
|
|
|
input [7:0] cyc_copy;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.a*","cyc_copy[0]",22)
|
|
|
|
// CHECK_COVER(-2,"top.t.a*","cyc_copy[1]",10)
|
|
|
|
// CHECK_COVER(-3,"top.t.a*","cyc_copy[2]",4)
|
|
|
|
// CHECK_COVER(-4,"top.t.a*","cyc_copy[3]",2)
|
|
|
|
// CHECK_COVER(-5,"top.t.a*","cyc_copy[4]",0)
|
|
|
|
// CHECK_COVER(-6,"top.t.a*","cyc_copy[5]",0)
|
|
|
|
// CHECK_COVER(-7,"top.t.a*","cyc_copy[6]",0)
|
|
|
|
// CHECK_COVER(-8,"top.t.a*","cyc_copy[7]",0)
|
2008-12-12 20:34:02 +00:00
|
|
|
|
2022-05-01 14:10:00 +00:00
|
|
|
reg toggle_internal;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.a*",4)
|
2008-12-12 20:34:02 +00:00
|
|
|
// 2 edges * (t.a1 and t.a2)
|
|
|
|
|
|
|
|
output reg toggle_up;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.a*",4)
|
2008-12-12 20:34:02 +00:00
|
|
|
// 2 edges * (t.a1 and t.a2)
|
|
|
|
|
|
|
|
always @ (posedge clk) begin
|
|
|
|
toggle_internal <= toggle;
|
|
|
|
toggle_up <= toggle;
|
|
|
|
end
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
module beta (/*AUTOARG*/
|
|
|
|
// Inputs
|
|
|
|
clk, toggle_up
|
|
|
|
);
|
|
|
|
|
|
|
|
input clk;
|
|
|
|
|
|
|
|
input toggle_up;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.b1","toggle_up",2)
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
/* verilator public_module */
|
|
|
|
|
|
|
|
always @ (posedge clk) begin
|
|
|
|
if (0 && toggle_up) begin end
|
|
|
|
end
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
module off (/*AUTOARG*/
|
|
|
|
// Inputs
|
|
|
|
clk, toggle
|
|
|
|
);
|
|
|
|
|
|
|
|
// verilator coverage_off
|
|
|
|
input clk;
|
|
|
|
// CHECK_COVER_MISSING(-1)
|
|
|
|
|
|
|
|
// verilator coverage_on
|
|
|
|
input toggle;
|
2016-05-07 18:10:33 +00:00
|
|
|
// CHECK_COVER(-1,"top.t.o1","toggle",2)
|
2008-12-12 20:34:02 +00:00
|
|
|
|
|
|
|
endmodule
|