宏定义 重复了会如何?
时间:10-02
整理:3721RD
点击:
如果在一个文件,例如a.vh中
`define KKK 128
而在另外一个文件,b.v中:
`include a.vh
`define KKK 34
那么最后编译的结果是不是:
在b.v中,KKK=34,
而其他的包含a.vh但并没有定义KKK的文件中,kkk=128
这么理解对吗?请指教
`define KKK 128
而在另外一个文件,b.v中:
`include a.vh
`define KKK 34
那么最后编译的结果是不是:
在b.v中,KKK=34,
而其他的包含a.vh但并没有定义KKK的文件中,kkk=128
这么理解对吗?请指教
同问,不知道和c是不是一样的
自己顶起来
不是的,Verilog里宏是全局的,具体取什么值,要看你加载的顺序,原则是使用最新的值。
即,a.v加载后在b.v加载前使用a.v的值,b.v加载后使用b.v中定义的值,不管你include哪个文件。
你可以简单试一下。
进来学习一下………………
111
正解!是和编译的顺序有关系的
学习,学习
这种情况强烈建议把类似的参数集中起来统一调用,
so in other words, it won't turn out to be this file `define is one thing and `define is another thing in the other file.
Instead, redefinition of macro means different guy is expecting different things, assuming there're more than 1 people on your project. This should be solved once spotted. VCS warns about it. lint tools would warn about it too.
换言之
何苦这样定义呢?
纯属了解可以
难道实际应用你会这样吗?
