第3章 Verilog 基本语法(已排).pptVIP

  • 11
  • 0
  • 约1.84万字
  • 约 71页
  • 2019-11-06 发布于湖北
  • 举报
* 3.4.6 条件操作符 条件操作符的语法为: LHS = condition ? true_expression:false_expression; 其意思是:if condition is TRUE, then LHS=true_expression, else LHS = false_expression 每个条件操作符必须有三个参数,缺少任何一个都会产生错误。最后一个操作数作为缺省值。 例如:assign out = (sel == 0) ? a : b; 若sel为0则out =a;若sel为1则out = b;如果sel为x或z,则结果可能为x或z。 * 条件操作符-使用实例 module likebufif( in, en, out); input in; input en; output out; assign out = (en == 1) ? in : bz; endmodule module like4to1( a, b, c, d, sel, out); input a, b, c, d; input [1: 0] sel; output out; assign out = sel == 2b00 ? a : se

文档评论(0)

1亿VIP精品文档

相关文档