Skip to content

Commit 4878840

Browse files
committed
v.0.8.5 Completed tests for decoder byte pipeline.
1 parent 1b9d3ff commit 4878840

File tree

2 files changed

+153
-7
lines changed

2 files changed

+153
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
# Unreleased
44

5+
- nothing to log
6+
7+
# v.0.8.5 - 2021-03-27
8+
9+
- Completed decoder (byte pipeline) testing.
10+
- Each instruction was tested by decoding two single opcodes
11+
- one opcode with no variable bits set
12+
- one opcode with random bits set
13+
514
- Added: decoder tests for st_z and sts_32
615

716
# v.0.8.4 - 2021-03-18

test/integration/decoder/decoder_test.c

Lines changed: 144 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@
2424
* cl<x> shadows bclr.
2525
* se<x> shadows bset.
2626
*
27+
* ldd shadows lds (16-bit)
28+
* std shadows sts (16-bit)
29+
*
2730
* todo: remove brcs, bclr, bset
31+
*
32+
* todo: swap ld_zq in opcode table
33+
* currently ld_zq is preferred
34+
* over ld_z. But for the sake of
35+
* simplicity, the decoder should
36+
* choose ld_z over ld_zq if q = 0.
37+
*
2838
* note: spm and spm #2
39+
*
2940
* */
3041

3142
/* Forward Declaration of static Functions */
@@ -134,6 +145,12 @@ static void test_decode_bytes_stx(vmcu_model_t *mcu);
134145
static void test_decode_bytes_sty(vmcu_model_t *mcu);
135146
static void test_decode_bytes_stz(vmcu_model_t *mcu);
136147
static void test_decode_bytes_sts_32(vmcu_model_t *mcu);
148+
static void test_decode_bytes_sts(vmcu_model_t *mcu);
149+
static void test_decode_bytes_sub(vmcu_model_t *mcu);
150+
static void test_decode_bytes_subi(vmcu_model_t *mcu);
151+
static void test_decode_bytes_swap(vmcu_model_t *mcu);
152+
static void test_decode_bytes_wdr(vmcu_model_t *mcu);
153+
static void test_decode_bytes_xch(vmcu_model_t *mcu);
137154

138155
/* --- Extern --- */
139156

@@ -251,6 +268,12 @@ void test_decoder(void) {
251268
start(test_decode_bytes_sty, m328p);
252269
start(test_decode_bytes_stz, m328p);
253270
start(test_decode_bytes_sts_32, m328p);
271+
start(test_decode_bytes_sts, m328p);
272+
start(test_decode_bytes_sub, m328p);
273+
start(test_decode_bytes_subi, m328p);
274+
start(test_decode_bytes_swap, m328p);
275+
start(test_decode_bytes_wdr, m328p);
276+
start(test_decode_bytes_xch, m328p);
254277

255278
/* destroy device model */
256279

@@ -1691,12 +1714,6 @@ static void test_decode_bytes_ldy(vmcu_model_t *mcu) {
16911714

16921715
static void test_decode_bytes_ldz(vmcu_model_t *mcu) {
16931716

1694-
// todo: swap ld_zq in opcode table
1695-
// currently ld_zq is preferred
1696-
// over ld_z. But for the sake of
1697-
// simplicity, the decoder should
1698-
// choose ld_z over ld_zq if q = 0.
1699-
17001717
printf("vmcu_decode_bytes() - LD_Z");
17011718

17021719
vmcu_instr_t instr;
@@ -1818,7 +1835,7 @@ static void test_decode_bytes_lds(vmcu_model_t *mcu) {
18181835

18191836
printf("vmcu_decode_bytes() - LDS");
18201837

1821-
/* opcode collision with LDD, STD */
1838+
/* opcode collision with LDD */
18221839

18231840
PASSED;
18241841
}
@@ -2875,3 +2892,123 @@ static void test_decode_bytes_sts_32(vmcu_model_t *mcu) {
28752892
PASSED;
28762893
}
28772894

2895+
static void test_decode_bytes_sts(vmcu_model_t *mcu) {
2896+
2897+
printf("vmcu_decode_bytes() - STS");
2898+
2899+
/* opcode collision with std */
2900+
2901+
PASSED;
2902+
}
2903+
2904+
static void test_decode_bytes_sub(vmcu_model_t *mcu) {
2905+
2906+
printf("vmcu_decode_bytes() - SUB");
2907+
2908+
vmcu_instr_t instr;
2909+
vmcu_decode_bytes(0x0018, &instr, mcu);
2910+
2911+
assert(instr.key == VMCU_IKEY_SUB);
2912+
assert(instr.opcode == 0x1800);
2913+
assert(instr.addr == 0x0000);
2914+
assert(instr.exec == true);
2915+
assert(instr.dword == false);
2916+
2917+
vmcu_decode_bytes(0x0318, &instr, mcu);
2918+
2919+
assert(instr.key == VMCU_IKEY_SUB);
2920+
assert(instr.opcode == 0x1803);
2921+
assert(instr.addr == 0x0000);
2922+
assert(instr.exec == true);
2923+
assert(instr.dword == false);
2924+
2925+
PASSED;
2926+
}
2927+
2928+
static void test_decode_bytes_subi(vmcu_model_t *mcu) {
2929+
2930+
printf("vmcu_decode_bytes() - SUBI");
2931+
2932+
vmcu_instr_t instr;
2933+
vmcu_decode_bytes(0x0050, &instr, mcu);
2934+
2935+
assert(instr.key == VMCU_IKEY_SUBI);
2936+
assert(instr.opcode == 0x5000);
2937+
assert(instr.addr == 0x0000);
2938+
assert(instr.exec == true);
2939+
assert(instr.dword == false);
2940+
2941+
vmcu_decode_bytes(0x1f50, &instr, mcu);
2942+
2943+
assert(instr.key == VMCU_IKEY_SUBI);
2944+
assert(instr.opcode == 0x501f);
2945+
assert(instr.addr == 0x0000);
2946+
assert(instr.exec == true);
2947+
assert(instr.dword == false);
2948+
2949+
PASSED;
2950+
}
2951+
2952+
static void test_decode_bytes_swap(vmcu_model_t *mcu) {
2953+
2954+
printf("vmcu_decode_bytes() - SWAP");
2955+
2956+
vmcu_instr_t instr;
2957+
vmcu_decode_bytes(0x0294, &instr, mcu);
2958+
2959+
assert(instr.key == VMCU_IKEY_SWAP);
2960+
assert(instr.opcode == 0x9402);
2961+
assert(instr.addr == 0x0000);
2962+
assert(instr.exec == true);
2963+
assert(instr.dword == false);
2964+
2965+
vmcu_decode_bytes(0x1294, &instr, mcu);
2966+
2967+
assert(instr.key == VMCU_IKEY_SWAP);
2968+
assert(instr.opcode == 0x9412);
2969+
assert(instr.addr == 0x0000);
2970+
assert(instr.exec == true);
2971+
assert(instr.dword == false);
2972+
2973+
PASSED;
2974+
}
2975+
2976+
static void test_decode_bytes_wdr(vmcu_model_t *mcu) {
2977+
2978+
printf("vmcu_decode_bytes() - WDR");
2979+
2980+
vmcu_instr_t instr;
2981+
vmcu_decode_bytes(0xa895, &instr, mcu);
2982+
2983+
assert(instr.key == VMCU_IKEY_WDR);
2984+
assert(instr.opcode == 0x95a8);
2985+
assert(instr.addr == 0x0000);
2986+
assert(instr.exec == true);
2987+
assert(instr.dword == false);
2988+
2989+
PASSED;
2990+
}
2991+
2992+
static void test_decode_bytes_xch(vmcu_model_t *mcu) {
2993+
2994+
printf("vmcu_decode_bytes() - XCH");
2995+
2996+
vmcu_instr_t instr;
2997+
vmcu_decode_bytes(0x0492, &instr, mcu);
2998+
2999+
assert(instr.key == VMCU_IKEY_XCH);
3000+
assert(instr.opcode == 0x9204);
3001+
assert(instr.addr == 0x0000);
3002+
assert(instr.exec == true);
3003+
assert(instr.dword == false);
3004+
3005+
vmcu_decode_bytes(0x7492, &instr, mcu);
3006+
3007+
assert(instr.key == VMCU_IKEY_XCH);
3008+
assert(instr.opcode == 0x9274);
3009+
assert(instr.addr == 0x0000);
3010+
assert(instr.exec == true);
3011+
assert(instr.dword == false);
3012+
3013+
PASSED;
3014+
}

0 commit comments

Comments
 (0)