What are the sequences in Specman? What are the significance of sequences? This post explains the way of implementing the sequences in specman.
Introduction: Sequences let you define the streams of data items sent over to the input protocol of the DUT. Before moving on to the details of sequences, let me give you some of the important definitions.
Item : It is a struct that represents the main inputs to the DUT - Basically a USB packet or an CPU instruction.
Sequence : It is a struct that represents the streams of data items generated one after another according to some protocol, say for example, in USB - Out or setup packet is transferred followed by Data packet.
Sequence driver : The SD acts as an agent b/w sequences and the Bus Functional Model (BFM). Basically, a SD takes the generated data items and pass it on to the BFM which in turns convert all your high level data items (Packets or Instruction) into low level data items (bits and bytes).
Basically a TCM which resides in the BFM does the actual transmission of data items. Both the sequence driver and BFM acts as a pair; The sequence driver serves as the interface upward towards the sequnces and the BFM serves as the interface downward towards DUT. Therefore the Sequence driver only interacts with BFM for the purpose of driving data item into the DUT.
How to use sequences?1. Define the sequence item struct - For an item to be used with sequences, it must have some common functionality.type usb_pid_t : [SETUP = 0xD, OUT = 0x1 , IN = 0x9];// Create the sequence item
struct usb_transaction_s like any_sequence_item {dev_addr : uint (bits : 7);ep_num : uint (bits:4);pid : usb_pid_t;data : list of uint (bits : 8);};2. Define the sequence and its driver using the sequence statement// Define the sequence
sequence usb_sequence_s usingitem = usb_transaction_s,created_driver : usb_transaction_driver_u; // Name of the drivercreated_kind : usb_transaction_kind_t; // Various sub types for the sequence3. Hook up the sequence driver to the environmentHave a BFM that knows how to drive the USB packet to the DUT.
unit usb_bfm {event usb_clk is rise ('usb_clk_30') @ sim;drive_packet ( packet : usb_transaction_s) @ usb_clk is {-------------}; // End of drive_packet TCM}; // End of unit usb_bfmThe BFM is instantiated in the Agent
extend usb_bfm { driver : usb_transaction_driver_u; // Reference to the sequence driver in the BFM };unit usb_agent {bfm : usb_bfm is instance; };extend usb_agent {driver : usb_transaction_driver_u is instance;keep bfm.driver == driver;};connect the pre-defined clock to the BFM clock
extend usb_bfm {on usb_clk { emit driver.clock }; };Pull item from driver, process it and inform through done
Instantiate the driver into the Agent
extend usb_bfm { execute_items () @ clock is { var sequential_items : usb_transaction_s; while (TRUE) { sequential_items = driver.get_next_item(); drive_packet (sequential_item);emit driver.packet_done;}; // End of while loop}; // End of execute_item TCMrun() is also {start execute_items ();}; // End of run method}; // End of usb_bfmIn the next post, we will see how to implemet the sequence library and how to write the test case s using the sequences.