115,Verilog-2005标准篇:verilog实用编译指令总结

Define类编译指令介绍:

`define <name> <string>



`ifdef <define_name>

   <statements>;

`elsif <define_name>

   <statements>;

`else

   <statements>;

`endif



`ifndef <define_name>

   <statements>;

`endif

例子:

`define DATA_WIDTH 16

`define DATA_WIDTH16



reg [`DATA_WIDTH-1:0] data;



`ifdef DATA_WIDTH8

   // If DATA_WIDTH8 was set, this would get compiled

`elsif DATA_WIDTH16

   // Since DATA_WIDTH16 is set, this does get compiled

`else

   // If DATA_WIDTH8 and DATA_WIDTH16 was not defined, this would be compiled

`endif

Include编译指令介绍

`include  "<file_name>"

例子:

`include "parameters.vh" // Include the contents of the parameters.vh file located in the current working directory.



`include "../data/ram_data.vh" // Include the contents of the ram_data.vh file in the relative directory ../data



`include "/export/vol1/sim_data/master.vh"// Include the contents of master.vh in the absolute directory /export/vol1/sim_data

timescale编译指令介绍:

// `timescale <units> / <precision>,仿真时需要该编译指令

// The units should be set to the base value in which time will be communicated to

// the simulator for that module.

// The precision is the minimum time units you wish the simulator to resolve. The

// smallest resolution value in all files and models compiled for simulation dictates

// the overall simulation resolution. In general for Xilinx FPGAs, a simulator

// resolution of 1ps is recommended since some components like the DCM require this

// resolution for proper operation and 1 ps is the resolution used for timing simulation.

//

// In general, this directive should appear at the top of the testbench, simulation models

// and all design files for a Verilog project.

`timescale 1 ns / 1 ns

`timescale 1 ns / 1 ps

`timescale 1 ns / 10 ps

`timescale 1 ns / 100 ps

`timescale 1 ps / 1 ps

`timescale 100 ps / 1 ps

例子:

  

`timescale 1 ns / 1ps

#1;           // Delays for 1 ns

#1.111;       // Delays for 1111 ps

#1.111111111; // Delays for 1111 ps since the resolution is more course than

              // what is specified, the delay amount is truncated

点赞加关注博主(ID:FPGA小飞)的博文,咱们一起系统学习verilog最终标准IEEE Std 1364-2005吧!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值