<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 測試測量 > 設計應用 > 編寫(xiě)高效的測試設計(testbenches)

編寫(xiě)高效的測試設計(testbenches)

作者: 時(shí)間:2008-06-26 來(lái)源:電子開(kāi)發(fā)網(wǎng) 收藏

  reset = 1;

本文引用地址:http://dyxdggzs.com/article/84843.htm

  data = 5’b00000;

  load = 0;

  sel = 2’b00;

  #200

  reset = 0;

  load = 1;

  #200

  data = 5’b00001;

  #100

  sel = 2’b01;

  load = 0;

  #200

  sel = 2’b10;

  #1000 $stop;

  end

  initial begin// this process block pipes the ASCII results to the

  //terminal or text editor

  $timeformat(-9,1,"ns",12);

  $display(" Time Clk Rst Ld SftRg Data Sel");

  $monitor("%t %b %b %b %b %b %b", $realtime,

  clock, reset, load, shiftreg, data, sel);

  end

  endmodule

  以上的設計實(shí)例化設計,設置時(shí)鐘,提供激勵信號。所有的進(jìn)程塊在仿真時(shí)間零點(diǎn)開(kāi)始。英鎊標記(#)說(shuō)明下一個(gè)激勵作用前的延遲。$stop命令使仿真器停止仿真(所有設計中都應該包含一個(gè)停止命令)。最后,$monitor語(yǔ)句返回ascII格式的結果到屏幕或者管道輸出到一個(gè)文本編輯器。接后的是一個(gè)VHDL描述的的測試設計,它實(shí)例化設計并提供激勵到上述用verilog描述的移位寄存器.

  library IEEE;

  use IEEE.std_logic_1164.all;

  entity testbench is

  end entity testbench;

  architecture test_reg of testbench is

  component shift_reg is

  port (clock : in std_logic;

  reset : in std_logic;

  load : in std_logic;

  sel : in std_logic_vector(1 downto 0);

  data : in std_logic_vector(4 downto 0);

  shiftreg : out std_logic_vector(4 downto 0));

  end component;

  signal clock, reset, load: std_logic;

  signal shiftreg, data: std_logic_vector(4 downto 0);

  signal sel: std_logic_vector(1 downto 0);

  constant ClockPeriod : TIME := 50 ns;

  begin

  UUT : shift_reg port map (clock => clock, reset => reset,

  load => load, data => data,

  shiftreg => shiftreg);

  process begin

  clock <= not clock after (ClockPeriod / 2);

  end process;

  process begin

  reset <= ’1’;

  data <= "00000";

  load <= ’0’;

  set <= "00";

  wait for 200 ns;

  reset <= ’0’;

  load <= ’1’;

  wait for 200 ns;

  data <= "00001";

  wait for 100 ns;

  sel <= "01";

  load <= ’0’;

  wait for 200 ns;

  sel <= "10";

  wait for 1000 ns;

  end process;

  end architecture test_reg;

  上述VHDL測試設計與之前提到的verilog測試設計的功能是相似的,如希望用一個(gè)命令來(lái)返回輸出到終端。在vhdl中,std_textio程序包被用于在終端上顯示信息, 它將被擱到下一節說(shuō)明。
自動(dòng)驗證

  推薦自動(dòng)實(shí)現測試結果的驗證,尤其是對于較大的設計來(lái)說(shuō)。自動(dòng)化減少了檢查設計是否正確所要求的時(shí)間,也使人可能的犯錯最少。

  一般有以下幾種常用的自動(dòng)測試驗證的方法:

  1、數據庫比較。首先,要創(chuàng )建一個(gè)包含預期輸出(一個(gè)黃金向量文件)的數據庫文件。然后,仿真輸出被捕獲并與黃金向量文件中參考的向量比較(在 unix中的diff 工具可以用來(lái)比較ascii數據文件)。然而,因為從輸出到輸入文件指針沒(méi)有提供,是這種方法的一個(gè)缺點(diǎn),使得跟蹤一個(gè)導致錯誤輸出的原因比較困難。

  2、波形比較。波形比較可以自動(dòng)或是手動(dòng)的運行。自動(dòng)的方法使用一個(gè)測試比較器來(lái)比較黃金波形與測試輸出波形。xilinx的hdl bencher工具可以用于執行一個(gè)自動(dòng)波形比較(關(guān)于hdl bencher的相關(guān)信息,請參看

  http://www.xilinx.com/products/software/statecad/index.htm

  3、自較驗測試。一個(gè)自較驗測試檢查預期的結果與運行時(shí)間的實(shí)際結果,并不是在仿真結束以后。因為有用的錯誤跟蹤信息可以?xún)冉ㄔ谝粋€(gè)測試設計中,用來(lái)說(shuō)明哪些地方設計有誤,調試時(shí)間可以非常明顯地縮短。更多的關(guān)于自較驗測試的信息在下一節說(shuō)明。
自較驗測試

  自較驗測試通過(guò)在一個(gè)測試文檔中放置一系列的預期向量表來(lái)實(shí)現。運行時(shí)間時(shí)間間隔將這些向量與定義好的實(shí)際仿真結果進(jìn)行比較。如果實(shí)際結果與預期結果匹配,仿真成功。如果結果不匹配,測試報告兩者的差異。

  為同步設計實(shí)現自較驗測試更簡(jiǎn)單一些,因為與實(shí)現的結果相比較可以在一個(gè)時(shí)鐘沿或任何一個(gè)整數倍的時(shí)鐘周期后。比較的方法基于設計本身的特性。比如一個(gè)用于內存I/O的測試應該檢查每一次更新數據時(shí)的結果或者從一個(gè)內存位置讀取。類(lèi)似的,如果一個(gè)設計用了一個(gè)顯而易見(jiàn)的組合塊的數字,在預期結果描述時(shí),組合時(shí)延就必須要考慮。

  在自較驗測試中,預期輸出與實(shí)際輸出在一個(gè)特定的運行時(shí)間間隔比較以便提供自動(dòng)的錯誤檢查。這個(gè)技術(shù)在小到中型的設計中非常好。但是,因為當設計復雜后,可能的輸出組合成指數倍的增長(cháng),為一個(gè)大型設計編寫(xiě)一個(gè)自較驗測試設計是非常困難和非常費時(shí)的。

  以下是一個(gè)用verilog和vhdl描述的自較驗測試的簡(jiǎn)單的例子:

  Verilog例子

  下述的設計實(shí)例中,預期的結果被詳細說(shuō)明。后面的代碼,兩種結果被比較,比較的結果被返回終端。如果沒(méi)有錯誤,一個(gè)“end of good simulation”消息會(huì )顯示。如果失配發(fā)生,根據期望與實(shí)際值的失配情況,錯誤會(huì )被相應報告。

  ‘timescale 1 ns / 1 ps

  module test_sc;

  reg tbreset, tbstrtstop;

  reg tbclk;

  wire [6:0] onesout, tensout;

  wire [9:0] tbtenthsout;

  parameter cycles = 25;

  reg [9:0] Data_in_t [0:cycles];

  // /////////////////////////////

  // Instantiation of the Design

  // /////////////////////////////

  stopwatch UUT (.CLK (tbclk), .RESET (tbreset), .STRTSTOP (tbstrtstop),

  .ONESOUT (onesout), .TENSOUT (tensout), .TENTHSOUT (tbtenthsout));

  wire [4:0] tbonesout, tbtensout;

  assign tbtensout = led2hex(tensout);

  assign tbonesout = led2hex(onesout);

  ///////////////////////////////////////////////////////////////

  //EXPECTED RESULTS

  ///////////////////////////////////////////////////////////////

  initial begin

  Data_in_t[1] =10’b1111111110;

  Data_in_t[2] =10’b1111111101;

  Data_in_t[3] =10’b1111111011;

  Data_in_t[4] =10’b1111110111;

  Data_in_t[5] =10 ’b1111101111;



關(guān)鍵詞: 測試 HLL

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>