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

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

?? testing.v.txt

?? verilog實例100多個
?? 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一区二区三区免费野_久草精品视频
亚洲综合在线观看视频| 麻豆国产欧美日韩综合精品二区 | 欧美性xxxxx极品少妇| 欧美一卡2卡3卡4卡| 亚洲欧洲国产日韩| 麻豆精品在线视频| 欧美亚洲禁片免费| 国产精品美女久久久久aⅴ国产馆| 午夜精品在线看| 99re免费视频精品全部| 久久久久99精品一区| 日韩激情视频在线观看| 欧洲另类一二三四区| 国产精品女上位| 免费观看久久久4p| 91社区在线播放| 国产偷v国产偷v亚洲高清| 图片区小说区国产精品视频| 色激情天天射综合网| 国产精品久久久久四虎| 国产一二三精品| 26uuu久久综合| 毛片av一区二区| 91精品国产综合久久精品图片| 一区二区三区精密机械公司| 99久久伊人精品| 国产精品卡一卡二| 成人污污视频在线观看| 国产日本欧美一区二区| 国产乱子伦视频一区二区三区| 日韩午夜电影在线观看| 日本不卡一二三区黄网| 日韩美一区二区三区| 欧美日韩国产美| 国产精品少妇自拍| 国产91对白在线观看九色| 久久先锋影音av| 国产在线视频精品一区| 国产亚洲综合性久久久影院| 国产综合色视频| 久久久精品日韩欧美| 国产精品乡下勾搭老头1| 精品嫩草影院久久| 国产一区二区中文字幕| 欧美国产亚洲另类动漫| 丁香亚洲综合激情啪啪综合| 国产精品久久久久久户外露出 | 亚洲男人的天堂av| 欧美亚洲高清一区| 日本视频中文字幕一区二区三区| 这里是久久伊人| 国产精品一区二区久激情瑜伽| 日本一区二区视频在线观看| 99国产精品久久久久久久久久久| 亚洲视频狠狠干| 欧美高清hd18日本| 国产一区美女在线| 亚洲欧洲性图库| 欧美精品一二三区| 国产一区二区三区香蕉| 椎名由奈av一区二区三区| 欧美三级欧美一级| 国产精品综合二区| 一区二区三区在线影院| 日韩女优电影在线观看| 成人免费看片app下载| 亚洲一区在线电影| 26uuu精品一区二区在线观看| 成人免费毛片aaaaa**| 日韩高清不卡一区二区三区| 久久嫩草精品久久久久| 一本色道**综合亚洲精品蜜桃冫| 日韩成人精品在线观看| 亚洲欧洲av色图| 26uuu国产一区二区三区| 一本色道久久综合亚洲91| 久久精品国产一区二区三| 亚洲日韩欧美一区二区在线| 日韩精品一区二区三区中文精品| a在线播放不卡| 精品一二线国产| 亚洲午夜国产一区99re久久| 久久蜜桃av一区二区天堂| 欧美色爱综合网| www.成人网.com| 国产最新精品免费| 日韩电影免费一区| 综合分类小说区另类春色亚洲小说欧美| 欧美乱妇23p| av一区二区三区黑人| 国产综合久久久久影院| 午夜精品福利在线| 亚洲猫色日本管| 欧美国产乱子伦| 欧美xxxxxxxxx| 欧美喷潮久久久xxxxx| 91首页免费视频| 国产激情精品久久久第一区二区 | 亚洲三级在线播放| 国产午夜精品在线观看| 精品欧美乱码久久久久久| 欧美色视频一区| 在线亚洲一区观看| 不卡av免费在线观看| 国产麻豆欧美日韩一区| 免费在线看一区| 日本成人超碰在线观看| 午夜电影久久久| 色综合久久99| 91精品国产一区二区三区蜜臀| 成人性生交大片免费看在线播放| 日本中文在线一区| 亚洲精品福利视频网站| 国产精品视频观看| 国产精品丝袜一区| 国产清纯白嫩初高生在线观看91 | 麻豆国产精品一区二区三区 | 一区二区三区日韩精品视频| 国产精品美女久久久久av爽李琼| 国产亚洲欧美在线| 久久久综合激的五月天| 2020国产成人综合网| 精品久久国产97色综合| 日韩你懂的在线观看| 欧美成人国产一区二区| 精品免费国产一区二区三区四区| 日韩一区二区三区视频在线 | 国产一区二区三区| 国产一区二区伦理| 国产白丝网站精品污在线入口| 国产a视频精品免费观看| 成人一级片在线观看| 国产成人午夜视频| 不卡的电视剧免费网站有什么| 99re成人精品视频| 欧美日韩你懂的| 欧美高清视频www夜色资源网| 69久久99精品久久久久婷婷| 日韩欧美一区电影| 国产人久久人人人人爽| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品女上位| 亚洲一区二区三区美女| 男男成人高潮片免费网站| 国产一区二区三区不卡在线观看| 成人免费av在线| 欧美视频完全免费看| 日韩一卡二卡三卡| 国产精品少妇自拍| 偷偷要91色婷婷| 国产高清在线观看免费不卡| 色综合天天综合色综合av | 三级不卡在线观看| 国产精品77777竹菊影视小说| 成人av在线一区二区| 欧美高清你懂得| 国产精品久久久久久久久搜平片 | 3d动漫精品啪啪1区2区免费 | 日韩精品中文字幕在线不卡尤物 | 亚洲手机成人高清视频| 亚洲mv大片欧洲mv大片精品| 国产精品一区二区三区网站| 欧美日韩亚州综合| 中文成人av在线| 天天爽夜夜爽夜夜爽精品视频| 国产一区二区三区黄视频| 欧美视频一区二区| 国产精品美女久久久久久2018| 青青草成人在线观看| 91小视频在线| 精品国产欧美一区二区| 亚洲国产成人va在线观看天堂 | 免费av成人在线| 色吊一区二区三区| 国产精品久久久久久久久免费樱桃 | 国产精品少妇自拍| 久久国产人妖系列| 欧美午夜精品久久久久久孕妇| 国产片一区二区| 久久99精品国产.久久久久久| 色婷婷亚洲精品| 国产精品久久免费看| 国产精品1区二区.| 日韩精品在线看片z| 日本欧美一区二区| 欧美日韩五月天| 亚洲精品免费在线播放| av欧美精品.com| 国产亚洲一二三区| 久久99国产精品尤物| 3d动漫精品啪啪一区二区竹菊| 亚洲午夜激情网页| 欧美亚洲动漫精品| 亚洲自拍偷拍网站| 色美美综合视频| 亚洲人成网站在线| 91官网在线免费观看| 亚洲精品高清在线| 在线观看日产精品| 亚洲一区在线电影|