Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么这个Verilog函数中没有assign语句? 来自C++背景,我开始学习Verilog。该代码描述了进入两个AND门的四个输入。这两个与门的输出进入或门。或门的输出是最终输出 // a user-defined AND gate module my_and2 (in, out); input [1:0] in; output out; assign out = in[1]&in[0]; endmodule // a user-defined OR gate module my_or2 (in, out); input [1:0] in; output out; assign out = in[1]|in[0]; endmodule // the AND-OR logic built on top of the user-defined AND and OR gates module and_or (in_top, out_top); input [3:0] in_top; output out_top; wire [1:0] sig; // instantiate the gate-level modules my_and2 U1 (.in(in_top[3:2]),.out(sig[1])); my_and2 U2 (.in(in_top[1:0]),.out(sig[0])); my_or2 U3 (.in(sig),.out(out_top)); endmodule_Verilog - Fatal编程技术网

为什么这个Verilog函数中没有assign语句? 来自C++背景,我开始学习Verilog。该代码描述了进入两个AND门的四个输入。这两个与门的输出进入或门。或门的输出是最终输出 // a user-defined AND gate module my_and2 (in, out); input [1:0] in; output out; assign out = in[1]&in[0]; endmodule // a user-defined OR gate module my_or2 (in, out); input [1:0] in; output out; assign out = in[1]|in[0]; endmodule // the AND-OR logic built on top of the user-defined AND and OR gates module and_or (in_top, out_top); input [3:0] in_top; output out_top; wire [1:0] sig; // instantiate the gate-level modules my_and2 U1 (.in(in_top[3:2]),.out(sig[1])); my_and2 U2 (.in(in_top[1:0]),.out(sig[0])); my_or2 U3 (.in(sig),.out(out_top)); endmodule

为什么这个Verilog函数中没有assign语句? 来自C++背景,我开始学习Verilog。该代码描述了进入两个AND门的四个输入。这两个与门的输出进入或门。或门的输出是最终输出 // a user-defined AND gate module my_and2 (in, out); input [1:0] in; output out; assign out = in[1]&in[0]; endmodule // a user-defined OR gate module my_or2 (in, out); input [1:0] in; output out; assign out = in[1]|in[0]; endmodule // the AND-OR logic built on top of the user-defined AND and OR gates module and_or (in_top, out_top); input [3:0] in_top; output out_top; wire [1:0] sig; // instantiate the gate-level modules my_and2 U1 (.in(in_top[3:2]),.out(sig[1])); my_and2 U2 (.in(in_top[1:0]),.out(sig[0])); my_or2 U3 (.in(sig),.out(out_top)); endmodule,verilog,Verilog,前两个模块对我来说很有意义。然而,最后一个没有。前两个模块的末尾有一个assign语句,用于设置输出变量的值。然而,最后一个没有。这是为什么?out\u top由U3实例输出驱动。Verilog是“事件驱动的”。在编写verilog时,请考虑敏感度列表 在与门的示例中,有表达式assignout=In[1]&In[0]。据说您的表达式对[0]中的和[1]中的敏感。这意味着在[0]中的或[1]中的发生更改时,表达式将重新计算,并且out的值将更新 因此,在顶级模块和_或中,您基本上是在构建一个对前

前两个模块对我来说很有意义。然而,最后一个没有。前两个模块的末尾有一个assign语句,用于设置输出变量的值。然而,最后一个没有。这是为什么?

out\u top由U3实例输出驱动。

Verilog是“事件驱动的”。在编写verilog时,请考虑敏感度列表

在与门的示例中,有表达式
assignout=In[1]&In[0]。据说您的表达式对[0]
中的
和[1]
中的
敏感。这意味着在[0]
中的
或[1]
中的
发生更改时,表达式将重新计算,并且
out
的值将更新

因此,在顶级模块
和_或
中,您基本上是在构建一个对前面表达式的输出敏感的表达式树。当然,此树是使用模块连接构建的。因此,该顶级模块的一个输入值的变化将波及其“逻辑锥”中的所有表达式

要驱动输入,您需要将更高级别的测试台模块驱动信号输入
和\u或
模块。这将提供按时间间隔的输入,从而触发
和\u或
中及以下的表达式。如果没有,您的sim卡将没有事件,因此不会触发任何表达式,并且sim卡将在0秒时超时,因为它是“事件饥饿”


PS:对于AND门表达式,
assignout=&in也会起作用。。。(简化和运算符)

简单地说,我喜欢将实例化看作是连接线


模块是数字电路块。你和或门模块是魔法发生的地方。你已经了解那部分了。通过实例化这些模块,就像将顶级模块的输入线与两个块和模块的输入连接起来一样。然后把它们的输出,并把它们贴在你的或块外的输入线上。最后,您要将或块的输出连接到顶层的输出信号线。

因此,实例化一个模块会自动运行它?实际上,该代码中没有任何内容是真正的“运行”,因为它不包含任何过程语句。它是一种显示连通性的结构描述。当然,模拟器将执行代码来影响信号的变化,但这些细节与电路建模并不完全相关。