Karaman`s Peasant Convolution Technique for VHDL

K2Algorithms-2008
Karaman’s Peasant Convolution Technique for VHDL implementations
In digital signal processing convolution is a fundamental computation that is ubiquitous in many application areas. In order
to compute convolution of long sequence, Overlap-Add method (OLA) and Overlap-Save method (OLS) methods are
employed. This paper presents a methodology of reducing convolution processing time using hardware computing and
implementations of discrete linear convolution of two finite length sequences. In this paper, a block convolution process is
proposed using a multiplier architecture based on horizontal weight adjustment algorithm of Russian Multiplication (Peasant
Multiplication) and embedding it in OLA method for reducing calculations. We can label the algorithm as Peasant
Convolution algorithm. The coding is done in VHDL for the FPGA, as it is being increasingly used for variety of
computationally intensive applications. Simulation and synthesis is done using Xilinx.
This implementation method is realized by simplifying the convolution building blocks. The purpose of this analysis is to prove
the feasibility of an FPGA that performs a convolution on an acquired image in real time. The proposed implementation uses
a changed hierarchical design approach, which efficiently and accurately quickens computation; reduces power, hardware
resources, and area considerably. The efficiency of the proposed convolution circuit is tested by embedding it during a prime
level FPGA. In addition, the presented circuit uses less power consumption and delay from input to output. It additionally
provides the required modularity, expandability, and regularity to form different convolutions for any variety of bits.
The introduction of field programmable gate arrays (FPGA), has made it feasible to provide hardware for application specific
computation design. The changes in designs in FPGA’s can be accomplished within a few hours, and thus result in significant
savings in cost and design cycle. FPGAs offer speed comparable to dedicated and fixed hardware systems for parallel algorithm.
The Peasant convolution algorithm proposed in this paper is been simulated and synthesized using the Xilinx design suite 12.1
with the device family as Spartan 6 (low power). The main point of this paper is to introduce a method for calculating the linear
convolution sum of two finite length sequences that is easy to learn and perform. It has been found on embedding Peasant
multiplication for OLA, there is a considerable improvement in their performance. The table below shows the synthesis report
of the proposed work with the logic resource utilization.
The algorithm in its simplest form can be explained with one example in decimal number system. The base of decimal system is
10.
To multiply two numbers
function, and under
even number in the
and
, write
, write
and
. Continue until
column and add the
in two columns. Under
, write
. Then cross out any entries in the
column. The result is the desired product. For example, for
The summary of the process is as follows:
1.
Divide the value of a by 2. Round the data to lower bound if division is a fraction.
2.
Multiply b by 2.
3.
Scratch value on b side if corresponding side of a is even number.
4.
Repeat step 1,2,3 till a side reduces to 1.
1|Page
, where
is the floor
column which are opposite an
K2Algorithms-2008
5.
Add all unscratched numbers on b side to get product.
The grate part of above algorithm is that it perfectly suits for binary number system.
Multiplicand (a) side
1
1
0
0
Step 1
1
Multiplier (b) side
0
1
0
1
Shift (A) to right side and (b) to left side
1
0
0
1
0
1
0
As LSB of (a) is 0 neglect shifted value of (b)
Step 2
1
0
1
1
0
1
0
0
0
0
Retain for addition
Step 3
1
0
1
0
1
0
Retain for addition
0
Result of addition
0
1
1
0
0
1
1
0
0
0
0
0
1
1
1
1
0
0
Addition is 60 as expected
How is Russian peasant multiplication related to binary numbers?
Binary numbers are numbers written in base two instead of base ten. This means that place value depends on powers of two
instead of powers of ten: instead of ones, tens, and hundreds places, base two has a ones place, a twos place, a fours place, and
so on. For example, fourteen in base two is 1110:
1110 (base 2)
= 1 * 23 + 1 * 22 + 1 * 21 + 0 * 20
=8+4+2+0
= 14.
Russian peasant multiplication is actually a quick way to convert two numbers to binary form, multiply them together, and
convert back to our number system. The connection is not surprising, because binary numbers use base two, and Russian
peasant multiplication depends on multiplying and dividing by two. To see the connection more clearly, let's investigate the
problem 12*13.
Halving
You can convert a number to binary form by repeatedly dividing by two and keeping track of the remainders. Let's try 12:
2|Page
K2Algorithms-2008
12/2 = 6 remainder 0
6/2 = 3 remainder 0
3/2 = 1 remainder 1
1/2 = 0 remainder 1.
Reading the remainders from bottom to top, we get 1100, so 12 in base two is 1100.
Why does this conversion method work? Let's try cutting twelve in half again, the same way. This time, we'll write everything in
base two. (Naturally, 2 in base two is 10.)
1100/10 = 110 remainder 0
110/10 = 11 remainder 0
11/10 = 1 remainder 1
1/10 = 0 remainder 1.
Dividing by two and then taking the remainder gives us a number's last digit in binary notation.
Here's what we know about 12, so far:
12 = 1100 (base 2)
= 1*23 + 1*22 + 0*2 + 0*1
= 23 + 22
= 8 + 4.
By halving 12 repeatedly, we have broken it down into powers of two.
The reference: Mathforum.org
Karaman is really thankful to the forum and the writer who have taken pains to explain the concept in best possible fluent
words
Russian Peasant Method of Multiplication
Date: 10/07/98 at 20:46:39
From: Kara Brown
Subject: 'Russian peasant 'method of multiplication
I understand the 'Russian peasant' method of multiplication, but I do not understand why it works.
ex:
39 x 52
78 x 26
156 x 13 (double and halve)
312 x 6
624 x 3
1248 x 1
3|Page
K2Algorithms-2008
156 + 624 +1248 = 2028 add only left with odd right
Can you explain? Thanks
Date: 10/08/98 at 09:06:46
From: Doctor Peterson
Subject: Re: 'Russian peasant 'method of multiplication
Hi, Kara,
Here's a past answer in our archives describing Russian Peasant Multiplication:
It's actually a way of simultaneously converting a number to binary and multiplying it by another number. To show the relation
clearly, I'll work with a small example, 10 x 6. I'm going to assume that you have at least some knowledge of binary numbers; if
not, write back and I can rephrase this more simply.
To convert the number 10 to binary, we divide it by two repeatedly and note which divisions give a remainder (of 1):
10 / 2 = 5 r 0 ------------------------------> 0
5 / 2 = 2 r 1 ----------------------> 1
2 / 2 = 1 r 0 --------------> 0
1 / 2 = 0 r 1 ------> 1
The answer is 10 = 1010 in binary (reading the remainders upwards).
This means that
10 = 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0 = 2^3 + 2^1 = 8 + 2
To see why this works, just write everything (except the 2) in binary:
1010 / 2 = 101 r 0 --------------------------> 0
101 / 2 = 10 r 1 -----------------> 1
10 / 2 = 1 r 0 ---------> 0
1 / 2 = 0 r 1 -> 1
All we're really doing is peeling off the rightmost digit at each step.
Now to multiply 10 by any other number, we just have to use the distributive rule to multiply that number by each power of 2
that is present in 10:
10 * x = (8+2) * x = (2^3 + 2^1) * x = 2^3 * x + 2^1 * x
We can find these multiples of powers of two by starting with the given number and doubling it repeatedly:
2^0 * 6: 6
2^1 * 6: 6 * 2 = 12
2^2 * 6:
4|Page
12 * 2 = 24
K2Algorithms-2008
2^3 * 6:
24 * 2 = 48
The answer to 10 * 6, then, is (2^3 * 6) + (2^1 * 6) = 48 + 12 = 60.
Now we can put everything together in one little chart:
Divide by 2 Remainder Power of 2 Double Sum
----------- --------- ---------- ------ ------10
5
0
1
6
2
1
2
12
12
1
0
4
24
0
1
8
48
48
-60
The two leftmost columns find the binary digits for 10, the next two find 6 multiplied by powers of two, and the last column
sums the powers of two that form 10, multiplied by 6, to get the result.
Russian multiplication just compresses the first, fourth, and fifth columns into a simple format:
10 6
5 12*
2 24
1 48*
--60
You don't need to write down the remainder, because it's 1 if the number you just divided by 2 is odd. You don't need to write
down the powers of two, just the doublings. By marking the doublings that correspond to odd halvings, you select the terms to
add to get the result. You may also notice that the lines that were added (marked by asterisks) show the binary value 1010
when you read up.
This also corresponds to how binary numbers are multiplied, because all we do is multiply 6 by either a one or a zero in each
place (which is really just selecting whether to include it in the sum), and shifting it one place to the left each time (which is
really a doubling):
0110
6
x 1010 x 10
------ ----0000 (6 * 1)
0110 6 * 2
0000 (6 * 4)
0110 6 * 8
------- ----0111100 6 * 10
5|Page