How 6502 Overflow Works

6502 Overflow Circuit

The 6502 was a ubiquitous microprocessor back in the 80s, powering devices such as the Apple II and the Nintendo Entertainment System. [Ken] took an in depth look at a small part of the processor: the overflow circuit.

In order to do signed calculations, a microprocessor’s arithmetic logic unit (ALU) needs to be able to calculate when an overflow occurs. This happens when two numbers are added that cannot fit in a single byte. The result of a calculation will be incorrect, so the processor must inform the program that an overflow has occurred. This is done by setting an overflow flag.

[Ken] uses this example to first explain how the overflow circuit works in logic. He then looks at the gates and a transistor implementation of the logic. Finally, he walks us through the circuit on the actual 6502 die, showing how the circuit is constructed in silicon.

This is a great example to learn a bit more about how ALUs work and how integrated circuits get built.

Veronica VGA board finalized

veronica-vga-board-finalized

The latest update in the Veronica 6502 computer project is this finalized VGA board which now has a home in the machine’s backplane.

We’ve been glued to the updates [Quinn Dunki] has been posting about the project for many months now. Getting the GPU working proved to take quite a bit of time, but we learned a ton just by following along. The video output had humble beginnings way back in March. That breadboarded circuit got complicated very quickly and that was before it was even interfaced with the CPU. As you can see from the image above, etching and populating the GPU board really cleans up the build. We’re sure it’s robust enough to move around at this point. We wonder if she’s planning on showing it off at a Maker Faire or another geeky gathering?

It really has become clear how wise [Quinn] was to design a backplane board early on. It plays right into the modular concept. She was even smart enough to include that SIL pin header on the near side of the board which was used heavily while prototyping this video module.

Interfacing a GPU with a CPU

interfacing-a-gpu-with-a-cpu

[Quinn Dunki] pulled together many months worth of work by interfacing her GPU with the CPU. This is one of the major points in her Veronica project which aims to build a computer from the ground up.

We’ve seen quite a number of posts from her regarding the AVR-powered GPU. So far the development of that component has been happening separately from the 6502 centered CPU. But putting them together is anything but trivial. The timing issues that were so important to consider when developing the GPU get even hairier when it comes writing to the VRAM from an external component. Her first thought was to share a portion of the external RAM between the CPU and GPU as a way to push rendering commands from one to the other. This proved troublesome both in timing and in the number of pins available on the AVR chip. She ended up using something of a virtual register on the AVR chip that can receive commands from the CPU asynchronously. Timing dictates that these commands be written only during vertical blanking so this virtual register also acts as a status register to let the CPU know when it can send the next command.

Her post is packed with the theory behind the design, timing tests on the oscilloscope, and a rather intimidating schematic. But the most important part is the video showing her success in the end.

Discrete 6502 processor sucked into Linux by a BeagleBone

Often when we see projects using embedded Linux we think of them as not being hardware hacks. But this is a horse of an entirely different color. [Matt Porter] is leveraging a little known feature to directly access a 6502 processor from inside a Linux environment. In other words, this hack lets you write code for a 6502 processor, then load and execute it all from the same Linux shell.

The project leverages the best parts of the BeagleBone, which is an ARM development board running embedded Linux. It’s got a lot of GPIO pins that are easy to get via the boards pin sockets. And the design of the processor makes it fast enough to work well as a host for the 6502 chip. Which brings us back to how this is done. The Linux kernel has support for Remote Processors and that’s the route [Matt] traveled. With everything wired up and a fair amount of kernel tweaking he’s able to map the chip to the /dev/bvuart directory. If you want all the details the best resource is this set of slides (PDF) from his talk at Embedded Linux Conference – Europe.

This is one way to get out of all that hardware work [Quinn Dunki] has been doing to build her own computer around a 6502 chip.

[Thanks Andrew via Dangerous Prototypes]

Homebrew computer is 16 bits of awesome

We’ve seen our share of homebrew computers over the years. Usually, these bare-bone systems use a small, early 80s-era microprocessor such as the Z80 or 6502. These little 8-bit machines are awesome, but somewhat limited in their capability. [BigDumbDinosaur] sent in a computer he’s been working on for a few years now featuring the infamous 65816 CPU – the same CPU found in the Apple IIgs, the Super Nintendo, and [Jeri Ellsworth]‘s C-ONE computer.

The 65816 is a direct descendant of the venerable 6502 CPU found in the Commodore 64, Apple II, and just about every 80s microcomputer of note. [BigDumbDinosaur] chose the 65816 for its backwards-compatibility with the fun to program 6502 and the ability to use high clock rates and tons of address space for a very cool design.

After a ton of careful design and consideration, [BigDumbDinosaur]‘s computer included a real-time clock, a watchdog timer, a serial port, 256kB of ROM, and 128kB of RAM.

It’s a really wonderful build, but [BigDumbDinosaur] isn’t done with this project yet. He’s working on version 2 of a 65816 computer that will use programmable ‘glue’ logic, a lot more RAM, have a SCSI interface (for a hard drive), and have preemptive multitasking.

An awesome job, and it’s wonderful to see the wonderful 65816 make its way into another homebrew computer. Now if only we could find a 68000-based homebrew computer…

Building a 6502 in Minecraft

We’ll admit that we haven’t been following Minecraft like we used to; its been a while since we’ve seen something amazing in Minecraft, but [eloraam]‘s 6502 emulator (part of her RedPower Minecraft mod) takes the cake.

The RedPower mod adds a lot of industrial technology to Minecraft. Pumps, solar panels, and pneumatic tubes to move blocks around are the staple of this mod, but with the addition of a fully emulated 6502 computer, Minecraft moves from an anachronistic medieval-themed steampunk aesthetic to a full-on machine age, mainframes everywhere style.

The heart of the 6502 portion of the RedPower mod are three craftable blocks; a CPU, a monitor, and a disk drive. All these blocks are connected together with ribbon cables and can interact with other blocks in the Minecraft universe. The CPU is an emulated 6502, with a few instructions borrowed from the 65816 and the addition of MUL and DIV. It’s possible to program this computer in assembly, but [eloraam] a Forth interpreter with the OS to make programming a little easier.

It’s been almost two years since we first saw the beginnings of a CPU made in Minecraft, but this mod takes everything to the next level. In actuality, this isn’t very different from the game [notch] is currently working on; both feature an emulated 80′s era computer that can do all your in-game bidding. We can’t imagine anything better to get us hooked on Minecraft again, and we’ve got to commend [eloraam] for some seriously awesome work.

After the break is a 23-minute tutorial on the functions of the RedPower CPU, as demonstrated by Minecraft aficionado [direwolf20].

[Read more...]

Your guide to building a homebrew 6502 computer

If you’ve ever thought about getting down to bare metal and building a homebrew computer from scratch [Garth Wilson] put up a great primer to the 6502, the same CPU found in Apple ][ computers, BBC Micros, Vic-20s, and the venerable Commodore 64 (a 6510 in the C64, but it's close enough).

In his guide to building a 6502 computer, [Garth] goes over all the basics – what you want the computer to do, how to decode addresses, and other important technical requirements for getting a homebrew project running.

If that’s not enough, [Garth] directs his readers to the fabulous 6502.org forums  where just about every topic is discussed. The guys on the forum have a standardized I2C pinout for the 6502, allowing noobs to easily connect pre-designed keyboards, displays, and storage devices to their projects. There are a ton of tutorials on the 6502.org site, more than enough to get a homebrew project off the ground.

If you’d like to see what you can do with a homebrew 6502, check out the homebrew projects page featuring a 6502 Nixie clock and CLPD-based 65816 single board computer. There’s a treasure trove of information here, just waiting to be pulled from the vine.