如何使用CSV Data Config文件中的唯一数据循环每个线程

时间:2017-12-04 23:34:07

标签: jmeter

我有25个用户的CSV数据配置文件。当我创建一个包含25个用户的Thread组时,我希望每个线程从CSV Data config中选择一行并循环。

所以

`timescale 1ns / 1ps

module Player (
    input wire clk,
    input wire rst,
    input wire button,
    input wire [29:0] set,
    input wire button_p1,
    input wire button_p2,
    output wire [3:0]oscore1,
    output wire [3:0]oscore2,
    output reg [7:0] LED_ON,
    output reg answer,
    output reg [3:0] digit,
    output reg [42:0]seg1,
    output reg [42:0]seg2
);

wire  Clk;
wire  rd_ptr;
reg [28:0] setlist [3:0];
wire  totlen;


reg button_old, button_raise;
reg number;
reg [3:0] Score_P1, Score_P2;
reg [6:0] sevseg;
reg Clk_10000;
reg [31:0] count;

always @(posedge clk or posedge rst) begin
    // detect rising edge
    button_old <= 0;
    button_raise <= 1'b0;
    if (button_old != button && button == 1'b1) begin
        button_raise <= 1'b1;
        button_old <= button;
        // increment number
        if(button_raise == 1'b1) begin
            Score_P1 = 4'b0000;
            Score_P2 =4'b0000;
            if(~rst) begin
                number <= 0;
            end
        end else if(button_p1 && !button_p2 && answer==1'b1) begin
            Score_P1 <= (Score_P1 + 1);
        end else if(button_p2 && !button_p1 && answer==1'b1) begin
            Score_P2 <= (Score_P2 + 1);
        end else if(button_p1 && button_p2 && answer==1'b1 || answer==1'b0) begin
            LED_ON [0] <= 1'b1;
        end else begin
            LED_ON [7] <= 1'b1;
        end
    end else begin
        button_old <=0;
        button_raise <=0;
    end
end

assign oscore1= Score_P1;
assign oscore2= Score_P2;

always @ (rd_ptr) begin
    assign answer = set [totlen-1];
    case (digit)
        4'b1000: sevseg = set [27:21];
        4'b0100: sevseg = set [20:14];
        4'b0010: sevseg = set [13:7];
        4'b0001: sevseg = set [6:0];
        default: sevseg= 7'b0000000;
    endcase

    setlist[0] = 29'b01111110100110011111101001111;
    setlist[1] = 29'b11111110100111111111101001111;
    setlist[2] = 29'b01111110000000111111100000000;
    setlist[3] = 29'b01111110100111111111100100000;
end

always@(digit or seg1 or seg2) begin
    case(digit)
        4'b1110: sevseg = seg1[41:35];
        4'b1101: sevseg = seg1[34:28];
        4'b1011: sevseg = seg2[27:21];
        4'b0111: sevseg = seg2[20:14];
    endcase
end

always @ (posedge Clk or negedge rst) begin
    if (!rst) begin
        count <= 32'd0;
        Clk_10000<=0;
    end else begin
        if (count == 'd10000) begin
            count <= 32'd0;
            Clk_10000 <= ~Clk_10000;
        end else begin
            count <= count +1;
        end
    end
end

always @ (posedge Clk_10000 or negedge rst) begin
    if (!rst) begin
        digit <= 4'b1110;
    end else if (Clk_10000) begin
        digit <= {digit [2:0], digit [3]};
    end
end

always @ (Score_P1)
begin
    case (Score_P1)
        4'b0000: seg1 <= 14'b0000001_0000001;
        4'b0001: seg1 <= 14'b0000001_1001111;
        4'b0010: seg1 <= 14'b0000001_0010010;
        4'b0011: seg1 <= 14'b0000001_0000110;
        4'b0100: seg1 <= 14'b0000001_1001100;
        4'b0101: seg1 <= 14'b0000001_0100100;
        4'b0110: seg1 <= 14'b0000001_0100000;
        4'b0111: seg1 <= 14'b0000001_0001111;
        4'b1000: seg1 <= 14'b0000001_0000000;
        4'b1001: seg1 <= 14'b0000001_0001100;
        4'b1010: seg1 <= 14'b1001111_0000001;
        4'b1011: seg1 <= 14'b1001111_1001111;
        4'b1100: seg1 <= 14'b1001111_0010010;
        4'b1101: seg1 <= 14'b1001111_0000110;
        4'b1110: seg1 <= 14'b1001111_0100100;
        4'b1111: seg1 <= 14'b1001111_0100000;
    endcase
end

always @ (Score_P2)
begin
    case (Score_P2)
        4'b0000: seg2 <= 14'b0000001_0000001;
        4'b0001: seg1 <= 14'b0000001_1001111;
        4'b0010: seg2 <= 14'b0000001_0010010;
        4'b0011: seg2 <= 14'b0000001_0000110;
        4'b0100: seg2 <= 14'b0000001_1001100;
        4'b0101: seg2 <= 14'b0000001_0100100;
        4'b0110: seg2 <= 14'b0000001_0100000;
        4'b0111: seg2 <= 14'b0000001_0001111;
        4'b1000: seg2 <= 14'b0000001_0000000;
        4'b1001: seg2 <= 14'b0000001_0001100;
        4'b1010: seg2 <= 14'b1001111_0000001;
        4'b1011: seg2 <= 14'b1001111_1001111;
        4'b1100: seg2 <= 14'b1001111_0010010;
        4'b1101: seg2 <= 14'b1001111_0000110;
        4'b1110: seg2 <= 14'b1001111_0100100;
        4'b1111: seg2 <= 14'b1001111_0100000;
    endcase
end
endmodule

因为我设置保持活着所以我想在同一个套接字上重用连接和相同的数据集。

User1 picks userA
Users2 pick userB.......userN pick user(SomeX)

但我观察到的是My CSV file Recycle on EOF False Stop Thread on EOF True Sharing Mode : Current Thread. Thread 1-1 User1 picks UserA ( iteration 1)

我期待的是

Thread 1-1 User 1 picks User B  iteration 2

1 个答案:

答案 0 :(得分:0)

根据您的描述,每个JMeter线程将独立地和单独地读取CSV文件,即:

  • Thread 1-1将处理所有25个CSV条目定义的迭代次数
  • Thread 1-2将处理所有25个CSV条目定义的迭代次数

假设您在CSV文件和虚拟用户中拥有相同数量的行,那么最好将“共享模式”设置为All threads,这样每个虚拟用户都可以从CSV文件中选择自己的行。

更多信息: