在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3443|回复: 1

[求助] verilog条件生成和条件编译的区别

[复制链接]
发表于 2016-7-28 14:16:35 | 显示全部楼层 |阅读模式
200资产
`ifdef `else `endif和generate...if...endgenerate之间的区别与联系,是否能相互替换?

知道的大神讲讲呗

发表于 2016-8-3 15:39:27 | 显示全部楼层
`ifdef, `else, `elsif, `endif, `ifndef:These conditional compilation compiler directives are used to include optionally lines of a Verilog HDL
source description during compilation. The `ifdef compiler directive checks for the definition of a
text_macro_name. If the text_macro_name is defined, then the lines following the `ifdef directive
are included. If the text_macro_name is not defined and an `else directive exists, then this source is
compiled. The `ifndef compiler directive checks for the definition of a text_macro_name. If the
text_macro_name is not defined, then the lines following the `ifndef directive are included. If the
text_macro_name is defined and an `else directive exists, then this source is compiled.
If the `elsif directive exists (instead of the `else) the compiler checks for the definition of the
text_macro_name. If the name exists the lines following the `elsif directive are included. The `elsif
directive is equivalent to the compiler directive sequence `else `ifdef ... `endif. This directive does not need a
corresponding `endif directive. This directive must be preceded by an `ifdef or `ifndef directive.
These directives may appear anywhere in the source description.


generate..if...endgenerate
Generate statements allow control over the declaration of variables, functions and tasks, as well as control
over instantiations. Generated instantiations are one or more: modules, user defined primitives, Verilog gate
primitives, continuous assignments, initial blocks and always blocks. Generated declarations and instantiations
can be conditionally instantiated into a design. Generated variable declarations and instantiations can
be multiply instantiated into a design.

不清楚的地方可以仔细看一下LRM,第一种属于预编译命令,发生在parse阶段。第二种属于生成语句,发生在elaboration阶段。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-22 09:36 , Processed in 0.013598 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表