Hello everyone!
A couple of days ago I started this thread
http://forum.6502.org/viewtopic.php?f=12&t=5470 regarding the use of a 74166 shift register to generate a composite video signal. To better explain how the signal was generated, I have layed down the rest of the schematics of the system as I have envisioned it. I would like to ask your help to make sure that what I have come up with is actually going to work! This is the first time I draw an electronic circuit schematic so there may be many errors, please forgive me! I've also tried to make a simple timing diagram to better understand the system operation, which you find attached.
The system operates as follows:
The system clock is 8MHz. However, the processor and memory run at 1MHz, so that 1 byte of video data can be generated every PHI0 cycle. Each video character is 8x8 pixels, therefore each character is 1uS "long". A composite video line signal is 64uS long, or exactly 64 characters (albeit some of those character will be used for the horizontal sync and front porch part of the signal).
Each video screen is 312 lines tall, or 39 characters (with some characters required for the vertical sync signal). Therefore, the screen has an height of 39 "rows" and a width of 64 "columns", and each row is divided in 8 lines.
The clock signal is generated by U23, an 8MHz can oscillator. It is connected to a 74163 counter, which is preset to binary value 1000, so that it will reach Terminal Counter after 8 clock periods. The TC signal is inverted an fed as /PL to the 74166 shift register to load the new byte of video data every 8 shifts. The sync signal is controlled by a charachter code of $FF and is generated by the comparator U13.
The video data is provided by U11, the character ROM. The input address for U11 is obtained by combining a "line" counter, which cycles from 0 to 7, and the actual character address. That address is stored in RAM, in a 64x39 = 2496 byte memory section.
The ROM does not directly read from the RAM, buth rather a flip-flop register (U10) is used to hold the character address. The register is loaded from RAM when PHI2 is low, using circuitry described below.
A set of 3 counters is used:
- a column counter (U14 and U15), which counts down from 63 to 0;
- a line counter (U18) which counts up from 0 to 7;
- a row counter (U16 and U17), which counts down from 38 to 0;
The PHI1 signal is fed in the column counter, which generates the first 6 bits of the character RAM address. The other 6 bits are provided by the row counter. Each time the column counter reaches 0, the line counter is increased. This way, all the 8 lines of each character are drawn sequentially. When the line counter reaches 7, the row counter is decreased to draw the next row of characters. When the row counter reaches 0, the screen has been fully drawn.
Memory access is controlled by two buffers, one for the CPU and one for the video counters. The CPU buffer is enabled when PHI1 is low, while the video buffer is enabled when PHI2 is low. The character register U10 is updated by the RE signal shown in the timing diagram, obtained as the OR result of PHI2 and output Q1 of the counter U9. I've used this approach so that the RAM /CS input is high when the control of the RAM itselft goes from the VIDEO circuit to the CPU, in an attempt to avoid spurious RAM writes.
The rest of the circuitry is quite standard, as it uses the glue logic explaned in the primer to also connect a ROM and one or multiple 6522 VIAs (only one shown in the scheme), the only difference beying in the RAM enable system to allow video memory output. Additional circuitry could be added to allow to change the character set (up to 16 different sets could be used) or to change the video memory location (maybe to allow fast screen changes or to read from ROM for static images).
Do you believe that the hereby described system may actually work? I am really inexperienced when it comes to timings, delays, setup times etc. In particular, I'm not sure if the register U20 would actually get loaded correctly, as its clock input goes high while the RAM is disabled.
Thank you in advance for your kind help!
Regards,
Davide