This section discusses the requirements and the e code required to implement the tests in the "Test Plan" on page 241. Each test is simply a small file containing e code. To run the test, compile the test file with the rest of the e files.
In this scenario, create packets with a certain probability distribution. There should be a mix of packets of different lengths. There should also be a mix of good and bad parity packets. To do so, extend the struct sbt_packet as follows:
The packet lengths should be distributed with 10% SMALL, 20% MEDIUM, and 70% LARGE.
The packet kind must be 70% with good parity and 30% with bad parity.
Extend the struct sys as follows:
Create exactly 50 packets and inject them into the DUT.
Example 13-9 presents e code for the test scenario 1 (distribution of packets).
File contains test that distributes the types of packets in a probabilistic distribution. 10% SMALL, 20% MEDIUM, 70% LARGE 70% Good parity, 30% Bad parity <' import sbt_env; -- Import all units instantiated in the environment. extend sbt_packet { keep soft payload_size == select { -- Weighted constraint for the -- payload_size field 10: SMALL; -- Probability 10% 20: MEDIUM; -- Probability 20% 70: LARGE; -- Probability 70% }; keep soft packet_kind == select {-- Weighted constraint for the -- packet_kind field 70: GOOD; -- Probability 70% 30: BAD; -- Probability 30% }; }; extend sys { keep sbt_env.sbt_driver.no_of_pkts == 50; -- Set number of packets -- This field will decide how many packets get generated in the -- sbt_driver and are injected into the DUT. }; '>
In this scenario, create a test that will make the sbt_receiver assert the read_enb_X (read_enb_0, read_enb_1 or read_enb_2) more than 30 clock cycles after vld_chan_X (vld_chan_0, vld_chan_1 or vld_chan2) is asserted. This will violate the protocol. To do so, extend the struct sbt_receiver as follows:
Set the rcv_delay field to be 40. This will violate the protocol.
Note the simplicity of e tests. The test files are simply small files with constraints.
e code for test scenario 2 (protocol violation) is show in Example 13-10.
File contains test that violates the protocol. This is done by setting a simple constraint that will violate the protocol for the latency between vld_chan_X and read_enb_X. <' extend sbt_receiver { keep rcv_delay == 40; -- Violate the DUT output protocol rule -- Latency is 40, violates the maximum -- limit of 30 }; '>