16657SN/A# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
26657SN/A# Copyright (c) 2009 The Hewlett-Packard Development Company
37567SBrad.Beckmann@amd.com# Copyright (c) 2010 Advanced Micro Devices, Inc.
46657SN/A# All rights reserved.
56657SN/A#
66657SN/A# Redistribution and use in source and binary forms, with or without
76657SN/A# modification, are permitted provided that the following conditions are
86657SN/A# met: redistributions of source code must retain the above copyright
96657SN/A# notice, this list of conditions and the following disclaimer;
106657SN/A# redistributions in binary form must reproduce the above copyright
116657SN/A# notice, this list of conditions and the following disclaimer in the
126657SN/A# documentation and/or other materials provided with the distribution;
136657SN/A# neither the name of the copyright holders nor the names of its
146657SN/A# contributors may be used to endorse or promote products derived from
156657SN/A# this software without specific prior written permission.
166657SN/A#
176657SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186657SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196657SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206657SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216657SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226657SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236657SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246657SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256657SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266657SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276657SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286657SN/A
296657SN/Afrom slicc.ast.StatementAST import StatementAST
306657SN/A
317567SBrad.Beckmann@amd.comclass StallAndWaitStatementAST(StatementAST):
327567SBrad.Beckmann@amd.com    def __init__(self, slicc, in_port, address):
336657SN/A        super(StatementAST, self).__init__(slicc)
347567SBrad.Beckmann@amd.com        self.in_port = in_port
357567SBrad.Beckmann@amd.com        self.address = address
3611320Ssteve.reinhardt@amd.com
376657SN/A    def __repr__(self):
3810308Snilay@cs.wisc.edu        return "[StallAndWaitStatementAst: %r]" % self.in_port
396657SN/A
406657SN/A    def generate(self, code, return_type):
417567SBrad.Beckmann@amd.com        self.in_port.assertType("InPort")
4211025Snilay@cs.wisc.edu        self.address.assertType("Addr")
436657SN/A
447567SBrad.Beckmann@amd.com        in_port_code = self.in_port.var.code
457567SBrad.Beckmann@amd.com        address_code = self.address.var.code
467567SBrad.Beckmann@amd.com        code('''
477567SBrad.Beckmann@amd.com        stallBuffer(&($in_port_code), $address_code);
4811111Snilay@cs.wisc.edu        $in_port_code.stallMessage($address_code, clockEdge());
497567SBrad.Beckmann@amd.com        ''')
50