valid/ready握手機制及verilog程式碼

糊涂二蛋發表於2024-06-23

目錄
  • valid/ready握手協議
  • valid/ready狀態機
  • verilog實現程式碼
  • 波形檔案

valid/ready握手協議

在兩個模組之間傳輸資料時候,可以使用valid/ready握手協議,保證資料傳輸的有效性。
傳送方準備傳送資料時,它傳送valid訊號給接收方,接收方準備好可以接收資料時候,他傳送ready訊號給傳送方,在valid和ready訊號都置高的時鐘上升沿,開始傳送資料。
image

image

valid/ready狀態機

傳送方接收方都會處於下圖所示四個狀態之一,它們的狀態轉化圖如下
image

verilog實現程式碼

傳送模組,檔名稱:transmitter.sv


`timescale 1ns/1ns	
module transmitter #(parameter DATA_WIDTH=8)  
  (
  input wire clk,
  input wire rst_n,
  output logic vld,
  output logic [DATA_WIDTH-1:0] data,
  input wire rdy
  );
  //下一個valid訊號
  logic next_vld;
  //下一個資料及hold的資料
  logic [DATA_WIDTH-1:0] next_data;
  reg [DATA_WIDTH-1:0] hold_data;
  //內部valid訊號
  logic  i_vld;
  //內部data訊號
  logic [DATA_WIDTH-1:0] i_data;
  //傳送資料佇列,記錄傳送的資料,便於debug顯示
  logic [DATA_WIDTH-1:0] sent_data[$];
  
  typedef enum {IDLE, WAIT_RDY, WAIT_VLD, TRANSFER} ff_state;

  ff_state current_state = IDLE;
  ff_state next_state    = IDLE;
  
  //根據現在狀態,更新下一個狀態
  always_comb begin
    case (current_state)
      IDLE: begin
        if (i_vld == 1 && rdy == 0) begin
          next_state = WAIT_RDY;
        end else if (i_vld == 0 && rdy == 1) begin
          next_state = WAIT_VLD;
        end else if (i_vld == 1 && rdy == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
      end
      
      WAIT_RDY: begin
        if (i_vld == 1 && rdy == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
      end
      
      WAIT_VLD: begin
        if (i_vld == 1 && rdy == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
        
      end
      
      TRANSFER: begin
        if (i_vld == 1 && rdy == 0) begin
          next_state = WAIT_RDY;
        end else if (i_vld == 0 && rdy == 1) begin
          next_state = WAIT_VLD;
        end else if (i_vld == 0 && rdy == 0) begin
          next_state = IDLE;  
        end else begin
          next_state = current_state;
        end
        
      end
      
    endcase
    
  end
  
  always_ff @(posedge clk or negedge rst_n) begin
    
    // Next state here is the previous state from the previous cycle
    $display("[DEBUG %d] next_vld: %d, next_state: %d, current_state: %d", $time, next_vld, next_state, current_state);
    
    if (!rst_n) begin
      current_state <= IDLE;
      i_vld <= 0;
      i_data <= 0;
    end else begin
      current_state <= next_state;
      
      //隨機賦值下一個valid訊號
      next_vld = $urandom;
      
      if (next_vld == 1 && next_state != WAIT_RDY) begin
        //在下一個時鐘週期傳送下一個資料,這兒是準備下一個資料
        //下一個資料時1-10之間的隨機值
        next_data = $urandom_range(1,10);
        //保持資料等於下一個資料
        hold_data = next_data;
        //把下一個資料放進傳送佇列
        sent_data.push_back(next_data);
      end else if (next_state == WAIT_RDY) begin
        next_data = hold_data;
      end else begin
        next_data = 0;
      end
      
      //更新內部訊號
      i_vld <= #0.1 (next_state == WAIT_RDY) ? 1 : next_vld;
      i_data <= #0.1 next_data;
    end
  end
  
  //更新介面訊號
  assign vld = i_vld;
  assign data = i_data;
endmodule

接收模組,檔名稱:receiver.sv

`timescale 1ns/1ns
module receiver #(parameter DATA_WIDTH=8)
  (
  input wire clk,
  input wire rst_n,
  input wire vld,
  input wire [DATA_WIDTH-1:0] data,
  output logic rdy
  );
  logic next_rdy;
  //內部ready訊號
  logic i_rdy;

  //接收資料佇列
  logic [DATA_WIDTH-1:0] received_data[$];
  
  logic no_random = 0;
  
  typedef enum {IDLE, WAIT_RDY, WAIT_VLD, TRANSFER} ff_state;

  ff_state current_state = IDLE;
  ff_state next_state    = IDLE;
  
  //狀態機更新
  always_comb begin
    case (current_state)
      IDLE: begin
        no_random = 0;
        
        if (i_rdy == 1 && vld == 0) begin
          next_state = WAIT_VLD;
        end else if (i_rdy == 0 && vld == 1) begin
          next_state = WAIT_RDY;
        end else if (i_rdy == 1 && vld == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
      end
      
      WAIT_VLD: begin
        no_random = 1;
        if (i_rdy == 1 && vld == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
      end
      
      WAIT_RDY: begin
        no_random = 0;
        if (i_rdy == 1 && vld == 1) begin
          next_state = TRANSFER;  
        end else begin
          next_state = current_state;
        end
        
      end
      
      TRANSFER: begin
        
        if (i_rdy == 1 && vld == 0) begin
          next_state = WAIT_VLD;
        end else if (i_rdy == 0 && vld == 1) begin
          next_state = WAIT_RDY;
        end else if (i_rdy == 0 && vld == 0) begin
          next_state = IDLE;
        end else begin
          next_state = current_state;
        end
        
      end
      
    endcase
    
  end
  
  always_ff @(posedge clk or negedge rst_n) begin
    $display("[DEBUG %d] current data: %d, current_state: %d, next_state: %d", $time, data, current_state, next_state);
    
    //把接收的資料放入接收佇列,以便debug顯示
    if (next_state == TRANSFER) begin
      // Sample the data
      $display("[DEBUG %0t] pushing %d data value", $time, data);
      received_data.push_back(data);
    end
    
    
    if (!rst_n) begin
      i_rdy <= 0;
      current_state <= #0.1 IDLE;
    end else begin
      //更新內部ready訊號
      i_rdy <= #0.1 (next_state == WAIT_VLD) ? 1 : $urandom;
      current_state <= #0.1 next_state;
    end
  end
  
  assign rdy = i_rdy;
endmodule

testbench檔名稱:valid_ready.tb

`timescale 1ns/1ns	
 
module test_top;
  reg _clk;
  reg _rst_n;
  
  wire [7:0] _data;
  wire _vld;
  wire _rdy;
  
	initial begin

    	$display("start a clock pulse");
    	$dumpfile("valid_ready.vcd"); 
    	$dumpvars(0, test_top); 
   		//#1000 $finish;
	end

  transmitter tx(_clk, _rst_n, _vld, _data, _rdy);
  receiver rx(_clk, _rst_n, _vld, _data, _rdy);
  
  initial begin
    
    _clk = 0;
    _rst_n = 1;
    
    #10;
    
    _rst_n = 0;
    
    #10;
    
    _rst_n = 1;
    
    #1000;
        
    foreach (rx.received_data[i]) begin
     $display("[DEBUG] RX RECEIVED %d: %d", i, rx.received_data[i]);
   end
    
   foreach (tx.sent_data[i]) begin
     $display("[DEBUG] TX SENT %d: %d", i, tx.sent_data[i]);
    end
    
    $finish;

  end
  
  always #5ns _clk = ~_clk;
endmodule

波形檔案

由於iverilog不支援一些systemverilog語法,我們在modelsim中建立工程,匯入上述三個檔案。執行模擬後,得到如下波形:

狀態IDLE=0,WAIT_RDY=1,WAIT_VLD=2,TRAMSFER=3
image

# start a clock pulse
# [DEBUG                    5] current data:   x, current_state:           0, next_state:           0
# [DEBUG                    5] next_vld: x, next_state:           0, current_state:           0
# [DEBUG                   10] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   10] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   15] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   15] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   25] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   25] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   35] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   35] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   45] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   45] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   55] current data:   0, current_state:           0, next_state:           0
# [DEBUG                   55] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                   65] current data:   0, current_state:           0, next_state:           2
# [DEBUG                   65] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                   75] current data:   6, current_state:           2, next_state:           3
# [DEBUG 75] pushing   6 data value
# [DEBUG                   75] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                   85] current data:   8, current_state:           3, next_state:           1
# [DEBUG                   85] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                   95] current data:   8, current_state:           1, next_state:           1
# [DEBUG                   95] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  105] current data:   8, current_state:           1, next_state:           3
# [DEBUG 105] pushing   8 data value
# [DEBUG                  105] next_vld: 1, next_state:           3, current_state:           1
# [DEBUG                  115] current data:   7, current_state:           3, next_state:           3
# [DEBUG 115] pushing   7 data value
# [DEBUG                  115] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  125] current data:   0, current_state:           3, next_state:           2
# [DEBUG                  125] next_vld: 0, next_state:           2, current_state:           3
# [DEBUG                  135] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  135] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  145] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  145] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  155] current data:   8, current_state:           2, next_state:           3
# [DEBUG 155] pushing   8 data value
# [DEBUG                  155] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  165] current data:   9, current_state:           3, next_state:           3
# [DEBUG 165] pushing   9 data value
# [DEBUG                  165] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  175] current data:  10, current_state:           3, next_state:           1
# [DEBUG                  175] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  185] current data:  10, current_state:           1, next_state:           1
# [DEBUG                  185] next_vld: 1, next_state:           1, current_state:           1
# [DEBUG                  195] current data:  10, current_state:           1, next_state:           3
# [DEBUG 195] pushing  10 data value
# [DEBUG                  195] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  205] current data:   7, current_state:           3, next_state:           1
# [DEBUG                  205] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  215] current data:   7, current_state:           1, next_state:           3
# [DEBUG 215] pushing   7 data value
# [DEBUG                  215] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  225] current data:   5, current_state:           3, next_state:           3
# [DEBUG 225] pushing   5 data value
# [DEBUG                  225] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  235] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  235] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  245] current data:   0, current_state:           0, next_state:           0
# [DEBUG                  245] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                  255] current data:   0, current_state:           0, next_state:           2
# [DEBUG                  255] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                  265] current data:   9, current_state:           2, next_state:           3
# [DEBUG 265] pushing   9 data value
# [DEBUG                  265] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  275] current data:   2, current_state:           3, next_state:           3
# [DEBUG 275] pushing   2 data value
# [DEBUG                  275] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  285] current data:   9, current_state:           3, next_state:           1
# [DEBUG                  285] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  295] current data:   9, current_state:           1, next_state:           1
# [DEBUG                  295] next_vld: 1, next_state:           1, current_state:           1
# [DEBUG                  305] current data:   9, current_state:           1, next_state:           3
# [DEBUG 305] pushing   9 data value
# [DEBUG                  305] next_vld: 1, next_state:           3, current_state:           1
# [DEBUG                  315] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  315] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  325] current data:   2, current_state:           0, next_state:           3
# [DEBUG 325] pushing   2 data value
# [DEBUG                  325] next_vld: 1, next_state:           3, current_state:           0
# [DEBUG                  335] current data:   1, current_state:           3, next_state:           1
# [DEBUG                  335] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  345] current data:   1, current_state:           1, next_state:           3
# [DEBUG 345] pushing   1 data value
# [DEBUG                  345] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  355] current data:   2, current_state:           3, next_state:           3
# [DEBUG 355] pushing   2 data value
# [DEBUG                  355] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  365] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  365] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  375] current data:   0, current_state:           0, next_state:           2
# [DEBUG                  375] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                  385] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  385] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  395] current data:  10, current_state:           2, next_state:           3
# [DEBUG 395] pushing  10 data value
# [DEBUG                  395] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  405] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  405] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  415] current data:   0, current_state:           0, next_state:           2
# [DEBUG                  415] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                  425] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  425] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  435] current data:   8, current_state:           2, next_state:           3
# [DEBUG 435] pushing   8 data value
# [DEBUG                  435] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  445] current data:   6, current_state:           3, next_state:           1
# [DEBUG                  445] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  455] current data:   6, current_state:           1, next_state:           1
# [DEBUG                  455] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  465] current data:   6, current_state:           1, next_state:           3
# [DEBUG 465] pushing   6 data value
# [DEBUG                  465] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  475] current data:   7, current_state:           3, next_state:           1
# [DEBUG                  475] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  485] current data:   7, current_state:           1, next_state:           1
# [DEBUG                  485] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  495] current data:   7, current_state:           1, next_state:           1
# [DEBUG                  495] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  505] current data:   7, current_state:           1, next_state:           3
# [DEBUG 505] pushing   7 data value
# [DEBUG                  505] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  515] current data:   7, current_state:           3, next_state:           3
# [DEBUG 515] pushing   7 data value
# [DEBUG                  515] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  525] current data:  10, current_state:           3, next_state:           3
# [DEBUG 525] pushing  10 data value
# [DEBUG                  525] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  535] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  535] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  545] current data:   7, current_state:           0, next_state:           3
# [DEBUG 545] pushing   7 data value
# [DEBUG                  545] next_vld: 1, next_state:           3, current_state:           0
# [DEBUG                  555] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  555] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  565] current data:   0, current_state:           0, next_state:           2
# [DEBUG                  565] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                  575] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  575] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  585] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  585] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  595] current data:   5, current_state:           2, next_state:           3
# [DEBUG 595] pushing   5 data value
# [DEBUG                  595] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  605] current data:   9, current_state:           3, next_state:           1
# [DEBUG                  605] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  615] current data:   9, current_state:           1, next_state:           3
# [DEBUG 615] pushing   9 data value
# [DEBUG                  615] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  625] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  625] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  635] current data:   0, current_state:           0, next_state:           0
# [DEBUG                  635] next_vld: 0, next_state:           0, current_state:           0
# [DEBUG                  645] current data:   1, current_state:           0, next_state:           1
# [DEBUG                  645] next_vld: 1, next_state:           1, current_state:           0
# [DEBUG                  655] current data:   1, current_state:           1, next_state:           1
# [DEBUG                  655] next_vld: 1, next_state:           1, current_state:           1
# [DEBUG                  665] current data:   1, current_state:           1, next_state:           3
# [DEBUG 665] pushing   1 data value
# [DEBUG                  665] next_vld: 1, next_state:           3, current_state:           1
# [DEBUG                  675] current data:   3, current_state:           3, next_state:           3
# [DEBUG 675] pushing   3 data value
# [DEBUG                  675] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  685] current data:   0, current_state:           3, next_state:           2
# [DEBUG                  685] next_vld: 0, next_state:           2, current_state:           3
# [DEBUG                  695] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  695] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  705] current data:   4, current_state:           2, next_state:           3
# [DEBUG 705] pushing   4 data value
# [DEBUG                  705] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  715] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  715] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  725] current data:   7, current_state:           0, next_state:           3
# [DEBUG 725] pushing   7 data value
# [DEBUG                  725] next_vld: 1, next_state:           3, current_state:           0
# [DEBUG                  735] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  735] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  745] current data:   6, current_state:           0, next_state:           3
# [DEBUG 745] pushing   6 data value
# [DEBUG                  745] next_vld: 1, next_state:           3, current_state:           0
# [DEBUG                  755] current data:   0, current_state:           3, next_state:           2
# [DEBUG                  755] next_vld: 0, next_state:           2, current_state:           3
# [DEBUG                  765] current data:   3, current_state:           2, next_state:           3
# [DEBUG 765] pushing   3 data value
# [DEBUG                  765] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  775] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  775] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  785] current data:   0, current_state:           0, next_state:           2
# [DEBUG                  785] next_vld: 0, next_state:           2, current_state:           0
# [DEBUG                  795] current data:   0, current_state:           2, next_state:           2
# [DEBUG                  795] next_vld: 0, next_state:           2, current_state:           2
# [DEBUG                  805] current data:   8, current_state:           2, next_state:           3
# [DEBUG 805] pushing   8 data value
# [DEBUG                  805] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  815] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  815] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  825] current data:   6, current_state:           0, next_state:           1
# [DEBUG                  825] next_vld: 1, next_state:           1, current_state:           0
# [DEBUG                  835] current data:   6, current_state:           1, next_state:           3
# [DEBUG 835] pushing   6 data value
# [DEBUG                  835] next_vld: 0, next_state:           3, current_state:           1
# [DEBUG                  845] current data:   9, current_state:           3, next_state:           3
# [DEBUG 845] pushing   9 data value
# [DEBUG                  845] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  855] current data:   5, current_state:           3, next_state:           3
# [DEBUG 855] pushing   5 data value
# [DEBUG                  855] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  865] current data:   7, current_state:           3, next_state:           3
# [DEBUG 865] pushing   7 data value
# [DEBUG                  865] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  875] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  875] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  885] current data:   8, current_state:           0, next_state:           3
# [DEBUG 885] pushing   8 data value
# [DEBUG                  885] next_vld: 1, next_state:           3, current_state:           0
# [DEBUG                  895] current data:   0, current_state:           3, next_state:           2
# [DEBUG                  895] next_vld: 0, next_state:           2, current_state:           3
# [DEBUG                  905] current data:   7, current_state:           2, next_state:           3
# [DEBUG 905] pushing   7 data value
# [DEBUG                  905] next_vld: 1, next_state:           3, current_state:           2
# [DEBUG                  915] current data:  10, current_state:           3, next_state:           1
# [DEBUG                  915] next_vld: 1, next_state:           1, current_state:           3
# [DEBUG                  925] current data:  10, current_state:           1, next_state:           1
# [DEBUG                  925] next_vld: 1, next_state:           1, current_state:           1
# [DEBUG                  935] current data:  10, current_state:           1, next_state:           1
# [DEBUG                  935] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  945] current data:  10, current_state:           1, next_state:           1
# [DEBUG                  945] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  955] current data:  10, current_state:           1, next_state:           1
# [DEBUG                  955] next_vld: 0, next_state:           1, current_state:           1
# [DEBUG                  965] current data:  10, current_state:           1, next_state:           3
# [DEBUG 965] pushing  10 data value
# [DEBUG                  965] next_vld: 1, next_state:           3, current_state:           1
# [DEBUG                  975] current data:   6, current_state:           3, next_state:           3
# [DEBUG 975] pushing   6 data value
# [DEBUG                  975] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG                  985] current data:   0, current_state:           3, next_state:           0
# [DEBUG                  985] next_vld: 0, next_state:           0, current_state:           3
# [DEBUG                  995] current data:   3, current_state:           0, next_state:           1
# [DEBUG                  995] next_vld: 1, next_state:           1, current_state:           0
# [DEBUG                 1005] current data:   3, current_state:           1, next_state:           3
# [DEBUG 1005] pushing   3 data value
# [DEBUG                 1005] next_vld: 1, next_state:           3, current_state:           1
# [DEBUG                 1015] current data:   6, current_state:           3, next_state:           3
# [DEBUG 1015] pushing   6 data value
# [DEBUG                 1015] next_vld: 1, next_state:           3, current_state:           3
# [DEBUG] RX RECEIVED           0:   6
# [DEBUG] RX RECEIVED           1:   8
# [DEBUG] RX RECEIVED           2:   7
# [DEBUG] RX RECEIVED           3:   8
# [DEBUG] RX RECEIVED           4:   9
# [DEBUG] RX RECEIVED           5:  10
# [DEBUG] RX RECEIVED           6:   7
# [DEBUG] RX RECEIVED           7:   5
# [DEBUG] RX RECEIVED           8:   9
# [DEBUG] RX RECEIVED           9:   2
# [DEBUG] RX RECEIVED          10:   9
# [DEBUG] RX RECEIVED          11:   2
# [DEBUG] RX RECEIVED          12:   1
# [DEBUG] RX RECEIVED          13:   2
# [DEBUG] RX RECEIVED          14:  10
# [DEBUG] RX RECEIVED          15:   8
# [DEBUG] RX RECEIVED          16:   6
# [DEBUG] RX RECEIVED          17:   7
# [DEBUG] RX RECEIVED          18:   7
# [DEBUG] RX RECEIVED          19:  10
# [DEBUG] RX RECEIVED          20:   7
# [DEBUG] RX RECEIVED          21:   5
# [DEBUG] RX RECEIVED          22:   9
# [DEBUG] RX RECEIVED          23:   1
# [DEBUG] RX RECEIVED          24:   3
# [DEBUG] RX RECEIVED          25:   4
# [DEBUG] RX RECEIVED          26:   7
# [DEBUG] RX RECEIVED          27:   6
# [DEBUG] RX RECEIVED          28:   3
# [DEBUG] RX RECEIVED          29:   8
# [DEBUG] RX RECEIVED          30:   6
# [DEBUG] RX RECEIVED          31:   9
# [DEBUG] RX RECEIVED          32:   5
# [DEBUG] RX RECEIVED          33:   7
# [DEBUG] RX RECEIVED          34:   8
# [DEBUG] RX RECEIVED          35:   7
# [DEBUG] RX RECEIVED          36:  10
# [DEBUG] RX RECEIVED          37:   6
# [DEBUG] RX RECEIVED          38:   3
# [DEBUG] RX RECEIVED          39:   6
# [DEBUG] TX SENT           0:   6
# [DEBUG] TX SENT           1:   8
# [DEBUG] TX SENT           2:   7
# [DEBUG] TX SENT           3:   8
# [DEBUG] TX SENT           4:   9
# [DEBUG] TX SENT           5:  10
# [DEBUG] TX SENT           6:   7
# [DEBUG] TX SENT           7:   5
# [DEBUG] TX SENT           8:   9
# [DEBUG] TX SENT           9:   2
# [DEBUG] TX SENT          10:   9
# [DEBUG] TX SENT          11:   2
# [DEBUG] TX SENT          12:   1
# [DEBUG] TX SENT          13:   2
# [DEBUG] TX SENT          14:  10
# [DEBUG] TX SENT          15:   8
# [DEBUG] TX SENT          16:   6
# [DEBUG] TX SENT          17:   7
# [DEBUG] TX SENT          18:   7
# [DEBUG] TX SENT          19:  10
# [DEBUG] TX SENT          20:   7
# [DEBUG] TX SENT          21:   5
# [DEBUG] TX SENT          22:   9
# [DEBUG] TX SENT          23:   1
# [DEBUG] TX SENT          24:   3
# [DEBUG] TX SENT          25:   4
# [DEBUG] TX SENT          26:   7
# [DEBUG] TX SENT          27:   6
# [DEBUG] TX SENT          28:   3
# [DEBUG] TX SENT          29:   8
# [DEBUG] TX SENT          30:   6
# [DEBUG] TX SENT          31:   9
# [DEBUG] TX SENT          32:   5
# [DEBUG] TX SENT          33:   7
# [DEBUG] TX SENT          34:   8
# [DEBUG] TX SENT          35:   7
# [DEBUG] TX SENT          36:  10
# [DEBUG] TX SENT          37:   6
# [DEBUG] TX SENT          38:   3
# [DEBUG] TX SENT          39:   6
# ** Note: $finish    : D:/gkd/verilog/modelsim/valid_ready_tb.sv(45)
#    Time: 1020 ns  Iteration: 0  Instance: /test_top
# 1

參考資料:
FIFO interface (ready/valid)
systemverilog-array陣列

相關文章