2019-10-09 06:47:26 -04:00
|
|
|
// DESCRIPTION: Verilator: --protect-lib example secret module
|
|
|
|
|
//
|
2026-01-26 20:24:34 -05:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
|
|
|
|
// SPDX-FileCopyrightText: 2017 Wilson Snyder
|
2020-03-21 11:24:24 -04:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2019-10-09 06:47:26 -04:00
|
|
|
|
|
|
|
|
// This module will be used as libsecret.a or libsecret.so without
|
|
|
|
|
// exposing the source.
|
|
|
|
|
|
2025-12-20 21:46:43 -05:00
|
|
|
module secret_impl (
|
|
|
|
|
input [31:0] a,
|
|
|
|
|
input [31:0] b,
|
|
|
|
|
output logic [31:0] x,
|
|
|
|
|
input clk,
|
|
|
|
|
input reset_l
|
|
|
|
|
);
|
2020-04-05 21:53:24 -04:00
|
|
|
|
2025-07-03 20:43:13 -04:00
|
|
|
logic [31:0] accum_q;
|
|
|
|
|
logic [31:0] secret_value;
|
2019-10-09 06:47:26 -04:00
|
|
|
|
2025-07-03 20:43:13 -04:00
|
|
|
initial $display("[%0t] %m: initialized", $time);
|
2019-10-09 06:47:26 -04:00
|
|
|
|
2025-07-03 20:43:13 -04:00
|
|
|
always @(posedge clk) begin
|
|
|
|
|
if (!reset_l) begin
|
|
|
|
|
accum_q <= 0;
|
|
|
|
|
secret_value <= 9;
|
|
|
|
|
end
|
|
|
|
|
else begin
|
|
|
|
|
accum_q <= accum_q + a;
|
2025-12-20 21:46:43 -05:00
|
|
|
if (accum_q > 10) x <= b;
|
|
|
|
|
else x <= a + b + secret_value;
|
2025-07-03 20:43:13 -04:00
|
|
|
end
|
|
|
|
|
end
|
2019-10-09 06:47:26 -04:00
|
|
|
|
|
|
|
|
endmodule
|