VIDEO:This is how I will try to generate video.
After viewing Ben Eater's
The world’s worst video card? video, I started to really think about building my own SBC. Yes, there are projects everywhere that use FPGAs or ATMega or PIC chips. But that relies on software emulating hardware, a think that I want not to do.
I decided to go 400x300 pixels screen area, drawn on 800x600 display resolution. 400x300 are 120000 pixels, and with 1 byte of color information for every pixel, it would need 120000 bytes for the screen bitmap.
To generate the signal I will use high speed counters. The part I'm thinking about is the CD74AC163E, that accepts clock speeds up to 103Mhz with 5V. But I don't need that much. I would go with 40 mhz. But If I only need 20mhz to draw 400x300 resolution, why not to choose 20mhz clock then? Well, I'm thinking of make the counter to send the MCU a FCLK tick every 5th clock tick. Timing would be:
Code:
"C" is every cycle of the main oscillator running at 40mhz.
"V" is every pulse sent by the counter array to the FAST SRAM.
"M" is every pulse sent by the counter array to the MCU.
1 2 3 4 5
12345678901234567890123456789012345678901234567890...
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...
V V V V V V V V V V V V V V V V V V V V V V V V V ...
M M M M M
My logic here is that every 2 cycles of the CLK, the counter gets one that sends to the SRAM to get a value from it (20mhz effective). And every odd 5th cycle, the MCU gets its FCLK input (8mhz effective). Alternating this way, the FAST video SRAM should be free to be accessed both by the video circuit and the MCU.
Following
this timing, it seems that every line of 400 pixels would need about 20μs to be drawn, and then there is a delay of 6,4μs where the SRAM is
not accessed, because the sync signals are generated with no data at all. 20μs = 20000ns. So 20000ns / 400 pixels = 50ns. It takes 50ns to draw a single pixel. A FAST SRAM of 15ns is more than enough to serve for that purpose. For every MCU cycle, the video circuit draws 5 pixels. This relation is higher even than the one the C64 had: for every CPU cycle, the VIC-II would draw 8 pixels.
But that leaves the timing with 4 free
slots of memory access that could be used by other chips that could do DMA access alternated with the video circuit. Maybe the CPU could write to the memory and a sound chip read from there, instead of I/O'ing the chip directly. Or an external or even second CPU or co-processor to write results of calculations done at higher clock speeds, like 3D acceleration or complex graphics generation, freeing the CPU of doing that.
I wrote earlier than a 400x300x8 bitmap would need a 120000 bytes of memory, and the FAST SRAM chips would provide 8000 bytes more, that are most than enough to use it as the
interface that would share those other chips.
What do you think? Is this feasible? Please, do comment if the numbers and ideas are right, wrong, doable... Because maybe all my theory is just wrong because of me misunderstanding all of this.