tillitis-key/hw/application_fpga/tb/reset_gen_vsim.v

71 lines
1.9 KiB
Verilog
Raw Normal View History

//======================================================================
//
// reset_gen_vsim.v
// ----------------
// Reset generator Verilator simulation of the application_fpga.
//
//
// Author: Joachim Strombergson
// Copyright (C) 2022 - Tillitis AB
// SPDX-License-Identifier: GPL-2.0-only
//
//======================================================================
`default_nettype none
2024-10-22 05:54:56 -04:00
module reset_gen #(
parameter RESET_CYCLES = 200
) (
input wire clk,
output wire rst_n
);
//----------------------------------------------------------------
// Registers with associated wires.
//----------------------------------------------------------------
reg [7 : 0] rst_ctr_reg = 8'h0;
reg [7 : 0] rst_ctr_new;
reg rst_ctr_we;
reg rst_n_reg = 1'h0;
reg rst_n_new;
//----------------------------------------------------------------
// Concurrent assignment.
//----------------------------------------------------------------
assign rst_n = rst_n_reg;
//----------------------------------------------------------------
// reg_update.
//----------------------------------------------------------------
2024-10-22 05:54:56 -04:00
always @(posedge clk) begin : reg_update
rst_n_reg <= rst_n_new;
2024-10-22 05:54:56 -04:00
if (rst_ctr_we) rst_ctr_reg <= rst_ctr_new;
end
//----------------------------------------------------------------
// rst_logic.
//----------------------------------------------------------------
2024-10-22 05:54:56 -04:00
always @* begin : rst_logic
rst_n_new = 1'h1;
rst_ctr_new = 8'h0;
rst_ctr_we = 1'h0;
2024-10-22 05:54:56 -04:00
if (rst_ctr_reg < RESET_CYCLES) begin
rst_n_new = 1'h0;
rst_ctr_new = rst_ctr_reg + 1'h1;
rst_ctr_we = 1'h1;
end
2024-10-22 05:54:56 -04:00
end
2024-10-22 05:54:56 -04:00
endmodule // reset_gen
//======================================================================
// EOF reset_gen.v
//======================================================================