LUT5

More
12 Dec 2012 23:49 #27634 by BigJohnT
Replied by BigJohnT on topic LUT5
And amazingly enough the name makes sense to me now...

LUT5 = Look Up Table 5 inputs.

John

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 21:49 - 13 Dec 2012 21:50 #27667 by andypugh
Replied by andypugh on topic LUT5
Lets look at this another way...

Why is it a _5_ element lookup? where does that number come from? The answer is that 2 ^ 5 is 32. And HAL uses 32-bit numbers.

The "magic number" you use in the HAL file is just a list of 32 possible output values. Each bit in the 32-bit number corresponds to one of the possible combinations of input pins.

Imagine it was LUT2 and we wanted an AND gate. The truth table is
0 0 = 0
0 1 = 0
1 0 = 0
1 1 = 1

the first line is binary 0. so bit 0 is 0. (ir the desired output for an input of 0 0)
The second line is binary 1, so bit 1 is 0. ditto line 2 (binary 2).
The last line, binary 3, is required to have an output of 1. Listing the outputs in sequence, we have 1000. (just read up the final column) That is 8 (or 8 in hex :-)

The 2-input XOR would be
0 0 = 0
0 1 = 1
1 0 = 1
1 1 = 0

Which is 0110 in binary, or 6.

How about an XOR with an "over-ride" in input 2 (counting from 0, so the third one).

0 0 0 = 0
0 0 1 = 1
0 1 0 = 1
0 1 1 = 0
1 0 0 = 1
1 0 1 = 1
1 1 0 = 1
1 1 1 = 1
That's b11110110 or 246 decimal or 0xF6 hex.

And as a final 3-bit example, if exactly 2 inputs are set... (which isn't any kind of boolean logic at all)
0 0 0 = 0
0 0 1 = 0
0 1 0 = 0
0 1 1 = 1
1 0 0 = 0
1 0 1 = 1
1 1 0 = 1
1 1 1 = 0
The magic number here is b01101000 or 104 decimal or 0x68

The component doesn't use any internal logic at all. It just looks at the input values, interprets those as a number from 0 to 31, and outputs the bit from the LUT value corresponding.
This is rather neat, as it means that we can combine the 5 inputs in any way we like.

I rather think that the existing docs massively complicate and obfuscate the way that it works with all the talk of summing of weights. it is rather simpler to think in terms of writing out the truth table and converting the output column from binary to hex or decimal.
Last edit: 13 Dec 2012 21:50 by andypugh.
The following user(s) said Thank You: DoWerna

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 21:53 #27668 by andypugh
Replied by andypugh on topic LUT5

Note that LUT5 will generate any of the 4,294,967,296
logical functions of 5 inputs


Actually, there are only 32 possible outputs of 5 inputs :-)

You are describing LUT32 which awaits the creation of the 4,294,967,296-bit CPU :-)

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 21:58 - 13 Dec 2012 21:59 #27669 by BigJohnT
Replied by BigJohnT on topic LUT5

And as a final 3-bit example, if exactly 2 inputs are set... (which isn't any kind of boolean logic at all)
0 0 0 = 0
0 0 1 = 0
0 1 0 = 0
0 1 1 = 1
1 0 0 = 0
1 0 1 = 1
1 1 0 = 1
1 1 1 = 0
The magic number here is b01101000 or 104 decimal or 0x68

The component doesn't use any internal logic at all. It just looks at the input values, interprets those as a number from 0 to 31, and outputs the bit from the LUT value corresponding.
This is rather neat, as it means that we can combine the 5 inputs in any way we like.

I rather think that the existing docs massively complicate and obfuscate the way that it works with all the talk of summing of weights. it is rather simpler to think in terms of writing out the truth table and converting the output column from binary to hex or decimal.


How do you compute the binary value?

John
Last edit: 13 Dec 2012 21:59 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:12 #27671 by andypugh
Replied by andypugh on topic LUT5

How do you compute the binary value?

By reading the output column from bottom to top? Or wasn't that the question?

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:34 #27673 by BigJohnT
Replied by BigJohnT on topic LUT5
That is the question, unfortunately it is Greek to me as to how to "read" the output column.

John

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:41 #27674 by andypugh
Replied by andypugh on topic LUT5

That is the question, unfortunately it is Greek to me as to how to "read" the output column.


The bottom number is a 0, so the first digit is zero. The next digit up is 1, so the next digit in the number is 1 and so on.

(As an aside the Ubuntu calculator, in View -> programmer mode, displays the bit-pattern corresponding to any number, and you can actually twiddle individual bits in the binary panel)

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:42 #27676 by andypugh
Replied by andypugh on topic LUT5
There are only 10 sorts of person in the world, those who understand binary, and those who don't. :-)

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:47 #27677 by BigJohnT
Replied by BigJohnT on topic LUT5
Now that calculator is cool... I think I got it now.

John

Please Log in or Create an account to join the conversation.

More
13 Dec 2012 22:56 #27678 by andypugh
Replied by andypugh on topic LUT5
I think the only thing missing is to say that the left-hand side of the table needs to be the numbers 0 to 32 written in strict binary order.

0 0 0 0 0 =
0 0 0 0 1 =
0 0 0 1 0 =
0 0 0 1 1 =
0 0 1 0 0 =
0 0 1 0 1 =
0 0 1 1 0 =
0 0 1 1 1 =
0 1 0 0 0 =
0 1 0 0 1 =
0 1 0 1 0 =
0 1 0 1 1 =
0 1 1 0 0 =
0 1 1 0 1 =
0 1 1 1 0 =
0 1 1 1 1 =
1 0 0 0 0 =
1 0 0 0 1 =
1 0 0 1 0 =
1 0 0 1 1 =
1 0 1 0 0 =
1 0 1 0 1 =
1 0 1 1 0 =
1 0 1 1 1 =
1 1 0 0 0 =
1 1 0 0 1 =
1 1 0 1 0 =
1 1 0 1 1 =
1 1 1 0 0 =
1 1 1 0 1 =
1 1 1 1 0 =
1 1 1 1 1 =

Please Log in or Create an account to join the conversation.

Time to create page: 0.088 seconds
Powered by Kunena Forum