// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: siu_l2_mon.vr // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved // 4150 Network Circle, Santa Clara, California 95054, U.S.A. // // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // For the avoidance of doubt, and except that if any non-GPL license // choice is available it will apply instead, Sun elects to use only // the General Public License version 2 (GPLv2) at this time for any // software where a choice of GPL license versions is made // available with the language indicating that GPLv2 or any later version // may be used, or where a choice of which version of the GPL is applied is // otherwise unspecified. // // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, // CA 95054 USA or visit www.sun.com if you need additional information or // have any questions. // // ========== Copyright Header End ============================================ #include "siumon.if.vrh" #include "siumon_ports_binds.vrh" #include "std_display_class.vrh" #include "siu_l2_packet.vrh" #include "siu_monitor.vrh" class siu_l2_monitor { l2_mon_port monitor; Siu_L2_Packet snd_packet; Siu_L2_Packet rec_packet; integer snd_mbox, rec_mbox; StandardDisplay dbg; string myname; integer myid; task new (l2_mon_port monitor, integer snd_mbox, integer rec_mbox, integer myid, StandardDisplay dbg); task monitor_l2_send (); task monitor_l2_recv (); function integer get_send_pkt(Cycle_Mode mode, integer cycle); function integer check_send(Cycle_Mode mode); function integer get_recv_pkt(Cycle_Mode mode, integer cycle); function integer check_recv(Cycle_Mode mode); } task siu_l2_monitor::new(l2_mon_port monitor, integer snd_mbox, integer rec_mbox, integer myid, StandardDisplay dbg) { this.monitor = monitor; snd_packet = new(RDD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); rec_packet = new(RDD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); this.dbg = dbg; myname = "siu-l2"; this.myid = myid; this.snd_mbox = snd_mbox; this.rec_mbox = rec_mbox; dbg.dispmon(myname, MON_NORMAL, psprintf ("siu-l2 monitor [%1d] ready", myid)); fork { monitor_l2_send(); } join none fork { monitor_l2_recv(); } join none } task siu_l2_monitor::monitor_l2_recv() { Siu_L2_Packet packet; integer i, data_cycles; integer fail, result, temp; while (1) { @(posedge monitor.$clk); if (monitor.$req_vld == 1'b0) { if (monitor.$dbg_req !== 2'b00) dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong when no req", myid)); } else if (monitor.$req_vld === 1'b1) { data_cycles = 0; fail = 0; temp = 0; // header result = get_recv_pkt(HEADER_C, 1); fail = check_recv(HEADER_C); case (monitor.$req[26:24]) { 3'b100: data_cycles = 16; 3'b010: data_cycles = 2; 3'b001: data_cycles = 2; default: dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet type unknown", myid)); } dbg.dispmon(myname, MON_NORMAL, psprintf ("l2%1d recv pkt=%x ", myid, rec_packet.id)); case (monitor.$req[26:24]) { 3'b100: if (monitor.$dbg_req != 2'b10) dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for WRI", myid)); 3'b010: if (monitor.$dbg_req != 2'b11) dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for WR8", myid)); 3'b001: if (monitor.$dbg_req != 2'b01) dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for RDD", myid)); default: dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet type wrong", myid)); } // addr cycles @(posedge monitor.$clk); result = get_recv_pkt(ADDR_C, 1); fail = check_recv(ADDR_C); if (monitor.$dbg_req != 2'b00) dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong at addr cycle", myid)); // data cycles for (i=0; i