新聞中心

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

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

        作者: 時間:2008-06-26 來源:電子開發網 收藏

          Data_in_t[6] =10’b1111011111;

        本文引用地址:http://www.104case.com/article/84843.htm

          Data_in_t[7] =10’b1110111111;

          Data_in_t[8] =10’b1101111111;

          Data_in_t[9] =10’b1011111111;

          Data_in_t[10]=10’b0111111111;

          Data_in_t[11]=10’b1111111110;

          Data_in_t[12]=10’b1111111110;

          Data_in_t[13]=10’b1111111101;

          Data_in_t[14]=10’b1111111011;

          Data_in_t[15]=10’b1111110111;

          Data_in_t[16]=10’b1111101111;

          Data_in_t[17]=10’b1111011111;

          Data_in_t[18]=10’b1110111111;

          Data_in_t[19]=10’b1101111111;

          Data_in_t[20]=10’b1011111111;

          Data_in_t[21]=10’b0111111111;

          Data_in_t[22]=10’b1111111110;

          Data_in_t[23]=10’b1111111110;

          Data_in_t[24]=10’b1111111101;

          Data_in_t[25]=10’b1111111011;

          end

          reg GSR;

          assign glbl.GSR = GSR;

          initial begin

          GSR = 1;

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

          // Wait till Global Reset Finished

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

          #100 GSR = 0;

          end

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

          // Create the clock

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

          initial begin

          tbclk = 0;

          // Wait till Global Reset Finished, then cycle clock

          #100 forever #60 tbclk = ~tbclk;

          end

          initial begin

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

          // Initialize All Input Ports

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

          tbreset = 1;

          tbstrtstop = 1;

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

          // Apply Design Stimulus

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

          #240 tbreset = 0;

          tbstrtstop = 0;

          #5000 tbstrtstop = 1;

          #8125 tbstrtstop = 0;

          #500 tbstrtstop = 1;

          #875 tbreset = 1;

          #375 tbreset = 0;

          #700 tbstrtstop = 0;

          #550 tbstrtstop = 1;

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

          // simulation must be halted inside an initial statement

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

          // #100000 $stop;

          end

          integer i,errors;

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

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

          // Block below compares the expected vs. actual results

          // at every negative clock edge.

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

          always @ (posedge tbclk)

          begin

          if (tbstrtstop)

          begin

          i = 0;

          errors = 0;

          end

          else

          begin

          for (i = 1; i <= cycles; i = i + 1)

          begin

          @(negedge tbclk)

          // check result at negedge

          $display("Time%d ns; TBSTRTSTOP=%b; Reset=%h; Expected

          TenthsOut=%b; Actual TenthsOut=%b", $stime, tbstrtstop, tbreset,

          Data_in_t[i], tbtenthsout);

          if ( tbtenthsout !== Data_in_t[i] )

          begin

          $display(" ------ERROR. A mismatch has occurred-----");

          errors = errors + 1;

          end

          end

          if (errors == 0)

          $display("Simulation finished Successfully.");

          else if (errors > 1)

          $display("%0d ERROR! See log above for details.",errors);

          else

          $display("ERROR! See log above for details.");

          #100 $stop;

          end

          end

          endmodule

          這種簡單的自較驗設計可以轉換到任何場合----當然,預期的輸出值和信號的名字在重用時是需要更改的。如果不需要每個時鐘沿檢查,需要的話可以修改for-loop結構。

          如果仿真成功,下圖的信息就會在顯示終端上顯示:


        上一頁 1 2 3 4 下一頁

        關鍵詞: 測試 HLL

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 微山县| 来宾市| 班玛县| 洪洞县| 民丰县| 汉源县| 广德县| 南岸区| 安康市| 乌兰县| 卓尼县| 徐汇区| 邹城市| 岳池县| 恭城| 永福县| 高密市| 乌拉特前旗| 东平县| 安义县| 沈阳市| 岗巴县| 寻乌县| 英德市| 合山市| 油尖旺区| 班玛县| 瑞昌市| 潼关县| 长宁区| 镇坪县| 凌源市| 韶山市| 金昌市| 安新县| 舞阳县| 金堂县| 湾仔区| 长岛县| 广安市| 夹江县|