src_dmem.h
6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* src_dmem.h
*
* This file lays out the DMEM usage for the RSP resampling task.
*
*/
#ifndef _src_dmem_h_
#define _src_dmem_h_ 1
/*
* usage of the 'eval' macro below implies that this code must pass
* throught the 'm4' macro processor. The RSP assembler does this,
* by default, but any C program including this might have trouble with this.
* Protect them by defining the eval() macro...
*/
#ifdef _LANGUAGE_C
# ifndef eval
# define eval(s) (s)
# endif /* eval */
#endif /* _LANGUAGE_C */
/*
* IMPORTANT NOTE:
*
* Many of the following fields require some alignment, for the ld/st to
* work as efficiently as possible... Add this someday...
*
*/
/*
* Memory layout of DMEM:
*
* The strategy is to divide up DMEM into a bunch of known regions
* that we can get to quickly to store/retrieve stuff.
*
* -------------------------------------------------
* | useful constants: |
* | |
* | |
* | |
* | |
* | |
* |-----------------------------------------------|
* | sinc table 1024 bytes |
* | |
* |-----------------------------------------------|
* | current buffer of input sound data |
* | 1024 bytes |
* | |
* |-----------------------------------------------|
* | current buffer of output sound data |
* | 1024 bytes |
* | |
* |-----------------------------------------------|
*
*/
/*
* Memory addressing Strategy:
*
* We'll probably always keep the base address of DMEM around in
* a register. We'll define all the fixed areas as offsets from
* there. We'll also try to keep things clean and flexible as they
* _will_ change during development.
*
*/
#ifndef DCACHEBASE
# define DCACHEBASE 0x00000000
#endif
#ifndef DCACHEBASEHI
# define DCACHEBASEHI 0x0000
#endif
#ifndef DCACHEBASELO
# define DCACHEBASELO 0x0000
#endif
/* these relate to the illustration above... */
#define BYTES_PER_SHORT 2
#define BYTES_PER_VECTOR 16
#define COEF_TAB_SIZE 256
#define SND_BUFF_SIZE 512
#define COEF_TAB_SIZEB eval(COEF_TAB_SIZE * BYTES_PER_SHORT)
#define SND_BUFF_SIZEB eval(SND_BUFF_SIZE * BYTES_PER_SHORT)
/* these relate to the illustration above... */
#define RSP_DATA_OFFSET eval(0)
#define C_MULINC eval(RSP_DATA_OFFSET)
#define C_ONE eval(C_MULINC + BYTES_PER_VECTOR)
#define C_SHIFT eval(C_ONE + BYTES_PER_VECTOR)
#define C_ZEROFOUR eval(C_SHIFT + BYTES_PER_VECTOR)
#define C_ONEFIVE eval(C_ZEROFOUR + BYTES_PER_VECTOR)
#define C_TWOSIX eval(C_ONEFIVE + BYTES_PER_VECTOR)
#define C_THREESEVEN eval(C_TWOSIX + BYTES_PER_VECTOR)
#define C_RAMP eval(C_THREESEVEN + BYTES_PER_VECTOR)
#define NUM_OF_CONSTS eval(RSP_DATA_OFFSET + C_RAMP + BYTES_PER_VECTOR)
/* FIXME: some state, which should go away eventually... */
#define ICA eval(C_RAMP + BYTES_PER_VECTOR)
#define CPH eval(ICA + BYTES_PER_VECTOR)
#define FCVOL eval(CPH + BYTES_PER_VECTOR)
#define ICVOL eval(FCVOL + BYTES_PER_VECTOR)
#define VT eval(ICVOL + BYTES_PER_VECTOR)
#define VR eval(VT + BYTES_PER_SHORT)
#define SND_PTR eval(VR + BYTES_PER_SHORT)
#define COEF_PTR eval(SND_PTR + BYTES_PER_SHORT)
#define PITCH eval(COEF_PTR + BYTES_PER_SHORT)
#define PHCOUNT eval(PITCH + BYTES_PER_SHORT)
#define OUTPUT_COUNT eval(PHCOUNT + BYTES_PER_SHORT)
#define NUM_OF_CH_PARMS eval(OUTPUT_COUNT - NUM_OF_CONSTS)
#define COEF_TAB eval(PHCOUNT + BYTES_PER_SHORT + 4) /* needs alignment */
#define INPUT_SND_DATA eval(COEF_TAB + (COEF_TAB_SIZE * BYTES_PER_SHORT))
#define OUTPUT_SND_DATA eval(INPUT_SND_DATA + (SND_BUFF_SIZE * BYTES_PER_SHORT))
#define TOP_OF_DMEM eval(OUTPUT_SND_DATA + (SND_BUFF_SIZE * BYTES_PER_SHORT))
/* During compilation, report an informative message about DMEM allocation: */
#ifdef _LANGUAGE_ASSEMBLY
# define _DumpDMEMOffset(o,s) errprint(#o : eval(DCACHEBASE + (o), 16) eval(s) )
errprint(--------------------------------------------------------------------
)
errprint( substr(__FILE__, 3, eval(len(__FILE__)-4)) : Total DMEM Size Allocated is eval(TOP_OF_DMEM) bytes.
)
errprint( substr(__FILE__, 3, eval(len(__FILE__)-4)) : DMEM Map:
)
_DumpDMEMOffset(C_MULINC, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_ONE, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_SHIFT, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_ZEROFOUR, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_ONEFIVE, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_TWOSIX, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_THREESEVEN, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(C_RAMP, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(ICA, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(CPH, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(FCVOL, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(ICVOL, BYTES_PER_VECTOR)
errprint( bytes.
)
_DumpDMEMOffset(VT, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(VR, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(SND_PTR, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(COEF_PTR, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(PITCH, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(PHCOUNT, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(OUTPUT_COUNT, BYTES_PER_SHORT)
errprint( bytes.
)
_DumpDMEMOffset(COEF_TAB, (COEF_TAB_SIZE * BYTES_PER_SHORT))
errprint(bytes.
)
_DumpDMEMOffset(INPUT_SND_DATA, (SND_BUFF_SIZE * BYTES_PER_SHORT))
errprint(bytes.
)
_DumpDMEMOffset(OUTPUT_SND_DATA, (SND_BUFF_SIZE * BYTES_PER_SHORT))
errprint(bytes.
)
errprint(--------------------------------------------------------------------
)
# undef _DumpDMEMOffset
#endif
#endif /* _src_dmem_h_ */