亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testing.v.txt

?? NC-Verlog/NC-VHDL/NC-SIM 1.150
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
Some Examples of Verilog testbench techniques.



      1.0   Introduction

      2.0   Generating Periodic Signals

      3.0   Generating and Receiving Serial Characters

      4.0   Memories

      5.0   Bus Models





1.0   Introduction



A testbench is a verilog program that wraps around an actual design.  

The testbench is typically not part of the design and does not result 

in actual circuitry or gates.  Verilog code for testbenches may be 

much more "free style" than Verilog code that must be 

synthesized - anything goes.  Here are some tidbits from various

 projects I've worked on.  The code is not completely general nor 

perfect, but hopefully may provide ideas for designers just starting

 out with testbench design.  Oh, and the names have been changed

 to protect the innocent.  I hope I haven't introduced error in 

doctoring up these examples.  Again, none of the following  code 

is intended to be synthesizable!



2.0   Generating Periodic Signals.



Say you have a period signal.  Try tossing in a little random fluctuation

 on where the edges occur - you may catch a an unexpected bug! 

 But, be careful about using random because if you move on to 

manufacturing test, then your testbench may not be deterministic. 

 Often, for the sake of the tester, you must enforce transitions to 

occur in specific periods.  In this case, you may need to add 

statements that delay changes to fall in these periods.  Anyway,

 let's drive the foo1in signal.  We'll add in some random, count 

the transitions and print out a message.



initial begin

   #1 foo1in = 0;

      forever begin

         #(`PERIOD/2 + ($random % 10)*(` PERIOD/20)) foo1in = 1;

         foo1_input_count = foo1_input_count + 1;

         $display ("#Foo1 rising edges = %d", foo1_input_count);

         #(` PERIOD/2 + ($random % 10)*(` PERIOD/20)) foo1in = 0;

      end

end


Here's another code snippet - a task that generates a period message..

task generate_syncs;
   event	send_sync;
   begin
      syncdata = SYNC_START;
      syncstb  = 0;
   
      fork
         // Generate periodic event for sending the sync
         forever #(1000000000.0 * RATE) ->send_sync; // convert RATE to nanoseconds
         
         // Wait on send_sync event, and then send SYNC synchronized with clk
         forever begin
            @(send_sync);
            syncdata = syncdata + CMTS_FREQ * CMTS_RATE;
            $display ("... SYNC = %h at time %0t, Local Time = %h", syncdata, $time, local_time);
            @(posedge clk) #1;
            syncstb = 1;
            @(posedge clk) #1;
            syncstb = 0;
         end
      join
   end
endtask


3.0   Generating and Receiving Serial Characters



Say your design inputs or outputs serial characters.  Here is some 

code for both.  First, some defines:



/*  Serial Parameters used for send_serial task and its callers. */

`define PARITY_OFF   1'b0

`define PARITY_ON    1'b1

`define PARITY_ODD   1'b0

`define PARITY_EVEN  1'b1

`define NSTOPS_1     1'b0

`define NSTOPS_2     1'b1

`define BAUD_9600    2'b00

`define BAUD_4800    2'b01

`define BAUD_2400    2'b10

`define BAUD_1200    2'b11

`define NBITS_7      1'b0

`define NBITS_8      1'b1



Here's how you call it:



send_serial (8'hAA, `BAUD_9600, `PARITY_EVEN, `PARITY_ON, `NSTOPS_1, `NBITS_7, 0);



Here's a task that sends a character.



task send_serial;

input [7:0] inputchar;

input baud;

input paritytype;

input parityenable;

input nstops;

input nbits;

input baud_error_factor;



reg       nbits;

reg       parityenable;

reg       paritytype;

reg [1:0] baud;

reg       nstops;

integer   baud_error_factor;  // e.g. +5 means 5% too fast and -5 means 5% too slow



reg   [7:0] char;

reg         parity_bit;

integer     bit_time;



begin

   char = inputchar;

   parity_bit = 1'b0;

   case (baud)

      `BAUD_9600: bit_time = 1000000000/(9600 + 96*baud_error_factor);

      `BAUD_4800: bit_time = 1000000000/(4800 + 48*baud_error_factor);

      `BAUD_2400: bit_time = 1000000000/(2400 + 24*baud_error_factor);

      `BAUD_1200: bit_time = 1000000000/(1200 + 12*baud_error_factor);

   endcase   



   $display ("Sending character %h, at %0d baud (err=%0d), %0d bits, %0s parity, %0d stops",

       (nbits == `NBITS_7) ? (char & 8'h7f) : char,

      1000000000/bit_time,

      baud_error_factor,

      (nbits == `NBITS_7) ? 7 : 8,

      (parityenable == `PARITY_OFF) ? "NONE" : (paritytype == `PARITY_EVEN) ? "EVEN" : "ODD",

      (nstops == `NSTOPS_1) ? 1 : 2

   );

      

   // Start bit

   serial_character = 1'b0;   // Start bit.

   #(bit_time);



   // Output data bits

   repeat ( (nbits == `NBITS_7) ? 7 : 8) begin

      serial_character = char[0];

      #(bit_time);

      char = {1'b0, char[7:1]};

   end

   

   if (parityenable == `PARITY_ON) begin

      parity_bit = (nbits == `NBITS_7) ? ^inputchar[6:0] : ^inputchar[7:0];

      if (paritytype == `PARITY_ODD)

         parity_bit = ~parity_bit; // even parity

         serial_character = parity_bit;

         #(bit_time);

      end

      serial_character = 1'b1;   // Stop bit.

      #(bit_time);

      if (nstops) // Second stop bit

         #(bit_time);

   end

endtask



Here's a task that receives serial characters.  This particular task was 

a bit messy in that it set some global variables in order to return a 

status, etc.  By all means - fix this up the way you like it!



reg [7:0] receive_serial_character_uart1;	// Global that receives tasks result



// ****  SERIAL CHARACTER LISTENER Task for UART1

//

//

task receive_serial_uart1;



input baud;

input paritytype;

input parityenable;

input nstops;

input nbits;



reg       nbits;

reg       parityenable;

reg       paritytype;

reg [1:0] baud;

reg       nstops;



integer     bit_time;



reg         expected_parity;



begin

receive_serial_result_uart1 = 0;

receive_serial_character_uart1 = 0;



case (baud)

   `BAUD_9600: bit_time = 1000000000/(9600);

   `BAUD_4800: bit_time = 1000000000/(4800);

   `BAUD_2400: bit_time = 1000000000/(2400);

   `BAUD_1200: bit_time = 1000000000/(1200);

endcase 

     

receive_serial_result_uart1 = `RECEIVE_RESULT_OK;  // Assume OK until bad things happen.



@(negedge uart1out);  // wait for start bit edge

#(bit_time/2);  // wait till center of start bit

if (uart1out != 0) // make sure its really a start bit

   receive_serial_result_uart1 = receive_serial_result_uart1 | `RECEIVE_RESULT_FALSESTART;

else begin

   repeat ( (nbits == `NBITS_7) ? 7 : 8) begin // get all the data bits (7 or 8)

      #(bit_time);  // wait till center

      // sample a data bit

      receive_serial_character_uart1 = {uart1out, receive_serial_character_uart1[7:1]};

   end



   // If we are only expecting 7 bits, go ahead and right-justify what we have

   if (nbits == `NBITS_7)

      receive_serial_character_uart1 = {1'b0, receive_serial_character_uart1[7:1]};

      

      #(bit_time);

      // now, we have either a parity bit, or a stop bit

      if (parityenable == `PARITY_ON) begin

         if (paritytype == `PARITY_EVEN)

            expected_parity = (nbits == `NBITS_7) ? (^receive_serial_character_uart1[6:0]) :            

                                                                               (^receive_serial_character_uart1[7:0]);

         else

            expected_parity = (nbits == `NBITS_7) ? (~(^receive_serial_character_uart1[6:0])) :  

                                                                               (~(^receive_serial_character_uart1[7:0]));

            if (expected_parity != uart1out)

               receive_serial_result_uart1 = receive_serial_result_uart1 | `RECEIVE_RESULT_BADPARITY;

         // wait for either 1 or 2 stop bits

      end

      else begin

			// this is a stop bit.

         if (uart1out != 1)

            receive_serial_result_uart1 = receive_serial_result_uart1 | `RECEIVE_RESULT_BADSTOP;

         else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品系列在线播放| 午夜久久福利影院| 丁香婷婷综合激情五月色| 久久亚洲一级片| 成人av综合一区| 亚洲视频精选在线| 日本韩国欧美一区二区三区| 亚洲一区二区三区爽爽爽爽爽| 欧美伦理电影网| 麻豆视频一区二区| 欧美高清在线视频| 在线观看不卡一区| 麻豆国产一区二区| 中文字幕亚洲成人| 欧美精品视频www在线观看| 麻豆精品一区二区av白丝在线| 久久久久久久综合| 欧洲一区二区av| 久久99久久久欧美国产| 中文字幕中文字幕一区| 欧美久久一区二区| 粉嫩久久99精品久久久久久夜| 尤物视频一区二区| 久久欧美一区二区| 欧洲另类一二三四区| 奇米一区二区三区| 国产精品美女www爽爽爽| 欧美色图12p| 成人h动漫精品一区二| 日韩二区三区在线观看| 国产精品久久久久永久免费观看| 欧美日韩一区精品| 成人va在线观看| 精品亚洲免费视频| 亚洲影院理伦片| 国产精品久久久久久久蜜臀| 91精品国产综合久久婷婷香蕉 | 国产精品一区二区三区99| 亚洲欧洲av在线| 久久综合狠狠综合| 在线播放一区二区三区| 成人免费观看av| 九一久久久久久| 亚洲成人在线免费| 亚洲色图制服丝袜| 久久精品亚洲精品国产欧美 | 中文字幕一区二区三区不卡在线 | 欧美系列一区二区| 国产成人精品影院| 久久av中文字幕片| 丝袜亚洲另类欧美| 亚洲精品久久久久久国产精华液| 日韩欧美精品在线| 欧美一卡二卡三卡| 欧美伦理影视网| 欧美性猛交xxxx黑人交| 99精品国产热久久91蜜凸| 久久国产剧场电影| 美国欧美日韩国产在线播放| 亚洲国产成人高清精品| 亚洲黄色小视频| 亚洲乱码精品一二三四区日韩在线| 精品国产自在久精品国产| 欧美精三区欧美精三区| 欧美亚洲图片小说| 欧美伊人精品成人久久综合97| 成人午夜电影久久影院| 极品少妇xxxx精品少妇| 老司机午夜精品99久久| 蜜臀av国产精品久久久久| 人人超碰91尤物精品国产| 污片在线观看一区二区| 午夜视黄欧洲亚洲| 三级在线观看一区二区| 亚洲.国产.中文慕字在线| 亚洲一区二区三区在线播放| 一区二区三区小说| 亚洲一二三四在线| 亚洲bt欧美bt精品| 美女脱光内衣内裤视频久久网站 | 性做久久久久久| 亚洲国产婷婷综合在线精品| 亚洲福利一二三区| 日韩av中文字幕一区二区三区| 日韩国产欧美在线视频| 轻轻草成人在线| 久久99蜜桃精品| 国产成人8x视频一区二区| 成人国产精品免费观看动漫| 色综合久久久久综合体| 欧美天天综合网| 4438成人网| 久久久亚洲综合| ...xxx性欧美| 亚洲超碰精品一区二区| 久热成人在线视频| 3atv一区二区三区| 久久久久久久久久久久电影| 中文成人av在线| 亚洲一区在线播放| 美女尤物国产一区| jizz一区二区| 欧美日韩电影在线| 国产午夜亚洲精品不卡| 一区二区免费看| 日韩激情av在线| 国产精品99久久久| 在线精品视频免费观看| 91精品国产高清一区二区三区 | 成人短视频下载| 欧美日韩精品一区二区在线播放| 日韩女优av电影在线观看| 国产精品久99| 日韩激情中文字幕| 成人一区二区三区视频 | 麻豆91免费观看| 成人av电影在线| 91精品在线麻豆| 国产精品久久久久一区| 日本va欧美va精品发布| 91丨九色丨国产丨porny| 欧美挠脚心视频网站| 日本一区二区免费在线| 亚洲成人av电影| 成a人片亚洲日本久久| 日韩视频一区二区在线观看| 国产精品欧美经典| 美脚の诱脚舐め脚责91| 色婷婷综合久久久| 国产日韩欧美综合一区| 免费观看日韩电影| 欧洲精品中文字幕| 久久精品噜噜噜成人88aⅴ| av电影一区二区| 精品国产凹凸成av人网站| 亚洲成人手机在线| 91丨九色丨蝌蚪丨老版| 国产亚洲福利社区一区| 日本不卡高清视频| 欧美日韩美少妇| 一区二区三国产精华液| 成人性生交大片免费看视频在线| 欧美成人三级在线| 首页国产欧美久久| 在线一区二区三区四区五区| 国产精品无人区| 国产成人免费高清| 久久只精品国产| 精品一区二区三区免费观看| 欧美亚洲一区二区在线观看| 亚洲人精品午夜| 不卡av电影在线播放| 久久精品无码一区二区三区| 久久国产精品一区二区| 欧美一级高清大全免费观看| 图片区小说区区亚洲影院| 欧美日韩一区二区三区不卡 | 制服丝袜国产精品| 性做久久久久久免费观看欧美| 色8久久人人97超碰香蕉987| 国产精品毛片无遮挡高清| 成人一级黄色片| 国产精品久久一卡二卡| www.亚洲国产| 亚洲欧美电影院| 日本韩国精品一区二区在线观看| 亚洲欧美一区二区不卡| 色综合久久久网| 亚洲一区二区三区小说| 欧美精品久久久久久久多人混战 | 亚洲一区二区影院| 欧美日韩国产高清一区二区三区| 亚瑟在线精品视频| 欧美一级日韩不卡播放免费| 久久国产精品72免费观看| 日韩精品一区二区三区中文不卡 | 欧美一区二区精品在线| 日本欧美一区二区三区乱码 | 欧美精品1区2区| 麻豆精品国产传媒mv男同 | 欧美精彩视频一区二区三区| www.亚洲激情.com| 亚洲电影一区二区| 91精品国产欧美一区二区| 狠狠色伊人亚洲综合成人| 久久久国际精品| 色噜噜狠狠色综合中国| 亚洲成人先锋电影| 2023国产精品| av亚洲产国偷v产偷v自拍| 夜夜嗨av一区二区三区中文字幕 | 国产精品麻豆一区二区| 色哟哟一区二区| 日本午夜一本久久久综合| 精品国产污网站| 91亚洲精品久久久蜜桃网站| 亚洲自拍偷拍av| 欧美xxxx在线观看| 99精品国产99久久久久久白柏| 亚洲第一会所有码转帖|