This section discusses the requirements and e code 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:
Since the receiver object is expected to be static, it should be defined as a unit. There will be three instances of the receiver object, each with a different hdl_path() corresponding to each channel.
Define a field port_no of type uint that specifies the channel with which that receiver object is associated.
Define a field rcv_delay of type uint that specifies the number of cycles to delay the assertion of vld_chan_X (vld_chan_0, vld_chan_1 or vld_chan2) by the router to the assertion of read_enb_X (read_enb_0, read_enb_1 or read_enb_2) by the receiver object. Set a soft constraint on rcv_delay to be equal to 10 cycles.
Define an event clk_fall that is emitted at the falling edge of the DUT clock.
Define a packet_start event that is emitted when the vld_chan_X (vld_chan_0, vld_chan_1 or vld_chan2) is asserted by the router.
Define a pkt_received event that is emitted when the receiver object completes the reception of one complete packet.
The method collect_packets() sits in a continuous loop waiting for packets from the DUT according to "DUT Output Protocol" on page 226.
Example 13-3 presents 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 '>