Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

verilog code to generate random sequence

Status
Not open for further replies.

rashmi.kotagiri

Newbie level 3
Joined
Nov 4, 2009
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
n/a
Activity points
1,301
hiii, how to write verilog code for pseudo random interleaver or else how to generate random sequence in verilog?
anybody know.. plz help me.. very urgent
 

An LFSR can be used to generate random values in case of RTL.

In case of verification you can use $random.
In the case define a MIN and MAX values and get
MIN + {$random(seed)}%(MAX-MIN+1)

e.g.
integer pkt_size_max, pkt_size_min, pkt_size;

pkt_size_max = 100;
pkt_size_min = 10;

for ( i = 0; i < 10; i = i + 1) begin
pkt_size = pkt_size_min + {$random(seed)} % (pkt_size_max-pkt_size_min+1)
$display("Generated packet size is %d". pkt_size);
end

The above code will return random packet values between 10 and 100.
To bring constraint random technique into verilog, you can change the values of pkt_size_max and pkt_size_min from the testcase.

Cheers,
eChipDesign
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top