Previous Section Next Section

13.3 Receiver Object

This section discusses the requirements and e code for the receiver object.

13.3.1 Requirements for the Receiver Object

The receiver object (sbt_receiver) follows the specification described in "DUT Output Protocol" on page 226. Requirements for the receiver object are as follows:

13.3.2 e Code for the Receiver Object

Example 13-3 presents e code for the receiver object.

Example 13-3 e Code for the Receiver Object
File contains e code for the receiver object.
Since this object is modeled as a unit, all references
to HDL signals assume that an hdl_path() has been defined
at a higher level.
<'
-- Import the sbt_packet
import sbt_packet;

unit sbt_receiver {

    port_no : uint;              -- port_no of corresponding port

    !rcv_packet : sbt_packet;   -- Packet that will be received

    rcv_delay : uint;           -- Delay that the receiver waits
                                -- before setting the read enable
        keep soft rcv_delay == 10; -- Soft constraint

    event clk_fall is fall('clock')@sim; -- Synchronizing clock

    -- Event telling the receiver that valid data are available for
    -- reception
    event packet_start is rise('vld_chan_(port_no)')@clk_fall;
    -- Event that will be emitted when a packet is fully received
    event pkt_received;

    -- collect_packets()
    --
    -- Collect data from output port #<port_no>
    collect_packets() @clk_fall is {

        -- List of bytes that will hold the received bytes
        -- from the channelx port
        var received_bytes : list of byte;

        -- Loop forever
        while TRUE {

            -- Wait until valid data are available
            wait until @packet_start;

            -- Wait a delay until receiving
            wait [rcv_delay];

            -- Set the read enable signal
            'read_enb_(port_no)' = 1;

            -- While data are valid on the channel loop
            while 'vld_chan_(port_no)' == 1 {

                -- Wait a cycle
                wait [1];

                -- Add the received byte to the list of bytes
                received_bytes.add('channel(port_no)');
                out(sys.time, " receiving data from channel ",
                     port_no);
            };

            -- Release the read enable signal
            'read_enb_(port_no)' = 0;

            -- Unpack the list of bytes to a sbt_packet struct
            -- (rcv_packet)
            unpack(packing.low, received_bytes, rcv_packet);

            -- Delete the list of bytes after the packet is received
            received_bytes.clear();

            -- Emit the pkt_received event
            emit pkt_received;
        };
     };
 -- Start the collect_packets() TCM
    run() is also {
        start collect_packets();
    };
}; -- end sbt_receiver
'>
Previous Section Next Section