注:参考https://www.xilinx.com/support/documentation/sw_manuals/xilinx11/ite_r_verilog_reserved_words.htm
1、module/endmodule
module,顾名思义是模块的意思,在verilogHDL中,module声明是唯一的设计单元。她描述了在同样的设计环境下,连接到其他设计单元的接口设计和她内部逻辑功能的设计。
module像如下定义:
module <module_name> (<portlist>);
.
. // module components
.
endmodule
其中,<module_name>是module的类型名称;<portlist>是端口列表,端口类型允许数据流入或流出模块单元。中间module components是模块单元实现的功能组件,可以是组合逻辑、时序逻辑、元器件库实例调用或其他模块单元的实例调用。
例如:
module top;
type1 childA(ports...); // "ports..." indicates a port list
type2 childB(ports...); // which will be explained later
endmodule
module type1(ports...);
type3 leaf1(ports...);
type3 leaf2(ports...);
endmodule
module type2(ports...);
type3 leaf3(ports...);
type1 node1(ports...);
endmodule
module type3(ports...);
// this module does not instantiate any other modules
endmodule
模块类型是不能被她自己实例化的,只能被其他模块实例化,如下:
module <module_name_1> (<portlist>);
.
.
<module_name_2> <instance_name> (<portlist>);
.
.
endmodule
通过规定说明,最顶层的module是不被其他任何模块实例化的,对于顶层的<module name>既可以是她的类型名称,也被用作她的实例化名称。如下:
module foo;
bar bee (port1, port2);
endmodule
module bar (port1, port2);
...
endmodule
其中,foo模块是top层的module,她不需要实例化,foo既作为模块类型名称又作为实例化名称。子模块名字是bee,她的类型名称是bar。
2、include
·include类似C语言的#include语句,指定包含一个本地的verilog头文件,且该包含语句可以放置在verilog文件中的任何地方。例如:
·include "config_para.vh" //包含配置参数的头文件,在调用她的地方用config_para.vh头文件中的内容替换该语句。
例如:
`ifndef _CONFIG_PARA_vh_
`define _CONFIG_PARA_vh_
parameter Tm = 2;
parameter Tn = 2;
`endif
module top (x,y);
input x;
output y;
`include "config_para.vh"
assign y = x;
endmodule // top
3、library
略