“Brain In A Vat” 6502

The 6502 was a revolutionary processor for its time. Offered at a small fraction of the cost of other processors available when it was released, it became adopted in such iconic computers at the Atari 2600, the Apple II, the NES, and the Commodore 64. For that reason it’s still extremely popular among retrocomputing enthusiasts who will often go to great lengths to restore these computers or build them from scratch. [jamesbowman] had an idea to build a 6502-based computer with the processor only, leaving the rest of the computer up to an FPGA.

He describes the system as a “brain in a vat” since a real 6502 is used as the “brain” and all other functions are passed off to the FPGA. In his build he uses an FPGA board with built-in graphics abilities, but the truly interesting part of this build is how the FPGA handles memory. If a particular value is placed on the data bus of the 6502, it loops forever through the entire memory and executes all of the instructions it finds. This saved a lot of time getting this system up and running, and he is able to demonstrate it by showing a waveform on the video output of the device.

Of course you can take an FPGA and emulate an entire computer based on a 6502, but using the actual silicon in a build like this really ensures that the user can learn and understand the hardware involved without some of the other tedium of doing things such as converting old video signals to HDMI for example. It’s a great take on retrocomputing that we expect to see more of in the future.

39 thoughts on ““Brain In A Vat” 6502

    1. I’m hesitant to ever use “dumb” to describe something but this certainly qualifies for it. This is nothing more than a 16 bit up counter that performs no actual processing. I’m not at all impressed. The 2nd paragraph of this article is a non sequitur and gives me pause, making me wonder if reading this site is just a waste of time?

      1. Any article shortcomings aside, the link in this linked article to the nop-gen documentation is an interesting bit to be aware of. I don’t do 6502 development but I could see it as a handy debugging tool to keep around for quick tests

        1. If you just want to step through memory addresses, put a jumper pin on each data line and set it high / low to emulate the NOP code. Switching in a monostable/astable (the good old 555) for the oscillator lets you step through address space.
          I did some work with a Z80, where the NOP code was $00. For the 6502, I believe the code is $EA.

          Using an FPGA instead of a 555 and a bunch of jumper cables? Sounds like overkill.

        1. Actually, the 6510 is a 6502 with 6 bits of I/O, and a tristate address bus. The bits most significantly used to memory map RAM into the address space.

          It’s the same instruction set.

          It’s the same as the 6502 in the Atari 2600, which lacked some pins but was otherwise a 6502.

  1. The price of the 6502 has been mythologized.

    Yes, from the start one could buy a single 6502 for $20. In 1975 that made it very tempting to hobbyists building from scratch, including Steve Wozniak.

    But we’re talking single quantities. If you were producing, the price went down a lot. That’s why the Altair was only around $400. Someone said at the time, I think as a joke, that one could buy an Altair to get an 8080. If MITS was paying hundreds of dollars, they couldn’t sell it so cheap.

    The Apple was built in a garage, the low CPU cost was a factor. But other companies couod aftord to pay a lot for a sample, or be given a sample, so single-price meant nothing. Commodore owned Mos Technology, they’d be stupid to use some other CPU.

    The story is there so it’s used to interpret the past. But nobody thinks how popular the 8080 was, despite it’s single quantity price being way higher. Nobody wonders how the TRS-80 could be “so cheap” when the single quantity price was so high.

    Besides, the price of the 8080 did drop in single quantity fairly fast after the Altair. I’m sure it was December 1975 that Godbout was advertising a package, the 8080, the clock IC, an eprom, and maybe ram for under $100. I tried to figure out how I coukd get that money.

    1. To put this in perspective, that $100 is around $520 today adjusted for inflation. When I was in high school I smoked an 8080 chip with a slip of a voltmeter probe; a local small manufacturer felt sorry for me and sold me a onesie for $20. probably in 1975 or so. That still REALLY hurt.

      1. The $25 introduction at Wescon got it into a lot of bright people’s hands who didn’t have a lot of capital. Mega corporations didn’t build these computers, hobbyists did. The success of them made their creators into mega corporations that we know today.

        Notice the established players at the time (Radio Shack, IBM) went Intel/Zilog.

        1. Huh?

          8080 systems were built in garages. MITS was an existing company when they released tye Altair, but no Commodore. But other than Apple (which by the time of the II had investors), how many garage companies had success with the 6502? OSI, maybe since they also sold systems with other CPUs. Maybe in the UK, but I’m not sure if Acorn started in a garage. But tgese aren’t even mentioned in the article.

          $20 6502s made a big splash, especially since Byte (was it the November issue?) in 1975 titled their article about it that way. But Apple is the one company that is directly traced to that low single price. We knew about it because of the low price, at a time when most of us didn’t really understand much more, but I don’t think the low price made that much impact otherwise..

          It was successful at Commodore, which owned the 6502, and it saw endless use in embedded systems, but was it really that low single unit price?

          Likewise, a lot more “garage” home computers were made with the 8080 or Z80, even with the high single unut price.

  2. From my child hood reading it was “very popular” to use the 6502 no op feature.
    It was used to magically increment the address bus, which sometimes was used for video output. Yes they used no ops to dump video out as this forced the processor into a simple precise cycle of reading memory (which they used the signals for but did not route the data of to the processor). Clever but unfortunately this also lead to the video requiring the processor to do stuff other than what you wanted it too. Anyhow they used the no op feature to “read” all of the video incrementally and use tricks to stuff no ops into the processor to do so.
    So it’s not “just a counter” as it’s actually using the entire address bus and cycling it. This feature allowed early systems to display graphics that would have required a lot more parts and cost.
    The feature is definitely not perfect for video but it works. Sort of like using a SPI bus for video output.

      1. Yes.

        I read Don Lancaster’s book first, but later I saw a bit in Byte (from earlier) about using the technique to bootstrap an 8080 system. Then there was a full article about 1980 for an 8080 trainer, using a stylus and pads carved from circuit board. So you could do a minimum hardware, but right off tgee bat start learning, presumably enough to create a monitor and mive forward.

        Dr. Dobbs had a book outthat coloected articles about the 68000, and it had an article abiut using NOPs to bootstrap. I think it might have been fresh for the book, I never saw it elsewhere.

      2. Probably most CPUs can do this without even needing an FPGA to feed it data. Julian Ilett did a “chip on breadboard” video on the z80’s basically use pull up/down resistors on the data bus to make the CPU think its being fed a specific instruction (NOP i think it was) repeatedly and its address bus will just count up the whole address space. Basically made binary counter out of a z80. Found this video handy to test a few z80’s I had laying around without having to actually slap them into a working system. https://www.youtube.com/watch?v=AZb4NLXx1aM

  3. Looks like a way to flog the Dazzler more than anything else.

    First I’d heard of it. It uses the FT815 EVE to handle video. A fantastically capable chip. I’ve spent hundreds of hours coding for it. It’s an exercise in frustration and general pain in the butt. Without a decent software wrapper and tools it’s way too hard to use for a general display, and even with the tools you need to structure your software around the display capabilities. The Dazzler better have a good API for it or it’s going to just fall flat.

  4. But seriously. Why are the traces from the 6502 all connected to the FGPA in order? What does it matter, apart from making it easier for the human to understand? Generally, you don’t want such long line running in parallel with each other. And for the FPGA, it really doesn’t matter which CPU pin is connected to which FPGA pin. Just define everything in a file, and you’re done. The compiler will take care of everything for you.

    With a whole bunch of pin swaps, you could also save at least half an inch of PCB too.

  5. And to think, a little software company called Diversified Software Research
    was able to make an Apple //e and 7 modems talk to each other thus making one
    of the first early chat systems run by computer hobbyists instead of large
    corporations like Compuserve etc. Ah yes….

    #0<T1:Deeply Shrouded) It was a time that shall never pass again.

  6. What’s the meaning of the sentence: “If a particular value is placed on the data bus of the 6502, it loops forever through the entire memory and executes all of the instructions it finds.” Does that mean “any” particular value, and what makes it “particular”. I’ve been playing with micros since 1975 in all forms. Lots had special ways of forcing a monitor ROM, which started via the processor’s reset vector, to boot the “system” much the way that the original IBM PC did. DR-DOS did that from a floppy using a “boot sector” that loaded another more complete boot program (like a BIOS). This has evolved a LOT since the early days. My first PC, the Radio Electronics published Mark-8 that used an 8008 (not a misprint) used cascaded synchronous binary counters to run the address lines via commands from a collections of front-panel switches that would let you manually enter the data (a recent Hackaday explored the Altair 8800, published months after the RE Mark-8 article in Popular Electronics). I put mine together using less-expensive surplus (mostly pulled) parts almost entirely from Poly Paks. Lots of work but it was fun.

    1. If a CPU sees a NOP, it does nothing except advance the program counter. That’s the basis of this. If you jam a NOP onto the databus, it does the same thing, but you don’t need to fill RAM with NOPs.

      So you can use it to cycle through video memory, or as a 16bit counter for RAM to load that RAM directly, no extra hardware needed.

      I think it was Sol Libs who wrote abiut it in Byte, as a troubleshooting method.

      Other opcodes may/will work, but they may alter the registers in the CPU (not good for some circumstances) and if it needs an operand, you have to make sure it exists.

      1. I get that jamming a no op does nothing, but since when is a no op a “special value” and not just a no op? Was this the author’s attempt to “dumb down” the discussion?

  7. This is really an advert for their FPGA graphics card they were crowd funding by the looks if you read the bottom of the article. How to use a shed load of pins on an expensive FPGA doodah to put a single byte onto the databus of a 6502. You can do that with some pull up resistors maybe a buffer chip if you wanted to be posh!!?!?

  8. You can double the speed of PC counting by putting 0x69 on the data bus. This does ‘ADC #0X69’ which takes 2 cycles and advances PC by 2. The NOP also takes 2 cycles but only advances PC by 1.

      1. I thought that some people might like code that allows testing of every address line* in half the time; you know, to work twice as fast. Some people pay a lot of money for computers that do things faster. Also, when using the address line to generate pixels for a monitor display, it allows twice the refresh rate for the same resolution. * Whilst the PC goes up in twos every two cycles, the address line goes up in ones; judging by your comment, I’m not sure that you realised that.

Leave a Reply to Alan Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.