完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我有一个关于以下代码片段的问题 -
imy模块在进行端口映射时将indatawidth和inchannelwidth作为参数。 和temp_val,temp_data是宽度的reg,具体取决于参数。 我按以下方式为regs分配值 - if(inchannelwidth inchannelwidth。即使存在if条件,模拟器仍会编译代码并输出错误。错误消息表示reg索引被反转。(因为现在inchannelwidth> indatawidht)。 所以我的问题是 - 在处理这样的动态参数时,编写代码/逻辑的最佳编码实践是什么,以便这样的模拟器/编译器不会因不同的参数条件而出错。 让我知道...... ž。 以上来自于谷歌翻译 以下为原文 hi, i had a question regarding the the following code snippet - imy module takes indatawidth and inchannelwidth as parameters while portmapping. and temp_val, temp_data are regs of width depending on the parameters. i assign values to the regs as follows - if (inchannelwidth < indatawidht - 4) temp_val[indatawidth-1:inchannelwidth] <= temp_data[indatawidht-1:inchannelwidth]; the above snippet works if the inchannelwidth < indatawidth. HOWEVER, the above logic fails (while compiling in modelsim), if the inchannelwidth > inchannelwidth. even though there is the if condition, the simulator still compiles the code and errors out. error message says the reg indexes are reversed. (because now inchannelwidth > indatawidht). so my question is - while dealing with such dynamic parameters, what is the best coding practice to write code/logic so that such the simulators/compilers dont error for different parameter conditions. do let me know ... z. |
|
相关推荐
1个回答
|
|
|
进一步的建议。
使用参数对模块进行编码时,请在标题中记录参数的可接受范围。 即 模块小发明 #( 参数FOO = 32,//最小1,无最大值 参数BAR = 3,//最小0,最大3 参数BAZ = 64 //目前仅支持64个参数QUX = 16 //最小8,仅为2的幂 )(); 您的模块只能在一个配置中使用,但至少通过思考可接受参数的范围,它将有助于您对逻辑进行编码。 这个记录的范围将受到下一个人的极大赞赏。 (通常情况下,下一个人是我自己的某个时候......) 问候, 标记 以上来自于谷歌翻译 以下为原文 Some further suggestions. When coding your module with parameters, please DOCUMENT the acceptable range for you parameter in the header. i.e. module gizmo#( parameter FOO = 32, // Min 1, no max parameter BAR = 3, // Min 0, Max 3 parameter BAZ = 64 // Only 64 currently supported parameter QUX = 16 // Min 8, powers of two only)(); Your module may only be used in one configuration, but by at least THINKING about the range of acceptable parameters, it'll help how you code the logic. And this documented range will be greatly appreciated by the next person. (More often than not, that next person is myself sometime down the road...) Regards, Mark |
|
|
|
|
只有小组成员才能发言,加入小组>>
3148 浏览 7 评论
3437 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2900 浏览 9 评论
4108 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
3083 浏览 15 评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
1363浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
1202浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-15 07:39 , Processed in 0.713524 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
21399
