LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert Simulink float-point data to FPGA fixed-point data

I built a model in simulink, whose data type is double. Then I convert it's data type to fixed-point and the altered model ran successfully in simulink.

But when I converted the fixed-point simulink model to VHDL file and put the file into FPGA(through CLIP node), the simulation results are wrong.

I guess I made some mistakes in data type conversion(float to fixed) which cause data loss but have no specific idea.I paste a screeshot and wonder if there is something wrong. (I can make sure that the set fixed-point type prevent overflow happening but not sure if there is a mistake in operation like plus and times).

0 Kudos
Message 1 of 5
(3,120 Views)

Did you post the correct attachment?  The diagram you attached doesn't show anything about a fixed point/floating point conversion.

0 Kudos
Message 2 of 5
(3,092 Views)

The attchment shows the converted data, which means conversion of float-point to fixed-point is completed. For example, sfix(32,31) represents 32 bit word length and 31 bit decimal length, which corresponds to FXP(+/-,32,1) in Labview FPGA.

For example, 2*2=4. I set them as (+/-,16,4), (+/-,16,4) and (+/-,16,5). I think (+/-,16,5) covers 4. But as I know, the result data type should be set as (+/-,32,8). I don't know if (+/-,16,5) is feasible.

In another simple case, I converted int32 to (+/-,16,10), which covers the full range of the data. The model runs correctly in simulink but wrong in FPGA. When I changed (+/-,16,10) to (+/-,32,26), the model runs correctly both in simulink and FPGA.

So I Think maybe there is some mistakes in my FXP configuration, which although covers the full range of results, but still wrong maybe due to integer/decimal word length settings. For the simple case, I find the problem luckily ,but for this complicated model, I can't identify the problem.

So I wonder if there are some general rules in converting float-point to fixed-point and word length configuration rules regarding fixed-point operation.

 

0 Kudos
Message 3 of 5
(3,073 Views)

No, your attachment doesn't show any converted data.  It shows some sort of functional flow chart.

 

I realize your subject line talks about Simulink.  That isn't an NI product.  Perhaps you should post your question in a forum dedicated to that software.  You talk about LabVIEW FPGA in your message, but you haven't shown anything about LabVIEW in your attachment.

0 Kudos
Message 4 of 5
(3,067 Views)

Hello 

0 Kudos
Message 5 of 5
(3,062 Views)