FPGA Clocks for Software Developers (or Anyone)

It used to be that designing hardware required schematics and designing software required code. Sure, a lot of people could jump back and forth, but it was clearly a different discipline. Today, a lot of substantial digital design occurs using a hardware description language (HDL) like Verilog or VHDL. These look like software, but as we’ve pointed out many times, it isn’t really the same. [Zipcpu] has a really clear blog post that explains how it is different and why.

[Zipcpu] notes something we’ve seen all too often on the web. Some neophytes will write sequential code using Verilog or VHDL as if it was a conventional programming language. Code like that may even simulate. However, the resulting hardware will — at best — be very inefficient and at worst will not even work.

Continue reading “FPGA Clocks for Software Developers (or Anyone)”

Cheap Powerbank Logic and Teardown

A fixture on many British high streets are pound shops. You may have an equivalent wherever in the world you are reading this; shops in which everything on sale has the same low price. They may be called dollar stores, one-Euro stores, or similar. In this case a pound, wich translates today to a shade under $1.24.

Amid the slightly random selection of groceries and household products are a small range of electronic goods. FM radios, USB cables and hubs, headphones, and mobile phone accessories. It was one of these that caught [Julian Ilett]’s eye, a USB power bank. (Video embedded below.)

You don’t get much for a quid, and it shows in this product. A USB cable that gets warm at the slightest current, a claimed 800 mA of output at 5V from a claimed 1200 mAh capacity, and all from an 18650 Li-ion cell of indeterminate origin. The active component is an FM9833E SOIC-8 switching regulator and charger (220K PDF data sheet, in Chinese).

A straightforward teardown of a piece of near-junk consumer electronics would not normally be seen as something we’d tempt you with, but [Julian] goes on to have some rather pointless but entertaining fun with these devices. If you daisy-chain them, they can be shown to have the properties of rudimentary digital logic, and in the video we’ve put below the break it is this that he proceeds to demonstrate. We see a bistable latch, a set-reset latch, a very slow astable multivibrator, and finally he pulls out a load more power banks for a ring oscillator.

If only [MacGyver] had found himself trapped in a container of power banks somewhere from which only solving a complex mathematical conundrum could release him, perhaps he could have fashioned an entire computer! The best conclusion is the one given at the end of the video by [Julian] himself, in which he suggests (and we’re paraphrasing here) that if you feel the idea to be unworthy of merit, you can tell him so in the comments.

Continue reading “Cheap Powerbank Logic and Teardown”

DIY Computer — 1968 Style

What does it mean to “build your own computer?” Today, it is likely to mean you bought a motherboard, a power supply, and a case and put it all together. You might even have made an embedded computer using a few chips, including an off the shelf CPU. However, there are those guys (like me) who have built entire computers using FPGAs and some (not like me) who have built computers out of TTL chips, discrete components, and even relays and we have covered quite a few of them.

It hasn’t always been that easy. Components are readily available now and relatively cheap (especially considering inflation). In the 1960’s, simple components cost more than you pay for them today and back then your hypothetical self was making less money. In just about every way imaginable, the cost was prohibitive.

clipSo what did you do if you were a kid saving money from a paper route in 1968 and you wanted to build a computer? Maybe you turned to How to Build a Working Digital Computer a book published in 1968 by [Edward Alcosser], [James Phillips], and [Allen Wolk]. This book did as the title promised: you could build a working digital computer. The components, though, were paper clips, tin cans, thread spools, and other household items. The only real electronic components you had to use were light bulbs and a battery, although you might also use store-bought switches in some places instead of the homemade versions shown in the book.

Continue reading “DIY Computer — 1968 Style”

Learn Flip Flops with (More) Simulation

In the previous installment, we talked about why flip flops are such an important part of digital design. We also looked at some latch circuits. This time, I want to look at some actual flip flops–that is circuit elements that hold their state based on some clock signal.

Just like last time, I want to look at sequential building blocks in three different ways: at the abstraction level, at the gate level, and then using Verilog and two online tools that you can also use to simulate the circuits. Remember the SR latch? It takes two inputs, one to set the Q output and the other to reset it. This unassuming building block is at the heart of many other logic circuits.

circ5A common enhancement to the SR latch is to include an enable signal. This precludes the output from changing when the enable signal is not asserted. The implementation is simple. You only need to put an additional gate on each input so that the output of the gate can’t assert unless the other input (the enable) is asserted. The schematic appears on the right.

In the case of this simulation (or the Verilog equivalent), the SR inputs become active high because of the inversion in the input NAND gates. If the enable input is low, nothing will change. If it is high, then asserted inputs on the S or R inputs will cause the latch to set or reset. Don’t set both high at the same time when the enable is high (or, go ahead–it is a simulation, so you can’t burn anything up).(Note: If you can’t see the entire circuit or you see nothing in the circuit simulator, try selecting Edit | Centre Circuit from the main menu.)

Continue reading “Learn Flip Flops with (More) Simulation”

Learn Flip Flops with Simulation

Digital design with combinatorial gates like AND, OR, and NOT gates is relatively straightforward. In particular, when you use these gates to form combinatorial logic, the outputs only depend on the inputs. The previous state of the outputs isn’t important in combinatorial logic. While this is simple, it also prevents you from building things like state machines, counters, and even CPUs.

Circuits that use their own outputs as inputs are known as sequential circuits. It is true that at the fundamental level, sequential circuits use conventional logic gates. However, you usually won’t deal with them as gates, but will deal with abstractions like latches, flip flops, and even higher level constructs. Learning about these higher level constructs will allow you to make more advanced digital designs that are robust. In fact, if you are using an FPGA, building blocks like flip flops are essential since a large portion of the chip will be made up of some kind of flip flop.

Continue reading “Learn Flip Flops with Simulation”

Need Timing Diagrams? Try Wavedrom

When working with anything digital, you’re going to end up reading or writing a timing diagram before long. For us, that’s meant keeping (text) notes, drawing something on a napkin, or using a tool like Inkscape. None of these are ideal.

An afternoon’s search for a better tool ended up with Wavedrom.

Just so you know where we’re coming from, here’s our list of desiderata for a timing diagram drawing solution:

  • Diagrams have a text-based representation, so their generation can be easily scripted and the results versioned and tracked throughout project development
  • Command-line rendering of images, because we like to automate everything
  • Looks good
  • Simple to use for common cases, but flexible enough to do some strange stuff when needed
  • Output modifiable when absolutely necessary: SVG would be nice

Basically, what we want is graphviz for timing diagrams.

Wavedrom nails four out of these five at the moment, and has promise to cover all of the bases. Give the online editor demo a try. We found it intuitive enough that we could make simple diagrams without even reading the fine manual. The tutorial has got you covered for more esoteric use cases.

foo

Clearly, some good thought has been put into the waveform description language, WaveJSON; it’s mostly readable and makes the essentials quick and easy. Because you can also enter straight SVG, it leaves the door open for full-fledged lunacy.

Wavedrom is written in JavaScript, and built for embedding in webpages; that’s the way they intend us to use it. On the other hand, if you want to run your own local version of the online editor, you can download it and install it locally if you’d like.

Our only quibble is that the standalone, command-line application wouldn’t generate images without the GUI on our Arch system. (Looks like there are some Google Chrome dependencies?) Otherwise, we think we’ve found our solution.

There are other applications out there. Drawtiming looks good, but we can’t quite get our head around the file format and the graphic output isn’t as flexible as we’d like: it only outputs GIF and we’re more into SVG because it can be edited easily after the fact.

There are font-based solutions that let you “type” the timing diagrams. We found Xwave and “Timing Diagram Font“. These work but aren’t particularly flexible; if you want something to happen at odd times, you’re out of luck. Plus, it just feels like a dirty hack, as if that were a bad thing.

Latex users can use tikz-timing, which makes sketching out your timing diagrams as much fun as laying out a very complex table in Latex (that is: not fun at all). On the other hand, it looks good, is ultimately flexible, outputs PDF, and would be scriptable if someone put the time in to write a nice frontend.

So for the next little while, we’re trying out Wavedrom.

What do you use for making timing diagrams?

Visualizing Digital Logic With EL Wire

[Bob] and [Aubrey] run the System Source Computer Museum a little north of Baltimore, Maryland. For an exhibit, they thought a visual representation of digital logic and came up with a two-bit binary adder. Yes, it’s just a full adder and exactly what you would find somewhere in the second or third chapter of any digital logic textbook. The way they’re illustrating how a full adder works is the killer feature here: they’re using EL wire for all of the wires connecting the gates.

The full adder is implemented with an Arduino Mega, but the interface is the real show here. On the left side of the display there are four illuminated toggle switches that show virtual electrons flowing through EL wires, through gates and finally out to a seven-segment display. The EL wires are controlled with an EL Escudo Dos shield – a good thing, since there are a lot of lines between switches, gates, and outputs.

You can check out [Aubrey]’s demo video that also shows off how they built it below. If you’re around Baltimore, you can check out the display at the museum.

Continue reading “Visualizing Digital Logic With EL Wire”