Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Level 3
Level 3

# X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

According to project requirements,the host will transfer one frame to the FPGA.The size of the frame is 2160KB.In  order to reduce errors, we will add a frame header such as “0x55AA_66BB” in  front of the frame.So the size of transfer data is 2160KB+4B.What should I do ?

If X > 16 KB, then let Y = (X % 16 KB). Now:
i) If Y == 0, then on completion of X bytes nothing needs to be done.

ii) If Y < 16 KB and (X % 1024) == 0, then on completion of X bytes, a zero-length packet must be sent so that the buffer in the device gets committed to GPIF.

But in my design,X>16KB,Y<16KB and (X)

Best Regards，
Jack chen
1 Solution
Moderator
Moderator

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Thank you for the clarification.

For your case, the size of DMA buffer is 16KB and the frame size (along with header) is 2160KB + 4B. The sum 2160KB + 4B is not divisible by 16KB. This means that the last DMA buffer will have 4B data and will not be committed to the FPGA side. So, you need to send a ZLP (Zero Length Packet) after one frame is transferred (2160KB + 4B) from the host.

Best Regards,
Jayakrishna
6 Replies
Moderator
Moderator

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Please let me know the size of the DMA buffer used in the firmware so that we can check if the calculations should be done on 16KB or not.

Based on your description, I find that the total frame size is 2160KB. Is the 4B header added at the host side before sending the data to the device or is it added on the firmware side? How is this header added? Is it before the start of the frame?

Best Regards,
Jayakrishna
Level 3
Level 3

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Thanks for your reply.

The size of the DMA buffer used in the firmware is 16KB.

The project require us to transfer pictures from host to the FPGA.We want to add the 4B header before the start of every frame,but we do not know how to do it.The 4B header is used for FPGA checked  correctness of the frame.The 4B header added at the host side in my plan.But if I add the 4B header at the host side,the total size of one frame will be  2160KB+4B,and i do not know how to transfer this by host.

So do you have some advice to meet my needs?

Best Regards，
Jack chen
Level 3
Level 3

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

As that KBA mentioned:

If X > 16 KB, then let Y = (X % 16 KB). Now:
i) If Y == 0, then on completion of X bytes nothing needs to be done.

ii) If Y < 16 KB and (X % 1024) == 0, then on completion of X bytes, a zero-length packet must be sent so that the buffer in the device gets committed to GPIF.

But in my design,X>16KB,Y<16KB and (X%1024)!=0. what should i do to transfer this frame at the host side.

Best Regards，
Jack chen
Moderator
Moderator

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Thank you for the clarification.

For your case, the size of DMA buffer is 16KB and the frame size (along with header) is 2160KB + 4B. The sum 2160KB + 4B is not divisible by 16KB. This means that the last DMA buffer will have 4B data and will not be committed to the FPGA side. So, you need to send a ZLP (Zero Length Packet) after one frame is transferred (2160KB + 4B) from the host.

Best Regards,
Jayakrishna
Level 3
Level 3

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Thanks a lot.

As you metioned,the code as follow at the host side.

xferdata(frame,len);//frame saved the header and picture                      //data,len=2048*1080+4= 2160KB+4B

xferdata(buf,len1);//len1=0

Is that correct?

Best Regards，
Jack chen
Moderator
Moderator

# Re: X>16KB , let Y = (X % 16 KB),Y<16KB and(X%1024)!=0.What should I do when I transfer X OUT?

Jump to solution

Hello,

Yes, the code mentioned in your previous response is proper.

Best Regards,
Jayakrishna