Help me understand how to design a video controller. - Page 1
Forum section: electronics / beginners

author: MarkS
author_rank: Unknown
timestamp: March 04, 2012, 10:01:20 pm
content: I want to start working on a 68030-based computer/game system as soon as funds allow. I can salvage a 25 MHz 68030 from an old Mac LC II, so I have the processor which is otherwise nearly impossible to source.I'm doing this as a learning exercise. I do not know nearly enough to build this, which is the point. I am going to research this step by step and thoroughly. There are two issues that truly have me perplexed though. One is sound generation, and the other is video. I'm going to worry about sound later. I'll need to see something to debug this, so video is a priority.My goal for video is 1024x768 8-bit at 60 Hz, using a VGA connector.I understand the basics. I have a section of memory as a frame buffer. The frame buffer is read 60 times a second, with each byte being translated by a color table to produce three bytes (red, green and blue). These bytes are then sent through a DAC (I'm looking at theADV7125), whose output is then sent to the VGA port and monitor.This, however, leaves me with tons of questions that I simply cannot find the answer to. From what I can gather about the VGA specifications (actually XGA in my case), I will need a 65 MHz pixel clock. That means that I am sending pixels to the monitor at 65 MHz. That also means that I must have pixel data to send at 65 MHz. How do I read from memory at 65 MHz when the processor is operating at 25 MHz. I would assume a separate video controller chip (maybe FPGA), but how can that work? The processor is so much slower that it cannot possibly finish a write to the frame buffer before the video controller comes back around to the data being written. I've looked into dual port RAM, but the prices are astronomical, so that is out.I know there are a lot of questions that I am not asking, but I don't know exactly what to ask. The problem that I am having is that the computer I am designing is so old that the information I am trying to find is all but nonexistent. Google searches are not turning up much. This is making it very hard to do research.How would I do this? Can anyone provide me with some references? All I have is a book, "Computer Graphics: Principles and Practice", which is useful since it was written at a time where the technology in question was still relevant. However, it references quite a bit of chips and processes that no longer exist or cannot be replicated with current chips and processes.I'm hoping someone has some ideas.

author: unknowndomain
author_rank: Regular Contributor
timestamp: March 04, 2012, 10:26:43 pm
content: Seems like you are jumping off into the deep end, you should probably assess looking into a easier project to start with, I know you said thats the point but you have gone way past intermediate into mega hard.

author: MarkS
author_rank: Unknown
timestamp: March 04, 2012, 11:06:04 pm
content: I really don't think this is mega hard, just mega uninformed. The sound and video are the only two parts that I can find no references on and the rest of the computer is really very easy. I'll be using SRAM and the 68030 has a built in MMU designed for SRAM. Most of the processor interfacing is really very easy and I have another book just on 68000 system design.I know that I can do this, but I must get past this video barrier.

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 04, 2012, 11:29:29 pm
content: If you're not adverse to using an FPGA then I would start by looking at reference designs such as this one:http://www.digilentinc.com/Data/Documents/Reference%20Designs/VGA%20RefComp.zipThat particular design supports 640x480 and 800x600. I'm sure you can find a 1024x768 reference design out there.That ZIP contains a PDF document as well as the VHDL code to implement a VGA controller. As you can see, it isn't particularly difficult.Refer to this document (sheet #10) to get an idea of what it will take hardware-wise to implement an 8-bit VGA interface:http://www.digilentinc.com/Data/Products/NEXYS2/Nexys2_sch.pdfAs you can see, it's butt-simple. No need for a DAC.If you do use an FPGA then that's likely where your color table will reside. The FPGA will also be the CPU's interface to the display memory. You can use cheap SRAM and just have the FPGA give priority to the display driver so far as memory access goes.Obviously there's more than one way to skin a cat but that's were I'd start.

author: amspire
author_rank: Super Contributor
timestamp: March 04, 2012, 11:32:51 pm
content: Sounds like you are trying to re-invent 1980. Building your own VGA graphics is a great design exercise, but you have to remember just how totally bad the graphics was back then.You said 8 bits - is that is 8 bit per channel color or 8 bits color converted in the graphics circuit to 24 bit color with a table (ie in the software, you can pick a 256 color palette, and then that is all you have to work with)? Lets assume you mean 8 bit color with a lookup table in the graphics.The way graphics had to work back then is that the processor is so slow that it is having trouble writing a complete frame in the period of a frame, even if the processor is doing nothing else. So the usual solution was to have several different frame buffers so while the graphics is using one buffer to write out to the screen, you are loading a second buffer from the micro. In this way, the graphics chip never needs to use the same memory chip at the same time as the micro.But lets say the memory bus can read and write at a full 25MHz, and you have to get each byte from somewhere first, so it takes at minimum a read and a write cycle to load one byte to graphics. I am assuming DMA, so we do not have to worry about reading instructions. Then 1024x168 bytes takes at absolute best 30 mS to write a whole screen full, so even if the processor is doing nothing else, it can only just manage to update the screen at 30Hz. If you plan to run software on the processor, you are going to struggle to get 15 screens per second refresh rate. So back in the 80's programmers had to be extremely inventive in fudging it. Ideas like sprites where you only change a tiny bit of the video memory for each frame.Things have just moved so many orders of magnitude past that point now that is it worth trying to build a system with an obsolete processor? Why not just run one of the 68000 game simulators on a modern computer, and look at a more contemporary project? I would never start a microprocessor project with just one microprocessor, so how much will it cost you to get several spare 68000 processors?Richard.

author: MarkS
author_rank: Unknown
timestamp: March 05, 2012, 03:26:06 am
content: I would prefer NOT to use an FPGA, but something tells me that isn't going to be possible. I'm also thinking that 1024x768 is a bit overreaching. Maybe 640x480.

author: Psi
author_rank: Super Contributor
timestamp: March 05, 2012, 03:50:35 am
content: Quote from: MarkS on March 04, 2012, 10:01:20 pmIf you're doing it as a learning exercise you should pick a modern microcontroller.That way;- More of the knowledge you gain will be useful to further your career.- You can spec a 300mhz ARM CPU and probably do 60fps in software if you really want to.- You wont pull your hair out trying to debug something with 20 year old tools that may not even run on modern computers.- If you accidentally blow up the 68030 you wont have to abandon the project. (almost always happens on large projects)- If you need help you wont have to visit a retirement village to find someone who knows about the platformjkHaving info in your CV about working with ARM hardware will be infinitely more useful than info about the Motorola 68030.On the other hand, if you're doing it just for kicks and love working with old hardware... Go for it!

author: joelby
author_rank: Frequent Contributor
timestamp: March 05, 2012, 03:54:58 am
content: Until you decide it's time to design your own controller from scratch, you could consider an existing solution, such as theGameduino, which won't do 1024x768, but it is very sophisticated for the price ($53).Since it's based on an FPGA, you could always modify it or write your own controller later if you wanted to. If you want higher resolution, you could consider using something a bit fancier like a Spartan-6 with DVI-D outputs.

author: MarkS
author_rank: Unknown
timestamp: March 05, 2012, 04:05:25 am
content: Quote from: Psi on March 05, 2012, 03:50:35 amIt is more this than anything else. However, I have gone the microcontroller route before and am familiar with it. I am more interested in familiarizing myself with the construction of an actual computer, and since my first computer was a Mac 512K and I learned to program on Macs, I have a certain level of sentiment for the 68000 series.I figure that this would be about as basic of a computer as I can get and still have it somewhat usable. Once I fully understand how to design a computer from the component level, I can move up to better (yet still old) processors like the 486 and beyond.

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 05, 2012, 04:10:14 am
content: Quote from: MarkS on March 05, 2012, 03:26:06 amI think an FPGA can actually buy you a lot of flexibility in this particular case. You might be able to leverage it for your sound support, for example. You can use it for I/O expansion and all kinds of 'glue logic' type of stuff. And it's not like you need an expensive one either.Yes, 640x480 might be a good place to start. If you do just a little bit of planning ahead then you should be able to support higher resolutions with pretty much the same hardware. You might just have to swap out a crystal, perhaps. Or, if you put it on a daughter board then you can just call the first version a proof of concept.Richard mentioned double buffering. That's something you might want to consider. It's not like SRAM's terribly expensive. Heck, you could even use triple buffering. The nice thing about doing one-offs is price is much less of a concern. So it costs you an extra 10 bucks? Whoop-de-do.You would have the FPGA do the buffer copying. This would leave the CPU to other tasks. Also, the FPGA will likely be running much faster than the CPU. You could run it at a multiple of the pixel clock.I misspoke when I said you wouldn't need a DAC. If you're going to have a 24-bit color space, then, yes, 8-bit DACs for each of the channels might be nice.Sounds like a fun project.Edit:You might consider SDRAM as well. This will allow you to leverage the 'burst' mode feature which will be handy when copying and when blitting to the display.

author: kripton2035
author_rank: Super Contributor
timestamp: March 05, 2012, 07:56:17 am
content: here is a full example fpga with source codeit may help you to understand the functions...it's rather "only" 320x240 but I think it's a good start.regards,http://elm-chan.org/works/crtc/report.html

author: amyk
author_rank: Super Contributor
timestamp: March 05, 2012, 11:52:39 am
content: Quote from: MarkS on March 04, 2012, 10:01:20 pmYou can salvage plenty of that from old video cards.Here is a good introduction to generating the necessary signals, you just need to couple that with VRAM to produce a workable display controller:http://faculty.lasierra.edu/~ehwang/public/mypublications/VGA%20Monitor%20Controller.pdf