2017-05-09 183 views
0

我正尝试使用verilog连接Altera FPGA上的两个引脚。fpga在verilog中将inout引脚分配给输入引脚

具体而言,我将inout引脚连接到input引脚。我收到错误。

引脚 “<名>” 有多个驱动器

错误是这个链接解释。

Altera description

这是解决方案:

module multi_driver(inout o, input a, b, en); 

    // Input a directly drives the bidir pin w/o a tri-state condition 
    assign o = a; 

    // If en = 1 below, there will be an electrical conflict in the design. 
    // To avoid this possibility, the Quartus II software issues an error 
    assign o = (en) ? b : 1'bz; 

endmodule 

有人能解释一下行assign o = (en) ? b : 1'bz;不正是?

+2

[Verilog问号(?)运算符]的可能的副本(http://stackoverflow.com/questions/12336139/verilog-question-mark-operator) –

+0

您提到的代码不是解决方案,而是不正确的代码示例:“例如,以下设计不正确地合成”。 – Qiu

回答

0

assign o = (en) ? b : 1'bz;是Verilog的三态锁存模板。当en高时o端口将被输出,其值将为b。当en为低端口时o将为1'bz(即高阻抗状态)。高阻态意味着它将形成它从模块外面强制的任何东西(即它是输入)。

如果您试图强制另一个信号assign o = a;而不管en信号,它会警告您该信号有多个驱动程序。只有当引脚处于高阻抗状态时,才可以连接来自模块外部的信号。