samedi 12 juin 2021

Cannot use $random function in Verilog

I try to design a game of guessing a random number by using DE0 plane in Verilog. However, I write a $random function to generate a number between 0~99, but the function cannot work successfully. My code:

module team43 (in_a, in_b, enter, answer, out_a, out_b);
    input [3:0]in_a;
    input [3:0]in_b;
    input enter, answer;
    output [6:0]out_a;
    output [6:0]out_b;
    reg [6:0]out_a;
    reg [6:0]out_b;
    reg [23:0]rand_num;
    integer seed;
    initial begin seed=0; end
    initial begin rand_num <= {$random(seed)}%100; end
endmodule

And errors occur:

Error (10174): Verilog HDL Unsupported Feature error at team43.v(12): system function "$random" is not supported for synthesis
Error: Can't elaborate top-level user hierarchy
Error: Quartus II Analysis & Synthesis was unsuccessful. 2 errors, 2 warnings
Error: Quartus II Full Compilation was unsuccessful. 4 errors, 2 warnings

I throughly search to figure out the error, but can't find out a suitable way to solve the error. Does anyone could help me solve the problem?




Aucun commentaire:

Enregistrer un commentaire