对`timescale的深入理解

在实际应用过程中,如网口IP CORE调试过程中,就会出现不同文件的module在不同的时间单位和精度的情况之下,因此,有必要对这个问题进行深入透彻地了解和分析。下面进行详细分析。

I.                    在顶层文件里instantiates each module,本身不写`timescale命令,但据说对modelsim的默认情况是`timescale 1ps/1ps,现看看波形图和各模块程序:


 

待测信号

Posedge time

`timescale

延迟时间表达式

b, d, f

5 ns

NONE

NONE

A

5 ns + 1.6 ns

1ns / 100ps

#1.55

C

5 ns + 1.55 ns

1ns / 10ps

#1.55

e

5 ns + 0.16 ns

100ps / 10ps

#1.55

分析:top文件完全没有干涉各模块的时间单位和精度。

程序如下:

// top.v文件,无` timescale

module top(a,b,c,d,e,f

    );

          output a,c,e;

          input  b,d,f;

          

          timescale_t t_1(.A(a),.B(b));

                   

          timescale_tt t_2(.C(c),.D(d));

                   

          timescale_ttt t_3(.E(e),.F(f));

                   

endmodule

 

//timescale_t.v文件

`timescale 1ns / 100ps

 

module timescale_t(

         A,B

    );

          

          output A;

          input  B;

          

          assign #1.55 A =  B;

                  

endmodule

 

//timescale_tt.v文件

`timescale 1ns / 10ps

 

module timescale_tt(

         C,D

         );

         

         output C;

         input  D;

 

         assign  #1.55 C = D;

         

endmodule

//timescale_ttt.v文件

`timescale 100ps / 10ps

 

module timescale_ttt(

         E,F

         );

         

         output E;

         input  F;

         

         assign #1.55 E = F;

         

endmodule

 

II.                 在顶层文件里写上`timescale 1ns/1ps,其他设置和程序不变,看看波形图:


 

待测信号

Posedge time

`timescale

延迟时间表达式

b, d, f

5 ns

1ns / 1ps

NONE

A

5 ns + 1.660 ns

1ns / 100ps

#1.55

C

5 ns + 1.550 ns

1ns / 10ps

#1.55

E

5 ns + 0.160 ns

100ps / 10ps

#1.55

分析:可见如果顶层写明了`timescale命令,那么它将会影响其模块内部各子模块的精度而不会对时间单位产生任何影响。但是,如果top.v中的时间精度比某个子模块的大,程序将如何处理呢?答案是,结果和I中的一样!

 

III.               在顶层文件的各实例化文件前面写上不同的`timescale,其他不变,看看效果:

 


显示,在一个module内部不可以编写`timescale命令!程序如下:

`timescale 1ns/100ps

module top(a,b,c,d,e,f

    );

          output a,c,e;

          input  b,d,f;

          

          `timescale 1ns / 100ps

          timescale_t t_1(.A(a),.B(b));

                   

                   `timescale 1ns / 10ps

          timescale_tt t_2(.C(c),.D(d));

                   

                   `timescale 100ps / 10ps

          timescale_ttt t_3(.E(e),.F(f));

                   

endmodule

 

对书中和网上疯狂转载的一段话进行修正:

“一个设计中的多个模块带有滋生的`timescale指令,模拟器总是定位在所有模块的最小时延精度上。”

这里的所有模块,指的是跟模块和某一个子模块相比较,并采用二者之间最小的精度,对于多个并行的子模块而言,它们是不会相互干扰对方的精度的。

 

转自:http://hi.baidu.com/lw2406/blog/item/87ed75011f316a316a60fb07.html

  • 0
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值