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.
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.