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.

Randomized packet is not generated with Atomic Generator in VMM

Status
Not open for further replies.

arunkumarnellur

Newbie level 1
Newbie level 1
Joined
Nov 11, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,306
Hello EDABoard:

I am trying the following snippet in VMM (pkt randomization with an atomic generator).
The output shows 'pkt' attributes set to 'zero' where as the randomized attributes are expected.

Could somebody suggest where the code needs to be fixed?

Thanks
Arun N



Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//filename: channel_connection.sv
 
 
`ifndef TEST_ATOMIC_GEN_SV_
`define TEST_ATOMIC_GEN_SV_
 
`include "vmm.sv"
 
class packet extends vmm_data;
 
    rand bit [31:0] vari;
    rand bit [31:0] vari2;
   
   extern function new();
   extern virtual function string   psdisplay (string prefix = "");
   extern virtual function vmm_data allocate  ();
   extern virtual function vmm_data copy      (vmm_data to = null);
   extern virtual function void     copy_data (vmm_data to = null);
   extern virtual function bit      compare   (vmm_data      to,
                                               output string diff,
                                               input int     kind = -1);
 
   extern  function void post_randomize();
endclass : packet
 
`vmm_channel(packet)
`vmm_atomic_gen(packet,"atomic_gen")
 
 
function packet::new();
   super.new();
endfunction
 
 
function string packet::psdisplay(string prefix);
  $write( psdisplay, "[%s] vari = 32'h%h; vari2 = 32'h%h\n",prefix, vari, vari2 );
endfunction
 
function vmm_data packet::allocate();
   packet i = new();
   allocate = i;
endfunction
 
function vmm_data packet::copy(vmm_data to);
   packet cpy;
   if (to == null)
      cpy = new();
   else
      if (!$cast(cpy,to)) begin
          copy = null;
         return copy;
      end
   copy_data(cpy);
   copy = cpy;
endfunction
 
function void packet::copy_data(vmm_data to);
   packet cpy;
   super.copy_data(to);
   if (!$cast(cpy, to)) begin
      return;
   end
endfunction
 
function bit packet::compare (vmm_data      to,
                                output string diff,
                                input int     kind);
   string str;
   compare = 1;
 
   return compare;
endfunction
 
function void packet::post_randomize();
  super.post_randomize();
endfunction
 
 
 
program test_atomic_gen;
 
  packet_atomic_gen pkt_gen = new("atomic_gen", "test");
  packet            pkt;
  
  initial 
  begin
    pkt = new();
    pkt_gen.stop_after_n_insts = 4; 
    pkt_gen.randomized_obj.vari.rand_mode(1); //vari to be randomized everytime
    pkt_gen.randomized_obj.vari2 = 32'h1234_5678;
    pkt_gen.randomized_obj.vari2.rand_mode(0);//turn-off vari2 randomization with a configured value.
    $display( "time: %t", $time );
    #100; 
    pkt_gen.start_xactor(); 
  end 
 
  initial 
  begin
    #200;
    forever 
    begin 
      $display( "time: %t", $time );
      pkt_gen.out_chan.get(pkt); 
      pkt.psdisplay(); 
    end 
  end
endprogram:test_atomic_gen
`endif //TEST_ATOMIC_GEN_SV_



command to run: vcs -full64 -sverilog -licqueue -ntb_opts rvm -R channel_connection.sv
Output:
time: 0
time: 200
[] vari = 32'h00000000; vari2 = 32'h00000000
time: 200
[] vari = 32'h00000000; vari2 = 32'h00000000
time: 200
[] vari = 32'h00000000; vari2 = 32'h00000000
time: 200
[] vari = 32'h00000000; vari2 = 32'h00000000
time: 200
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top