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数组

posted on 2024-06-23 19:39  糊涂二蛋  阅读(427)  评论(0编辑  收藏  举报