-
Card Design Fixes and the Simulator
06/12/2024 at 17:08 • 0 commentsI spent an all-nighter making a simulator for the card, which can load the schematic from KiCad, then spent an egregious amount of time in the sim making the card work. As promised last log, I will show a bit more on the simulator:
For those that prefer reading over watching, I'll do some brief explanation of the simulator, then go over the card itself.
About the Simulator
The simulator loads the KiCad PCB file, constructing a netlist and list of components. There's a (small) component library, which has a simulation model for each component type. The simulator schedules chip updates based on each IC's propagation delay, so the simulator should be largely accurate from a timing perspective too.
I love MUXes
I replaced many of the logic gates with MUXes, as it is a lot easier to understand what the logic is doing, and the logic is just so much more flexible this way. I got the idea from LUTs in FPGAs, which work in a very similar fashion. The MUXes can accept quite a lot of inputs if you're creative, since you have select lines, enable lines, and inputs - this can afford you a lot more logic per chip than logic gates.
I think I went over this in my last log but I don't remember; well, I needed to change the RAM ICs. The speeds on this board are extremely fast, with a maximum of a 32Mhz pixel clock. I needed RAM that could read/write in less than 30ns for the card to have the whole display written fast enough from the Teensy (or whatever other device). Hopefully I did my math right because I already made the card use different RAM ICs, and these are blazing fast, at 25ns. Unfortunately, this dramatically reduces the maximum graphics memory, which is now 128K (up to 262144 pixels). These numbers are halved if you use hardware double buffering. This limits the highest resolutions to 640x400, or 540x480, for example. This bothers me, so maybe I'll have to make an upgraded card in the future.
For reference, here is the RAM chip I'm using now: https://www.renesas.com/us/en/document/dst/71256sa-datasheet
Schematics and Other Details
I think the design will work, based on the simulation, so I'm finally uploading the schematics after this log is posted. This time I'll add the component libraries and such too, so there will be less issues a few years from now in KiCad 11.0, or whatever will be brewing by then.
-
Problems with the New Version - and a Simulator
06/03/2024 at 23:01 • 0 commentsMy board design had a LOT of problems.
Let's take inventory of my mistakes, so you can hold them against me:
- The address connections A16 and A17 from the VRAM to the uPD7220 were not set up completely right, causing a strange monitor flicker in mixed mode, and lack of memory access if the software didn't have a special setup
- VRAM control lines were not generated correctly
- The VRAM was not fast enough to do what I had in mind. I thought I checked this and I knew the timing was close, so I must have done my math wrong.
- Probably something else I forgot
I thought there might be a minor issue or two with the design, as the design of the VRAM access is very ambitious - accessing two words per cycle using careful timing, then switching what device controls the memory every other cycle. Yes, a lot can go wrong. But what I didn't expect, is that so much would go wrong. I practically have to re-design more than half the board. Well, that is more or less what I've been working on.
Here's a video showing what the debugging was like; hopefully the video isn't too chaotic:
At some point I realized that I couldn't figure this all out by messing with the hardware directly - there were just too many things wrong with the board. The breadboard was losing me both signal integrity and voltage - the board ran at less than 4.3v. I needed a simulator. Well, I wrote one. It works decently well, loads my schematics straight from KiCad, can show me the VGA video output, and has a few other random features. Here's the source on my personal gitlab server, and here is a picture of it:
-
V2 Board Design
05/12/2024 at 01:12 • 0 commentsKiCad 3D render of my board design:I tried to make the parts of the circuit clearly visible on the board. I also added LEDs, which I typically forget when designing a board. Every board needs blinking lights. Well, I think this board has turned out nicely, at least in the 3D render; it has the clean look I wanted.
-
V2 Schematic Ready
05/11/2024 at 20:14 • 0 commentsI have the schematic finished now. I checked the major critical paths to the VRAM, fining one that was too slow. The VRAM takes up to 55ns from address input to data output, and I have only 62.5ns, so really it is super close. Since the uPD7220 uses an address latching mechanism, I managed to move my address-modifying critical path to before this latching is done. The timing there is much more forgiving. Other than that, I added some pretty LEDs and checked/fixed some of the logic done in the circuit.I may add more decoupling capacitors still, but that isn't a real design change. The capacitors are the only SMD components I'm using.
-
New Schematic is Nearly Complete
05/10/2024 at 18:55 • 0 commentsMy schematic so far:
This schematic is way better organized, and hopefully it will still make sense to me 5 years from now. I've added a ton of features since the last board revision, namely:
- The CPU can now directly access the VRAM
- I doubled the maximum pixel clock by allowing for uPD7220's wide mode (see last log)
- Added support for double buffering
- I octupled the maximum VRAM to 512KiB from 32KiB. Now we can have larger resolutions with enough RAM left over to double-buffer
Doing all this added a TON of extra logic, so if you compare the above schematic with the schematic of the previous board, this one has at least twice the components, and is far denser.
I had to add a lot of buffers so that the VRAM bus could be shared. This concerns me because it adds a few tens of nanoseconds to certain datapaths, meanwhile I've doubled the maximum VRAM clock speed to 16Mhz. The VRAM uses 55ns alone, and that doesn't count any of the hardware for uPD7220 memory cycle detection, bus sharing logic, etc. So the next step will include checking my datapaths to make sure all the components process fast enough for my clocks.
-
"Wide display mode"
05/09/2024 at 16:20 • 0 comments -
We can certainly make this better.
05/09/2024 at 15:39 • 0 commentsI hadn't looked at this project in a long time, and the other day I was browsing it and noticed several comments asking for the schematics. But hadn't I uploaded schematics? So I double checked the files, found the attached schematic zip, and decided to open it up. Oh geez, what a mess! It had been created with a very old KiCad version compared to today, and I don't think I uploaded the symbol libraries, so the schematics were useless. I can see now why people asked for the schematics!
Very useful indeed. (not) I spent some time the other day cleaning this up, as well as fixing a few hardware bugs related to the color DAC and oscillator. I modified the schematic to match the modifications on my board at home, which works quite well. Here's the schematic now, which I uploaded: -
Zilog Made a Clone!
04/18/2019 at 01:47 • 0 commentsI bought this chip off of Ebay. It seems that Zilog created a uPD7220 clone - and it works! These chips seem to be rather rare and information on them is scarce. I did manage to deduce that there were two variants of chips: one operating at 6Mhz, and one at 8Mhz. I got the 8Mhz one and tried doubling my pixel clock to 16Mhz (the GDC uses a halved clock). That worked too, and that allowed me to make a more stable video signal. I had a problem with the 8Mhz pixel clock where there was not time to output a valid video signal. Now I can output more pixels than I have VRAM for.
The chip is also a super pretty Zilog gem <3
-
Rendering characters!
04/05/2019 at 19:41 • 0 commentsI've managed to make my card render characters! I used the Z80 computer this project was originally intended for this time, instead of the Arduino testbench.
There is not a font yet, so I just rendered a bunch of smiley faces and tested that the program could keep track of the cursor position.
It's working very well, but I would like to render things a bit faster. I think the Z80 math routines run slow however, for calculating cursor positions and colors.
It doesn't help that my card has 16 colors - it appears that the uPD7220 was designed to just do black and white. This means that I have to send a few more commands to the uPD7220 to select a group of bits for a pixel (multiple colors) instead of just one bit (black and white). The uPD7220 automatically selects a single bit when a command is sent to set the VRAM address, but my program must select multiple.
Here is my graphics driver for the Z80: https://github.com/NuclearManD/z80-code/blob/master/G00nOS/upd7220.z80
You may need to look at some of the other files, but all graphics functions are there (er, rather, the ones I've written thus far).
-
Finally on HaD after more than a year! And finally working!
04/04/2019 at 06:29 • 0 commentsOver a year ago I wanted a graphics card for my Z80 computer. I made a prototype with the uPD7220, but I never got it working. Until...
As it turned out, I made TONS on mistakes in the original design. There are issues with the new design too, but it works well enough (after a hack, more on that later). Anyway, after playing with the first prototype and trying various hacks, I ended up with a valid VGA signal!
I don't think the uPD7220 was ever supposed to output VGA, considering VGA was introduced about four years after the uPD was, so it's awesome that it can output a VGA signal.
After studying the uPD datasheet and my schematic in depth, I eventually found most of the problems and ended up with my second prototype (which I am using now). I've managed to get it to do the basic things I need it to do. Getting from basic initialization to drawing pixels was very difficult, especially with such a complex device and no example code/libraries, but it was definately worth it. I now want to share what I've learned about it so that more people can use this GDC (GDC = Graphic Display Controller).
I plan on adding more and more information to this project so others can use my work as a reference. I also am going to create a Z80 driver, which I will post here as well.