首页 > 其他分享 >Verilog编译指令

Verilog编译指令

时间:2022-08-14 16:03:03浏览次数:82  
标签:模块 31 编译 指令 Verilog resetall include

编译指令

编译指令(Compiler directive)能够让仿真器和综合工具执行一些特殊的操作。特点:

  1. 以`(重音符号)为前缀
  2. 从处理位置一直保持有效,除非被其他指令覆盖或者取消
  3. `resetall指令将所有编译指令复位成默认值

主要的编译指令:

  1. celldefine和endcelldefine:
  • 用于将模块标记为单元(cell),一些PLI程序可能会使用到。目前不常用。
  1. default_nettype
  • 用于指定隐含声明线网(Implicit net declaration)的类型。类型可以是none, wire, wand, wor, tri, triand, trior, tri0, tri1.
  • 只能在模块外部使用。
  • 默认类型是wire。
  • 如果设置为`default_nettype none,那么所有的线网都要清晰申明,否则会报错。
  1. define和undef
  • 前者用于定义一个宏替换,后者用于取消一个宏替换,resetall对define不起作用。
  • 可以在模块内外,效果都是一样的,parameter就只能在模块内。
  • 看看这个讲解,很基础,很清晰。
  • 宏定义的还可以这样使用:
    `define macro_name(arguements) text_string(arguements)
//Compare two 32-bit signed number
`define gt(x,y) ((x[32] == 0 && y[31] == 0) ? (x[30:0] > y[30:0]) : \
                 (x[31] == 1 && y[31] == 1) ? (x[30:0] > y[30:0]) : \
                 (x[31] == 0 && y[31] == 1) ? 1 : 0)
//pay attention that there is no ";" next to the ending of `define sentence!
reg [31:0] pig,dig;

if (`gt(pig,dog)) $display ("Info : Pig is greater than dog");
  1. include
  • include用于在源文件中插入另一个文件,要插入的内容可以是全局宏定义,也可以是经常使用的任务和函数。
  • 最好不要在文件名中使用绝对路径和相对路径,而是在编译时使用+incdir指定路径名。
  • resetall对include不起作用
  • 一个include不能插入多个文件,必须用多条include语句来实现。
  • include "../../primitive.v"插入的文件必须使用""括起来。
  1. ifdef,else,elsif,endif,ifndef
  • 用到再说
  1. resetall
  • 在编译中碰到resetall,所有指令恢复默认值。
  • resetall不能在模块和UDP中使用。
  1. line
  • 没懂
  1. timescale
  • 用于指定后续模块的仿真时间单位(time_unit)和时间精度(time_precision)。
  1. unconnected_drive和nounconnected_drive
  • 对于模块为连接的input端口,unconnected_dirve pull1/pull0,用于指定这些端口的上拉(1),下拉(0)
  • resetall = nounconnected_drive
  1. begin_keywords和end_keywords
  • 说明对一块源代码块使用哪一个保留关键字集合。
  1. pragma
  • 改变verilog源程序解释的指令。

掌握常用的编译指令就好

标签:模块,31,编译,指令,Verilog,resetall,include
From: https://www.cnblogs.com/xing-usetc/p/16585290.html

相关文章

  • [verilog手撕专题]时钟分频
    时钟分频前言,本专题属于verilog手撕专题中的一节,思维导图如下,其他专题请见导航2^n时钟分频modulediv_4(inputclk,inputrst_n,outputregclk_out)......
  • imx6 buildroot编译
    1.下载源码地址:https://buildroot.org/   随便选一个,下载后解决解压2.配置Targetoptions->TargetArchitecture=ARM(littleendian)->TargetBinaryF......
  • arm指令寻址方式
    1.数据处理指令的操作数的寻址方式语法:<opcode>{<cond>}{S}<Rd>,<Rn>,<shifter_operand>其中:<opcode>            指令助记符,eg:add表示算术加操作 ......
  • arm指令集
    1.跳转指令范围:跳转范围在[-32M,32M]b/bl语法:b<cond>des_addrbl<cond>des_addr涵义:跳转至目标地址des_addr执行区别:b仅仅是跳转......
  • 解决 MAUI 在mac上编译提示 The path 'XXXXXXX\Shared\MainLayout.razor.css' would
    路径'XXXXXXX\Shared\MainLayout.razor.css'将导致应用程序包之外的文件并且无法使用DescriptionTheerrorhappenswithBlazorMAUIHybridProject.Projectcompil......