/* * Milkymist-NG SoC * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module m1reset( input sys_clk, input trigger_reset, output reg sys_rst, output ac97_rst_n, output videoin_rst_n, output flash_rst_n ); reg [19:0] rst_debounce; initial rst_debounce <= 20'hFFFFF; initial sys_rst <= 1'b1; always @(posedge sys_clk) begin if(trigger_reset) rst_debounce <= 20'hFFFFF; else if(rst_debounce != 20'd0) rst_debounce <= rst_debounce - 20'd1; sys_rst <= rst_debounce != 20'd0; end assign ac97_rst_n = ~sys_rst; assign videoin_rst_n = ~sys_rst; /* * We must release the Flash reset before the system reset * because the Flash needs some time to come out of reset * and the CPU begins fetching instructions from it * as soon as the system reset is released. * From datasheet, minimum reset pulse width is 100ns * and reset-to-read time is 150ns. */ reg [7:0] flash_rstcounter; initial flash_rstcounter <= 8'd0; always @(posedge sys_clk) begin if(trigger_reset) flash_rstcounter <= 8'd0; else if(~flash_rstcounter[7]) flash_rstcounter <= flash_rstcounter + 8'd1; end assign flash_rst_n = flash_rstcounter[7]; endmodule