dimanche 2 mai 2021

How to make a set of values to be randomized then synthesized Quartus 14.1 System Verilog? [duplicate]

Is there a way to make a group of certain values (a card deck in this instance) be randomized, and then after randomization display its values on a FPGA one by one. If not what is the closest way to mimic randomization of specified values in Quartus for system verilog? as seen below $urandom_range() function not supported, guessing similar functions are not supported as well. Thank you for your time.


module blackjack(input logic clk);

 logic [3:0]array[51:0];
  logic [3:0]array2[51:0];

  

initial begin

 array[0] = 4'd1;
    array[1] = 4'd2;
    array[2] = 4'd3;
    array[3] = 4'd4;
    array[4] = 4'd5;
    array[5] = 4'd6;
    array[6] = 4'd7;
    array[7] = 4'd8;
    array[8] = 4'd9;
    array[9] = 4'd10;
    array[10] = 4'd11; 
    array[11] = 4'd12;  
    array[12] = 4'd13;   
    array[13] = 4'd1;   
    array[14] = 4'd2;
    array[15] = 4'd3;
    array[16] = 4'd4;
    array[17] = 4'd5;
    array[18] = 4'd6;
    array[19] = 4'd7;
    array[20] = 4'd8;
    array[21] = 4'd9;
    array[22] = 4'd10;
    array[23] = 4'd11;
    array[24] = 4'd12;
    array[25] = 4'd13;
    array[26] = 4'd1;
    array[27] = 4'd2;
    array[28] = 4'd3;
    array[29] = 4'd4;
    array[30] = 4'd5;
    array[31] = 4'd6;
    array[32] = 4'd7;
    array[33] = 4'd8;
    array[34] = 4'd9;
    array[35] = 4'd10;
    array[36] = 4'd11;
    array[37] = 4'd12;
    array[38] = 4'd13;
    array[39] = 4'd1;
    array[40] = 4'd2;
    array[41] = 4'd3;
    array[42] = 4'd4;
    array[43] = 4'd5;
    array[44] = 4'd6;
    array[45] = 4'd7;
    array[45] = 4'd8;
    array[47] = 4'd9;
    array[48] = 4'd10;
    array[49] = 4'd11;
    array[50] = 4'd12;
    array[51] = 4'd13;
    
      for(int i = 0; i < 52; i++) begin
  
        int k = $urandom_range(0,51); //system function "$urandom_range" is not supported for synthesis

  
            if(array[k] == 0)begin
                i = i-1;
                continue;
            end
            else 
            array2[i] = array[k];
            array[k] = 4'd0;
        end
    

  
end
  
    
endmodule
        



Aucun commentaire:

Enregistrer un commentaire