OpenCores
URL https://opencores.org/ocsvn/sdram_16bit/sdram_16bit/trunk

Subversion Repositories sdram_16bit

[/] [sdram_16bit/] [trunk/] [testbench/] [top_tb.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ultra_embe
`timescale 100ps/100ps
2
 
3
//-----------------------------------------------------------------
4
// Module
5
//-----------------------------------------------------------------
6
module top_tb ;
7
 
8
//-----------------------------------------------------------------
9
// Simulation
10
//-----------------------------------------------------------------
11
`include "simulation.svh"
12
 
13
`CLOCK_GEN(clk, 200)
14
`RESET_GEN(rst, 200)
15
 
16
`ifdef TRACE
17
    `TB_VCD(top_tb, "waveform.vcd")
18
`endif
19
 
20
`TB_RUN_FOR(10ms)
21
 
22
//-----------------------------------------------------------------
23
// Registers / Wires
24
//-----------------------------------------------------------------
25
wire [31:0] addr;
26
wire [31:0] data_w;
27
wire [31:0] data_r;
28
wire [3:0]  sel;
29
wire [2:0]  cti;
30
wire        stb;
31
wire        cyc;
32
wire        we;
33
wire        stall;
34
wire        ack;
35
 
36
// SDRAM Interface
37
wire          sdram_clk;
38
wire          sdram_cke;
39
wire          sdram_cs;
40
wire          sdram_ras;
41
wire          sdram_cas;
42
wire          sdram_we;
43
wire [1:0]    sdram_dqm;
44
wire [12:0]   sdram_addr;
45
wire [1:0]    sdram_ba;
46
wire [15:0]   sdram_data;
47
 
48
//-----------------------------------------------------------------
49
// Instantiation
50
//-----------------------------------------------------------------
51
 
52
// Wishbone master
53
wb_master
54
#(
55
    .MIN_ADDRESS(0),
56
    .MAX_ADDRESS(`MAX_ADDRESS),
57
    .BURST_ENABLED(1),
58
    .READ_ONLY(0)
59
)
60
u_master
61
(
62
    .clk_i(clk),
63
    .rst_i(rst),
64
 
65
    // Wishbone I/F
66
    .addr_o(addr),
67
    .data_o(data_w),
68
    .data_i(data_r),
69
    .stb_o(stb),
70
    .sel_o(sel),
71
    .cyc_o(cyc),
72
    .cti_o(cti),
73
    .we_o(we),
74
    .stall_i(stall),
75
    .ack_i(ack)
76
);
77
 
78
// SDRAM Controller
79
sdram
80
#(
81
    .SDRAM_START_DELAY(1000),
82
    .SDRAM_TARGET("SIMULATION")
83
)
84
u_dut
85
(
86
    .clk_i(clk),
87
    .rst_i(rst),
88
 
89
    // Wishbone I/F
90
    .addr_i(addr),
91
    .data_i(data_w),
92
    .data_o(data_r),
93
    .stb_i(stb),
94
    .sel_i(sel),
95
    .cyc_i(cyc),
96
    .we_i(we),
97
    .stall_o(stall),
98
    .ack_o(ack),
99
 
100
    // SDRAM Interface
101
    .sdram_clk_o(sdram_clk),
102
    .sdram_cke_o(sdram_cke),
103
    .sdram_cs_o(sdram_cs),
104
    .sdram_ras_o(sdram_ras),
105
    .sdram_cas_o(sdram_cas),
106
    .sdram_we_o(sdram_we),
107
    .sdram_dqm_o(sdram_dqm),
108
    .sdram_addr_o(sdram_addr),
109
    .sdram_ba_o(sdram_ba),
110
    .sdram_data_io(sdram_data)
111
);
112
 
113
// SDRAM
114
`PART
115
u_ram
116
(
117
    .dq(sdram_data),
118
    .addr(sdram_addr),
119
    .ba(sdram_ba),
120
    .clk(sdram_clk),
121
    .cke(sdram_cke),
122
    .csb(sdram_cs),
123
    .rasb(sdram_ras),
124
    .casb(sdram_cas),
125
    .web(sdram_we),
126
    .dqm(sdram_dqm)
127
);
128
 
129
//-------------------------------------------------------------------
130
// Debug
131
//-------------------------------------------------------------------
132
integer perf_cycles;
133
integer perf_resps;
134
 
135
initial
136
begin
137
    perf_cycles = 0;
138
    perf_resps  = 0;
139
end
140
 
141
always @ (posedge clk)
142
begin
143
    perf_cycles = perf_cycles + 1;
144
    if (ack)
145
        perf_resps  = perf_resps + 1;
146
 
147
    if (perf_cycles == 50000)
148
    begin
149
        $display("Transfer Rate = %dMB/s\n", ((perf_resps * 4) * 1000) / 1048576);
150
        perf_resps = 0;
151
        perf_cycles = 0;
152
    end
153
end
154
 
155
//-----------------------------------------------------------------
156
// Test bench timeout
157
//-----------------------------------------------------------------
158
`TB_TIMEOUT(clk, rst, stb && !stall, 100000)
159
 
160
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.