2012-04-05 03:55:20 +02:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
2026-01-27 02:24:34 +01:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
|
|
|
|
// SPDX-FileCopyrightText: 2020 Wilson Snyder
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2012-04-05 03:55:20 +02:00
|
|
|
|
|
|
|
|
// bug477
|
|
|
|
|
|
|
|
|
|
module t (
|
2026-03-10 02:38:29 +01:00
|
|
|
input rst_n,
|
|
|
|
|
input clk,
|
|
|
|
|
output out
|
|
|
|
|
);
|
2012-04-05 03:55:20 +02:00
|
|
|
|
2026-03-10 02:38:29 +01:00
|
|
|
submod #(.STAGES(5)) u2 (.*);
|
2012-04-05 03:55:20 +02:00
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
2026-03-10 02:38:29 +01:00
|
|
|
module submod ( /*AUTOARG*/
|
|
|
|
|
// Outputs
|
|
|
|
|
out,
|
|
|
|
|
// Inputs
|
|
|
|
|
rst_n,
|
|
|
|
|
clk
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
parameter STAGES = 4;
|
|
|
|
|
|
|
|
|
|
input rst_n;
|
|
|
|
|
input clk;
|
|
|
|
|
output out;
|
|
|
|
|
|
|
|
|
|
reg [STAGES-1:0] r_rst;
|
|
|
|
|
|
|
|
|
|
generate
|
|
|
|
|
// for i=0..5 (5+1-1)
|
|
|
|
|
for (genvar i = 0; i < STAGES + 1 - 1; i = i + 1) begin
|
|
|
|
|
always @(posedge clk or negedge rst_n) begin
|
|
|
|
|
if (~rst_n) r_rst[i] <= 1'b0;
|
|
|
|
|
else begin
|
|
|
|
|
if (i == 0) r_rst[i] <= 1'b1;
|
|
|
|
|
else r_rst[i] <= r_rst[i-1]; // i=0, so -1 wraps to 7
|
|
|
|
|
end
|
2012-04-05 03:55:20 +02:00
|
|
|
end
|
2026-03-10 02:38:29 +01:00
|
|
|
end
|
|
|
|
|
endgenerate
|
2012-04-05 03:55:20 +02:00
|
|
|
|
2026-03-10 02:38:29 +01:00
|
|
|
wire out = r_rst[STAGES-1];
|
2012-04-05 03:55:20 +02:00
|
|
|
|
|
|
|
|
endmodule
|