6.1.1、模块定义module,endmodule,include,library

注:参考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

        略

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值