@@ -60,20 +60,22 @@ component saa5050_rom IS
60
60
);
61
61
end component ;
62
62
63
- -- Data input registered in the bus clock domain
63
+ -- Register inputs in the bus clock domain
64
64
signal di_r : std_logic_vector (6 downto 0 );
65
+ signal dew_r : std_logic ;
66
+ signal lose_r : std_logic ;
65
67
-- Data input registered in the pixel clock domain
66
68
signal code : std_logic_vector (6 downto 0 );
67
69
signal line_addr : unsigned (3 downto 0 );
68
70
signal rom_address : std_logic_vector (11 downto 0 );
69
71
signal rom_data : std_logic_vector (7 downto 0 );
70
72
71
- -- Latched timing signals for detection of falling edges
72
- signal dew_r : std_logic ;
73
- signal lose_r : std_logic ;
74
73
-- Delayed display enable derived from LOSE by delaying for one character
75
74
signal disp_enable : std_logic ;
76
- signal disp_enable_r : std_logic ;
75
+ -- Latched timing signals for detection of falling edges
76
+ signal dew_latch : std_logic ;
77
+ signal lose_latch : std_logic ;
78
+ signal disp_enable_latch : std_logic ;
77
79
78
80
-- Row and column addressing is handled externally. We just need to
79
81
-- keep track of which of the 10 lines we are on within the character...
@@ -116,13 +118,17 @@ begin
116
118
-- Generate flash signal for 3:1 ratio
117
119
flash <= flash_counter(5 ) and flash_counter(4 );
118
120
119
- -- Sync data input
121
+ -- Sync inputs
120
122
process (DI_CLOCK,nRESET)
121
123
begin
122
124
if nRESET = '0' then
123
125
di_r <= (others => '0' );
126
+ dew_r <= '0' ;
127
+ lose_r <= '0' ;
124
128
elsif rising_edge (DI_CLOCK) and DI_CLKEN = '1' then
125
129
di_r <= DI;
130
+ dew_r <= DEW;
131
+ lose_r <= LOSE;
126
132
end if ;
127
133
end process ;
128
134
@@ -145,88 +151,59 @@ begin
145
151
rom_address <= (others => '0' ) when (double_high = '0' and double_high2 = '1' ) else
146
152
gfx & code & std_logic_vector (line_addr);
147
153
148
- -- process(CLOCK,nRESET)
149
- -- variable line_addr : unsigned(3 downto 0);
150
- -- variable c : std_logic_vector(6 downto 0);
151
- -- begin
152
- -- -- Derive line address taking double height into account
153
- -- if double_high = '1' then
154
- -- line_addr := "0" & line_counter(3 downto 1);
155
- -- if double_high2 = '1' then
156
- -- line_addr := line_addr + 5;
157
- -- end if;
158
- -- else
159
- -- line_addr := line_counter;
160
- -- end if;
161
- --
162
- -- -- If this is the second row of a double height pair and double_high
163
- -- -- is not asserted then we fetch a blank instead (0)
164
- -- if double_high = '0' and double_high2 = '1' then
165
- -- c := (others => '0');
166
- -- else
167
- -- c := di_r;
168
- -- end if;
169
- --
170
- -- if nRESET = '0' then
171
- -- rom_address <= (others => '0');
172
- -- elsif rising_edge(CLOCK) and CLKEN = '1' then
173
- -- rom_address <= gfx & c & std_logic_vector(line_addr);
174
- -- end if;
175
- -- end process;
176
-
177
154
-- Character row and pixel counters
178
155
process (CLOCK,nRESET)
179
156
begin
180
157
if nRESET = '0' then
181
- dew_r <= '0' ;
182
- lose_r <= '0' ;
158
+ dew_latch <= '0' ;
159
+ lose_latch <= '0' ;
183
160
disp_enable <= '0' ;
184
- disp_enable_r <= '0' ;
161
+ disp_enable_latch <= '0' ;
185
162
double_high1 <= '0' ;
186
163
double_high2 <= '0' ;
187
164
line_counter <= (others => '0' );
188
165
pixel_counter <= (others => '0' );
189
166
flash_counter <= (others => '0' );
190
167
elsif rising_edge (CLOCK) and CLKEN = '1' then
191
168
-- Register syncs for edge detection
192
- dew_r <= DEW ;
193
- lose_r <= LOSE ;
194
- disp_enable_r <= disp_enable;
169
+ dew_latch <= dew_r ;
170
+ lose_latch <= lose_r ;
171
+ disp_enable_latch <= disp_enable;
195
172
196
173
-- When first entering double-height mode start on top row
197
174
if double_high = '1' and double_high1 = '0' and double_high2 = '0' then
198
175
double_high1 <= '1' ;
199
176
end if ;
200
177
178
+ -- Count pixels between 0 and 5
179
+ if pixel_counter = 5 then
180
+ -- Start of next character and delayed display enable
181
+ pixel_counter <= (others => '0' );
182
+ disp_enable <= lose_latch;
183
+ else
184
+ pixel_counter <= pixel_counter + 1 ;
185
+ end if ;
186
+
201
187
-- Rising edge of LOSE is the start of the active line
202
- if LOSE = '1' and lose_r = '0' then
188
+ if lose_r = '1' and lose_latch = '0' then
203
189
-- Reset pixel counter - small offset to make the output
204
190
-- line up with the cursor from the video ULA
205
- pixel_counter <= "010" ;
206
- else
207
- -- Count pixels between 0 and 5
208
- if pixel_counter = 5 then
209
- -- Start of next character and delayed display enable
210
- pixel_counter <= (others => '0' );
211
- disp_enable <= lose_r;
212
- else
213
- pixel_counter <= pixel_counter + 1 ;
214
- end if ;
191
+ pixel_counter <= "011" ;
192
+ end if ;
193
+
194
+ -- Count frames on end of VSYNC (falling edge of DEW)
195
+ if dew_r = '0' and dew_latch = '1' then
196
+ flash_counter <= flash_counter + 1 ;
215
197
end if ;
216
198
217
- if DEW = '1' then
199
+ if dew_r = '1' then
218
200
-- Reset line counter and double height state during VSYNC
219
201
line_counter <= (others => '0' );
220
202
double_high1 <= '0' ;
221
203
double_high2 <= '0' ;
222
204
else
223
- -- Count frames on end of VSYNC (falling edge of DEW)
224
- if DEW = '0' and dew_r = '1' then
225
- flash_counter <= flash_counter + 1 ;
226
- end if ;
227
-
228
205
-- Count lines on end of active video (falling edge of disp_enable)
229
- if disp_enable = '0' and disp_enable_r = '1' then
206
+ if disp_enable = '0' and disp_enable_latch = '1' then
230
207
if line_counter = 9 then
231
208
line_counter <= (others => '0' );
232
209
0 commit comments