OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [sim/] [w65/] [interp.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#define fetch8(x) fetch8func((cycles++,(x)))
2
#define NFAKES 16
3
typedef struct
4
  {
5
    unsigned  a;
6
    unsigned  x;
7
    unsigned  y;
8
    unsigned  pc;               /* Keep pbr in there too */
9
    unsigned  dbr;
10
    unsigned  d;
11
    unsigned  s;
12
    unsigned  p;
13
    unsigned  e;
14
    unsigned  char *memory;
15
    unsigned  int exception;
16
    unsigned  int ticks;
17
    unsigned  int cycles;
18
    unsigned  int insts;
19
    unsigned  int r[NFAKES];
20
  }
21
saved_state_type;
22
 
23
 
24
 
25
#define GET_P      \
26
  ((GET_NBIT << 7) \
27
 | (GET_VBIT << 6) \
28
 | (GET_MBIT << 5) \
29
 | (GET_XBIT << 4) \
30
 | (GET_DBIT << 3) \
31
 | (GET_IBIT << 2) \
32
 | (GET_ZBIT << 1) \
33
 | (GET_CBIT << 0))
34
 
35
#define SET_P(_bits)   \
36
{ int bits = _bits;    \
37
SET_NBIT((bits>>7)&1); \
38
SET_VBIT((bits>>6)&1); \
39
SET_MBIT((bits>>5)&1); \
40
SET_XBIT((bits>>4)&1); \
41
SET_DBIT((bits>>3)&1); \
42
SET_IBIT((bits>>2)&1); \
43
SET_ZBIT((bits>>1)&1); \
44
SET_CBIT((bits>>0)&1);  }
45
 
46
#define BFLAG           (1<<4)
47
#define DFLAG           (1<<3)
48
 
49
#define GET_A           (the_a)
50
#define GET_E           (the_e)
51
#define GET_B           (the_b)
52
#define GET_CBIT        (the_cbit)
53
#define GET_D           (the_d)
54
#define GET_DBIT        (the_dbit)
55
#define GET_DBR_HIGH    (the_dbr)
56
#define GET_DBR_LOW     (the_dbr >> 16)
57
#define GET_DPR         (the_dpr)
58
#define GET_IBIT        (the_ibit)
59
#define GET_MBIT        (the_mbit)
60
#define SET_XBIT(x)     { the_xbit = x; }       
61
#define GET_NBIT        (the_nbit)
62
#define GET_PBRPC       (the_pc)
63
#define GET_PBR_HIGH    (the_pc & 0xff0000)
64
#define GET_PBR_LOW     (the_pc >> 16)
65
#define GET_PC          (the_pc & 0xffff)
66
#define GET_S           (the_s)
67
#define GET_VBIT        (the_vbit)
68
#define GET_X           (the_x)
69
#define GET_XBIT        (the_xbit)
70
#define GET_Y           (the_y)
71
#define GET_ZBIT        (the_zbit)
72
#define IFLAG           (1<<2)
73
#define INC_PC(x)       {the_pc += x;}
74
#define POP16(x)        { int _xx; POP8(x); POP8(_xx); x+= _xx<<8;}
75
#define POP24(x)        { int _xx; POP8(x); POP8(_xx); x += _xx << 8; POP8(_xx); x += _xx << 16; }
76
#define POP8(x)         { SET_S(GET_S +1); x =  fetch8(GET_S);}
77
#define PUSH16(x)       { int _xx = x;PUSH8(_xx >> 8); PUSH8(_xx);}
78
#define PUSH8(x)        { store8(GET_S, x); SET_S(GET_S-1);}
79
#define SET_A(x)        { the_a = x & AMASK; }
80
#define SET_B(x)        { the_b = x;}
81
#define SET_CBIT(x)     { the_cbit = x;}
82
#define SET_CBIT_M(x)   { the_cbit = (x & (GET_MBIT ? 0x100: 0x10000)) != 0;}
83
#define SET_CBIT_X(x)   { the_cbit = (x & (GET_XBIT ? 0x100: 0x10000)) != 0;}
84
#define SET_D(x)        {the_d = x;}
85
#define SET_DBIT(x)     { the_dbit= x;}
86
#define SET_DBR_LOW(x)  {the_dbr = (x<<16);}
87
#define SET_DPR(x)      { the_dpr = x;}
88
#define SET_E(x)        { the_e = x;}
89
#define SET_IBIT(x)     { the_ibit = x;}
90
#define SET_MBIT(x)     { the_mbit = x; }
91
#define SET_NBIT(x)     { the_nbit = x;}
92
#define SET_NBIT_16(x)  { the_nbit= ( ((x) & (0x8000)) != 0);}
93
#define SET_NBIT_8(x)  { the_nbit= ( ((x) & (0x80)) != 0);}
94
#define SET_NBIT_M(x)   { if (GET_MBIT) { SET_NBIT_8(x); } else { SET_NBIT_16(x);}}
95
#define SET_NBIT_X(x)   { if (GET_XBIT) { SET_NBIT_8(x); } else { SET_NBIT_16(x);}}
96
#define SET_PBR(x)      { the_pc = (the_pc & 0xffff) + ((x)<<16);}
97
#define SET_PBRPC(x)    { the_pc = x;}
98
#define SET_ONLY_PC(x)  { the_pc = (the_pc & 0xff0000) + ((x ) & 0xffff);}
99
#define SET_S(x)        {the_s = x; }
100
#define SET_VBIT_16(x)  {the_vbit = ((((int)x) < -0x8000) || (((int)x) > 0x7fff));}
101
#define SET_VBIT_8(x)   {the_vbit = ((((int)x) < -0x80) || (((int)x) > 0x7f));}
102
/*#define SET_VBIT_M(x)   { if(GET_MBIT) {SET_VBIT_8(x);}else {SET_VBIT_16(x);}}*/
103
#define SET_ZBIT_16(x)  { the_zbit = ((x & 0xffff) == 0);}
104
#define SET_ZBIT_8(x)   { the_zbit = ((x & 0xff) == 0);}
105
#define SET_ZBIT_M(x)   { if(GET_MBIT) {SET_ZBIT_8(x);}else {SET_ZBIT_16(x);}}
106
#define SET_ZBIT_X(x)   { if(GET_XBIT) {SET_ZBIT_8(x);}else {SET_ZBIT_16(x);}}
107
#define SET_VBIT(x)     { the_vbit = x; }
108
#define SET_ZBIT(x)     { the_zbit = x; }
109
#define SET_X(x)        { the_x = (x) & (GET_XBIT ? 0xff : 0xffff);}
110
#define SET_Y(x)        { the_y = (x) & (GET_XBIT ? 0xff : 0xffff);}
111
 
112
#define AMASK            ( GET_MBIT ? 0xff : 0xffff)
113
#define SMASK             ( GET_MBIT ? 0x80 : 0x8000)
114
#define SET_VBIT_M(s1,acc,d) ( the_vbit = ((s1 ^ acc) & (acc ^ d) & SMASK )!=0)
115
 
116
/*#define fetch8(x) (memory[x&MMASK])*/
117
#define fetch16(x) (fetch8(x) + (fetch8((x)+1)<<8))
118
#define fetch24(x) (fetch8(x) + (fetch8((x)+1)<<8) + (fetch8((x)+2)<<16))
119
#define fetch8sext(x) ((char)fetch8(x))
120
#define fetch16sext(x) ((short)fetch16(x))
121
#define store8(x,y) {memory[x&MMASK]=y;}
122
#define store16(x,y) { store8(x,y); store8(x+1,y>>8);}
123
#define SEXTM(x)  (GET_MBIT ? ((char)x): ((short)x))
124
 
125
 
126
#define STARTFUNC()     \
127
  register unsigned char *memory;\
128
  int the_s;            \
129
  int the_b;            \
130
  int the_x;            \
131
  int the_d;            \
132
  int the_y;            \
133
  int the_dbr;          \
134
  int the_pc;           \
135
  int the_nbit;         \
136
  int the_vbit;         \
137
  int the_z;            \
138
  int the_mbit;         \
139
  int the_ibit;         \
140
  int the_xbit;         \
141
  int the_zbit;         \
142
  int the_cbit;         \
143
  int the_dbit;         \
144
  int the_dpr;          \
145
  int the_e;            \
146
  int the_a;            \
147
  int tick_start = get_now ();\
148
  int cycles = 0;              \
149
  int insts = 0;       \
150
                                    \
151
  SET_E (saved_state.e);            \
152
  SET_P (saved_state.p);            \
153
  SET_A (saved_state.a);            \
154
  SET_X (saved_state.x);            \
155
  SET_Y (saved_state.y);            \
156
  SET_ONLY_PC (saved_state.pc);     \
157
  SET_PBR (saved_state.pc >> 16);   \
158
  SET_DBR_LOW (saved_state.dbr);    \
159
  SET_D (saved_state.d);            \
160
  SET_S (saved_state.s);            \
161
  memory = saved_state.memory ;     \
162
{ int k; for (k = 0; k < NFAKES; k++)       \
163
 store16(0x10 + k * 2, saved_state.r[k]); }\
164
                                    \
165
    top:                              \
166
 
167
 
168
 
169
#define ENDFUNC() \
170
 rethink:          \
171
  saved_state.ticks += get_now () - tick_start;\
172
  saved_state.cycles += cycles;   \
173
  saved_state.insts += insts;     \
174
{ int k; for (k = 0; k < NFAKES; k++)       \
175
saved_state.r[k] = fetch16(0x10 + k * 2); }\
176
                                  \
177
  saved_state.e = GET_E;          \
178
  saved_state.p = GET_P;          \
179
  saved_state.a = GET_A;          \
180
  saved_state.x = GET_X;          \
181
  saved_state.y = GET_Y;          \
182
  saved_state.pc = GET_PBRPC;     \
183
  saved_state.dbr = GET_DBR_LOW;  \
184
  saved_state.d = GET_D;          \
185
  saved_state.s = GET_S;          \
186
                                  \
187
  return 0;                        \
188
 
189
 
190
extern saved_state_type saved_state;
191
 
192
#define MMASK 0xfffff
193
#define NUMSEGS 16
194
#define RETHINK goto rethink;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.