2019-10-09 12:47:26 +02:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
|
|
|
|
// This file ONLY is placed into the Public Domain, for any use,
|
|
|
|
|
// without warranty, 2019 by Todd Strader.
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2019-10-09 12:47:26 +02:00
|
|
|
|
2020-02-18 23:52:28 +01:00
|
|
|
module secret #(parameter GATED_CLK = 0)
|
2020-02-21 11:50:09 +01:00
|
|
|
(
|
2020-12-06 03:55:06 +01:00
|
|
|
input [31:0] accum_in,
|
|
|
|
|
output wire [31:0] accum_out,
|
|
|
|
|
input accum_bypass,
|
|
|
|
|
output [31:0] accum_bypass_out,
|
|
|
|
|
input s1_in,
|
|
|
|
|
output logic s1_out,
|
2020-12-15 15:51:14 +01:00
|
|
|
input s1up_in[2],
|
|
|
|
|
output logic s1up_out[2],
|
2020-12-06 03:55:06 +01:00
|
|
|
input [1:0] s2_in,
|
|
|
|
|
output logic [1:0] s2_out,
|
|
|
|
|
input [7:0] s8_in,
|
|
|
|
|
output logic [7:0] s8_out,
|
|
|
|
|
input [32:0] s33_in,
|
2020-02-21 11:50:09 +01:00
|
|
|
output logic [32:0] s33_out,
|
2020-12-06 03:55:06 +01:00
|
|
|
input [63:0] s64_in,
|
2020-02-21 11:50:09 +01:00
|
|
|
output logic [63:0] s64_out,
|
2020-12-06 03:55:06 +01:00
|
|
|
input [64:0] s65_in,
|
2020-02-21 11:50:09 +01:00
|
|
|
output logic [64:0] s65_out,
|
2020-12-06 03:55:06 +01:00
|
|
|
input [128:0] s129_in,
|
2020-02-21 11:50:09 +01:00
|
|
|
output logic [128:0] s129_out,
|
2020-12-06 03:55:06 +01:00
|
|
|
input [3:0] [31:0] s4x32_in,
|
2020-02-21 11:50:09 +01:00
|
|
|
output logic [3:0] [31:0] s4x32_out,
|
2023-03-21 01:44:11 +01:00
|
|
|
/*verilator lint_off ASCRANGE*/
|
2020-12-09 00:29:45 +01:00
|
|
|
input [0:15] s6x16up_in[0:1][2:0],
|
|
|
|
|
output logic [0:15] s6x16up_out[0:1][2:0],
|
2023-03-21 01:44:11 +01:00
|
|
|
/*verilator lint_on ASCRANGE*/
|
2020-12-09 00:29:45 +01:00
|
|
|
input [15:0] s8x16up_in[1:0][0:3],
|
|
|
|
|
output logic [15:0] s8x16up_out[1:0][0:3],
|
|
|
|
|
input [15:0] s8x16up_3d_in[1:0][0:1][0:1],
|
|
|
|
|
output logic [15:0] s8x16up_3d_out[1:0][0:1][0:1],
|
2020-12-06 03:55:06 +01:00
|
|
|
input clk_en,
|
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
|
|
|
input clk);
|
2019-10-23 14:32:02 +02:00
|
|
|
|
2020-12-06 03:55:06 +01:00
|
|
|
logic [31:0] secret_accum_q = 0;
|
|
|
|
|
logic [31:0] secret_value = 7;
|
2019-10-09 12:47:26 +02:00
|
|
|
|
|
|
|
|
initial $display("created %m");
|
|
|
|
|
|
2022-05-01 16:10:00 +02:00
|
|
|
logic the_clk;
|
2020-02-21 11:47:00 +01:00
|
|
|
generate
|
|
|
|
|
if (GATED_CLK != 0) begin: yes_gated_clock
|
2022-05-15 17:03:32 +02:00
|
|
|
logic clk_en_latch;
|
2020-02-21 11:50:09 +01:00
|
|
|
/* verilator lint_off COMBDLY */
|
2021-01-05 20:26:01 +01:00
|
|
|
/* verilator lint_off LATCH */
|
2020-02-21 11:50:09 +01:00
|
|
|
always_comb if (clk == '0) clk_en_latch <= clk_en;
|
2021-01-05 20:26:01 +01:00
|
|
|
/* verilator lint_on LATCH */
|
2020-02-21 11:50:09 +01:00
|
|
|
/* verilator lint_on COMBDLY */
|
|
|
|
|
assign the_clk = clk & clk_en_latch;
|
2020-02-21 11:47:00 +01:00
|
|
|
end else begin: no_gated_clock
|
2020-02-21 11:50:09 +01:00
|
|
|
assign the_clk = clk;
|
2020-02-21 11:47:00 +01:00
|
|
|
end
|
|
|
|
|
endgenerate
|
|
|
|
|
|
2020-02-18 23:52:28 +01:00
|
|
|
always @(posedge the_clk) begin
|
2019-10-09 12:47:26 +02:00
|
|
|
secret_accum_q <= secret_accum_q + accum_in + secret_value;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
// Test combinatorial paths of different sizes
|
|
|
|
|
always @(*) begin
|
|
|
|
|
s1_out = s1_in;
|
2020-12-15 15:51:14 +01:00
|
|
|
s1up_out = s1up_in;
|
2019-10-09 12:47:26 +02:00
|
|
|
s2_out = s2_in;
|
|
|
|
|
s8_out = s8_in;
|
|
|
|
|
s64_out = s64_in;
|
|
|
|
|
s65_out = s65_in;
|
|
|
|
|
s129_out = s129_in;
|
|
|
|
|
s4x32_out = s4x32_in;
|
|
|
|
|
end
|
|
|
|
|
|
2020-12-09 00:29:45 +01:00
|
|
|
for (genvar i = 0; i < 3; ++i) begin
|
|
|
|
|
assign s6x16up_out[0][i] = s6x16up_in[0][i];
|
|
|
|
|
assign s6x16up_out[1][i] = s6x16up_in[1][i];
|
|
|
|
|
end
|
|
|
|
|
for (genvar i = 0; i < 4; ++i) begin
|
|
|
|
|
assign s8x16up_out[0][i] = s8x16up_in[0][i];
|
|
|
|
|
assign s8x16up_out[1][i] = s8x16up_in[1][i];
|
|
|
|
|
end
|
|
|
|
|
for (genvar i = 0; i < 8; ++i) begin
|
|
|
|
|
assign s8x16up_3d_out[i[2]][i[1]][i[0]] = s8x16up_3d_in[i[2]][i[1]][i[0]];
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2019-11-30 15:18:49 +01:00
|
|
|
sub sub (.sub_in(s33_in), .sub_out(s33_out));
|
|
|
|
|
|
2019-10-09 12:47:26 +02:00
|
|
|
// Test sequential path
|
|
|
|
|
assign accum_out = secret_accum_q;
|
|
|
|
|
|
|
|
|
|
// Test mixed combinatorial/sequential path
|
|
|
|
|
assign accum_bypass_out = accum_bypass ? accum_in : secret_accum_q;
|
|
|
|
|
|
|
|
|
|
final $display("destroying %m");
|
|
|
|
|
|
|
|
|
|
endmodule
|
2019-11-30 15:18:49 +01:00
|
|
|
|
|
|
|
|
module sub (
|
|
|
|
|
input [32:0] sub_in,
|
|
|
|
|
output [32:0] sub_out);
|
|
|
|
|
|
|
|
|
|
/*verilator no_inline_module*/
|
|
|
|
|
|
|
|
|
|
assign sub_out = sub_in;
|
|
|
|
|
|
|
|
|
|
endmodule
|