2010-05-26 05:49:58 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
`timescale 1 ns / 100 ps
|
|
|
|
|
|
|
|
module system_tb;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Parameter (may differ for physical synthesis)
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
parameter tck = 20; // clock period in ns
|
|
|
|
parameter uart_baud_rate = 1152000; // uart baud rate for simulation
|
|
|
|
|
|
|
|
parameter clk_freq = 1000000000 / tck; // Frequenzy in HZ
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
reg clk;
|
|
|
|
reg rst;
|
|
|
|
wire led;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// UART STUFF (testbench uart, simulating a comm. partner)
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
wire uart_rxd;
|
|
|
|
wire uart_txd;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Device Under Test
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
system #(
|
|
|
|
.clk_freq( clk_freq ),
|
|
|
|
.uart_baud_rate( uart_baud_rate )
|
|
|
|
) dut (
|
|
|
|
.clk( clk ),
|
|
|
|
// Debug
|
|
|
|
.rst( rst ),
|
|
|
|
.led( led ),
|
|
|
|
// Uart
|
|
|
|
.uart_rxd( uart_rxd ),
|
|
|
|
.uart_txd( uart_txd )
|
|
|
|
);
|
|
|
|
|
|
|
|
/* Clocking device */
|
|
|
|
initial clk <= 0;
|
|
|
|
always #(tck/2) clk <= ~clk;
|
|
|
|
|
|
|
|
/* Simulation setup */
|
|
|
|
initial begin
|
2010-09-22 01:05:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-26 05:49:58 +03:00
|
|
|
$dumpfile("system_tb.vcd");
|
2010-09-22 01:05:23 +03:00
|
|
|
//$monitor("%b,%b,%b,%b",clk,rst,uart_txd,uart_rxd);
|
2010-09-24 18:27:12 +03:00
|
|
|
// $dumpvars(-1, dut);
|
|
|
|
$dumpvars(-1,clk,rst,uart_txd,uart_rxd);
|
2010-05-26 05:49:58 +03:00
|
|
|
// reset
|
2010-06-11 16:06:13 +03:00
|
|
|
#0 rst <= 0;
|
|
|
|
#80 rst <= 1;
|
2010-05-26 05:49:58 +03:00
|
|
|
|
|
|
|
#(tck*10000) $finish;
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endmodule
|