Verilog Language
Modules:Hierarchy
Three modules
You are given a module my_dff with two inputs and one output (that implements a D flip-flop). Instantiate three of them, then chain them together to make a shift register of length 3. The clk port needs to be connected to all instances.
The module provided to you is: module my_dff ( input clk, input d, output q );
Note that to make the internal connections, you will need to declare some wires. Be careful about naming your wires and module instances: the names must be unique.
您将获得一个具有两个输入和一个输出(实现 D 触发器)的模块 my_dff。 实例化其中三个,然后将它们链接在一起以形成长度为 3 的移位寄存器。 clk 端口需要连接到所有实例。
提供给你的模块是:module my_dff ( input clk, input d, output q );
请注意,要进行内部连接,您需要声明一些电线。 命名电线和模块实例时要小心:名称必须是唯一的。
Module Declaration
module top_module ( input clk, input d, output q );
module top_module ( input clk, input d, output q );
wire a;//线网类型,接受第一个寄存器的输出
wire b;
my_dff my_dff1(clk,d,a);
my_dff my_dff2(clk,a,b);
my_dff my_dff3(clk,b,q);
endmodule