Designing a 8-bit VGA card - Page 1
Forum section: electronics / general

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 17, 2023, 06:20:18 pm
content: Hey everyone,Another project I'm working on is a simple "video card" for my Z80 system.Of course I've taken inspiration from Ben Eater, but now that I have the basics I'm looking to actually make this thing functional. I am running 640x480 but I've divided the pixel count by 4, so I'm really only running 160x120, which is 19200 pixels.I thought about using a modern MCU of some kind for the video controller... I know it is "cheating" on a build this old but I -really- hate composite. I know that's sacrilegious lolI'd much rather have VGA or something clear. Composite signals and CRTs just hurt my eyes!So instead of shelling out for old ICs on eBay, I'm just gonna try to homebrew a controller.So with these old video cards there are usually 2 modes.Text modeandGraphics mode.Text modedoesn't seem so bad, and will be my first goal on this project. This can easily be implemented in I/O space.Because I plan to do 8x8 pixel characters, my 19200 pixel/byte frame buffer can basically be reduced to a 300 byte frame buffer using character ROM.Actually less because I would have at least 1 character blank buffer around the perimeter of the screen.So the pins I would need on my MCU (Likely an Atmega32 or something with a high pin count) would be:8 pins - Z80 to MCU data bus3 pins - Z80 to MCU address lines1 pin - IOREQ1 pin - Z80 WR1 pin - Z80 RD1 pin - Chip Select8 pins - MCU to framebuffer RAM data4 pins - MCU to framebuffer address1 pin - MCU to framebuffer RAM WR1 pin - MCU to framebuffer EnableTotal: 29 pins I think?That leaves me 3 pins if I forgot something, I think it can be done with a 32 IO pin Atmega32.Butgraphics modeon the other hand... this won't really work. I would need 16 bit address space from the MCU to the frame buffer, not to mention the high overhead of writing 1 pixel would need 6 operations.Code:LD A, VID_ADDRESS_MSBOUT (VIDEO_WR)LD A, VID_ADDRESS_LSBOUT (VIDEO_WR)LD A, ACTUAL_VID_DATAOUT (VIDEO_WR)For text mode this is fine, roughly 131 cycles to write 1 letter on screen isn't a big deal, but if I'm wanting to write an entire frame buffer it is massive.Let's say I want to fill an entire screen (assuming the video controller doesn't have a blank command or something to do this without all of the overhead) it could take me almost 80ms to blank the frame buffer at 4MHz. Without a raster or DMA this would be awful.So I'm kind of stuck here. I want a graphics mode but FPGA's are kind of pricey.Maybe there is a happy medium? Maybe tile graphics or something? I would love to hear yall's thoughts!EDIT: If I really do have 2-3 pins left over on the MCU I could also use those to trigger latches connected to 2 RAM IC's enable pins and whatnot. Then I could use them to build a double frame buffer and switch between the RAM chips and then there would be seamless writing to the screen.

author: BrianHG
author_rank: Super Contributor
timestamp: July 17, 2023, 10:48:31 pm
content: Discussed and functioning here:https://www.eevblog.com/forum/fpga/fpga-vga-controller-for-8-bit-computer/Includes full windows, sprites, hardware accelerated geometry and blitter with rotate and image scaling with a stereo audio.All for a Z80, including built in MMU.Note that the Lattice ECP5 fpgas are now available once again. 20$ fpga could fit everything mentioned above with a DDR3 513mb of ram and SD card read/write & HDMI out with embedded sound.

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 18, 2023, 01:23:37 pm
content: Thanks Brian, I'll check this thread out!As for the Lattice ECP5... that is interesting...An FPGA would be the best bet for this video card honestly, and it has enough I/O to make it easy to implement on the circuit...

author: granzeier
author_rank: Regular Contributor
timestamp: July 19, 2023, 03:03:46 am
content: Another option would be the Propeller from Parallax (https://www.parallax.com/propeller-1/.) They run about $11 (https://www.mouser.com/c/semiconductors/embedded-processors-controllers/microcontrollers-mcu/32-bit-microcontrollers-mcu/?m=Parallax&series=Propeller&gclid=EAIaIQobChMIseDTheGZgAMV6szICh2R2AgQEAAYAyAAEgJv1_D_BwE.) There is a project called PropTerm (https://www.shaels.net/index.php/propterm,) which is an ANSI terminal built on the Propeller. The one presented in that link used the Propeller Proto Board, but if you look at the Proto Board schematics (https://www.mouser.com/datasheet/2/321/parallax_32212-propeller-protoboard-documentation--1197468.pdf, page 5) you can see that it only needs eight pins from the Propeller. Several people have used this for a simple VGA video card.In addition, Grant Searle uses an ATmega328 processor for video output and keyboard input (http://searle.x10host.com/MonitorKeyboard/index.html) for some of his systems. This produces 80x25 displays on either PAL, or NTSC.

author: DiTBho
author_rank: Super Contributor
timestamp: July 19, 2023, 07:47:24 am
content: Similar concept to thePropTermon thePropellerfrom Parallax, is the PicoMite implemented with a RPI Pico MPUYou can buy a kithere(it comes with a built-in text editor, it's not that bad)

author: RoGeorge
author_rank: Super Contributor
timestamp: July 19, 2023, 09:40:05 am
content: The usual approach for text terminals was to use a ROM to store the pixels of the character set. The output octet from the ROM was loaded in a parallel to serial register, and the serial stream of bits were turning on/off the pixels on the screen. The ROM was used as a lookup table.There were counters continuously counting the video lines pixels, and parts of them were tied to the address line of the ROM, and other bits from the counters were tied to the address lines of the RAM that was storing the entire 80x24 characters to be displayed on a screen. Same counters were used to create sync signals for lines and frames, needed to drive the spot on a cathodic ray tube.For a graphic display, some were using the same idea of counters tied to the address lines of a memory, just that they were mapping to the screen a piece of RAM instead.The tricky part was that that piece of RAM has to be addressed by both the video stream generator and the processor. Since the hardware was too scarce to use double buffering (for example ZX Spectrum was having only 8 bits as buffer, the parallel to serial register that was generating the video signals), it was tricky to make the processor read/write just between other reads needed by the video generator. It was a piece of memory will dual addressing, memory mapped pixels, nothing more. No graphic functions and no video acceleration. Even so, video games like this were possible (it was no sound card either, the sound is made by poking 1 bit tied to a speaker, all driven with a 3.5MHz Z80:Knight Lore Walkthrough, ZX SpectrumRZX ArchiveToday it would be a pity to not use an FPGA devboard as a videocard. Some devboards even have a HDMI output (or some more recent type of video connector). Monitors with VGA connectors became rare.I suspect your Z80 computer is mostly as a learning exercise, and an FPGA is the next learning step after designing with discreet logic chips. At first use an existing FPGA project, then you can experiment at any time with your own card design on the same hardware.

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 20, 2023, 01:35:05 pm
content: I was afraid of using an FPGA mostly because I'm not too practiced with SMT let alone BGA soldering. So when it came time to move all of this on to a PCB I was worried I wouldn't be able to design it or solder it properly.But the Propeller chip is a super interesting idea because it also comes in a DIP package... this is a seriously awesome suggestion.Do you think running it at the 640x480 standard clock of 25.175 MHz would be okay? I know it can go up to 80 MHz but I mean as far as signal propagation and all that goes. From a quick glance of the datasheet I can't find any propagation information.As far as sound goes I have a AY-3-8910 I want to use! I actually have 2 and thought about hacking together 2 channel sound.

author: granzeier
author_rank: Regular Contributor
timestamp: July 21, 2023, 12:12:50 pm
content: Quote from: JamesIsAwkward on July 20, 2023, 01:35:05 pmMarco Maccaferri has an article (https://www.maccasoft.com/electronics/vga-serial-terminal/) where he describes his VGA board for his RC2014 computer. He gives the specs as:Quote

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 21, 2023, 01:32:48 pm
content: And somehow he does that with only a 5 MHz clock?? What in the world? I was thinking of double or tripling my 640x480 60Hz clock to make sure I have enough wiggle room to create all of the signals....

author: DiTBho
author_rank: Super Contributor
timestamp: July 21, 2023, 02:16:44 pm
content: VGA 640x480 is fineeven with fonts 8x16: { colls, rows } = { 640, 480 } / { 8, 16 } = { 80, 30 }25Mhz is fine as "pixel clock" and practical for hobby stuff.p.s.you can use a "FPGA module" instead of soldering it on a PCB.

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 21, 2023, 04:08:35 pm
content: No I mean that project linked above with the propeller pulled off 640x480 with a 5MHz clock which doesn't make sense to me haha

author: granzeier
author_rank: Regular Contributor
timestamp: July 21, 2023, 04:13:24 pm
content: Quote from: JamesIsAwkward on July 21, 2023, 04:08:35 pmI admit that I have not read the entire article, just skimmed it. I have seen several of these Propeller VGA systems, several in person, and this looked like what you wanted.You will need to read the article in detail to put it to use in your computer. If this does not do the job, you can search for "parallax propeller VGA output". There are several other articles out there.

author: JamesIsAwkward
author_rank: Contributor
timestamp: July 21, 2023, 04:17:32 pm
content: Oh it looks like the propeller has an internal clock multiplier you can use, so 5MHz with the 16x internal multiplier is a 80MHz clock rate. Neat!

author: RoGeorge
author_rank: Super Contributor
timestamp: July 21, 2023, 04:39:08 pm
content: In case you settle for a Propeller chip, the one in the link looks like the first version of the chip. The author and designer of Propeller open sourced the HDL code of the chip a few years ago (so in theory it can be ported, if not ported already, into an FPGA design).That was after he designed a new chip, Propeller II, faster, bigger and with many other improvements. Might worth also looking into Propeller II, if you plan to buy the chip only and not the entire devboard.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 21, 2023, 09:05:47 pm
content: You can otherwise also use a RP2040 of course.