【问题标题】:Verilog basic gate data flow not working for NAND & NOR, but works for XNOR & XORVerilog 基本门数据流不适用于 NAND 和 NOR,但适用于 XNOR 和 XOR
【发布时间】:2021-11-24 09:43:28
【问题描述】:

我有一些使用数据流语句的基本代码,但是 nor 和 nand 函数不适用于此。

module basic_gates_bitwise_df(
input A,
input B,
output andd,orr,nota,nandd,norr,xorr,xnorr
);
assign andd=A&B;
assign orr=A|B;
assign nota=~A;
assign nandd=A~&B;
assign norr=A~|B ;
assign xorr=A^B;
assign xnorr=A~^B;
endmodule

我遇到了这样的错误:

ERROR:HDLCompiler:806 - "F:\basic.v" Line 37: Syntax error near "~&".
ERROR:HDLCompiler:806 - "F:\basic.v" Line 38: Syntax error near "~|".
ERROR:HDLCompiler:598 - "F:\basic.v" Line 21: 
Module<basic_gates_bitwise_df> ignored due to previous errors.

我可以尝试什么来解决这个问题?

【问题讨论】:

  • ~&amp; 和其他人在您的情况下应该是什么意思? verilog 中的两个操作数上没有这样的运算符。它们只能用作一元归约运算符。你期待什么?

标签: verilog fpga digital register-transfer-level vlsi


【解决方案1】:

有时您会通过不同的模拟器获得更有用的信息。例如,在 edaplayground 上使用 Synopsys VCS:

Error-[SE] Syntax error
  Following verilog source has syntax error :
    Invalid use of unary operator '~&'
   token is ';'
  assign nandd=A~&B;
                    ^
1 error

要修复错误,请更改:

assign nandd=A~&B;
assign norr=A~|B ;

到:

assign nandd=~(A&B);
assign norr=~(A|B);

请参阅 IEEE Std 1800-2017,第 11.4.9 节 归约运算符

一元归约运算符应在一个 单个操作数产生单个位结果。

对于 NAND,您应该对 2 个输入进行 AND,然后将 AND 表达式取反。


~^ 没有语法错误,因为它既是二元运算符,也是一元运算符。

【讨论】:

    猜你喜欢
    • 2018-11-18
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多