【问题标题】:What the meaning of "|" and "&" in the if statement of Verilog [duplicate]“|”是什么意思和 Verilog 的 if 语句中的“&”[重复]
【发布时间】:2020-06-17 06:37:48
【问题描述】:
我看到了下面的 Verilog if 语句代码。想知道“|”的含义/目的是什么和“&”在 dl 和 dl_n 之前?有好心人解释一下吗?或者我应该从谷歌寻找什么关键字?
if((count_w > 1) && ~(|dl==1'b0 && &dl_n==1'b1)) begin
//Statements
end
【问题讨论】:
标签:
verilog
register-transfer-level
【解决方案1】:
这些在 Verilog 中称为 reduction operators。
| 用作OR,& 用作AND。
以下是归约运算符:
| Operator| Type |
|_________|_________|
| & | And |
| ~& | Nand |
| | | Or |
| ~| | Nor |
| ^ | Xor |
| ~^ | Xnor |
|_________|_________|
【解决方案2】:
这些是 一元归约 运算符。 |val 是归约 OR,&val 是归约 AND。
【解决方案3】:
归约运算符:
- &(与)
- ~& (NAND)
- | (或)
- ~| (NOR)
- ^(异或)
- ~^ 或 ^~ (XNOR)
不过,不要与“&&”混淆,因为这是本地 AND。此外,归约应该紧挨着变量,如果定位在两个变量之间,如 "a & b" ,它是按位运算,例如:
wire c = &a ^ |b;
/* The value of a has an AND reduction,
b an OR reduction,
and the results of those reductions takes a bit wise XOR operation between them,
this assigned to c.*/