Sort Faster With FPGAs

Sorting. It’s a classic problem that’s been studied for decades, and it’s a great first step towards “thinking algorithmically.” Over the years, a handful of sorting algorithms have emerged, each characterizable by it’s asymptotic order, a measure of how much longer an algorithm takes as the problem size gets bigger. While all sorting algorithms take longer to complete the more elements that must be sorted, some are slower than others.

For a sorter like bubble sort, the time grows quadradically longer for a linear increase in the number of inputs; it’s of order O(N²).With a faster sorter like merge-sort, which is O(N*log(N)), the time required grows far less quickly as the problem size gets bigger. Since sorting is a bit old-hat among many folks here, and since O(N*log(N)) seems to be the generally-accepted baseline for top speed with a single core, I thought I’d pop the question: can we go faster?

In short — yes, we can! In fact, I’ll claim that we can sort in linear time, i.e a running time of O(N). There’s a catch, though: to achieve linear time, we’ll need to build some custom hardware to help us out. In this post, I’ll unfold the problem of sorting in parallel, and then I”ll take us through a linear-time solution that we can synthesize at home on an FPGA.

Need to cut to the chase? Check out the full solution implemented in SystemVerilog on GitHub. I’ve wrapped it inside an SPI communication layer so that we can play with it using an everyday microcontroller.

To understand how it works, join us as we embark on an adventure in designing algorithms for hardware. If you’re used to thinking of programming in a stepwise fashion for a CPU, it’s time to get out your thinking cap!

Continue reading “Sort Faster With FPGAs”

J.C. Bose And The Invention Of Radio

The early days of electricity appear to have been a cutthroat time. While academics were busy uncovering the mysteries of electromagnetism, bands of entrepreneurs were waiting to pounce on the pure science and engineer solutions to problems that didn’t even exist yet, but could no doubt turn into profitable ventures. We’ve all heard of the epic battles between Edison and Tesla and Westinghouse, and even with the benefit of more than a century of hindsight it’s hard to tell who did what to whom. But another conflict was brewing at the turn of 19th century, this time between an Indian polymath and an Italian nobleman, and it would determine who got credit for laying the foundations for the key technology of the 20th century – radio.

Continue reading “J.C. Bose And The Invention Of Radio”

Why No Plane Parachutes? And Other Questions.

This week I was approached with a question. Why don’t passenger aircraft have emergency parachutes? Whole plane emergency parachutes are available for light aircraft, and have been used to great effect in many light aircraft engine failures and accidents.

But the truth is that while parachutes may be effective for light aircraft, they don’t scale. There are a series of great answers on Quora which run the numbers of the size a parachute would need to be for a full size passenger jet. I recommend reading the full thread, but suffice it to say a ballpark estimate would require a million square feet (92903 square meters) of material. This clearly isn’t very feasible, and the added weight and complexity would no doubt bring its own risks.

Continue reading “Why No Plane Parachutes? And Other Questions.”

What’s In A Tool? A Case For Made In USA.

A lot of people make the argument that you can’t go wrong buying a tool made in USA, Germany, Japan, Switzerland, etc. They swear that any Chinese tool will be garbage and it’s not worth purchasing them. Now, any discerning mind will say, “Wait a minute, why? China has a huge economy, experienced people, and the ability to use all the scary chemicals that make the best steel. Why would their tools be any better or worse than ours?” It’s a very valid argument. There are lots of Chinese tools that are the best in the world. Most of what we see in our stores are not. So what is the difference. Why does a country who can make the best tools not make the best tools? Surely it isn’t purely cost cutting. Is it cultural? The opinion I wish to put forth is that it’s a matter of design intent communication.

I’ve worked as an engineer in industry. The one common thread between a quality product and a bad product has always been this, ”Is the person who designed the product involved in making the product?” If the person or peoples who imbued the design intent into the original product are actively involved in and working towards the execution of that product, that product has a vastly greater chance of being good. Or in other words: outsourcing doesn’t produce a bad product because the new people making the product don’t care. It makes a bad product because the people who understand the intent behind the product are separated from its execution.

As you can see the export made crescent wrench is not made to the same tolerances as the previous wrench.
As you can see the export made crescent wrench is not made to the same tolerances as the previous wrench.

Let’s take the Crescent wrench as an example. Crescent wrenches used to be made in USA. In the past few years they have begun to make them in China. We can spot many visual differences right away. The new Crescent wrench has a different shape, the logo has changed and the stamping for the logo is dodgy, and worse, the tool just doesn’t operate as well as it used to. The jaws aren’t as hard and they wiggle more. What happened? How could Crescent mess up their flagship so badly. Surely they intended just to cut costs, not to reduce quality. This isn’t shameful in itself

What happened to the Crescent wrench is easily explained by anyone who has seen a product from design to execution before. A factory in the USA set out to make a good adjustable wrench. Hundreds of engineers and employees worked in a building to make a good wrench. When their machines didn’t work, they came up with solutions. When their quality was lacking, they implemented better processes. They had a list of trusted suppliers. They could guarantee that the materials that came in would be imbued with their vision and intent when the product came out. The intent and will of all those people built up in one place over time.

Continue reading “What’s In A Tool? A Case For Made In USA.”

Ham Radio Public Service Activities – Rewarding And Useful

“Hi! I’m Rud, Kilo Five Romeo Uniform Delta.” That’s me introducing myself at a ham meeting. Ham radio operators kid that we don’t have last names, we have call signs.

Becoming an Amateur Radio Operator (ARO), our more formal name, is not difficult and opens a world of interesting activities, including hacking. As with anything new, becoming actively involved with an existing club can be daunting. The other hams at a meeting are catching up with their buddies and often seem uninterested in the new guy standing nearby. Some groups will invite new members to stand and introduce themselves early in the meeting, which helps break the ice.

Regardless of how anyone else acts at the meeting there is one ham who is always looking for someone new – the ham who manages public service events, where amateur radio operators help establish communications for large public gatherings. These can be local bike rides, walks, or runs; I’ve even seen hams working an art show. In the nomenclature adopted since 9/11, these are “planned incidents” in contrast to “unplanned incidents” like hurricanes, tornadoes, forest fires, snow storms, and other natural or man made disasters. Working planned incidents is training for unplanned incidents when that need arises. The basic activities for AROs are the same.

Here in the Houston there are two very big events that enlist hundreds of hams. The big one in January is the Houston Marathon. The other large event is the Houston to Austin Multiple Sclerosis 150 (MS 150) mile bike ride in April. That event starts on Saturday morning, takes a break mid-way on Saturday evening, and finally wraps up late on Sunday evening. Starting in the fall there are warm-up events for the Marathon and in the late winter bike rides to prepare riders for the MS-150. There are also other marathons, Iron Man races, walks, runs, and races throughout the year. Wherever your are, there are probably events nearby and they can always make use of your radio capability.

landing-page-banners-51a

Continue reading “Ham Radio Public Service Activities – Rewarding And Useful”

Hams In Space: Project OSCAR

In early December 1961, a United States Air Force rocket took off from Vandenberg Air Force Base in California carrying a special payload. The main payload was a Corona surveillance satellite, but tucked just aft of that spacecraft was a tiny package of homebrew electronics stuffed into something the looked like a slice of cake. What was in that package and how it came to tag along on a top-secret military mission is the story of OSCAR 1, the world’s first amateur radio satellite.

Continue reading “Hams In Space: Project OSCAR”

Stallman’s One Mistake

We all owe [Richard Stallman] a large debt for his contributions to computing. With a career that began in MIT’s AI lab, [Stallman] was there for the creation of some of the most cutting edge technology of the time. He was there for some of the earliest Lisp machines, the birth of the Internet, and was a necessary contributor for Emacs, GCC, and was foundational in the creation of GPL, the license that made a toy OS from a Finnish CS student the most popular operating system on the planet. It’s not an exaggeration to say that without [Stallman], open source software wouldn’t exist.

Linux, Apache, PHP, Blender, Wikipedia and MySQL simply wouldn’t exist without open and permissive licenses, and we are all richer for [Stallman]’s insight that software should be free. Hardware, on the other hand, isn’t. Perhaps it was just a function of the time [Stallman] fomented his views, but until very recently open hardware has been a kludge of different licenses for different aspects of the design. Even in the most open devices, firmware uses GPLv3, hardware documentation uses the CERN license, and Creative Commons is sprinkled about various assets.

If [Stallman] made one mistake, it was his inability to anticipate everything would happen in hardware eventually. The first battle on this front was the Tivoization of hardware a decade ago, leading to the creation of GPLv3. Still, this license does not cover hardware, leading to an interesting thought experiment: what would it take to build a completely open source computer? Is it even possible?

Continue reading “Stallman’s One Mistake”