## Modular Circuits

If you look up “modular circuits” in a Google search, you are likely to find circuit boards that fit together in a modular fashion. This is NOT what we’re talking about when we use the term *modular circuits*.

When we talk about modular circuits, we’re talking about circuits that perform an arithmetic or logical function using modular arithmetic. Modular arithmetic is often associated with arithmetic that is bounded by a finite, wrap-around number space. For example, the formula ** a x b mod m** is modular multiplication because of the mod function applied to the result of the multiplication of

*a x b*. For example, if

*a=3, b=4*, and

*m = 5*, then the result is 2, since

*3×4=12 mod 5 = 2*. In this case, the modulus of m=5 ensures the modular arithmetic result is bounded between 0 and 4.

In practice, any finite counter or computer “accumulator” will wrap around at some count; that count is the modulus of the accumulator. For binary systems, this is always a value that is some power of two. For example, for a 16-bit register, the register value will wrap around every 2^{16} counts. However, we normally think of modular circuits when we are using an “arbitrary modulus”, or some modulus other than a power of two.

Residue number systems (RNS) use a series of modular circuits to perform arithmetic, each circuit processing a specific answer for a specific digit modulus. Many circuits have been developed over the decades to perform various modular arithmetic to perform RNS processing. A comprehensive survey of many of these modular circuit designs is documented and distilled by P.V. Ananda Mohan in his book entitled Residue Number Systems.

At Maitrix, we focus on modular circuit design with a goal of unifying modular operations to perform general purpose computation, what we call Modular Computation. With the advent of modern FPGA’s, we have found that pipelined RNS circuits perform very well, and can easily compete with optimized binary circuits on the very same FPGA device!