|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



VMM ATOMIC GENERATOR


VMM has two types of generators. Atomic generator and Scenario generator.

Atomic generator is a simple generator which generates transactions randomly.

`vmm_atomic_gen is a macro which is used to define a class named <class_name>_atomic_gen for any user-specified class derived from vmm_data, using a process similar to the `vmm_channel macro.

 
To use <class_name>_atomic_gen class, a <class_name>_channel must exist. <class_name>_atomic_gen generates transactions and pushes it to <class_name>_channel. A <class_name>_channel object can be passed to generator while constructing.

function new(string instance,
            int stream_id = -1,
            <class_name>_channel out_chan = null);


The generator will stop generating the transaction after generating stop_after_n_insts.  User can set the stop_after_n_insts to any unsigned int value. By default this values is 0.

If stop_after_n_insts is 0, then generator generates infinite number of transactions.
If stop_after_n_insts is non zero positive number, then generator generates stop_after_n_insts transactions.

We will see an example of creating a atomic generator for a packet class. Packet class is in file Packet.sv .

1) define `vmm_atomic_gen macro for packet class. This macro creates a packet_atomic_gen class creates and randomizes packet transactions.

    `vmm_atomic_gen(packet,"packet atomic generator")

2) define `vmm_channel for the packet class. This macro creates a packet_channel which will be used by the packet_atomic_gen to store the transactions. Any other component can take the transactions from this channel.

     `vmm_channel(packet)

3) Create an object of pcakt_atomic_gen.

    packet_atomic_gen pkt_gen = new("Atomic Gen","test"); 

4) Set the number of transactions to be generated to 4

    pkt_gen.stop_after_n_insts = 4;

5) Start the generator to generate transactions. These transactions are available to access through pkt_chan as soon as they are generated.

    pkt_gen.start_xator(); 

6) Collect the packets from the pkt_chan and display the packet content to terminal.

    pkt_gen.out_chan.get(pkt);
    pkt.display();


Completed Example

`vmm_channel(Packet)
`vmm_atomic_gen(Packet,"Atomic Packet Generator")

program test_atomic_gen();
  
  Packet_atomic_gen pkt_gen = new("Atomic Gen","test"); 
  Packet pkt;
    initial
       begin 
          pkt_gen.stop_after_n_insts = 4;
          #100; pkt_gen.start_xactor();
       end

    initial
       #200 forever
            begin
                pkt_gen.out_chan.get(pkt);
                pkt.display();
            end
    
endprogram 

Download the example

vmm_atomic_gen.tar
Browse the code in vmm_atomic_gen.tar

Commands to run the simulation
vcs -sverilog -f filelist -R -ntb_opts rvm -ntb_opts dtm

Log file report

      packet #1952805748.0.0
      da:0xdb
      sa:0x71
      length:0x0e (data.size=1)
      data[0]:0x63
      fcs:0xe9

      packet #1952805748.0.1
      da:0xa7
      sa:0x45
      length:0xa4 (data.size=5)
      data[0]:0x00   data[1]:0x4f  ....     data[3]:0xe7   data[4]:0xd8
      fcs:0x31

      packet #1952805748.0.2
      da:0x15
      sa:0xe6
      length:0xa1 (data.size=1)
      data[0]:0x80
      fcs:0x01

      packet #1952805748.0.3
      da:0xd7
      sa:0xa9
      length:0xdc (data.size=3)
      data[0]:0xcc   data[1]:0x7c   data[1]:0x7c
      fcs:0x67


Index
Introduction
Vmm Log
Vmm Env
Vmm Data
Vmm Channel
Vmm Atomic Generator
Vmm Xactor
Vmm Callback
Vmm Test
Vmm Channel Record And Playback
Vmm Scenario Generator
Vmm Opts

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright © 2007-2017 :: all rights reserved www.testbench.in::Disclaimer