![]() |
|
||||||||||||||
| . 网站首页 . 产品新知 . 业界资讯 . 技术文库 . 下载中心 . 服务导航 . | ||
|
||
|
|||||
| Verilog HDL常见问题 | |||||
作者:61EDA 文章来源:本站原创 点击数: 更新时间:2008-2-4 ![]() |
|||||
|
问题:在使用case语句建模组合逻辑的时候,综合工具提示会出现latch 引申:实际上这个问题还经常出现在使用if...else建模组合逻辑当中。 问题:如何使用Verilog语言描述一个双向口。 对双向口,我们可以将其理解为2个分量:一个输入分量,一个输出分量。另外还需要一个控制信号控制输出分量何时输出。此时,我们就可以很容易地对双向端口建模。 例子:
inout inout_pin; wire inout_pin; wire input_of_inout; assign input_of_inout = inout_pin; assign inout_pin = out_en ? output_of_inout : z; endmodule 在仿真的时候,需要注意双向口的处理。如果是直接与另外一个模块的双向口连接,那么只要保证一个模块在输出的时候,另外一个模块没有输出(处于高阻态)就可以了。
答案:
1 (defined as true), 0 (defined as false),
引申:
4.1.9 Logical operators The operators logical and (&&) and logical or (||) are logical connectives. The result of the evaluation of a logical comparison shall be 1 (defined as true), 0 (defined as false), or, if the result is ambiguous, the unknown value (x). The precedence of && is greater than that of ||, and both are lower than relational and equality operators. A third logical operator is the unary logical negation operator (!). The negation operator converts a nonzero or true operand into 0 and a zero or false operand into 1. An ambiguous truth value remains as x. Examples: Example 1—If reg alpha holds the integer value 237 and beta holds the value zero, then the following examples perform as described: regA = alpha && beta; // regA is set to 0 Example 2—The following expression performs a logical and of three subexpressions without needing any parentheses: a < size-1 && b != c && index != lastone However, it is recommended for readability purposes that parentheses be used to show very clearly the precedence intended, as in the following rewrite of this example: (a < size-1) && (b != c) && (index != lastone) Example 3—A common use of ! is in constructions like the following: if (!inword) In some cases, the preceding construct makes more sense to someone reading the code than this equivalent construct: if (inword == 0) |
|||||
| 文章录入:admin 责任编辑:admin | |||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | |||||
| 最新热点 | 最新推荐 | 相关文章 | ||
| Verilog讨论组精彩内容摘录 Verilog三段式状态机描述 Verilog 代码风格-供参考… |
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 | | |||
|