-
Notifications
You must be signed in to change notification settings - Fork 1
/
system_tb.v
85 lines (68 loc) · 2.29 KB
/
system_tb.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
`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 = 115200; // 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;
wire uart_rxd1;
wire uart_txd1;
//----------------------------------------------------------------------------
// I2C
//----------------------------------------------------------------------------
wire i2c_scl, i2c_sda;
reg sda_out = 1'bz;
assign i2c_sda = sda_out;
//----------------------------------------------------------------------------
// Device Under Test
//----------------------------------------------------------------------------
system #(
.clk_freq( clk_freq ),
.uart_baud_rate( uart_baud_rate )
) dut (
.clk( clk ),
// Debug
.rst( rst ),
.led( led ),
// UART0
.uart_rxd( uart_rxd ),
.uart_txd( uart_txd ),
// UART1
.uart_rxd1( uart_rxd1 ),
.uart_txd1( uart_txd1 ),
// I2C Wires
.sda(i2c_sda),
.scl(i2c_scl)
);
/* Clocking device */
initial begin
clk <= 0;
end
always #(tck/2) clk <= ~clk;
/* Simulation setup */
initial begin
$dumpfile("system_tb.vcd");
//$monitor("%b,%b,%b,%b",clk,rst,uart_txd,uart_rxd);
$dumpvars(-1, dut);
//$dumpvars(-1,clk,rst,uart_txd);
// reset
#0 rst <= 0;
#80 rst <= 1;
#(tck*100000) $finish;
end
endmodule