Verilog: Non-integer parameters

你离开我真会死。 提交于 2020-02-24 04:25:24

问题


I have a parameter as follows:

parameter PARAM = 7'd69;

When I try to assign that value to the register below:

reg [6:0] r;

Like this:

r <= PARAM;

I get synthesis warnings:

Warning (10230): ... truncated value with size 32 to match size of target (7)

-

This I assume is because PARAM is being interpreted as an integer because it is defined as a parameter. Is there any way to define PARAM as 7 bits wide?

I could always pass this in as a 7 bit input to my module but I was wondering if there is a more elegant solution.


回答1:


You can define parameter as follow:

parameter [6:0]PARAM = 7'd69;

That way you're telling your compiler that PARAM size is 7 bits.



来源:https://stackoverflow.com/questions/18362402/verilog-non-integer-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!