VDP Madness

Building your first 6502-based project? We'll help you get started here.
Post Reply
ramblecube
Posts: 3
Joined: 22 Sep 2019

VDP Madness

Post by ramblecube »

I'm working on designing my first homebrew computer, and I have a good handle on most every component- except for the VDP.

I could live without video and go for serial/term output, but my goal is to have composite output. Additionally, I'm trying to avoid using an FPGA, AVR, Gameduino, or Propeller.

My goal is to use a TMS9918. It's well documented, but there are a few problems:

- It needs a specialized 10.738633MHz clock for NTSC sync, which I can't find on eBay or AliExpress
- It's built for DRAM, and while there's a SRAM glue logic solution that I'm trying to wrap my head around, I'm having a fair amount of trouble understanding it
- There are some timing differences between the 6502 and the VDP which I'm not sure how to handle
- I don't know if interrupts are required to make good use of the chip, and I'm not sure how interrupts work

Basically, I can understand the "instantaneous" components of the design, like the RAM, ROM, CPU, I/O chips, glue logic, etc... I can probably even handle a sound chip. However, the VDP portion of the design seems unusually complex.

I'm a little lost! I have an incomplete schematic right now, with the RAM, CPU, reset circuitry, etc. implemented.... but that VDP has me toast! :|

Am I in over my head? Thanks, guys.
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: VDP Madness

Post by floobydust »

I would recommend searching for the CRT Controller Handbook by Gerry Kane. You can find a download for certain. It doesn’t cover the 9918 controller, but several others and covers the basics of video generation very well. This would give you a solid background on video and perhaps persuade you to a different controller as well.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: VDP Madness

Post by Dr Jefyll »

Welcome, ramblecube! :)
ramblecube wrote:
I could live without video and go for serial/term output, but my goal is to have composite output.
Since it's your first homebrew, it might be wise to make operation with serial your first goal, then let video be Step Two of the plan. What construction technique do you have in mind? PCB maybe isn't the best option, compared with wirewrap, soldered point-to-point, and solderless breadboard. These latter choices have more flexibility for fixing design errors and adding features.

That crystal frequency you mention needn't be 100% exact, btw -- video monitors (especially the old CRT type) have a degree of tolerance regarding scan frequencies. And the DRAM and other issues you cite don't seem to me like deal breakers, especially if you already have a working computer before you begin the video phase.

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
ttlworks
Posts: 1464
Joined: 09 Nov 2012
Contact:

Re: VDP Madness

Post by ttlworks »

Welcome to the forum.

Since it's your first computer, I would suggest to add an UART to the design, and to go with the address decoding of Daryl Rictor's SBC-2
This would give you the chance to test with a RS232 connection if your computer works as intended.
Then to add the TMS9918 as a second step.

When using the 'search' function, it appears that the TMS9918 already went mentioned in our forum quite a few times.
Edit: searching HaD for TMS9918 might be helpful, too.
Last edited by ttlworks on Mon Sep 23, 2019 10:55 am, edited 1 time in total.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: VDP Madness

Post by BigEd »

Welcome! As others have said, it's best to first build something simple and work your way up. Things you don't understand at present will become more clear.

For the crystal, it looks like you should be able to find one at 21.47727 MHZ and then divide by two.

If you don't have an electronics reference, I'd recommend Horowitz and Hill's Art of Electronics, and I'd also recommend searching https://electronics.stackexchange.com/
Martin A
Posts: 197
Joined: 02 Jan 2016

Re: VDP Madness

Post by Martin A »

The 9918/28/29 uses a crystal directly between pins 39 and 40. A quick check on Mouser shows they have a couple of thousand in stock. If you use a 21.7mhz crystal divided by 2, the data sheet says both Xtal1 and Xtal2 need to be driven.

The VDP's usual ram chips while being fairly easy to find on ebay etch, are something of a pain to use, since the 4116 needs 3 supplies.
ramblecube
Posts: 3
Joined: 22 Sep 2019

Re: VDP Madness

Post by ramblecube »

floobydust wrote:
I would recommend searching for the CRT Controller Handbook by Gerry Kane. You can find a download for certain. It doesn’t cover the 9918 controller, but several others and covers the basics of video generation very well. This would give you a solid background on video and perhaps persuade you to a different controller as well.
I read first part, as well as the parts for the DP83520. I think I finally understand video generation- through my past in Genesis disassembles, I understood the software end, but the clouds are clearing on the hardware side of things.

Thank you so so much for the suggestion!
ramblecube
Posts: 3
Joined: 22 Sep 2019

Re: VDP Madness

Post by ramblecube »

BigEd wrote:
Welcome! As others have said, it's best to first build something simple and work your way up. Things you don't understand at present will become more clear.

For the crystal, it looks like you should be able to find one at 21.47727 MHZ and then divide by two.

If you don't have an electronics reference, I'd recommend Horowitz and Hill's Art of Electronics, and I'd also recommend searching https://electronics.stackexchange.com/
Martin A wrote:
The 9918/28/29 uses a crystal directly between pins 39 and 40. A quick check on Mouser shows they have a couple of thousand in stock. If you use a 21.7mhz crystal divided by 2, the data sheet says both Xtal1 and Xtal2 need to be driven.

The VDP's usual ram chips while being fairly easy to find on ebay etch, are something of a pain to use, since the 4116 needs 3 supplies.
I didn't know about clock divisions until now. That could save me from buying a crystal, too!
dolomiah
Posts: 102
Joined: 18 Nov 2015
Location: UK
Contact:

Re: VDP Madness

Post by dolomiah »

Your project is very similar to mine - I have built a 65c02 computer with TMS9918 as the VDP.

As recommended by others, I would also say get it working through serial first and build from there. This is what I did too.

The next step for interfacing a TMS9918 is a bit fiddly but rewarding and works well once done - the capabilities are pretty good for late 1970s and the composite video output is easy to connect to a monitor.

On the clock for the VDP
- I also had difficulty in sourcing a 10.738635Mhz crystal, but as noted by BigEd and others, you can use a 21.47727Mhz crystal which are easier to find
- I use the 21.7 crystal as the clock for a 4-bit counter (74xx161) then use the Q0 output to drive the VDP at 10.738635Mhz to XTAL1 and XTAL2 (remembering to invert one of them of course)
- Indeed I also used the Q1 output to drive the 65c02 at 5.36Mhz and Q3 to drive my keyboard strobe and sound chip at 1.34Mhz

On the interface to the 65c02
- More glue is needed as the VDP needs /CSW and /CSR with MODE to be asserted properly
- MODE in mine is A0 from the CPU address bus i.e. I access VDP RAM on even address (A0=0) and VDP status/control register on odd (A0=1)
- /CSW and /CSR need to be derived from your address decoding scheme and CPU R/W

On the SRAM interface
- There is an excellent article which shows how to wire up the VDP to a regular SRAM - without this it would have been a non-starter for me
- Again it's a fair bit of building to do, but not highly complex and works well

On the software side, I had to put in some delays (NOP instructions) between writing a command to the VDP (e.g. to read VRAM) and reading the result - this is for a 5.36Mhz 65c02, but I think even at 1Mhz one or two NOPs were needed.

Hope this helps in your decisions! I definitely recommend getting board to work over serial first so that you have some way to communicate with the computer whilst you get the VDP working..

More outline details on hackaday - https://hackaday.io/project/5789-6502-homebrew-computer
Post Reply