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

Subversion Repositories vga_lcd

[/] [vga_lcd/] [trunk/] [rtl/] [verilog/] [vga_wb_slave.v] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 rudi
//
2
// file: wb_slave.v
3
// project: VGA/LCD controller
4
// author: Richard Herveille
5
// rev 1.0 August  6th, 2001. Initial verilog release
6
//
7
 
8
`include "timescale.v"
9
 
10
module vga_wb_slave(CLK_I, RST_I, nRESET, ADR_I, DAT_I, DAT_O, SEL_I, WE_I, STB_I, CYC_I, ACK_O, ERR_O, INTA_O,
11
                bl, csl, vsl, hsl, pc, cd, vbl, cbsw, vbsw, ven, avmp, acmp, bsint_in, hint_in, vint_in, luint_in, sint_in,
12
                Thsync, Thgdel, Thgate, Thlen, Tvsync, Tvgdel, Tvgate, Tvlen, VBARa, VBARb, CBAR);
13
 
14
        //
15
        // inputs & outputs
16
        //
17
 
18
        // wishbone slave interface
19
        input         CLK_I;
20
        input         RST_I;
21
        input         nRESET;
22
        input  [ 4:2] ADR_I;
23
        input  [31:0] DAT_I;
24
        output [31:0] DAT_O;
25
        reg [31:0] DAT_O;
26
        input  [ 3:0] SEL_I;
27
        input         WE_I;
28
        input         STB_I;
29
        input         CYC_I;
30
        output        ACK_O;
31
        output        ERR_O;
32
        output        INTA_O;
33
 
34
        // control register settings
35
        output bl;   // blanking level
36
        output csl;  // composite sync level
37
        output vsl;  // vsync level
38
        output hsl;  // hsync level
39
        output pc;   // pseudo color
40
        output [1:0] cd;   // color depth
41
        output [1:0] vbl;  // video memory burst length
42
        output cbsw; // clut bank switch enable
43
        output vbsw; // video memory bank switch enable
44
        output ven;  // vdeio system enable
45
 
46
        // status register inputs
47
        input avmp;     // active video memory page
48
        input acmp;     // active clut memory page
49
        input bsint_in; // bank switch interrupt request
50
        input hint_in;  // hsync interrupt request
51
        input vint_in;  // vsync interrupt request
52
        input luint_in; // line fifo underrun interrupt request
53
        input sint_in;  // system error interrupt request
54
 
55
        // Horizontal Timing Register
56
        output [ 7:0] Thsync;
57
        output [ 7:0] Thgdel;
58
        output [15:0] Thgate;
59
        output [15:0] Thlen;
60
 
61
        // Vertical Timing Register
62
        output [ 7:0] Tvsync;
63
        output [ 7:0] Tvgdel;
64
        output [15:0] Tvgate;
65
        output [15:0] Tvlen;
66
 
67
        output [31: 2] VBARa;
68
        reg [31: 2] VBARa;
69
        output [31: 2] VBARb;
70
        reg [31: 2] VBARb;
71
        output [31:11] CBAR;
72
        reg [31:11] CBAR;
73
 
74
        //
75
        // variable declarations
76
        //
77
        parameter [2:0] CTRL_ADR  = 3'b000;
78
        parameter [2:0] STAT_ADR  = 3'b001;
79
        parameter [2:0] HTIM_ADR  = 3'b010;
80
        parameter [2:0] VTIM_ADR  = 3'b011;
81
        parameter [2:0] HVLEN_ADR = 3'b100;
82
        parameter [2:0] VBARA_ADR = 3'b101;
83
        parameter [2:0] VBARB_ADR = 3'b110;
84
        parameter [2:0] CBAR_ADR  = 3'b111;
85
 
86
 
87
        reg [31:0] ctrl, stat, htim, vtim, hvlen;
88
        wire HINT, VINT, BSINT, LUINT, SINT;
89
        wire hie, vie, bsie;
90
        wire acc, acc32, reg_acc;
91
 
92
        //
93
        // Module body
94
        //
95
 
96
        assign acc     = CYC_I & STB_I;
97
        assign acc32   = (SEL_I == 4'b1111);
98
        assign reg_acc = acc & acc32  & WE_I;
99
        assign ACK_O   = acc &  acc32;
100
        assign ERR_O   = acc & !acc32;
101
 
102
 
103
        // generate registers
104
        always@(posedge CLK_I or negedge nRESET)
105
        begin : gen_regs
106
                if(!nRESET)
107
                        begin
108
                                htim  <= #1 0;
109
                                vtim  <= #1 0;
110
                                hvlen <= #1 0;
111
                                VBARa <= #1 0;
112
                                VBARb <= #1 0;
113
                                CBAR  <= #1 0;
114
                        end
115
                else if (RST_I)
116
                        begin
117
                                htim  <= #1 0;
118
                                vtim  <= #1 0;
119
                                hvlen <= #1 0;
120
                                VBARa <= #1 0;
121
                                VBARb <= #1 0;
122
                                CBAR  <= #1 0;
123
                        end
124
                else if (reg_acc)
125
                        case (ADR_I)    // synopsis full_case parallel_case
126
                                HTIM_ADR  : htim  <= #1 DAT_I;
127
                                VTIM_ADR  : vtim  <= #1 DAT_I;
128
                                HVLEN_ADR : hvlen <= #1 DAT_I;
129
                                VBARA_ADR : VBARa <= #1 DAT_I[31: 2];
130
                                VBARB_ADR : VBARb <= #1 DAT_I[31: 2];
131
                                CBAR_ADR  : CBAR  <= #1 DAT_I[31:11];
132
                        endcase
133
        end
134
 
135
 
136
        // generate control register
137
        always@(posedge CLK_I or negedge nRESET)
138
                if (!nRESET)
139
                        ctrl <= #1 0;
140
                else if (RST_I)
141
                        ctrl <= #1 0;
142
                else if (reg_acc & (ADR_I == CTRL_ADR) )
143
                        ctrl <= #1 DAT_I;
144
                else
145
                        begin
146
                                ctrl[5] <= #1 ctrl[5] & !bsint_in;
147
                                ctrl[4] <= #1 ctrl[4] & !bsint_in;
148
                        end
149
 
150
 
151
        // generate status register
152
        always@(posedge CLK_I or negedge nRESET)
153
                if (!nRESET)
154
                        stat <= #1 0;
155
                else if (RST_I)
156
                        stat <= #1 0;
157
                else
158
                        begin
159
                                stat[17] <= #1 acmp;
160
                                stat[16] <= #1 avmp;
161
                                if (reg_acc & (ADR_I == STAT_ADR) )
162
                                        begin
163
                                                stat[6] <= #1 bsint_in | (stat[6] & !DAT_I[6]);
164
                                                stat[5] <= #1 hint_in  | (stat[5] & !DAT_I[5]);
165
                                                stat[4] <= #1 vint_in  | (stat[4] & !DAT_I[4]);
166
                                                stat[1] <= #1 luint_in | (stat[3] & !DAT_I[1]);
167
                                                stat[0] <= #1 sint_in  | (stat[0] & !DAT_I[0]);
168
                                        end
169
                                else
170
                                        begin
171
                                                stat[6] <= #1 stat[6] | bsint_in;
172
                                                stat[5] <= #1 stat[5] | hint_in;
173
                                                stat[4] <= #1 stat[4] | vint_in;
174
                                                stat[1] <= #1 stat[1] | luint_in;
175
                                                stat[0] <= #1 stat[0] | sint_in;
176
                                        end
177
                        end
178
 
179
 
180
        // decode control register
181
        assign bl   = ctrl[15];
182
        assign csl  = ctrl[14];
183
        assign vsl  = ctrl[13];
184
        assign hsl  = ctrl[12];
185
        assign pc   = ctrl[11];
186
        assign cd   = ctrl[10:9];
187
        assign vbl  = ctrl[8:7];
188
        assign cbsw = ctrl[5];
189
        assign vbsw = ctrl[4];
190
        assign bsie = ctrl[3];
191
        assign hie  = ctrl[2];
192
        assign vie  = ctrl[1];
193
        assign ven  = ctrl[0];
194
 
195
        // decode status register
196
        assign BSINT = stat[6];
197
        assign HINT  = stat[5];
198
        assign VINT  = stat[4];
199
        assign LUINT = stat[1];
200
        assign SINT  = stat[0];
201
 
202
        // decode Horizontal Timing Register
203
        assign Thsync = htim[31:24];
204
        assign Thgdel = htim[23:16];
205
        assign Thgate = htim[15:0];
206
        assign Thlen  = hvlen[31:16];
207
 
208
        // decode Vertical Timing Register
209
        assign Tvsync = vtim[31:24];
210
        assign Tvgdel = vtim[23:16];
211
        assign Tvgate = vtim[15:0];
212
        assign Tvlen  = hvlen[15:0];
213
 
214
 
215
        // assign output
216
        always@(ADR_I or ctrl or stat or htim or vtim or hvlen or VBARa or VBARb or CBAR or acmp)
217
        case (ADR_I) // synopsis full_case parallel_case
218
                CTRL_ADR  : DAT_O = ctrl;
219
                STAT_ADR  : DAT_O = stat;
220
                HTIM_ADR  : DAT_O = htim;
221
                VTIM_ADR  : DAT_O = vtim;
222
                HVLEN_ADR : DAT_O = hvlen;
223
                VBARA_ADR : DAT_O = {VBARa, 2'b0};
224
                VBARB_ADR : DAT_O = {VBARb, 2'b0};
225
                CBAR_ADR  : DAT_O = {CBAR, acmp, 10'b0};
226
        endcase
227
 
228
        // generate interrupt request signal
229
        assign INTA_O = (HINT & hie) | (VINT & vie) | (BSINT & bsie) | LUINT | SINT;
230
endmodule
231
 
232
 
233
 
234
 

powered by: WebSVN 2.1.0

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