1 /* CPU family header for sh4a / sh4a.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright (C) 2000-2010 Red Hat, Inc.
7 This file is part of the Red Hat simulators.
16 #include "cgen-types.h"
18 // forward declaration
29 static const int max_delay = 1;
30 static const int pipe_sz = 2; // max_delay + 1
32 template <typename ELT>
37 ELT buf[WRITE_BUF_SZ];
39 write_stack () : t(-1), sz(WRITE_BUF_SZ) {}
40 inline bool empty () { return (t == -1); }
41 inline void clear () { t = -1; }
42 inline void pop () { if (t > -1) t--;}
43 inline void push (const ELT &e) { if (t+1 < sz) buf [++t] = e;}
44 inline ELT &top () { return buf [t>0 ? ( t<sz ? t : sz-1) : 0];}
47 // look ahead for latest write with index = idx, where time of write is
48 // <= dist steps from base (present) in write_stack array st.
49 // returning def if no scheduled write is found.
51 template <typename STKS, typename VAL>
52 inline VAL lookahead (int dist, int base, STKS &st, VAL def, int idx=0)
54 for (; dist > 0; --dist)
56 write_stack <VAL> &v = st [(base + dist) % pipe_sz];
57 for (int i = v.t; i > 0; --i)
58 if (v.buf [i].idx0 == idx) return v.buf [i];
65 template <typename MODE>
71 write (PCADDR _pc, MODE _val, USI _idx0=0) : pc(_pc), val(_val), idx0(_idx0) {}
76 // write stacks used in parallel execution
82 write_stack< write<UDI> > h_pc_writes [pipe_sz];
83 write_stack< write<SI> > h_pr_writes [pipe_sz];
86 // unified writeback function (defined in sh4a-write.cc)
87 void writeback (int tick, sh4a::sh4a_cpu* current_cpu);
88 // unified write-stack clearing function (defined in sh4a-write.cc)
91 }; // end struct sh4a::write_stacks
93 } // end sh4a namespace
95 #endif /* DEFS_SH4A_H */