2022-10-03 06:55:24 -04:00
|
|
|
//======================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
);
|
2022-10-03 06:55:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// 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;
|
2022-10-03 06:55:24 -04:00
|
|
|
|
2024-10-22 05:54:56 -04:00
|
|
|
if (rst_ctr_we) rst_ctr_reg <= rst_ctr_new;
|
|
|
|
end
|
2022-10-03 06:55:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// 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;
|
2022-10-03 06:55:24 -04:00
|
|
|
|
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;
|
2022-10-03 06:55:24 -04:00
|
|
|
end
|
2024-10-22 05:54:56 -04:00
|
|
|
end
|
2022-10-03 06:55:24 -04:00
|
|
|
|
2024-10-22 05:54:56 -04:00
|
|
|
endmodule // reset_gen
|
2022-10-03 06:55:24 -04:00
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// EOF reset_gen.v
|
|
|
|
//======================================================================
|