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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [bench/] [rtfBitmpController_tb.v] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 robfinch
// ============================================================================
2
//  Bitmap Controller Test Bench
3
//
4
//        __
5
//   \\__/ o\    (C) 2008-2013  Robert Finch, Stratford
6
//    \  __ /    All rights reserved.
7
//     \/_//     robfinch<remove>@opencores.org
8
//       ||
9
//
10
//
11
// This source file is free software: you can redistribute it and/or modify 
12
// it under the terms of the GNU Lesser General Public License as published 
13
// by the Free Software Foundation, either version 3 of the License, or     
14
// (at your option) any later version.                                      
15
//                                                                          
16
// This source file is distributed in the hope that it will be useful,      
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
19
// GNU General Public License for more details.                             
20
//                                                                          
21
// You should have received a copy of the GNU General Public License        
22
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
23
//                                                                          
24
//
25
//      Verilog 1995
26
//
27
// ============================================================================
28
 
29
module rtfBitmapController_tb();
30
 
31
reg rst;
32
reg pixel_clk;
33
reg sys_clk;
34
wire hsync;
35
wire vsync;
36
wire blank;
37
wire border;
38
wire [23:0] bm_rgb;
39
reg bmp_clk;
40
wire [1:0] bm_bte;
41
wire [2:0] bm_cti;
42
wire bm_cyc;
43
wire bm_stb;
44
wire bm_ack;
45
wire [33:0] bm_adr_o;
46
wire [31:0] bm_dat_i;
47
reg cyc,stb,we;
48
reg [33:0] adr;
49
reg [31:0] dat;
50
reg [7:0] state;
51
reg [9:0] x;
52
wire ack;
53
 
54
initial begin
55
        #0 rst <= 1'b0;
56
        #0 pixel_clk <= 1'b0;
57
        #0 bmp_clk <= 1'b0;
58
        #0 sys_clk <= 1'b0;
59
        #0 lfsr <= 32'd0;
60
        #10 rst <= 1'b1;
61
        #40 rst <= 1'b0;
62
end
63
 
64
always #5.83 pixel_clk <= ~pixel_clk;
65
always #4 bmp_clk <= ~bmp_clk;
66
always #20 sys_clk <= ~sys_clk;
67
 
68
 
69
reg [31:0] lfsr;
70
wire lfsr_fb;
71
xnor(lfsr_fb,lfsr[0],lfsr[1],lfsr[21],lfsr[31]);
72
assign bm_ack = bm_cyc;
73
assign bm_dat_i = lfsr;
74
always @(posedge bmp_clk)
75
        lfsr <= {lfsr[30:0],lfsr_fb};
76
 
77
WXGASyncGen1366x768_60Hz u3
78
(
79
        .rst(rst),
80
        .clk(pixel_clk),
81
        .hSync(hsync),
82
        .vSync(vsync),
83
        .blank(blank),
84
        .border(border)
85
);
86
 
87
rtfBitmapController ubmc
88
(
89
        .rst_i(rst),
90
 
91
        .s_clk_i(sys_clk),
92
        .s_cyc_i(cyc),
93
        .s_stb_i(cyc),
94
        .s_ack_o(ack),
95
        .s_we_i(we),
96
        .s_adr_i(adr),
97
        .s_dat_i(dat),
98
 
99
        .clk_i(bmp_clk),
100
        .bte_o(bm_bte),
101
        .cti_o(bm_cti),
102
        .bl_o(bm_bl),
103
        .cyc_o(bm_cyc),
104
        .stb_o(bm_stb),
105
        .ack_i(bm_ack),
106
        .we_o(),
107
        .sel_o(),
108
        .adr_o(bm_adr_o),
109
        .dat_i(bm_dat_i),
110
        .dat_o(),
111
 
112
        .vclk(pixel_clk),
113
        .hSync(hsync),
114
        .vSync(vsync),
115
        .blank(blank),
116
        .rgbo(bm_rgb),
117
        .xonoff(1'b1)
118
);
119
 
120
always @(posedge sys_clk)
121
if (rst) begin
122
        state <= 8'd0;
123
end
124
else begin
125
case(state)
126
0:       begin
127
        x <= 0;
128
        wb_write(32'hFFDC5000,32'h00000601);
129
        end
130
1:      wb_nack();
131
2:      wb_write(32'hFFDC5002,12'd1364);
132
3:      wb_nack();
133
4:      wb_write(32'hFFDC5800+x,lfsr);
134
5:      wb_nack();
135
6:      begin
136
                x <= x + 10'd1;
137
                if (x < 10'd512)
138
                        state <= 4;
139
                else
140
                        next_state();
141
        end
142
7:      state <= 7;
143
endcase
144
end
145
 
146
task wb_write;
147
input [31:0] ad;
148
input [31:0] dt;
149
begin
150
        cyc <= 1'b1;
151
        we <= 1'b1;
152
        adr <= {ad,2'b00};
153
        dat <= dt;
154
        next_state();
155
end
156
endtask
157
 
158
task wb_nack;
159
begin
160
        if (ack) begin
161
                cyc <= 1'b0;
162
                we <= 1'b0;
163
                next_state();
164
        end
165
end
166
endtask
167
 
168
task next_state;
169
begin
170
        state <= state + 8'd1;
171
end
172
endtask
173
 
174
endmodule

powered by: WebSVN 2.1.0

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