Previous Section Next Section

13.4 Data Checker Object

This section discusses the requirements and e code for the data checker object.

13.4.1 Requirements for the Data Checker Object

The data checker object is implemented in form of a scoreboard (sbt_scoreboard). Requirements for the scoreboard are as follows:

13.4.2 e Code for the Data Checker (Scoreboard) Object

Example 13-4 presents e code for the data checker (scoreboard) object.

Example 13-4 e Code for the Data Checker (Scoreboard) Object
File contains e code for the scoreboard object.
This object is instantiated in the receiver object.
<'
import sbt_packet;

unit sbt_scoreboard {

    -- Expected list of packets that have been driven into the DUT
    !exp_packets : list of sbt_packet;

    -- add_packet()
    -- Adds a new packet to the exp_packets list
    add_packet(packet_in : sbt_packet) is {
        exp_packets.add(packet_in);
    };
    -- check_packet()
    -- Tries to find the received packet in the exp_packets list.
    -- Since the order of packets that have been sent into the DUT is
    -- the same for the outcoming packets on the receiver side,
    -- the first packet in the exp_packets list
    -- has to match the received packet. Each time we check a packet
    -- we delete the matched (first) packet from the expected packets
    -- list.
    check_packet(packet_out : sbt_packet) is {
        var diff : list of string;

        -- Compare the physical fields (addr, len, data, parity) of
        -- the received packet with the first packet in the
        -- exp_packets list.
        -- The last parameter indicates that we only care to report up
        -- to 10 differences.
        diff = deep_compare_physical(exp_packets[0], packet_out, 10);


        -- If there is a mismatch, diff will get the mismatches as
        -- a list of strings. Simulation will stop and the
        -- mismatches will be displayed.
        check that (diff.is_empty()) else
            dut_error("Packet not found on scoreboard", diff);

        -- If the match was successful, continue with the following
        -- actions
        out("Found received packet on scoreboard");
        -- On a match delete the matched packet
        exp_packets.delete(0);
    };

};

-- Extend the sbt_driver. When a packet is driven into the DUT
-- (indicated by the event packet_started) the
-- add_packet() method of the appropriate
-- scoreboard (indicated by the packets addr field) is called and the
-- cur_packet is copied to the exp_packets list
extend sbt_driver {
    -- Create a pointer to top level environment so we can reference
    -- the sbt_receivers
    parent_env: sbt_env; -- Pointer to the parent of sbt_driver
        keep parent_env == get_enclosing_unit(sbt_env);

    on packet_started {
    -- Add a copy of the cur_packet (rather than pointer) to
    -- the appropriate receiver instance.
    parent_env.sbt_receivers[cur_packet.addr].scoreboard.add_packet(cur_packet.copy());
    };
};

-- Extend the sbt_receiver. Create an instance of the scoreboard.
-- When a packet was received (indicated by the event received_packet)
-- the scoreboard's check_packet() method is called which tries to
-- find a matching packet on the scoreboard's exp_packets list
extend sbt_receiver {
    scoreboard : sbt_scoreboard is instance; -- Instantiate scoreboard

    on pkt_received { -- At every pkt_received event
        scoreboard.check_packet(rcv_packet); -- Check packet against
                                             -- scoreboard element
    };
};
'>
Previous Section Next Section