computer_knowledge_notes/Languages/Verilog/模块.md

28 lines
563 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#### 模块的结构
```verilog
/* 端口定义 */
module 模块名(端口名);
/* I/O说明 */
input 端口名; // 输入口
output 端口名; // 输出口
/* 内部信号说明 */
reg [width-1:0] 变量;
wire [width-1:0] 变量;
/* 功能定义 */
assign 方程式; // 方法一用assign声明逻辑
and and_inst(q,a,b); // 方法二,用实例元件创建逻辑
always @(posedge clr); // 方法三用always块
begin
if(clr) q<=0;
else if(en) q<=d;
end
endmodule
```