This section discusses the requirements and e code 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:
Since the scoreboard is expected to be static, it should be defined as a unit. The scoreboard is instantiated inside the receiver object because there needs to be separate data checking per channel.
Define a list exp_packets of type sbt_packet that holds the list of expected packets on that channel. Do not generate this list during the generation phase.
Define a method add_packet() that takes one packet as an argument and adds it to the list of expected packets.
Define a method check_packet() that takes one packet as an argument and checks it for equality against the first element of the exp_packets list.
Extend the sbt_driver defined in "Driver Object" on page 246. At every packet_started event, add a packet to the exp_packets list.
Extend the sbt_receiver defined in "Receiver Object" on page 250. At every pkt_received event, check the received packet against the first element in the exp_packets list.
Example 13-4 presents 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 }; }; '>