Photos

www.flickr.com

19 February 2008 - 19:00First FPGA project ideas

I decided recently that I want to really learn computer hardware design. Not just the theoretical “I know how the machine works” understanding, but actually having done it. So, the obvious thing was to get an FPGA and design stuff using it. fpga4fun was some of the inspiration for this. I ended up ordering one of their Cyclone II boards after deciding that I was going to play with the Altera stuff (Xilinx has comparable parts. For more sources of FPGA dev boards, see Sparkfun(only one), Digilent, and XESS.) The Altera software (Quartus II) seemed a little bit less obtuse. Otherwise I can’t say I found myself strongly in favor of one or the other. As for Verilog versus VHDL, I’m learning Verilog because it’s more readable, and more commercially popular (at least in the USA). Once I understand what I’m doing, I’m sure I can learn VHDL later.

Over the weekend, I’d been playing with the free version of Altera’s Quartus II software, writing a bit of Verilog and seeing what it compiles into. The Cyclone II EP2C5 is a reasonably capable part — 4608 “Logic Elements” (each is a 4-input lookup table — 4 bits in, 1 bit out, any truth table), carry chain logic, a register on the output, various stuff to connect it locally, across the chip, and to the clock distribution network), 119808 bits of ram in “block ram” scattered about the chip, 13 18×18 multipliers, and 2 PLLs for clock generation.

So, I got to thinking that a suitably hard project is a modern reimplementation of the 1980s home computer / game console. This would consist of a number of subprojects:

  • a CPU — probably early MIPS, R2000/R3000 or something. a subset of MIPS32. Not too hard to understand, I still have the Patterson and Hennessy textbook that gave a pretty nice introduction to it. Also, existing GCC support.
  • SDRAM controller — having looked at a datasheet, supporting a single 4Mx16 SDRAM chip shouldn’t be that hard.
  • Display controller. Low-color-depth VGA wouldn’t be too hard, but then I’d constantly have to hook a VGA monitor up, etc. A more interesting choice seems to be to support one these Sharp LCDs
  • SPI interface to an SD card. Have the first stage bootloader in the FPGA block ram load code from here into the SDRAM.
  • USB low-speed host controller, really only supporting keyboard/mouse/joystick. Another challenging piece, but not that bad
  • Serial port for debugging software.
  • Sound controller. Maybe an all-digital implementation of the SID in a C-64, or maybe the much simpler sound chip found in the TI 99/4a, IBM PC Jr., Sega Master System, etc.

So far, I’ve written Verilog for parts of a 3 voice + 1 noise sound chip (the simple one above), and I’ve implemented a register file and an ALU. Most importantly, I figured out how to use the right idioms to make the register file out of block ram, instead of consuming a quarter of all the logic elements on the chip.

But, wow, that’s a big first project. While I can design and test it piece by piece, I think it might be more fun to start out with something simple: A 16 bit stack-based CPU, interfaced to the on-board block ram (only about 13K bytes), with a serial console. I’ll have to cobble together some sort of assembler, but that’s not that hard. Especially when the instruction set is simple. I’ve been reading Stack Computers for inspiration.

Another possibility, instead of a stack CPU is some kind of stripped-down mips-like 16 bit architecture. You get into some compromises with 16 bit instructions if you want a reasonable number of instructions and the usual 3-operand instruction format, though.

(For more links, see my del.icio.us.)

No Comments | Tags: CPU, Electronics, FPGA, Verilog

12 February 2008 - 21:37Touch sensor tweaking

The one thing that wasn’t quite behaving right about the LED lamp was the touch sensor. I was having trouble both with it being far too sensitive (and sensitive to interference from other devices nearby — I’d plug in my laptop to an adjacent outlet and it would sense a “touch”), but also it was often not self-calibrating properly.

So, I reread Quantum Research Application Note AN-KD02, “Secrets of a Successful QTouch Design”, and I finally tried properly doing the procedure in section 3 for probing the sensor field. And I discovered one thing: the Rsns value I’d previously guessed at was far too small. I was using 1K, while I got the appropriate sort of risetime with about 18-25k. I decided that Cs was probably also far too high, so I tried reducing it from .044 uF to .022 uF.

It’s a little bit less sensitive now — you have to touch the area on the outside of the glass with at least a couple fingertips, but it’s far more reliable and less prone to interference.

Also, it seems to be recalibrating its threshold more quickly now.

I may try adjusting the value of Cs a little more (need to buy more values of 1206 surface-mount capacitors), but I think I’m almost “done” now.

On another note, I think there’s some FPGA design in my future. It’s got quite a learning curve, but it looks like fun.

No Comments | Tags: Electronics, LED

9 February 2008 - 19:48LED Lamp, done

LED touch lamp (almost complete)

More details in a couple days…

No Comments | Tags: Electronics, LED

2 February 2008 - 21:03More LED lamp software development

I’ve completed the software.

I abandoned the SOIC test clip in favor of wires soldered directly to the board. The SOIC test clip loses contact with the IC if you just look at it funny. It’s very irritating. In the future, all boards will have an in-system programming (ISP) connector.

I just need to finish the mechanical part. I’m waiting on an order for some more nylon screws because I screwed up and ordered the wrong length.

No Comments | Tags: AVR, Electronics, LED

1 February 2008 - 20:22Weird DMM experience

Last night while I was hacking together an adapter from a 6 pin header to wires to a SOIC test clip, I was using my Fluke 179 in ohmmeter mode to check that I’d made the connections I wanted to make and not the ones I didn’t want to make. I’d put the probes on something right after I’d soldered it, and got a steady -0.2 ohms.

I was surprised. Seeing a negative value in the ohmmeter mode usually means there’s voltage in the circuit. I shorted the probes together and got a less-surprising 0.4 ohms or something like that. Then, when I put the probes back on the connections under test, I got a similar, small positive value.

And then I realize what had happened: while the connections under test were cool enough for the solder to be solid, things were hot enough to be noticeably exhibiting the Seebeck effect, like thermocouples intended for this purpose.

No Comments | Tags: Electronics