2008-10-29 02:38:01 +01:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
2020-03-21 16:24:24 +01:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
|
// any use, without warranty, 2020 by Wilson Snyder.
|
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2008-10-29 02:38:01 +01:00
|
|
|
|
|
|
|
|
module t (/*AUTOARG*/
|
|
|
|
|
// Inputs
|
|
|
|
|
clk
|
|
|
|
|
);
|
|
|
|
|
input clk;
|
|
|
|
|
|
2022-05-01 16:10:00 +02:00
|
|
|
integer cyc = 0;
|
|
|
|
|
reg [63:0] crc;
|
|
|
|
|
reg [63:0] sum;
|
2008-10-29 02:38:01 +01:00
|
|
|
|
|
|
|
|
// Take CRC data and apply to testblock inputs
|
|
|
|
|
wire [9:0] in = crc[9:0];
|
|
|
|
|
|
|
|
|
|
/*AUTOWIRE*/
|
|
|
|
|
|
Deprecate clocker attribute and --clk option (#6463)
The only use for the clocker attribute and the AstVar::isUsedClock that
is actually necessary today for correctness is to mark top level inputs
of --lib-create blocks as being (or driving) a clock signal. Correctness
of --lib-create (and hence hierarchical blocks) actually used to depend
on having the right optimizations eliminate intermediate clocks (e.g.:
V3Gate), when the top level port was not used directly in a sensitivity
list, or marking top level signals manually via --clk or the clocker
attribute. However V3Sched::partition already needs to trace through the
logic to figure out what signals might drive a sensitivity list, so it
can very easily mark all top level inputs as such.
In this patch we remove the AstVar::attrClocker and AstVar::isUsedClock
attributes, and replace them with AstVar::isPrimaryClock, automatically
set by V3Sched::partition. This eliminates all need for manual
annotation so we are deprecating the --clk/--no-clk options and the
clocker/no_clocker attributes.
This also eliminates the opportunity for any further mis-optimization
similar to #6453.
Regarding the other uses of the removed AstVar attributes:
- As of 5.000, initial edges are triggered via a separate mechanism
applied in V3Sched, so the use in V3EmitCFunc.cpp is redundant
- Also as of 5.000, we can handle arbitrary sensitivity expressions, so
the restriction on eliminating clock signals in V3Gate is unnecessary
- Since the recent change when Dfg is applied after V3Scope, it does
perform the equivalent of GateClkDecomp, so we can delete that pass.
2025-09-20 16:50:22 +02:00
|
|
|
Test test (// Outputs
|
|
|
|
|
.a(),
|
|
|
|
|
.b(),
|
|
|
|
|
/*AUTOINST*/
|
2022-05-01 16:10:00 +02:00
|
|
|
// Inputs
|
|
|
|
|
.clk (clk),
|
|
|
|
|
.in (in[9:0]));
|
2008-10-29 02:38:01 +01:00
|
|
|
|
|
|
|
|
// Aggregate outputs into a single result vector
|
|
|
|
|
wire [63:0] result = {64'h0};
|
|
|
|
|
|
|
|
|
|
// Test loop
|
|
|
|
|
always @ (posedge clk) begin
|
|
|
|
|
`ifdef TEST_VERBOSE
|
2021-11-13 16:46:25 +01:00
|
|
|
$write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result);
|
2008-10-29 02:38:01 +01:00
|
|
|
`endif
|
|
|
|
|
cyc <= cyc + 1;
|
2021-11-13 16:46:25 +01:00
|
|
|
crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]};
|
|
|
|
|
sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]};
|
2008-10-29 02:38:01 +01:00
|
|
|
if (cyc==0) begin
|
2022-05-01 16:10:00 +02:00
|
|
|
// Setup
|
|
|
|
|
crc <= 64'h5aef0c8d_d70a4497;
|
2008-10-29 02:38:01 +01:00
|
|
|
end
|
|
|
|
|
else if (cyc<10) begin
|
2022-05-01 16:10:00 +02:00
|
|
|
sum <= 64'h0;
|
2008-10-29 02:38:01 +01:00
|
|
|
end
|
|
|
|
|
else if (cyc<90) begin
|
|
|
|
|
end
|
|
|
|
|
else if (cyc==99) begin
|
2022-05-01 16:10:00 +02:00
|
|
|
$write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum);
|
|
|
|
|
if (crc !== 64'hc77bb9b3784ea091) $stop;
|
|
|
|
|
// What checksum will we end up with (above print should match)
|
2008-10-29 02:38:01 +01:00
|
|
|
`define EXPECTED_SUM 64'h0
|
2022-05-01 16:10:00 +02:00
|
|
|
if (sum !== `EXPECTED_SUM) $stop;
|
|
|
|
|
$write("*-* All Finished *-*\n");
|
|
|
|
|
$finish;
|
2008-10-29 02:38:01 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
|
|
module Test (/*AUTOARG*/
|
Deprecate clocker attribute and --clk option (#6463)
The only use for the clocker attribute and the AstVar::isUsedClock that
is actually necessary today for correctness is to mark top level inputs
of --lib-create blocks as being (or driving) a clock signal. Correctness
of --lib-create (and hence hierarchical blocks) actually used to depend
on having the right optimizations eliminate intermediate clocks (e.g.:
V3Gate), when the top level port was not used directly in a sensitivity
list, or marking top level signals manually via --clk or the clocker
attribute. However V3Sched::partition already needs to trace through the
logic to figure out what signals might drive a sensitivity list, so it
can very easily mark all top level inputs as such.
In this patch we remove the AstVar::attrClocker and AstVar::isUsedClock
attributes, and replace them with AstVar::isPrimaryClock, automatically
set by V3Sched::partition. This eliminates all need for manual
annotation so we are deprecating the --clk/--no-clk options and the
clocker/no_clocker attributes.
This also eliminates the opportunity for any further mis-optimization
similar to #6453.
Regarding the other uses of the removed AstVar attributes:
- As of 5.000, initial edges are triggered via a separate mechanism
applied in V3Sched, so the use in V3EmitCFunc.cpp is redundant
- Also as of 5.000, we can handle arbitrary sensitivity expressions, so
the restriction on eliminating clock signals in V3Gate is unnecessary
- Since the recent change when Dfg is applied after V3Scope, it does
perform the equivalent of GateClkDecomp, so we can delete that pass.
2025-09-20 16:50:22 +02:00
|
|
|
// Outputs
|
|
|
|
|
a, b,
|
2008-10-29 02:38:01 +01:00
|
|
|
// Inputs
|
|
|
|
|
clk, in
|
Deprecate clocker attribute and --clk option (#6463)
The only use for the clocker attribute and the AstVar::isUsedClock that
is actually necessary today for correctness is to mark top level inputs
of --lib-create blocks as being (or driving) a clock signal. Correctness
of --lib-create (and hence hierarchical blocks) actually used to depend
on having the right optimizations eliminate intermediate clocks (e.g.:
V3Gate), when the top level port was not used directly in a sensitivity
list, or marking top level signals manually via --clk or the clocker
attribute. However V3Sched::partition already needs to trace through the
logic to figure out what signals might drive a sensitivity list, so it
can very easily mark all top level inputs as such.
In this patch we remove the AstVar::attrClocker and AstVar::isUsedClock
attributes, and replace them with AstVar::isPrimaryClock, automatically
set by V3Sched::partition. This eliminates all need for manual
annotation so we are deprecating the --clk/--no-clk options and the
clocker/no_clocker attributes.
This also eliminates the opportunity for any further mis-optimization
similar to #6453.
Regarding the other uses of the removed AstVar attributes:
- As of 5.000, initial edges are triggered via a separate mechanism
applied in V3Sched, so the use in V3EmitCFunc.cpp is redundant
- Also as of 5.000, we can handle arbitrary sensitivity expressions, so
the restriction on eliminating clock signals in V3Gate is unnecessary
- Since the recent change when Dfg is applied after V3Scope, it does
perform the equivalent of GateClkDecomp, so we can delete that pass.
2025-09-20 16:50:22 +02:00
|
|
|
);
|
|
|
|
|
/*verilator hier_block*/
|
2008-10-29 02:38:01 +01:00
|
|
|
input clk;
|
|
|
|
|
input [9:0] in;
|
|
|
|
|
|
Deprecate clocker attribute and --clk option (#6463)
The only use for the clocker attribute and the AstVar::isUsedClock that
is actually necessary today for correctness is to mark top level inputs
of --lib-create blocks as being (or driving) a clock signal. Correctness
of --lib-create (and hence hierarchical blocks) actually used to depend
on having the right optimizations eliminate intermediate clocks (e.g.:
V3Gate), when the top level port was not used directly in a sensitivity
list, or marking top level signals manually via --clk or the clocker
attribute. However V3Sched::partition already needs to trace through the
logic to figure out what signals might drive a sensitivity list, so it
can very easily mark all top level inputs as such.
In this patch we remove the AstVar::attrClocker and AstVar::isUsedClock
attributes, and replace them with AstVar::isPrimaryClock, automatically
set by V3Sched::partition. This eliminates all need for manual
annotation so we are deprecating the --clk/--no-clk options and the
clocker/no_clocker attributes.
This also eliminates the opportunity for any further mis-optimization
similar to #6453.
Regarding the other uses of the removed AstVar attributes:
- As of 5.000, initial edges are triggered via a separate mechanism
applied in V3Sched, so the use in V3EmitCFunc.cpp is redundant
- Also as of 5.000, we can handle arbitrary sensitivity expressions, so
the restriction on eliminating clock signals in V3Gate is unnecessary
- Since the recent change when Dfg is applied after V3Scope, it does
perform the equivalent of GateClkDecomp, so we can delete that pass.
2025-09-20 16:50:22 +02:00
|
|
|
output reg a [9:0];
|
2008-10-29 02:38:01 +01:00
|
|
|
integer ai;
|
|
|
|
|
always @* begin
|
|
|
|
|
for (ai=0;ai<10;ai=ai+1) begin
|
2022-05-01 16:10:00 +02:00
|
|
|
a[ai]=in[ai];
|
2008-10-29 02:38:01 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
Deprecate clocker attribute and --clk option (#6463)
The only use for the clocker attribute and the AstVar::isUsedClock that
is actually necessary today for correctness is to mark top level inputs
of --lib-create blocks as being (or driving) a clock signal. Correctness
of --lib-create (and hence hierarchical blocks) actually used to depend
on having the right optimizations eliminate intermediate clocks (e.g.:
V3Gate), when the top level port was not used directly in a sensitivity
list, or marking top level signals manually via --clk or the clocker
attribute. However V3Sched::partition already needs to trace through the
logic to figure out what signals might drive a sensitivity list, so it
can very easily mark all top level inputs as such.
In this patch we remove the AstVar::attrClocker and AstVar::isUsedClock
attributes, and replace them with AstVar::isPrimaryClock, automatically
set by V3Sched::partition. This eliminates all need for manual
annotation so we are deprecating the --clk/--no-clk options and the
clocker/no_clocker attributes.
This also eliminates the opportunity for any further mis-optimization
similar to #6453.
Regarding the other uses of the removed AstVar attributes:
- As of 5.000, initial edges are triggered via a separate mechanism
applied in V3Sched, so the use in V3EmitCFunc.cpp is redundant
- Also as of 5.000, we can handle arbitrary sensitivity expressions, so
the restriction on eliminating clock signals in V3Gate is unnecessary
- Since the recent change when Dfg is applied after V3Scope, it does
perform the equivalent of GateClkDecomp, so we can delete that pass.
2025-09-20 16:50:22 +02:00
|
|
|
output reg [1:0] b [9:0];
|
2008-10-29 02:38:01 +01:00
|
|
|
integer j;
|
|
|
|
|
|
|
|
|
|
generate
|
|
|
|
|
genvar i;
|
|
|
|
|
for (i=0; i<2; i=i+1) begin
|
2022-05-01 16:10:00 +02:00
|
|
|
always @(posedge clk) begin
|
|
|
|
|
for (j=0; j<10; j=j+1) begin
|
|
|
|
|
if (a[j])
|
|
|
|
|
b[i][j] <= 1'b0;
|
|
|
|
|
else
|
|
|
|
|
b[i][j] <= 1'b1;
|
|
|
|
|
end
|
|
|
|
|
end
|
2008-10-29 02:38:01 +01:00
|
|
|
end
|
|
|
|
|
endgenerate
|
|
|
|
|
endmodule
|