samedi 16 avril 2022

Random coordinate generator for VERILOG

I have been trying to implement a random number generator for one variable between 10 and 1390 and for another variable between 110 and 890. I have been unable to get anywahere with my current ideas and would appreciate any help or input to correct me. My current code can be seen below however I am not confident in it at all, the values are not exact to those described above as I have modified it to experiment.

reg [10:0] randx;
reg [10:0] randy;


reg [9:0] i = 600;
reg [9:0] j = 400;

always @ (posedge clk)
begin
if (i<820)
i <= i + 40;
else 
i<= 600;
end

always @ (posedge clk)
begin
if (j>200)
j <= j - 40;
else 
j <= 400;
end

always @ (i,j)
begin
randx <= i;
randy <= j;
end



Aucun commentaire:

Enregistrer un commentaire