basic.isa revision 10184:bbfa3152bdea
16157Snate@binkert.org// -*- mode:c++ -*-
26157Snate@binkert.org
36157Snate@binkert.org// -*- mode:c++ -*-
46157Snate@binkert.org
56157Snate@binkert.org// Copyright (c) 2003-2005 The Regents of The University of Michigan
66157Snate@binkert.org// All rights reserved.
76157Snate@binkert.org//
86157Snate@binkert.org// Redistribution and use in source and binary forms, with or without
96157Snate@binkert.org// modification, are permitted provided that the following conditions are
106157Snate@binkert.org// met: redistributions of source code must retain the above copyright
116157Snate@binkert.org// notice, this list of conditions and the following disclaimer;
126157Snate@binkert.org// redistributions in binary form must reproduce the above copyright
136157Snate@binkert.org// notice, this list of conditions and the following disclaimer in the
146157Snate@binkert.org// documentation and/or other materials provided with the distribution;
156157Snate@binkert.org// neither the name of the copyright holders nor the names of its
166157Snate@binkert.org// contributors may be used to endorse or promote products derived from
176157Snate@binkert.org// this software without specific prior written permission.
186157Snate@binkert.org//
196157Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
206157Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
216157Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
226157Snate@binkert.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
236157Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
246157Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
256157Snate@binkert.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
266157Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
276157Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
286157Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
296157Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
306157Snate@binkert.org//
316157Snate@binkert.org// Authors: Steve Reinhardt
326157Snate@binkert.org//          Korey Sewell
336168Snate@binkert.org
346168Snate@binkert.org// Declarations for execute() methods.
356168Snate@binkert.orgdef template BasicExecDeclare {{
366157Snate@binkert.org        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
376157Snate@binkert.org}};
386157Snate@binkert.org
396157Snate@binkert.org// Basic instruction class declaration template.
406157Snate@binkert.orgdef template BasicDeclare {{
41        /**
42         * Static instruction class for "%(mnemonic)s".
43         */
44        class %(class_name)s : public %(base_class)s
45        {
46          public:
47                /// Constructor.
48                %(class_name)s(MachInst machInst);
49                %(BasicExecDeclare)s
50        };
51}};
52
53// Basic instruction class constructor template.
54def template BasicConstructor {{
55        %(class_name)s::%(class_name)s(MachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
56        {
57                %(constructor)s;
58        }
59}};
60
61
62// Basic instruction class execute method template.
63def template BasicExecute {{
64        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
65        {
66                Fault fault = NoFault;
67
68                %(fp_enable_check)s;
69                %(op_decl)s;
70                %(op_rd)s;
71                if(fault == NoFault)
72                {
73                  %(code)s;
74                  if(fault == NoFault){
75                    %(op_wb)s;
76                  }
77                }
78                return fault;
79        }
80}};
81
82// Basic decode template.
83def template BasicDecode {{
84        return new %(class_name)s(machInst);
85}};
86
87// Basic decode template, passing mnemonic in as string arg to constructor.
88def template BasicDecodeWithMnemonic {{
89        return new %(class_name)s("%(mnemonic)s", machInst);
90}};
91
92// The most basic instruction format...
93def format BasicOp(code, *flags) {{
94        iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
95        header_output = BasicDeclare.subst(iop)
96        decoder_output = BasicConstructor.subst(iop)
97        decode_block = BasicDecode.subst(iop)
98        exec_output = BasicExecute.subst(iop)
99}};
100