2012年10月13日 星期六

寫testbench 的錯誤

寫testbench 的錯誤


 一個 *.V  verilog 程式 可以被testbench 呼叫 好幾次

例如 

 comp1  UUT1   (.a(a0),.b(b0),.y(y0) );
 comp1  UUT2   (.a(a1),.b(b1),.y(y1) );
 comp1  UUT3   (.a(a2),.b(b2),.y(y2) );

 上例中 有一個comp1.v 的程式
  
  comp1 (input a , input b , output y)

 被呼叫3次  每一次變數均不同
 第一次 輸入a0 ,b0 輸出y0
 第二次 輸入a1 ,b1 輸出y1
 第三次 輸入a2 ,b2 輸出y2

自己不能呼叫自己 verilog 沒有此功能
自己呼叫自己叫 recursive


如下程式

`timescale 1us/1us               //主程式
module  comp2test (a,b,eq2,gt2,lt2) ;
   input [1:0]a;
   input [1:0]b;
   output eq2,gt2,lt2;
  
  wire el,gl,ll;
  wire eh,gh,lh;
  wire gla,lla;
  
  and(gla,gl,eh);
  and(lla,ll,eh);
  comp2test  comp1_g1(.eq(el),.gt(gl),.lt(ll),.a(a[0]),.b(b[0]));
  comp2test  comp1_g2(.eq(eh),.gt(gh),.lt(lh),.a(a[1]),.b(b[1]));
  
  and(eq2,el,eh);
  or(gt2,gla,gh);
  or(lt2,lla,lh);

endmodule

  正確的程式為comp2test.v及comp1.v二支程式
   modelsim --> simulation run --> run comp2test   


請參考


沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...