完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我使用Vivado for Matrix Multiplication在verilog中编写了一个代码,我想在FPGA ARTIX-7板上实现它。 在我的代码中,我有一个“Generate(genvar)块”和一个“always @ block”,我在两者中都有“for loops”。 我的问题是这些“for loops”可以合成FPGA实现吗? 我知道Genvar块是硬件,没关系。 我关注的是always @ block中的“for循环”。 我应该使用FSM吗?还是有其他选择吗? 或者对于循环来说很好,我可以继续使用FPGA IMplementation吗? 提前致谢, 沙 以上来自于谷歌翻译 以下为原文 Hi, I have written a code in verilog using Vivado for Matrix Multiplication and i want to implement it on FPGA ARTIX-7 board. In my code i have a "Generate(genvar) block" and an "always@ block" and i have "for loops" in both. My question is are these "for loops" synthesizeable for FPGA Implementation? I know the Genvar block is hardware and that is fine. I'm concerned with the "for loops" i have in the always@ block. Should i be using an FSM for this or is there any other alternative? Or are for loops fine and can i go ahead with FPGA IMplementation? Thanks in advance, Sandy |
|
相关推荐
5个回答
|
|
你好@ u4223374
我看到了你的几个帖子 https://forums.xilinx.com/t5/General-Technical-Discussion/is-nested-for-loops-synthesizable/td-p/685820 关于设计FSM。 你能帮我解决我的问题吗? 提前致谢, 沙 以上来自于谷歌翻译 以下为原文 Hi @u4223374 I saw couple of your posts on https://forums.xilinx.com/t5/General-Technical-Discussion/is-nested-for-loops-synthesizable/td-p/685820 regarding designing FSM. Can you help me with my problem as well? Thanks in advance, Sandy |
|
|
|
@ sandy_1022
哇,现在每个人都想要我! 答案与您链接的主题几乎相同。 您可以使用循环,但综合工具将构建整个循环以同时运行。 如果您正在进行3 * 3矩阵乘法,那么这将占用27个DSP片 - 这可能正是您想要的,并且可以节省写出长而错误的27行代码。 如果您正在进行64 * 64矩阵乘法,那么这将占用262,144个DSP片(即22个最大的Virtex Ultrascale +芯片) - 这很可能不是您所追求的。 实际上,对于任何超过3 * 3矩阵的东西,您可能需要实现一个FSM,每个时钟周期(例如)一个输出元素。 这将每个周期的工作从n³减少到n - 因此64 * 64矩阵只需要64个DSP片(但它需要64 * 64 = 4096个时钟周期)。 当然,FSM意味着您可以即时更改矩阵大小,而使用for循环,任何大小更改都需要重新运行合成和实现。 以上来自于谷歌翻译 以下为原文 @sandy_1022 Wow, everyone wants me now! The answer is pretty much the same as in the thread you linked. You can use a loop, but the synthesis tool will build the entire loop to run simultaneously. If you're doing 3*3 matrix multiplication, then this will occupy 27 DSP slices - which may well be exactly what you want, and saves writing out 27 long, mistake-prone lines of code. If you're doing 64*64 matrix multiplication, then this will occupy 262,144 DSP slices (ie 22 of the largest Virtex Ultrascale+ chips) - which is most likely not what you're after. Realistically, for anything over a 3*3 matrix you probably need to implement a FSM that does (for example) one output element per clock cycle. This reduces the work per cycle from n³ to n - so a 64*64 matrix will only need 64 DSP slices (but it'll take 64*64 = 4096 clock cycles). And, of course, a FSM means that you can change the matrix size on-the-fly, whereas with the for-loop any size changes require synthesis and implementation to be re-run. |
|
|
|
嗨@ u4223374,
感谢您的答复。 我已经使用case语句将我的整个“for循环”转换为FSM。 我的下一个问题是,我可以将我的“for loop”变量等同于FSM中的零吗? 如果我的for循环是for(m = 0; m因为我有多个“for循环”并再次使用相同的变量,我必须将它等于零,以便我可以使用相同的变量 循环不同。 再次感谢, 沙 以上来自于谷歌翻译 以下为原文 Hi @u4223374, Thanks for your response. I have converted my entire "for loops" into an FSM using case statements. My Next question is , Can i equate my "for loop" variable to zero inside the FSM? Something like "m<=4'b0000" if my for loop is for(m=0;m<4;m=m+1) because i have multiple "for loops" and to use the same variable again, i have to equate it to zero so that i can use the same variable for a different for loop. Thanks again, Sandy |
|
|
|
@ sandy_1022
你能发一个代码的例子吗? 您当然可以在FSM内将值重置为零,以便再次使用它。 例如,在2D循环中,这样的工作正常: reg [3:0] m = 4'b0; reg [3:0] n = 4'b0; reg done = 1'b0; 总是@(posedge clk)开始 如果(〜完成)开始 如果(m 唯一的限制是你只能在一个区块中设置它; 如果你在其他地方设置m,它也不能在FSM中设置。 以上来自于谷歌翻译 以下为原文 @sandy_1022 Could you post an example of the code? You can certainly reset a value back to zero inside the FSM so you can use it again. For example, in a 2D loop something like this works fine: reg [3:0] m = 4'b0;reg [3:0] n = 4'b0;reg done = 1'b0;always @(posedge clk) beginif (~done) beginif (m < 4) beginm <= m + 1'b1;end else if (m < 4) beginm <= 1'b0;n <= n + 1'b1;end else beginm <= 1'b0;n <= 1'b0;done <= 1'b1;endendendThe only limitation is that you can only set it in one block; if you're setting m somewhere else, it cannot be set in the FSM too. |
|
|
|
喜@ u4223374,
你的帖子非常有帮助。 非常感谢 谢谢, 沙 以上来自于谷歌翻译 以下为原文 hi @u4223374, Your post was very helpful. Thank you so much Thanks, Sandy |
|
|
|
只有小组成员才能发言,加入小组>>
2420 浏览 7 评论
2823 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2294 浏览 9 评论
3374 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2461 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1171浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
585浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
451浏览 1评论
2005浏览 0评论
729浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 14:26 , Processed in 1.488216 second(s), Total 87, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号