mirror of
https://github.com/alangarf/apple-one.git
synced 2025-01-24 12:31:16 +00:00
Added synchronous reset to clk enable divider to avoid undefined logic state in simulation
This commit is contained in:
parent
cca11b7925
commit
9465e0c14d
@ -25,7 +25,7 @@
|
||||
|
||||
module apple1_top_tb;
|
||||
|
||||
reg clk25, uart_rx;
|
||||
reg clk25, uart_rx, rst_n;
|
||||
wire uart_tx, uart_cts;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -33,7 +33,9 @@ module apple1_top_tb;
|
||||
|
||||
initial begin
|
||||
clk25 = 1'b0;
|
||||
uart_rx = 1'b0;
|
||||
uart_rx = 1'b0;
|
||||
rst_n = 1'b0;
|
||||
#40 rst_n = 1'b1;
|
||||
|
||||
$display("Starting...");
|
||||
$dumpfile("apple1_top_tb.vcd");
|
||||
@ -48,15 +50,11 @@ module apple1_top_tb;
|
||||
always
|
||||
#20 clk25 = !clk25;
|
||||
|
||||
always
|
||||
begin
|
||||
#10000 $finish;
|
||||
end
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Core of system
|
||||
top core_top(
|
||||
.clk25(clk25),
|
||||
.rst_n(rst_n),
|
||||
.uart_rx(uart_rx),
|
||||
.uart_tx(uart_tx),
|
||||
.uart_cts(uart_cts)
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
module top(
|
||||
input clk25, // 25 MHz master clock
|
||||
input rst_n, // active low synchronous reset (needed for simulation)
|
||||
|
||||
input uart_rx,
|
||||
output uart_tx,
|
||||
output uart_cts,
|
||||
@ -51,7 +53,7 @@ module top(
|
||||
reg [4:0] clk_div;
|
||||
always @(posedge clk25)
|
||||
begin
|
||||
if (clk_div == 25)
|
||||
if ((clk_div == 25) || (rst_n == 1'b0))
|
||||
clk_div <= 0;
|
||||
else
|
||||
clk_div <= clk_div + 1'b1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user