1 /* CPU family header for sh5 / sh5_media.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright (C) 2000-2009 Red Hat, Inc.
7 This file is part of the Red Hat simulators.
12 #ifndef DEFS_SH5_MEDIA_H
13 #define DEFS_SH5_MEDIA_H
16 #include "cgen-types.h"
18 // forward declaration
29 static const int max_delay = 0;
30 static const int pipe_sz = 1; // 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
84 // unified writeback function (defined in sh5_media-write.cc)
85 void writeback (int tick, sh5::sh5_cpu* current_cpu);
86 // unified write-stack clearing function (defined in sh5_media-write.cc)
89 }; // end struct sh5_media::write_stacks
91 } // end sh5_media namespace
93 #endif /* DEFS_SH5_MEDIA_H */