Subversion Repositories pentevo

Rev

Rev 668 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 668 Rev 684
Line 42... Line 42...
42
 
42
 
43
 
43
 
44
        // atm video mode input
44
        // atm video mode input
45
        input  wire        mode_atm_n_pent,
45
        input  wire        mode_atm_n_pent,
46
 
46
 
47
        input  wire        mode_60hz,
47
        input  wire [ 1:0] modes_raster,
48
 
48
 
49
 
49
 
50
        output reg         vblank,
50
        output reg         vblank,
51
        output reg         vsync,
51
        output reg         vsync,
52
 
52
 
Line 58... Line 58...
58
 
58
 
59
 
59
 
60
 
60
 
61
 
61
 
62
        localparam VBLNK_BEG = 9'd00;
62
        localparam VBLNK_BEG = 9'd00;
63
        localparam VSYNC_BEG = 9'd08;
-
 
64
        localparam VSYNC_END = 9'd11;
-
 
65
        localparam VBLNK_END = 9'd32;
-
 
66
 
63
 
67
        localparam INT_BEG = 9'd0;
64
        localparam VSYNC_BEG_50HZ = 9'd08;
-
 
65
        localparam VSYNC_END_50HZ = 9'd11;
-
 
66
        localparam VBLNK_END_50HZ = 9'd32;
68
 
67
       
-
 
68
        localparam VSYNC_BEG_60HZ = 9'd04;
-
 
69
        localparam VSYNC_END_60HZ = 9'd07;
-
 
70
        localparam VBLNK_END_60HZ = 9'd22;
-
 
71
 
-
 
72
 
69
        // pentagon (x192)
73
/*      // pentagon (x192)
70
        localparam VPIX_BEG_PENT = 9'd080;
74
        localparam VPIX_BEG_PENT = 9'd080;
71
        localparam VPIX_END_PENT = 9'd272;
75
        localparam VPIX_END_PENT = 9'd272;
72
 
76
 
73
        // ATM (x200)
77
        // ATM (x200)
74
        localparam VPIX_BEG_ATM = 9'd076;
78
        localparam VPIX_BEG_ATM = 9'd076;
75
        localparam VPIX_END_ATM = 9'd276;
79
        localparam VPIX_END_ATM = 9'd276;
-
 
80
*/
-
 
81
 
-
 
82
        localparam VPIX_BEG_PENTAGON = 9'd076; // for pentagon raster: actual begin is for x200 s, add 4 for x192 modes
-
 
83
        localparam VPIX_END_PENTAGON = 9'd272; // actual end is for x192 modes, add 4 for x200 modes.
76
 
84
 
-
 
85
        localparam VPIX_BEG_60HZ     = 9'd042;
77
        localparam VPERIOD = 9'd320; // pentagono foreva!
86
        localparam VPIX_END_60HZ     = 9'd238;
78
 
87
 
79
        // ntsc
88
        localparam VPIX_BEG_48K      = 9'd060;
80
        localparam VSYNC60_BEG = 9'd04;
89
        localparam VPIX_END_48K      = 9'd256;
-
 
90
 
81
        localparam VSYNC60_END = 9'd07;
91
        localparam VPIX_BEG_128K     = 9'd059;
82
        localparam VBLNK60_END = 9'd22;
92
        localparam VPIX_END_128K     = 9'd255;
-
 
93
 
-
 
94
/*      // ntsc
83
        // pentagon (x192)
95
        // pentagon (x192)
84
        localparam VPIX60_BEG_PENT = 9'd046;
96
        localparam VPIX60_BEG_PENT = 9'd046;
85
        localparam VPIX60_END_PENT = 9'd238;
97
        localparam VPIX60_END_PENT = 9'd238;
86
        // ATM (x200)
98
        // ATM (x200)
87
        localparam VPIX60_BEG_ATM = 9'd042;
99
        localparam VPIX60_BEG_ATM = 9'd042;
88
        localparam VPIX60_END_ATM = 9'd242;
100
        localparam VPIX60_END_ATM = 9'd242;
89
        //
101
*/      //
-
 
102
 
-
 
103
        localparam VPERIOD_PENTAGON = 9'd320;
90
        localparam VPERIOD60 = 9'd262;
104
        localparam VPERIOD_60HZ     = 9'd262;
-
 
105
        localparam VPERIOD_48K      = 9'd312;
-
 
106
        localparam VPERIOD_128K     = 9'd311;
-
 
107
 
-
 
108
 
-
 
109
        localparam INT_BEG      = 9'd0;
-
 
110
        localparam INT_BEG_48K  = 9'd1;
-
 
111
        localparam INT_BEG_128K = 9'd1;
-
 
112
       
-
 
113
       
91
 
114
       
92
        reg [8:0] vcount;
115
        reg [8:0] vcount;
93
        reg mode60;
-
 
94
 
116
 
-
 
117
        reg [8:0] vperiod;
-
 
118
        reg [8:0] vpix_beg;
-
 
119
        reg [8:0] vpix_end;
95
 
120
 
96
 
121
 
97
 
122
 
98
        initial
123
        initial // for simulation only
99
        begin
124
        begin
100
                vcount = 9'd0;
125
                vcount = 9'd0;
101
                vsync = 1'b0;
126
                vsync = 1'b0;
102
                vblank = 1'b0;
127
                vblank = 1'b0;
103
                vpix = 1'b0;
128
                vpix = 1'b0;
104
                int_start = 1'b0;
129
                int_start = 1'b0;
-
 
130
                vperiod = 'd0;
-
 
131
                vpix_beg = 'd0;
-
 
132
                vpix_end = 'd0;
105
        end
133
        end
106
 
134
 
-
 
135
        always @(posedge clk)
-
 
136
        case( modes_raster )
-
 
137
                default: vperiod <= VPERIOD_PENTAGON - 9'd1;
-
 
138
                2'b01:   vperiod <= VPERIOD_60HZ     - 9'd1;
-
 
139
                2'b10:   vperiod <= VPERIOD_48K      - 9'd1;
-
 
140
                2'b11:   vperiod <= VPERIOD_128K     - 9'd1;
-
 
141
        endcase
-
 
142
 
-
 
143
        always @(posedge clk)
-
 
144
        case( modes_raster )
-
 
145
                default: vpix_beg <= VPIX_BEG_PENTAGON;
-
 
146
                2'b01:   vpix_beg <= VPIX_BEG_60HZ    ;
-
 
147
                2'b10:   vpix_beg <= VPIX_BEG_48K     ;
-
 
148
                2'b11:   vpix_beg <= VPIX_BEG_128K    ;
-
 
149
        endcase
-
 
150
 
-
 
151
        always @(posedge clk)
-
 
152
        case( modes_raster )
-
 
153
                default: vpix_end <= VPIX_END_PENTAGON;
-
 
154
                2'b01:   vpix_end <= VPIX_END_60HZ    ;
-
 
155
                2'b10:   vpix_end <= VPIX_END_48K     ;
-
 
156
                2'b11:   vpix_end <= VPIX_END_128K    ;
-
 
157
        endcase
-
 
158
 
-
 
159
 
107
        always @(posedge clk) if( hsync_start )
160
        always @(posedge clk) if( hsync_start )
108
        begin
161
        begin
109
                if( vcount==((mode60?VPERIOD60:VPERIOD)-9'd1) )
162
                if( vcount==vperiod )
110
                begin
163
                begin
111
                        vcount <= 9'd0;
164
                        vcount <= 9'd0;
112
                        mode60 <= mode_60hz;
-
 
113
                end
165
                end
114
                else
166
                else
115
                        vcount <= vcount + 9'd1;
167
                        vcount <= vcount + 9'd1;
116
        end
168
        end
117
 
169
 
Line 119... Line 171...
119
 
171
 
120
        always @(posedge clk) if( hsync_start )
172
        always @(posedge clk) if( hsync_start )
121
        begin
173
        begin
122
                if( vcount==VBLNK_BEG )
174
                if( vcount==VBLNK_BEG )
123
                        vblank <= 1'b1;
175
                        vblank <= 1'b1;
124
                else if( vcount==(mode60?VBLNK60_END:VBLNK_END) )
176
                else if( vcount==( (modes_raster==2'b01) ? VBLNK_END_60HZ : VBLNK_END_50HZ ) )
125
                        vblank <= 1'b0;
177
                        vblank <= 1'b0;
126
        end
178
        end
127
 
179
 
128
 
180
 
129
        always @(posedge clk)
181
        always @(posedge clk)
130
        begin
182
        begin
131
                if( (vcount==(mode60?VSYNC60_BEG:VSYNC_BEG)) && hsync_start )
183
                if( vcount==( modes_raster==2'b01 ? VSYNC_BEG_60HZ : VSYNC_BEG_50HZ ) && hsync_start )
132
                        vsync <= 1'b1;
184
                        vsync <= 1'b1;
133
                else if( (vcount==(mode60?VSYNC60_END:VSYNC_END)) && line_start  )
185
                else if( vcount==( modes_raster==2'b01 ? VSYNC_END_60HZ : VSYNC_END_50HZ ) && line_start  )
134
                        vsync <= 1'b0;
186
                        vsync <= 1'b0;
135
        end
187
        end
136
 
188
 
137
 
189
 
138
        always @(posedge clk)
190
        always @(posedge clk)
139
        begin
191
        begin
-
 
192
                //if( hint_start && vcount==( modes_raster[1] ? (modes_raster[0] ? INT_BEG_128K : INT_BEG_48K) : INT_BEG ) )
140
                if( (vcount==INT_BEG) && hint_start )
193
                if( hint_start && vcount==( modes_raster[1] ? (modes_raster[0] ? INT_BEG_128K : INT_BEG_48K) : INT_BEG ) )
141
                        int_start <= 1'b1;
194
                        int_start <= 1'b1;
142
                else
195
                else
143
                        int_start <= 1'b0;
196
                        int_start <= 1'b0;
144
        end
197
        end
145
 
198
 
146
 
199
 
147
 
200
 
148
        always @(posedge clk) if( hsync_start )
201
        always @(posedge clk) if( hsync_start )
149
        begin
202
        begin
150
                if( vcount==(mode60?(mode_atm_n_pent ? VPIX60_BEG_ATM : VPIX60_BEG_PENT):(mode_atm_n_pent ? VPIX_BEG_ATM : VPIX_BEG_PENT)) )
203
                if( vcount==(vpix_beg + (9'd4 & {9{~mode_atm_n_pent}})) )
151
                        vpix <= 1'b1;
204
                        vpix <= 1'b1;
152
                else if( vcount==(mode60?(mode_atm_n_pent ? VPIX60_END_ATM : VPIX60_END_PENT):(mode_atm_n_pent ? VPIX_END_ATM : VPIX_END_PENT)) )
205
                else if( vcount==(vpix_end + (9'd4 & {9{mode_atm_n_pent}})) )
153
                        vpix <= 1'b0;
206
                        vpix <= 1'b0;
154
        end
207
        end
155
 
208
 
156
 
209
 
157
endmodule
210
endmodule