Ok, we seem to be getting somewhere with this post. I am snipping
everything above because it is unreadable due to the Google Groups
formatting problems.
On 7/20/2013 4:52 PM, lokesh kumar wrote:
>
> Lets consider a 5 bit number, A = 10100
>
> If we do the squaring of it then we will get,
>
> A = 10100
> x 10100
> -------------
> 00000
> 00000
> 10100
> 00000
> 10100
> -------------------
> c= 100010000 (XOR operation is performed to add)
This agrees with what we covered before.
> Now Irreducible polynomial is used to reduce it to 5-bit. (The aim is: if the input is out 5-bit then we need to reduce the output to 5-bit)
Ah! That's the part that was missing.
> So for a 5-bit number the irreducible polynomial is , F(x) = x^5 + x^2 + 1 (we can write it in binary form as 100101) (It is a standard value)
>
> Now both c and F(x) are added to reduce it to 5-bit. (from the MSB)
Is this the same as dividing? I'd like to understand the theory behind
this... or maybe not... ;^) lol
But seriously, this rings a bell that division and multiplication are
similar if not the same in polynomial arithmetic.
>
> 100010000 (value of c that we got after the squaring)
> xor 100101 ( value of F(x) that we calculated)
> -------------------
> 000111000 ( it is not 5-bit)
>
> So now again do the xor operation to the result with the irreducible polynomial.
>
>
> 111000 (Do not consider 3 zeros from the left)
> xor 100101 (irreducible polynomial)
> ---------------
> 011101 ( now it is reduced to a 5-bit number,(do not consider the zero at left side))
>
> If you take a close look on the result then, we have taken A = 10100 and we got c = 100010000 (before reduction)
>
> so simply we insert one zero between all the bits of A, then we will also get the same result.
>
> c = 0 1 0 0 0 1 0 0 0 0 ( zeros are indicated)
> | | | | |
Yes, this part actually doesn't require any hardware, just a bit of code
to assign different wires.
> If you remove the indicated zeros then tht value is equal to "A"
>
> So now my main aim is to design a generalised code for 5-bit. Suppose I am giving a 5-bit input, A = a4 a3 a2 a1 a0
>
> Then after squaring, I am getting a result C = 0-a4-0-a3-0-a2-0-a1-0-a0 ( zeros are added between all the bits of A)
>
> Now I have to use same irreducible polynomial (100101) to reduce it to 5-bit.
>
> How can I design this code? Please help me out. Hope everything is clear now.
Yes, more or less. Applying the irreducible polynomial (ip) to the
result is not hard to do, but the iteration can be done a couple of
ways. Is there a way to *know* how many times it must be applied?
Obviously this is what the code you provided is doing. I'm guessing
there must be some way of knowing how many times the ip must be applied
and perhaps even it is always the same number? If so, I can easily
generate the code similar to the 163 bit wide solution. If not, the
code will have to loop on applying the ip I think.
We could have a value of c = 101010101
applying the ip
101010101
100101 - once
001111101
100101 - twice
0110111
100101 - three times
010010 result!
This took three iterations and the number is not fixed although I think
we can set a max limit at three. So we will need to loop and either
exit conditionally or loop for the max count and conditionally execute
the XOR. Better, just make the 1's in each ip the value of the msb in
the appropriate bit of each intermediate c value. I bet if you dig into
the 163 bit version that is what they are doing. I can't figure it out
myself. First thing they do is to fold the input vector so the msbs are
in the bit positions that would be filled with zeros. Then they
generate vectors s, t and u which are all then XOR'd together to produce
the output.
Do you have a preference about whether this is clocked in a register and
takes multiple clock cycles or goes through successive stages of logic
without registers or clocks?
Any reason to generalize this for N bit wide inputs? I think we have
all the pieces now so we could do that as long as we can define the ip
for each value of N. Just doing it for N=5 is simpler of course.
If you do this normalization on a few test values to make sure it gives
the right answer and tell me if you want it as straight logic,
registered iteratively or pipelined, I'll give you an implementation.
--
Rick