LUT only works in simulation

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

LUT only works in simulation

Post by howard123 »

Hello

I am using a 24FV16KA304 device with FC7 and am not able to get my look-up table to work on hardware. It does work perfectly however in simulation.

I have stored about 1100 numbers in the range 1727 to 29271 using the LUT macro.

There is a compiler warning stating that these values are truncated to UINT. I should not have thought it a problem as my numbers are in that range and it is what the macro requires and the chip ROM is 16 bit anyway. Please correct me if I am wrong.

During simulation the loop exits with the correct value but on hardware the loop does not exit unless I force it to escape. My uninformed guess is that the numbers are not stored in ROM correctly.

Any ideas?

Howard
LUT test high res.fcfx
(14.37 KiB) Downloaded 308 times
LUT test high res.msg.txt
(98.93 KiB) Downloaded 297 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: LUT only works in simulation

Post by LeighM »

Hi,
The problem is that the LUT component is generating a byte array for the target ROM, so the integers are limited to 255.
Looks like we need to add a property to set the bit width.
In the meantime I have a workaround that should give you what you want.
You will need to add this simulation icon into the start of your main ...
lut16.jpg
lut16.jpg (6.82 KiB) Viewed 6754 times
Then use the simulation "step" button to step over this icon, that will force the component into 16 bit integer mode.
Then you can compile to chip.

Or to avoid having to remember to run the icon, and if you are feeling adventurous, create a Compile Start event macro ...
EvStart.jpg
EvStart.jpg (58.85 KiB) Viewed 6754 times

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: LUT only works in simulation

Post by howard123 »

Thanks
The first method worked. No more truncation messages and hence a fast compile. The second method, which would be more convenient, did not work.

Would you mind having a look at what I have done and correct as necessary.

Hope you can fix this sometime. :D

regards
Howard
LUT test high res 02.fcfx
(21.22 KiB) Downloaded 281 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: LUT only works in simulation

Post by LeighM »

Updated project attached ...
Attachments
LUT test high res 03.fcfx
(21.3 KiB) Downloaded 272 times

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: LUT only works in simulation

Post by howard123 »

Thanks that has worked.
It has used a considerable amount of program store - 4290 bytes. Are the LUT integers being declared as UINT32?
thanks

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: LUT only works in simulation

Post by LeighM »

No, UINT16

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LUT only works in simulation

Post by Benj »

Here is an updated LUT component with a user configurable data type, this should allow you to select exactly which data type you want to use.

If you have a go with it then please let me know how you get on.

Simply copy the attached file to your "Flowcode 7/Components" directory and restart Flowcode for the changes to be loaded.
lut.fcpx
(5.81 KiB) Downloaded 292 times

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: LUT only works in simulation

Post by howard123 »

Thanks Ben that works perfectly
cheers
Howard

Post Reply