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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [tb/] [arch/] [run] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 sinclairrf
#!/bin/bash
2
 
3
# Test moving data into and out of the data stack and the return stack.
4
function test_nomem() {
5
  for ARCH in arch-nomem-*.9x8; do
6
    TEST="${NAME}/${ARCH}";
7
    cp ${ARCH} arch.9x8
8
    ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
9
    verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
10
    iverilog -o tb tb.v arch.v || exit 1;
11
    if [ -n "`./tb | cmp - tb-nomem.good 2>&1`" ]; then
12
      echo "${TEST} failed" > /dev/stderr;
13
      exit 1;
14
    fi
15
    echo "Tested:  ${TEST}";
16
  done
17
}
18
 
19
# Test the high-order bits of the return stack for several PC widths and
20
# "COMBINE" configuration commands.
21
function test_calls() {
22
  for ARCH in arch-calls-*.9x8; do
23
    SIZE="`echo ${ARCH} | sed -e 's/arch-calls-//' -e 's/[.-].*//'`";
24
    for (( ixcombine=0; ixcombine<4; ++ixcombine )); do
25
      TEST="${NAME}/${ARCH}@${ixcombine}";
26
      case ${ixcombine} in
27
        ( 0 ) sed -e "/@COMBINE@/d" ${ARCH} > arch.9x8;;
28
        ( 1 ) sed -e "s/@COMBINE@/COMBINE INSTRUCTION,DATA_STACK/" ${ARCH} > arch.9x8;;
29
        ( 2 ) sed -e "s/@COMBINE@/COMBINE INSTRUCTION,RETURN_STACK/" ${ARCH} > arch.9x8;;
30
        ( 3 ) sed -e "s/@COMBINE@/COMBINE RETURN_STACK,DATA_STACK/" ${ARCH} > arch.9x8;;
31
        ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
32
              exit 1;;
33
      esac
34
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
35
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
36
      iverilog -o tb tb.v arch.v || exit 1;
37
      if [ -n "`./tb | cmp - "arch-calls-${SIZE}.good" 2>&1`" ]; then
38
        echo "${TEST} failed" > /dev/stderr;
39
        exit 1;
40
      fi
41
      echo "Tested:  ${TEST}";
42
    done
43
  done
44
}
45
 
46
# Test memory writes and reads when there is one memory for several memory sizes
47
# and "COMBINE" configuration commands.
48
function test_1mem() {
49
  ARCH="arch-1mem";
50
  for SIZE in 16 32 64 128 256; do
51
    for (( ixcombine=0; ixcombine<2; ++ixcombine )); do
52
      TEST="${NAME}/${ARCH}@${SIZE}.${ixcombine}";
53
      case ${ixcombine} in
54
        ( 0 ) sed -e "s/@CONFIG@/MEMORY RAM ram_a ${SIZE}/" ${ARCH}.9x8 > arch.9x8;;
55
        ( 1 ) sed -e "s/@CONFIG@/MEMORY RAM ram_a ${SIZE}\nCOMBINE ram_a/" ${ARCH}.9x8 > arch.9x8;;
56
        ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
57
              exit 1;;
58
      esac
59
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
60
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
61
      iverilog -o tb tb.v arch.v || exit 1;
62
      if [ -n "`./tb | cmp - "${ARCH}-${SIZE}.good" 2>&1`" ]; then
63
        echo "${TEST} failed" > /dev/stderr;
64
        exit 1;
65
      fi
66
      echo "Tested:  ${TEST}";
67
    done
68
  done
69
}
70
 
71
# Test memory writes and reads when there are two memories for several memory
72
# sizes and "COMBINE" configuration commands.
73
function test_2mem() {
74
  ARCH="arch-2mem";
75
  for SIZE_A in 32 128 256; do
76
    SED_A="-e 's/@MEM_A@/MEMORY RAM ram_a ${SIZE_A}/'";
77
    for SIZE_B in 16 128 256; do
78
      SED_B="${SED_A} -e 's/@MEM_B@/MEMORY RAM ram_b ${SIZE_B}/'";
79
      for (( ixcombine=0; ixcombine<4; ++ixcombine )); do
80
        TEST="${NAME}/${ARCH}@${SIZE_A}.${SIZE_B}.${ixcombine}";
81
        case ${ixcombine} in
82
          ( 0 ) SED="${SED_B} -e '/@COMBINE@/d'";;
83
          ( 1 ) SED="${SED_B} -e 's/@COMBINE@/COMBINE ram_a/'";;
84
          ( 2 ) SED="${SED_B} -e 's/@COMBINE@/COMBINE ram_b/'";;
85
          ( 3 ) SED="${SED_B} -e 's/@COMBINE@/COMBINE ram_a,ram_b/'";;
86
          ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
87
                exit 1;;
88
        esac
89
        eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
90
        ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
91
        verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
92
        iverilog -o tb tb.v arch.v || exit 1;
93
        if [ -n "`./tb | cmp - "${ARCH}-${SIZE_A}-${SIZE_B}.good" 2>&1`" ]; then
94
          echo "${TEST} failed" > /dev/stderr;
95
          exit 1;
96
        fi
97
        echo "Tested:  ${TEST}";
98
      done
99
    done
100
  done
101
}
102
 
103
# Test memory writes and reads when there are three memories for several memory
104
# sizes and "COMBINE" configuration commands.
105
function test_3mem() {
106
  ARCH="arch-3mem";
107
  for SIZE in " 32  32  32" \
108
              "128 256 256" \
109
              "256 128 256" \
110
              "256 256 128" \
111
              "256 256 256" \
112
  ; do
113
    SIZE=(${SIZE});
114
    SIZE_A=${SIZE[0]};
115
    SIZE_B=${SIZE[1]};
116
    SIZE_C=${SIZE[2]};
117
    for (( ixcombine=0; ixcombine<8; ++ixcombine )); do
118
      TEST="${NAME}/${ARCH}@${SIZE_A}.${SIZE_B}.${SIZE_C}.${ixcombine}";
119
      SED="-e 's/@MEM_A@/MEMORY RAM ram_a ${SIZE_A}/'";
120
      SED+=" -e 's/@MEM_B@/MEMORY RAM ram_b ${SIZE_B}/'";
121
      SED+=" -e 's/@MEM_C@/MEMORY RAM ram_c ${SIZE_C}/'";
122
      case ${ixcombine} in
123
        ( 0 ) SED+=" -e '/@COMBINE@/d'";;
124
        ( 1 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a/'";;
125
        ( 2 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b/'";;
126
        ( 3 ) SED+=" -e 's/@COMBINE@/COMBINE ram_c/'";;
127
        ( 4 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b/'";;
128
        ( 5 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_c/'";;
129
        ( 6 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b,ram_c/'";;
130
        ( 7 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b,ram_c/'";;
131
        ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
132
              exit 1;;
133
      esac
134
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
135
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
136
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
137
      iverilog -o tb tb.v arch.v || exit 1;
138
      if [ -n "`./tb | grep fetch | cmp - "${ARCH}-${SIZE_A}-${SIZE_B}-${SIZE_C}.good" 2>&1`" ]; then
139
        echo "${TEST} failed" > /dev/stderr;
140
        exit 1;
141
      fi
142
      echo "Tested:  ${TEST}";
143
    done
144
  done
145
}
146
 
147
# Test memory writes and reads when there are four memories for several memory
148
# sizes and "COMBINE" configuration commands.
149
function test_4mem() {
150
  ARCH="arch-4mem";
151
  for SIZE in "128 128 128 128" \
152
              "256 256 256 256" \
153
  ; do
154
    SIZE=(${SIZE});
155
    SIZE_A=${SIZE[0]};
156
    SIZE_B=${SIZE[1]};
157
    SIZE_C=${SIZE[2]};
158
    SIZE_D=${SIZE[3]};
159
    for (( ixcombine=0; ixcombine<16; ++ixcombine )); do
160
      TEST="${NAME}/${ARCH}@${SIZE_A}.${SIZE_B}.${SIZE_C}.${SIZE_D}.${ixcombine}";
161
      SED="-e 's/@MEM_A@/MEMORY RAM ram_a ${SIZE_A}/'";
162
      SED+=" -e 's/@MEM_B@/MEMORY RAM ram_b ${SIZE_B}/'";
163
      SED+=" -e 's/@MEM_C@/MEMORY RAM ram_c ${SIZE_C}/'";
164
      SED+=" -e 's/@MEM_D@/MEMORY RAM ram_d ${SIZE_D}/'";
165
      case ${ixcombine} in
166
        (  0 ) SED+=" -e '/@COMBINE@/d'";;
167
        (  1 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a/'";;
168
        (  2 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b/'";;
169
        (  3 ) SED+=" -e 's/@COMBINE@/COMBINE ram_c/'";;
170
        (  4 ) SED+=" -e 's/@COMBINE@/COMBINE ram_d/'";;
171
        (  5 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b/'";;
172
        (  6 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_c/'";;
173
        (  7 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_d/'";;
174
        (  8 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b,ram_c/'";;
175
        (  9 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b,ram_d/'";;
176
        ( 10 ) SED+=" -e 's/@COMBINE@/COMBINE ram_c,ram_d/'";;
177
        ( 11 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b,ram_c/'";;
178
        ( 12 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b,ram_d/'";;
179
        ( 13 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_c,ram_d/'";;
180
        ( 14 ) SED+=" -e 's/@COMBINE@/COMBINE ram_b,ram_c,ram_d/'";;
181
        ( 15 ) SED+=" -e 's/@COMBINE@/COMBINE ram_a,ram_b,ram_c,ram_d/'";;
182
        ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
183
              exit 1;;
184
      esac
185
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
186
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
187
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
188
      iverilog -o tb tb.v arch.v || exit 1;
189
      if [ -n "`./tb | grep fetch | cmp - "${ARCH}-${SIZE_A}-${SIZE_B}-${SIZE_C}-${SIZE_D}.good" 2>&1`" ]; then
190
        echo "${TEST} failed" > /dev/stderr;
191
        exit 1;
192
      fi
193
      echo "Tested:  ${TEST}";
194
    done
195
  done
196
}
197
 
198
# Test memory reads when there is a single ROM for several memory sizes and
199
# "COMBINE" configuration commands.
200
function test_1rom() {
201
  ARCH="arch-1rom";
202
  for SIZE_Z in 16 32 64 128 256; do
203
    for (( ixcombine=0; ixcombine<5; ++ixcombine )); do
204
      TEST="${NAME}/${ARCH}@${SIZE_Z}.${ixcombine}";
205
      SED="-e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
206
      case ${ixcombine} in
207
        ( 0 ) SED+=" -e '/@COMBINE@/d'";;
208
        ( 1 ) SED+=" -e 's/@COMBINE@/COMBINE rom_z/'";;
209
        ( 2 ) SED+=" -e 's/@COMBINE@/COMBINE INSTRUCTION,rom_z/'";;
210
        ( 3 ) SED+=" -e 's/@COMBINE@/COMBINE DATA_STACK,rom_z/'";;
211
        ( 4 ) SED+=" -e 's/@COMBINE@/COMBINE RETURN_STACK,rom_z/'";;
212
        ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
213
              exit 1;;
214
      esac
215
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
216
      gawk --assign SIZE_Z=${SIZE_Z} -f init-1rom.awk > init.s;
217
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
218
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
219
      iverilog -o tb tb.v arch.v || exit 1;
220
      if [ -n "`./tb | gawk -f test-rom3.awk 2>&1`" ]; then
221
        echo "${TEST} failed" > /dev/stderr;
222
        exit 1;
223
      fi
224
      echo "Tested:  ${TEST}";
225
    done
226
  done
227
}
228
 
229
# Test memory reads when there are two ROMs for several memory sizes and
230
# "COMBINE" configuration commands.
231
function test_2rom() {
232
  ARCH="arch-2rom";
233
  for SIZE_Z in 16 128 256; do
234
    for SIZE_Y in 16 128 256; do
235
      for (( ixcombine=0; ixcombine<13; ++ixcombine )); do
236
        TEST="${NAME}/${ARCH}@${SIZE_Z}.${SIZE_Y}.${ixcombine}";
237
        SED="-e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
238
        SED+=" -e 's/@ROM_Y@/MEMORY ROM rom_y ${SIZE_Y}/'";
239
        case ${ixcombine} in
240
          (  0 ) SED+=" -e '/@COMBINE@/d'";;
241
          (  1 ) SED+=" -e 's/@COMBINE@/COMBINE rom_z/'";;
242
          (  2 ) SED+=" -e 's/@COMBINE@/COMBINE rom_y/'";;
243
          (  3 ) SED+=" -e 's/@COMBINE@/COMBINE rom_z,rom_y/'";;
244
          (  4 ) SED+=" -e 's/@COMBINE@/COMBINE INSTRUCTION,rom_z/'";;
245
          (  5 ) SED+=" -e 's/@COMBINE@/COMBINE INSTRUCTION,rom_y/'";;
246
          (  6 ) SED+=" -e 's/@COMBINE@/COMBINE INSTRUCTION,rom_z,rom_y/'";;
247
          (  7 ) SED+=" -e 's/@COMBINE@/COMBINE DATA_STACK,rom_z/'";;
248
          (  8 ) SED+=" -e 's/@COMBINE@/COMBINE DATA_STACK,rom_y/'";;
249
          (  9 ) SED+=" -e 's/@COMBINE@/COMBINE DATA_STACK,rom_z,rom_y/'";;
250
          ( 10 ) SED+=" -e 's/@COMBINE@/COMBINE RETURN_STACK,rom_z/'";;
251
          ( 11 ) SED+=" -e 's/@COMBINE@/COMBINE RETURN_STACK,rom_y/'";;
252
          ( 12 ) SED+=" -e 's/@COMBINE@/COMBINE RETURN_STACK,rom_z,rom_y/'";;
253
          ( * ) echo "Invalid value of ixcombine = ${ixcombine}" > /dev/stderr;
254
                exit 1;;
255
        esac
256
        eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
257
        gawk --assign SIZE_Z=${SIZE_Z} --assign SIZE_Y=${SIZE_Y} -f init-2rom.awk > init.s;
258
        ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
259
        verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
260
        iverilog -o tb tb.v arch.v || exit 1;
261
        if [ -n "`./tb | gawk -f test-rom3.awk -f test-rom2.awk 2>&1`" ]; then
262
          echo "${TEST} failed" > /dev/stderr;
263
          exit 1;
264
        fi
265
        echo "Tested:  ${TEST}";
266
      done
267
    done
268
  done
269
}
270
 
271
# Test memory reads when there are three ROMs for several memory sizes and
272
# "COMBINE" configuration commands.
273
function test_3rom() {
274
  ARCH="arch-3rom";
275
  COMBINES=(
276
    ""
277
    "COMBINE rom_z"
278
    "COMBINE rom_y"
279
    "COMBINE rom_x"
280
    "COMBINE rom_z,rom_y"
281
    "COMBINE rom_z,rom_x"
282
    "COMBINE rom_y,rom_x"
283
    "COMBINE rom_z,rom_y,rom_x"
284
    "COMBINE rom_z,rom_y\nCOMBINE rom_x"
285
    "COMBINE INSTRUCTION,rom_z"
286
    "COMBINE INSTRUCTION,rom_z,rom_y"
287
    "COMBINE INSTRUCTION,rom_z,rom_y,rom_x"
288
    "COMBINE INSTRUCTION,rom_z,rom_y\nCOMBINE rom_x"
289
    "COMBINE DATA_STACK,rom_z"
290
    "COMBINE DATA_STACK,rom_z,rom_y"
291
    "COMBINE DATA_STACK,rom_z,rom_y,rom_x"
292
    "COMBINE DATA_STACK,rom_z,rom_y\nCOMBINE rom_x"
293
    "COMBINE RETURN_STACK,rom_z"
294
    "COMBINE RETURN_STACK,rom_z,rom_y"
295
    "COMBINE RETURN_STACK,rom_z,rom_y,rom_x"
296
    "COMBINE RETURN_STACK,rom_z,rom_y\nCOMBINE rom_x"
297
    "COMBINE INSTRUCTION,rom_z,rom_y\nCOMBINE DATA_STACK,rom_x"
298
    "COMBINE INSTRUCTION,rom_z,rom_y\nCOMBINE RETURN_STACK,rom_x"
299
    "COMBINE INSTRUCTION,rom_z\nCOMBINE DATA_STACK,rom_y\nCOMBINE RETURN_STACK,rom_x"
300
    "COMBINE DATA_STACK,rom_z,rom_y\nCOMBINE RETURN_STACK,rom_x"
301
  );
302
  for SIZE in " 32  32  32" \
303
              "128 256 256" \
304
              "256 128 256" \
305
              "256 256 128" \
306
              "256 256 256" \
307
  ; do
308
    SIZE=(${SIZE});
309
    SIZE_Z=${SIZE[0]};
310
    SIZE_Y=${SIZE[1]};
311
    SIZE_X=${SIZE[2]};
312
    for (( ixcombine=0; ixcombine<${#COMBINES[*]}; ++ixcombine )); do
313
      TEST="${NAME}/${ARCH}@${SIZE_Z}.${SIZE_Y}.${SIZE_X}.${ixcombine}";
314
      SED="-e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
315
      SED+=" -e 's/@ROM_Y@/MEMORY ROM rom_y ${SIZE_Y}/'";
316
      SED+=" -e 's/@ROM_X@/MEMORY ROM rom_x ${SIZE_X}/'";
317
      SED+=" -e 's/@COMBINE@/${COMBINES[$ixcombine]}/'";
318
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
319
      gawk --assign SIZE_Z=${SIZE_Z} --assign SIZE_Y=${SIZE_Y} --assign SIZE_X=${SIZE_X} -f init-3rom.awk > init.s;
320
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
321
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
322
      iverilog -o tb tb.v arch.v || exit 1;
323
      if [ -n "`./tb | gawk -f test-rom3.awk -f test-rom2.awk -f test-rom1.awk 2>&1`" ]; then
324
        echo "${TEST} failed" > /dev/stderr;
325
        exit 1;
326
      fi
327
      echo "Tested:  ${TEST}";
328
    done
329
  done
330
}
331
 
332
# Test memory reads when there are four ROMs for several memory sizes and
333
# "COMBINE" configuration commands.
334
function test_4rom() {
335
  ARCH="arch-4rom";
336
  COMBINES=(
337
    ""
338
    "COMBINE rom_z"
339
    "COMBINE rom_y"
340
    "COMBINE rom_x"
341
    "COMBINE rom_w"
342
    "COMBINE rom_z,rom_y"
343
    "COMBINE rom_z,rom_x"
344
    "COMBINE rom_z,rom_w"
345
    "COMBINE rom_y,rom_x"
346
    "COMBINE rom_y,rom_w"
347
    "COMBINE rom_x,rom_w"
348
    "COMBINE rom_z,rom_y,rom_x"
349
    "COMBINE rom_z,rom_y,rom_w"
350
    "COMBINE rom_z,rom_x,rom_w"
351
    "COMBINE rom_y,rom_x,rom_w"
352
    "COMBINE rom_z,rom_y,rom_x,rom_w"
353
    "COMBINE rom_z,rom_y\nCOMBINE rom_x"
354
    "COMBINE rom_z,rom_y\nCOMBINE rom_w"
355
    "COMBINE rom_z,rom_y\nCOMBINE rom_x,rom_w"
356
    "COMBINE rom_z,rom_y\nCOMBINE rom_x\nCOMBINE rom_w"
357
    "COMBINE rom_z\nCOMBINE rom_y\nCOMBINE rom_x\nCOMBINE rom_w"
358
  );
359
  for X in INSTRUCTION DATA_STACK RETURN_STACK; do
360
    COMBINES+=(
361
      "COMBINE ${X},rom_z"
362
      "COMBINE ${X},rom_z,rom_y"
363
      "COMBINE ${X},rom_z,rom_y,rom_x"
364
      "COMBINE ${X},rom_z,rom_y,rom_x,rom_w"
365
      "COMBINE ${X},rom_z,rom_y\nCOMBINE rom_x"
366
      "COMBINE ${X},rom_z,rom_y\nCOMBINE rom_w"
367
      "COMBINE ${X},rom_z,rom_y\nCOMBINE rom_x\nCOMBINE rom_w"
368
    );
369
  done
370
  for X in "INSTRUCTION DATA_STACK" "INSTRUCTION RETURN_STACK" "DATA_STACK RETURN_STACK"; do
371
    XX=(${X});
372
    COMBINES+=(
373
      "COMBINE ${XX[0]},rom_z,rom_y\nCOMBINE ${XX[1]},rom_x"
374
      "COMBINE ${XX[0]},rom_z,rom_y\nCOMBINE ${XX[1]},rom_x,rom_w"
375
      "COMBINE ${XX[0]},rom_z,rom_y,rom_x\nCOMBINE ${XX[1]},rom_w"
376
      "COMBINE ${XX[0]},rom_z,rom_y\nCOMBINE ${XX[1]},rom_x\nCOMBINE rom_w"
377
    );
378
  done
379
  COMBINES+=(
380
    "COMBINE INSTRUCTION,rom_z,rom_y\nCOMBINE DATA_STACK,rom_x\nCOMBINE RETURN_STACK,rom_w"
381
  );
382
  for SIZE in " 32  32  32  32" \
383
              "128 256 256 256" \
384
              "256 128 256 256" \
385
              "256 256 128 256" \
386
              "256 256 256 128" \
387
              "256 256 256 256" \
388
  ; do
389
    SIZE=(${SIZE});
390
    SIZE_Z=${SIZE[0]};
391
    SIZE_Y=${SIZE[1]};
392
    SIZE_X=${SIZE[2]};
393
    SIZE_W=${SIZE[3]};
394
    for (( ixcombine=0; ixcombine<${#COMBINES[*]}; ++ixcombine )); do
395
      TEST="${NAME}/${ARCH}@${SIZE_Z}.${SIZE_Y}.${SIZE_X}.${SIZE_W}.${ixcombine}";
396
      SED="-e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
397
      SED+=" -e 's/@ROM_Y@/MEMORY ROM rom_y ${SIZE_Y}/'";
398
      SED+=" -e 's/@ROM_X@/MEMORY ROM rom_x ${SIZE_X}/'";
399
      SED+=" -e 's/@ROM_W@/MEMORY ROM rom_w ${SIZE_W}/'";
400
      SED+=" -e 's/@COMBINE@/${COMBINES[$ixcombine]}/'";
401
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
402
      gawk --assign SIZE_Z=${SIZE_Z} --assign SIZE_Y=${SIZE_Y} --assign SIZE_X=${SIZE_X} --assign SIZE_W=${SIZE_W} -f init-4rom.awk > init.s;
403
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
404
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
405
      iverilog -o tb tb.v arch.v || exit 1;
406
      if [ -n "`./tb | gawk -f test-rom3.awk -f test-rom2.awk -f test-rom1.awk -f test-rom0.awk 2>&1`" ]; then
407
        echo "${TEST} failed" > /dev/stderr;
408
        exit 1;
409
      fi
410
      echo "Tested:  ${TEST}";
411
    done
412
  done
413
}
414
 
415
# Test memory reads when there is a single ROM and two RAMs for several memory
416
# sizes and "COMBINE" configuration commands.
417
function test_1r2m() {
418
  ARCH="arch-1r2m";
419
  COMBINES=(
420
    ""
421
    "COMBINE ram_a"
422
    "COMBINE ram_b"
423
    "COMBINE rom_z"
424
    "COMBINE ram_a,ram_b"
425
    "COMBINE ram_a,rom_z"
426
    "COMBINE ram_b,rom_z"
427
    "COMBINE ram_a,ram_b,rom_z"
428
    "COMBINE ram_a,ram_b\nCOMBINE rom_z"
429
    "COMBINE ram_a\nCOMBINE ram_b,rom_z"
430
    "COMBINE ram_b\nCOMBINE ram_a,rom_z"
431
  );
432
  for X in INSTRUCTION DATA_STACK RETURN_STACK; do
433
    COMBINES+=(
434
      "COMBINE ${X},rom_z"
435
      "COMBINE ${X},rom_z\nCOMBINE ram_a,ram_b"
436
    );
437
  done
438
  for SIZE in " 32  32  32" \
439
              "128 256 256" \
440
              "256 128 256" \
441
              "256 256 128" \
442
              "256 256 256" \
443
  ; do
444
    SIZE=(${SIZE});
445
    SIZE_A=${SIZE[0]};
446
    SIZE_B=${SIZE[1]};
447
    SIZE_Z=${SIZE[2]};
448
    for (( ixcombine=0; ixcombine<${#COMBINES[*]}; ++ixcombine )); do
449
      TEST="${NAME}/${ARCH}@${SIZE_A}.${SIZE_B}.${SIZE_Z}.${ixcombine}";
450
      SED="-e 's/@RAM_A@/MEMORY RAM ram_a ${SIZE_A}/'";
451
      SED+=" -e 's/@RAM_B@/MEMORY RAM ram_b ${SIZE_B}/'";
452
      SED+=" -e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
453
      SED+=" -e 's/@COMBINE@/${COMBINES[$ixcombine]}/'";
454
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
455
      gawk --assign SIZE_Z=${SIZE_Z} -f init-1rom.awk > init.s;
456
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
457
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
458
      iverilog -o tb tb.v arch.v || exit 1;
459
      if [ -n "`./tb | gawk -f test-rom3.awk -f test-ram1.awk -f test-ram0.awk 2>&1`" ]; then
460
        echo "${TEST} failed" > /dev/stderr;
461
        exit 1;
462
      fi
463
      echo "Tested:  ${TEST}";
464
    done
465
  done
466
}
467
 
468
# Test memory reads when there are two ROMs and two RAMs for several memory
469
# sizes and "COMBINE" configuration commands.
470
function test_2r2m() {
471
  ARCH="arch-2r2m";
472
  COMBINES=(
473
    ""
474
    "COMBINE ram_a"
475
    "COMBINE ram_b"
476
    "COMBINE rom_y"
477
    "COMBINE rom_z"
478
    "COMBINE ram_a,ram_b"
479
    "COMBINE ram_a,rom_z"
480
    "COMBINE ram_a,rom_y"
481
    "COMBINE ram_b,rom_z"
482
    "COMBINE ram_b,rom_y"
483
    "COMBINE rom_y,rom_z"
484
    "COMBINE ram_a,ram_b,rom_z"
485
    "COMBINE ram_a,ram_b,rom_y,rom_z"
486
    "COMBINE ram_a,rom_y,ram_b,rom_z"
487
    "COMBINE ram_a,ram_b\nCOMBINE rom_z,rom_y"
488
    "COMBINE ram_a\nCOMBINE ram_b,rom_z"
489
    "COMBINE ram_b\nCOMBINE ram_a,rom_z"
490
  );
491
  for X in INSTRUCTION DATA_STACK RETURN_STACK; do
492
    COMBINES+=(
493
      "COMBINE ${X},rom_z"
494
      "COMBINE ${X},rom_z,rom_y"
495
      "COMBINE ${X},rom_z\nCOMBINE ram_a,ram_b"
496
      "COMBINE ${X},rom_z,rom_y\nCOMBINE ram_a,ram_b"
497
    );
498
  done
499
  for SIZE in " 32  32  32  32" \
500
              "128 256 256 256" \
501
              "256 128 256 256" \
502
              "256 256 128 256" \
503
              "256 256 256 128" \
504
              "256 256 256 256" \
505
  ; do
506
    SIZE=(${SIZE});
507
    SIZE_A=${SIZE[0]};
508
    SIZE_B=${SIZE[1]};
509
    SIZE_Z=${SIZE[2]};
510
    SIZE_Y=${SIZE[3]};
511
    for (( ixcombine=0; ixcombine<${#COMBINES[*]}; ++ixcombine )); do
512
      TEST="${NAME}/${ARCH}@${SIZE_A}.${SIZE_B}.${SIZE_Z}.${SIZE_Y}.${ixcombine}";
513
      SED="-e 's/@RAM_A@/MEMORY RAM ram_a ${SIZE_A}/'";
514
      SED+=" -e 's/@RAM_B@/MEMORY RAM ram_b ${SIZE_B}/'";
515
      SED+=" -e 's/@ROM_Z@/MEMORY ROM rom_z ${SIZE_Z}/'";
516
      SED+=" -e 's/@ROM_Y@/MEMORY ROM rom_y ${SIZE_Y}/'";
517
      SED+=" -e 's/@COMBINE@/${COMBINES[$ixcombine]}/'";
518
      eval sed ${SED} ${ARCH}.9x8 > arch.9x8;
519
      gawk --assign SIZE_Z=${SIZE_Z} --assign SIZE_Y=${SIZE_Y} -f init-2rom.awk > init.s;
520
      ./ssbcc -q arch.9x8 || { echo "ssbcc failed on ${TEST}"; exit 1; }
521
      verilator --lint-only arch.v || { echo "lint failed on ${TEST}"; exit 1;}
522
      iverilog -o tb tb.v arch.v || exit 1;
523
      if [ -n "`./tb | gawk -f test-rom3.awk -f test-rom2.awk -f test-ram1.awk -f test-ram0.awk 2>&1`" ]; then
524
        echo "${TEST} failed" > /dev/stderr;
525
        exit 1;
526
      fi
527
      echo "Tested:  ${TEST}";
528
    done
529
  done
530
}
531
 
532
################################################################################
533
#
534
# Either run the specified test(s) or run all of the tests.
535
#
536
################################################################################
537
 
538
NAME="arch";
539
 
540
rm -f ssbcc;
541
ln -s ../../../../ssbcc;
542
 
543
if [ $# -eq 0 ]; then
544
  TESTS="nomem calls 1mem 2mem 3mem 4mem 1rom 2rom 3rom 4rom 1r2m 2r2m";
545
else
546
  TESTS="$*";
547
fi
548
 
549
for CURTEST in ${TESTS}; do
550
  case ${CURTEST} in
551
    ( nomem ) test_nomem;;
552
    ( calls ) test_calls;;
553
    ( 1mem  ) test_1mem;;
554
    ( 2mem  ) test_2mem;;
555
    ( 3mem  ) test_3mem;;
556
    ( 4mem  ) test_4mem;;
557
    ( 1rom  ) test_1rom;;
558
    ( 2rom  ) test_2rom;;
559
    ( 3rom  ) test_3rom;;
560
    ( 4rom  ) test_4rom;;
561
    ( 1r2m  ) test_1r2m;;
562
    ( 2r2m  ) test_2r2m;;
563
    ( *     ) echo "Unrecognized test:  ${TEST}" > /dev/stderr; exit 1;;
564
  esac
565
done
566
 
567
# Remove the temporary output files.
568
rm -f arch.9x8 arch.9x8-meta arch.mem arch.v init.s ssbcc tb;
569
 
570
# Print success message and return success indication.
571
echo "Passed:  ${NAME}";
572
exit 0;

powered by: WebSVN 2.1.0

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