A $1 GPU?

Topics regarding the Uzebox hardware/AVCore/BaseBoard (i.e: PCB, resistors, connectors, part list, schematics, hardware issues, etc.) should go here.
tanjent
Posts: 5
Joined: Wed Feb 11, 2009 11:08 pm

A $1 GPU?

Post by tanjent »

So I've been pondering how to give the Uzebox more graphical oomph without breaking the wonderful simplicity of the design (i.e. not by adding microcontrollers, FPGAs, or any other sort of programmable logic).

Here's my (possibly terrible) idea -

Instead of keeping tiles in ROM, the Uzebox copies them to an external asynchronous SRAM. Then to draw a tile, the CPU just does something like (assuming 6 cycles / pixel like the current modes) -

ADD R12,R13 // R12 = pixel cursor, R13 = 1
OUT PORTB,R12 // PORTB connected to the low 8 pins of the SRAM
(free cycle here)
(free cycle here)
(free cycle here)
(free cycle here)
ADD R12,R130
OUT PORTB,R12
...

then after every 8 pixels you change R12, and during hblank you change the high bits of the address through some other port.

You'd be limited to 256 distinct pixels per scanline, which could either be a prerendered scanline or some sort of tile arrangement (you could pack the Nth row of 32 8-pixel-wide tiles into one row of SRAM)

I've read through the specs of this part - http://search.digikey.com/scripts/DkSea ... -2158-5-ND - and it seems like it might work. It's a 32k asynchronous SRAM with an access time of 15 nanoseconds (far faster than the pixel clock) and Digikey sells it for $1.44 in bulk, Mouser for $1.11 (though they don't have it stocked at the moment).

You could even patch it into the existing design (I think) without changing the rest of the hardware, depending on your kit (I've got an Adafruit one) - patch the SRAM into some unused port pins, patch the SRAM output pins into the current output, change the code to set the old output to high-impedance and write pixels to the new ports.

I'm not a hardware guy, I write video games for a living (as do apparently a good number of other people on this board), but I'm curious to see if this would work. I'll probably order a few SRAMs off Digikey and give it a whirl. :)

-tanjent
User avatar
TonyD
Posts: 134
Joined: Mon Oct 27, 2008 2:23 pm
Location: Newcastle, UK
Contact:

Re: A $1 GPU?

Post by TonyD »

Interesting idea you have there Tangent.

Have a look at http://tinyvga.com/avr-sdram-vga where a 8M SDRAM is used with a meg8515 to give a VGA output of 512x480 pixels with 256 colours. The design uses the burst mode of a SDRAM to read up to 512 bytes without MCU help. I think the SDRAM is clocked at 18.432MHz.

I was thinking of doing something similar using the burst write mode of a PC133 (133MHz clock) SDRAM to make a cheap logic analyzer or DSO with fast ADC.

- Tony
User avatar
pragma
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: A $1 GPU?

Post by pragma »

patch the SRAM output pins into the current output
I don't think that will work the way you think it will. Then again, I'm not an EE.

$0.02:
The problem, as I see it, is that a RAM chip has two "ports" on it: address and data. Obviously the data port is read/write, and the address is write only. The problem comes in where you have to write to the RAM since its data pins sit on the same "bus" with the resistor ladder and the NTSC encoder. So writes to this external SRAM will also change the voltage for the RGB pins on the encoder. I don't know enough about the behavior of that chip to say if this will generate side-effects during vblank or not. But writing to the video RAM during hblank and field time is right out; I guess you could render audio during all that time instead or something like that.

But I agree that more RAM is the key to bigger and better graphics modes on this architecture.
tanjent
Posts: 5
Joined: Wed Feb 11, 2009 11:08 pm

Re: A $1 GPU?

Post by tanjent »

pragma wrote:
patch the SRAM output pins into the current output
I don't think that will work the way you think it will. Then again, I'm not an EE.

$0.02:
The problem, as I see it, is that a RAM chip has two "ports" on it: address and data. Obviously the data port is read/write, and the address is write only. The problem comes in where you have to write to the RAM since its data pins sit on the same "bus" with the resistor ladder and the NTSC encoder. So writes to this external SRAM will also change the voltage for the RGB pins on the encoder. I don't know enough about the behavior of that chip to say if this will generate side-effects during vblank or not. But writing to the video RAM during hblank and field time is right out; I guess you could render audio during all that time instead or something like that.

But I agree that more RAM is the key to bigger and better graphics modes on this architecture.
Yeah, you could only write to the chip during HBLANK/VBLANK, or before the game starts up, then once you're done you put the write pins of the MCU into high-impedance mode and it shouldn't affect the output (I think). During rendering the MCU is only sending addresses to the chip, never data.
tanjent
Posts: 5
Joined: Wed Feb 11, 2009 11:08 pm

Re: A $1 GPU?

Post by tanjent »

TonyD wrote:Interesting idea you have there Tangent.

Have a look at http://tinyvga.com/avr-sdram-vga where a 8M SDRAM is used with a meg8515 to give a VGA output of 512x480 pixels with 256 colours. The design uses the burst mode of a SDRAM to read up to 512 bytes without MCU help. I think the SDRAM is clocked at 18.432MHz.

I was thinking of doing something similar using the burst write mode of a PC133 (133MHz clock) SDRAM to make a cheap logic analyzer or DSO with fast ADC.

- Tony
Similar idea, though the SRAM chip is vastly smaller and with a much simpler interface (write to address pins, data pops out the data pins 15ns later)
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: A $1 GPU?

Post by uze6666 »

Hmmm, I'd need to see a schematics of your idea. I thought a lot how to use external SRAM with minimum parts and without degrading performance. The biggest problem is that you don't have 15 free lines for addressing. Then there's the problem that during HSYNC & VBLANK video signal at the AD725 must be zero volts. Writing to the data port at that time would result in garbage and screwup of the TV sync. Maybe that could be done with the AD723, since it has a chip enable pin. Then there could be performance penalties if you need to split adresses/data writes to multiple ports. Nonetheless that could be a nice hack.

Anyway, that's a nice chip you found. It must be recent because apart the expensive NVSRAM, I ain't saw DIP SRAM for a while.

Uze
tanjent
Posts: 5
Joined: Wed Feb 11, 2009 11:08 pm

Re: A $1 GPU?

Post by tanjent »

uze6666 wrote:Hmmm, I'd need to see a schematics of your idea. I thought a lot how to use external SRAM with minimum parts and without degrading performance. The biggest problem is that you don't have 15 free lines for addressing. Then there's the problem that during HSYNC & VBLANK video signal at the AD725 must be zero volts. Writing to the data port at that time would result in garbage and screwup of the TV sync. Maybe that could be done with the AD723, since it has a chip enable pin. Then there could be performance penalties if you need to split adresses/data writes to multiple ports. Nonetheless that could be a nice hack.

Anyway, that's a nice chip you found. It must be recent because apart the expensive NVSRAM, I ain't saw DIP SRAM for a while.

Uze
Then you'd be forced to load your graphics data at startup and not change it during runtime. That might be a fair tradeoff, seeing as how the SRAM is big enough for 512 8x8 tiles.

I'm surprised there aren't plenty of free (or multiplexable) IO pins though - the chip has 32, what are they all being used for?

I'll play around with it and let you know what I find.
tanjent
Posts: 5
Joined: Wed Feb 11, 2009 11:08 pm

Re: A $1 GPU?

Post by tanjent »

uze6666 wrote:Hmmm, I'd need to see a schematics of your idea. I thought a lot how to use external SRAM with minimum parts and without degrading performance. The biggest problem is that you don't have 15 free lines for addressing. Then there's the problem that during HSYNC & VBLANK video signal at the AD725 must be zero volts. Writing to the data port at that time would result in garbage and screwup of the TV sync. Maybe that could be done with the AD723, since it has a chip enable pin. Then there could be performance penalties if you need to split adresses/data writes to multiple ports. Nonetheless that could be a nice hack.

Anyway, that's a nice chip you found. It must be recent because apart the expensive NVSRAM, I ain't saw DIP SRAM for a while.

Uze
Parts ordered, SRAMs should be here in another day or two.

In the meantime I've been pondering how to squeeze the chip into the design. Assuming I don't use the MMC card or the MIDI interface, it should be doable - I could move the joypad pins to port B, remove the seral pin on D0, and use ports A and D for address and C for data. I think there would be juuuust enough pins to do it - I'd also have to add a SRAM write enable pin, and you probably would have to rewrite the chip using an AVR ISP (pretty sure I'd have to use the serial bootloader pins for something else).

Or I could add a latch connecting port C and the IO pins on the SRAM and use port C both for the low 8 bits of the address and for data writing, and then I just have to steal pins from port D for the high 7 bits of address plus a few pins off A for write enable / latch output enable / latch. I've got some 8-bit latch chips that should do the trick.

First steps are going to be to hook the 644 to a breadboard and then hook all its pins back into the Uzebox board - hopefully this will work (and hopefully the crystal doesn't freak out about a few inches of jumper wire between it and the chip...). Then I'll try hooking up some pins to the SRAM and using it as a sort of palette look-up table. And from there all is chaos. :)

Weeeeeeeeee
Lerc
Posts: 64
Joined: Sat Aug 30, 2008 11:13 pm

Re: A $1 GPU?

Post by Lerc »

I'd been wondering about something along those lines myself. I found the TinyVGA site when hunting for info on how it might work.

As usual, I was thinking of going a bit more perverse and reading the data in then out again.

That way you can (maybe) do some trickery like have a SDRAM send you a series of bytes, The Main pixel loop can then maybe do sprites or something with the backdrop being provided by a simple IN instruction .

You'd have to do memory changing jiggery pokery during the blanks. I think The TinyVGA indicates it's in the ballpark of possible.
havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Re: A $1 GPU?

Post by havok1919 »

Something else worth looking at would be check out old Macintosh video memory SIMM/DIMMs. Those old VRAMs (or newer SGRAMs, etc) often had dual data ports that could be independently clocked. I actually used an older video FIFO (like for TV's) on a product which was super easy-- those have separate read/write pointers so the CPU can just write pixels "whenever it can" and then the pixel clock shifts pixels out at a regular rate. As long as the two pointers never pass each other you're in good shape. (So you can be cramming data in during VBLANK and HBLANK and even if you ultimately fall behind during the line/frame the buffer saves you.)

-Clay
Post Reply