114097Spfotouhi@ucdavis.edu# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
214097Spfotouhi@ucdavis.edu# Copyright (c) 2009 The Hewlett-Packard Development Company
314097Spfotouhi@ucdavis.edu# Copyright (c) 2010 Advanced Micro Devices, Inc.
414097Spfotouhi@ucdavis.edu# All rights reserved.
514097Spfotouhi@ucdavis.edu#
614097Spfotouhi@ucdavis.edu# Redistribution and use in source and binary forms, with or without
714097Spfotouhi@ucdavis.edu# modification, are permitted provided that the following conditions are
814097Spfotouhi@ucdavis.edu# met: redistributions of source code must retain the above copyright
914097Spfotouhi@ucdavis.edu# notice, this list of conditions and the following disclaimer;
1014097Spfotouhi@ucdavis.edu# redistributions in binary form must reproduce the above copyright
1114097Spfotouhi@ucdavis.edu# notice, this list of conditions and the following disclaimer in the
1214097Spfotouhi@ucdavis.edu# documentation and/or other materials provided with the distribution;
1314097Spfotouhi@ucdavis.edu# neither the name of the copyright holders nor the names of its
1414097Spfotouhi@ucdavis.edu# contributors may be used to endorse or promote products derived from
1514097Spfotouhi@ucdavis.edu# this software without specific prior written permission.
1614097Spfotouhi@ucdavis.edu#
1714097Spfotouhi@ucdavis.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1814097Spfotouhi@ucdavis.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1914097Spfotouhi@ucdavis.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2014097Spfotouhi@ucdavis.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2114097Spfotouhi@ucdavis.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2214097Spfotouhi@ucdavis.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2314097Spfotouhi@ucdavis.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2414097Spfotouhi@ucdavis.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2514097Spfotouhi@ucdavis.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2614097Spfotouhi@ucdavis.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2714097Spfotouhi@ucdavis.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2814097Spfotouhi@ucdavis.edu
2914097Spfotouhi@ucdavis.edufrom slicc.ast.StatementAST import StatementAST
3014097Spfotouhi@ucdavis.edu
3114097Spfotouhi@ucdavis.educlass CheckProbeStatementAST(StatementAST):
3214097Spfotouhi@ucdavis.edu    def __init__(self, slicc, in_port, address):
3314097Spfotouhi@ucdavis.edu        super(StatementAST, self).__init__(slicc)
3414097Spfotouhi@ucdavis.edu        self.in_port = in_port
3514097Spfotouhi@ucdavis.edu        self.address = address
3614097Spfotouhi@ucdavis.edu
3714097Spfotouhi@ucdavis.edu    def __repr__(self):
3814097Spfotouhi@ucdavis.edu        return "[CheckProbeStatementAst: %r]" % self.in_port
3914097Spfotouhi@ucdavis.edu
4014097Spfotouhi@ucdavis.edu    def generate(self, code, return_type):
4114097Spfotouhi@ucdavis.edu        self.in_port.assertType("InPort")
4214097Spfotouhi@ucdavis.edu        self.address.assertType("Addr")
4314097Spfotouhi@ucdavis.edu
4414097Spfotouhi@ucdavis.edu        in_port_code = self.in_port.var.code
4514097Spfotouhi@ucdavis.edu        address_code = self.address.var.code
4614097Spfotouhi@ucdavis.edu        code('''
4714097Spfotouhi@ucdavis.edu    if (m_is_blocking &&
4814097Spfotouhi@ucdavis.edu        (m_block_map.count($address_code) == 1) &&
4914097Spfotouhi@ucdavis.edu        (m_block_map[$address_code] == &$in_port_code)) {
5014097Spfotouhi@ucdavis.edu            $in_port_code.delayHead(clockEdge(), cyclesToTicks(Cycles(1)));
5114097Spfotouhi@ucdavis.edu            continue;
5214097Spfotouhi@ucdavis.edu        }
5314097Spfotouhi@ucdavis.edu        ''')
54