Author Topic: Designing a 8-bit VGA card  (Read 2161 times)

0 Members and 1 Guest are viewing this topic.

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Designing a 8-bit VGA card
« on: July 17, 2023, 06:20:18 pm »
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 lol
I'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 mode and Graphics mode.
Text mode doesn'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 bus
  • 3 pins - Z80 to MCU address lines
  • 1 pin - IOREQ
  • 1 pin - Z80 WR
  • 1 pin - Z80 RD
  • 1 pin - Chip Select
  • 8 pins - MCU to framebuffer RAM data
  • 4 pins - MCU to framebuffer address
  • 1 pin - MCU to framebuffer RAM WR
  • 1 pin - MCU to framebuffer Enable

Total: 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.


But graphics mode on 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: [Select]
LD     A, VID_ADDRESS_MSB
OUT    (VIDEO_WR)
LD     A, VID_ADDRESS_LSB
OUT    (VIDEO_WR)
LD     A, ACTUAL_VID_DATA
OUT    (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.
« Last Edit: July 17, 2023, 06:39:40 pm by JamesIsAwkward »
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7841
  • Country: ca
Re: Designing a 8-bit VGA card
« Reply #1 on: July 17, 2023, 10:48:31 pm »
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.
« Last Edit: July 17, 2023, 10:51:51 pm by BrianHG »
 

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Re: Designing a 8-bit VGA card
« Reply #2 on: July 18, 2023, 01:23:37 pm »
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...
 

Offline granzeier

  • Regular Contributor
  • *
  • Posts: 84
  • Country: us
Re: Designing a 8-bit VGA card
« Reply #3 on: July 19, 2023, 03:03:46 am »
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.
 
The following users thanked this post: I wanted a rude username

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Designing a 8-bit VGA card
« Reply #4 on: July 19, 2023, 07:47:24 am »
Similar concept to the PropTerm on the Propeller from Parallax, is the PicoMite implemented with a RPI Pico MPU

You can buy a kit here
(it comes with a built-in text editor, it's not that bad)
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6437
  • Country: ro
Re: Designing a 8-bit VGA card
« Reply #5 on: July 19, 2023, 09:40:05 am »
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  :scared::

Knight Lore Walkthrough, ZX Spectrum
RZX Archive




Today 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.

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Re: Designing a 8-bit VGA card
« Reply #6 on: July 20, 2023, 01:35:05 pm »
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.
 

Offline granzeier

  • Regular Contributor
  • *
  • Posts: 84
  • Country: us
Re: Designing a 8-bit VGA card
« Reply #7 on: July 21, 2023, 12:12:50 pm »
...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.
...
Marco 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
All functions are carried out by its 8 cores that run a firmware capable of generating a VGA signal with a resolution of 80×25 characters (720×400 pixels at 70Hz), manage the USB (or PS/2) protocol for the connection of a standard PC keyboard, manage the serial interface with baud rates ranging from a minimum of 9600 up to a maximum of 115200 bits per second and ANSI / VT-100 emulation.
 

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Re: Designing a 8-bit VGA card
« Reply #8 on: July 21, 2023, 01:32:48 pm »
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....
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Designing a 8-bit VGA card
« Reply #9 on: July 21, 2023, 02:16:44 pm »
VGA 640x480 is fine

even 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.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Re: Designing a 8-bit VGA card
« Reply #10 on: July 21, 2023, 04:08:35 pm »
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
 

Offline granzeier

  • Regular Contributor
  • *
  • Posts: 84
  • Country: us
Re: Designing a 8-bit VGA card
« Reply #11 on: July 21, 2023, 04:13:24 pm »
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
I 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.
 

Offline JamesIsAwkwardTopic starter

  • Contributor
  • Posts: 15
Re: Designing a 8-bit VGA card
« Reply #12 on: July 21, 2023, 04:17:32 pm »
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!
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6437
  • Country: ro
Re: Designing a 8-bit VGA card
« Reply #13 on: July 21, 2023, 04:39:08 pm »
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.

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14764
  • Country: fr
Re: Designing a 8-bit VGA card
« Reply #14 on: July 21, 2023, 09:05:47 pm »
You can otherwise also use a RP2040 of course.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf