From efd0269b55e2db03f5c12d6f47b00b0c2a57ff66 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Thu, 3 Sep 2020 20:22:41 +0200 Subject: rename stack_machine to stack_machine_old (prepare for redesign of the machine) --- tests/stack_machine_add/instructions.s.tcl | 20 --- tests/stack_machine_add/test.v | 1 - tests/stack_machine_add/words_to_verify.mem | 9 -- tests/stack_machine_cond_jump/instructions.s.tcl | 45 ------- tests/stack_machine_cond_jump/test.v | 1 - tests/stack_machine_cond_jump/words_to_verify.mem | 9 -- tests/stack_machine_div/instructions.s.tcl | 23 ---- tests/stack_machine_div/test.v | 1 - tests/stack_machine_div/words_to_verify.mem | 12 -- tests/stack_machine_jump/instructions.s.tcl | 22 ---- tests/stack_machine_jump/test.v | 1 - tests/stack_machine_jump/words_to_verify.mem | 2 - tests/stack_machine_load_store/instructions.s.tcl | 109 ---------------- tests/stack_machine_load_store/test.v | 1 - tests/stack_machine_load_store/words_to_verify.mem | 12 -- tests/stack_machine_mul/instructions.s.tcl | 42 ------- tests/stack_machine_mul/test.v | 1 - tests/stack_machine_mul/words_to_verify.mem | 19 --- .../instructions.s.tcl | 32 ----- .../test.v | 1 - .../words_to_verify.mem | 1 - tests/stack_machine_old_add/instructions.s.tcl | 20 +++ tests/stack_machine_old_add/test.v | 1 + tests/stack_machine_old_add/words_to_verify.mem | 9 ++ .../stack_machine_old_cond_jump/instructions.s.tcl | 45 +++++++ tests/stack_machine_old_cond_jump/test.v | 1 + .../words_to_verify.mem | 9 ++ tests/stack_machine_old_div/instructions.s.tcl | 23 ++++ tests/stack_machine_old_div/test.v | 1 + tests/stack_machine_old_div/words_to_verify.mem | 12 ++ tests/stack_machine_old_jump/instructions.s.tcl | 22 ++++ tests/stack_machine_old_jump/test.v | 1 + tests/stack_machine_old_jump/words_to_verify.mem | 2 + .../instructions.s.tcl | 109 ++++++++++++++++ tests/stack_machine_old_load_store/test.v | 1 + .../words_to_verify.mem | 12 ++ tests/stack_machine_old_mul/instructions.s.tcl | 42 +++++++ tests/stack_machine_old_mul/test.v | 1 + tests/stack_machine_old_mul/words_to_verify.mem | 19 +++ .../instructions.s.tcl | 32 +++++ .../test.v | 1 + .../words_to_verify.mem | 1 + tests/stack_machine_old_store/instructions.s.tcl | 29 +++++ tests/stack_machine_old_store/test.v | 140 +++++++++++++++++++++ tests/stack_machine_old_store/words_to_verify.mem | 3 + tests/stack_machine_old_sub/instructions.s.tcl | 21 ++++ tests/stack_machine_old_sub/test.v | 1 + tests/stack_machine_old_sub/words_to_verify.mem | 9 ++ tests/stack_machine_old_swap/instructions.s.tcl | 15 +++ tests/stack_machine_old_swap/test.v | 1 + tests/stack_machine_old_swap/words_to_verify.mem | 5 + tests/stack_machine_old_tee/instructions.s.tcl | 15 +++ tests/stack_machine_old_tee/test.v | 1 + tests/stack_machine_old_tee/words_to_verify.mem | 5 + tests/stack_machine_store/instructions.s.tcl | 29 ----- tests/stack_machine_store/test.v | 140 --------------------- tests/stack_machine_store/words_to_verify.mem | 3 - tests/stack_machine_sub/instructions.s.tcl | 21 ---- tests/stack_machine_sub/test.v | 1 - tests/stack_machine_sub/words_to_verify.mem | 9 -- tests/stack_machine_swap/instructions.s.tcl | 15 --- tests/stack_machine_swap/test.v | 1 - tests/stack_machine_swap/words_to_verify.mem | 5 - tests/stack_machine_tee/instructions.s.tcl | 15 --- tests/stack_machine_tee/test.v | 1 - tests/stack_machine_tee/words_to_verify.mem | 5 - 66 files changed, 609 insertions(+), 609 deletions(-) delete mode 100755 tests/stack_machine_add/instructions.s.tcl delete mode 120000 tests/stack_machine_add/test.v delete mode 100644 tests/stack_machine_add/words_to_verify.mem delete mode 100755 tests/stack_machine_cond_jump/instructions.s.tcl delete mode 120000 tests/stack_machine_cond_jump/test.v delete mode 100644 tests/stack_machine_cond_jump/words_to_verify.mem delete mode 100755 tests/stack_machine_div/instructions.s.tcl delete mode 120000 tests/stack_machine_div/test.v delete mode 100644 tests/stack_machine_div/words_to_verify.mem delete mode 100755 tests/stack_machine_jump/instructions.s.tcl delete mode 120000 tests/stack_machine_jump/test.v delete mode 100644 tests/stack_machine_jump/words_to_verify.mem delete mode 100755 tests/stack_machine_load_store/instructions.s.tcl delete mode 120000 tests/stack_machine_load_store/test.v delete mode 100644 tests/stack_machine_load_store/words_to_verify.mem delete mode 100755 tests/stack_machine_mul/instructions.s.tcl delete mode 120000 tests/stack_machine_mul/test.v delete mode 100644 tests/stack_machine_mul/words_to_verify.mem delete mode 100755 tests/stack_machine_multiinstructions_load_store/instructions.s.tcl delete mode 120000 tests/stack_machine_multiinstructions_load_store/test.v delete mode 120000 tests/stack_machine_multiinstructions_load_store/words_to_verify.mem create mode 100755 tests/stack_machine_old_add/instructions.s.tcl create mode 120000 tests/stack_machine_old_add/test.v create mode 100644 tests/stack_machine_old_add/words_to_verify.mem create mode 100755 tests/stack_machine_old_cond_jump/instructions.s.tcl create mode 120000 tests/stack_machine_old_cond_jump/test.v create mode 100644 tests/stack_machine_old_cond_jump/words_to_verify.mem create mode 100755 tests/stack_machine_old_div/instructions.s.tcl create mode 120000 tests/stack_machine_old_div/test.v create mode 100644 tests/stack_machine_old_div/words_to_verify.mem create mode 100755 tests/stack_machine_old_jump/instructions.s.tcl create mode 120000 tests/stack_machine_old_jump/test.v create mode 100644 tests/stack_machine_old_jump/words_to_verify.mem create mode 100755 tests/stack_machine_old_load_store/instructions.s.tcl create mode 120000 tests/stack_machine_old_load_store/test.v create mode 100644 tests/stack_machine_old_load_store/words_to_verify.mem create mode 100755 tests/stack_machine_old_mul/instructions.s.tcl create mode 120000 tests/stack_machine_old_mul/test.v create mode 100644 tests/stack_machine_old_mul/words_to_verify.mem create mode 100755 tests/stack_machine_old_multiinstructions_load_store/instructions.s.tcl create mode 120000 tests/stack_machine_old_multiinstructions_load_store/test.v create mode 120000 tests/stack_machine_old_multiinstructions_load_store/words_to_verify.mem create mode 100755 tests/stack_machine_old_store/instructions.s.tcl create mode 100644 tests/stack_machine_old_store/test.v create mode 100644 tests/stack_machine_old_store/words_to_verify.mem create mode 100755 tests/stack_machine_old_sub/instructions.s.tcl create mode 120000 tests/stack_machine_old_sub/test.v create mode 100644 tests/stack_machine_old_sub/words_to_verify.mem create mode 100755 tests/stack_machine_old_swap/instructions.s.tcl create mode 120000 tests/stack_machine_old_swap/test.v create mode 100644 tests/stack_machine_old_swap/words_to_verify.mem create mode 100755 tests/stack_machine_old_tee/instructions.s.tcl create mode 120000 tests/stack_machine_old_tee/test.v create mode 100644 tests/stack_machine_old_tee/words_to_verify.mem delete mode 100755 tests/stack_machine_store/instructions.s.tcl delete mode 100644 tests/stack_machine_store/test.v delete mode 100644 tests/stack_machine_store/words_to_verify.mem delete mode 100755 tests/stack_machine_sub/instructions.s.tcl delete mode 120000 tests/stack_machine_sub/test.v delete mode 100644 tests/stack_machine_sub/words_to_verify.mem delete mode 100755 tests/stack_machine_swap/instructions.s.tcl delete mode 120000 tests/stack_machine_swap/test.v delete mode 100644 tests/stack_machine_swap/words_to_verify.mem delete mode 100755 tests/stack_machine_tee/instructions.s.tcl delete mode 120000 tests/stack_machine_tee/test.v delete mode 100644 tests/stack_machine_tee/words_to_verify.mem (limited to 'tests') diff --git a/tests/stack_machine_add/instructions.s.tcl b/tests/stack_machine_add/instructions.s.tcl deleted file mode 100755 index c3cfe4d..0000000 --- a/tests/stack_machine_add/instructions.s.tcl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### store 2 values to memory, load them back, add them and store the result - -set_sp h7FFFC -const 12345678 -store@ h1EEE0 -const 40302010 -store@ h1EEE4 - -load@ h1EEE0 -stack down -load@ h1EEE4 -# adding 40302010 to 12345678 should yield 52647688 -add -stack up -store@ h1EEE8 -halt diff --git a/tests/stack_machine_add/test.v b/tests/stack_machine_add/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_add/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_add/words_to_verify.mem b/tests/stack_machine_add/words_to_verify.mem deleted file mode 100644 index db077bc..0000000 --- a/tests/stack_machine_add/words_to_verify.mem +++ /dev/null @@ -1,9 +0,0 @@ -// address value - 1EEE0 614E // 12345678 in hex is BC614E - 1EEE2 BC - - 1EEE4 F5BA // 40302010 in hex is 266F5BA - 1EEE6 266 - - 1EEE8 5708 // 52647688 in hex is 3235708 - 1EEEA 323 diff --git a/tests/stack_machine_cond_jump/instructions.s.tcl b/tests/stack_machine_cond_jump/instructions.s.tcl deleted file mode 100755 index 467a719..0000000 --- a/tests/stack_machine_cond_jump/instructions.s.tcl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -## also look at stack_machine_jump test - -## we're going to write numbers from 0 to 7 to addresses h400 - h41C - -# this will translate to 3 16-bit instructions -set_sp h7FFFC - -## set up the counter -# each of those 2 will translate to 1 16-bit instruction -const 0 -stack down - -## this is the point we later jump to, address 10 - -tee -## compute address: counter * 4 + h400 -stack down -const 4 -mul -const h400 -add -stack up -## load computed address to im -exchange_im -## save value of counter at address pointed by im -swap -store -swap -## increase counter by 1 -const 1 -add -## compare value of counter to 8 -tee -stack down -const 8 -sub -stack up -## loop if counter != 8 -cond_jump 10 - -halt diff --git a/tests/stack_machine_cond_jump/test.v b/tests/stack_machine_cond_jump/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_cond_jump/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_cond_jump/words_to_verify.mem b/tests/stack_machine_cond_jump/words_to_verify.mem deleted file mode 100644 index 4b77b8a..0000000 --- a/tests/stack_machine_cond_jump/words_to_verify.mem +++ /dev/null @@ -1,9 +0,0 @@ -// address value - 00400 0 // verify the first number written - 00402 0 - - 00408 2 // verify a number in the middle - 0040A 0 - - 0041C 7 // verify the last number - 0041E 0 diff --git a/tests/stack_machine_div/instructions.s.tcl b/tests/stack_machine_div/instructions.s.tcl deleted file mode 100755 index e2d55dc..0000000 --- a/tests/stack_machine_div/instructions.s.tcl +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### store 2 values to memory, load them back, divide one by another and store -### the result (both quotient and remainder); this is analogous to addition -### and substraction tests - -set_sp h7FFFC -const 777681520 -store@ h1EEE0 -const 3721 -store@ h1EEE4 - -load@ h1EEE0 -stack down -load@ h1EEE4 -# dividing 777681520 by 3721 should yield 208997 r 3683 -div -store@ h1EEE8 -stack up -store@ h1EEEC -halt diff --git a/tests/stack_machine_div/test.v b/tests/stack_machine_div/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_div/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_div/words_to_verify.mem b/tests/stack_machine_div/words_to_verify.mem deleted file mode 100644 index 8543226..0000000 --- a/tests/stack_machine_div/words_to_verify.mem +++ /dev/null @@ -1,12 +0,0 @@ -// address value - 1EEE0 7A70 // 777681520 in hex is 2E5A7A70 - 1EEE2 2E5A - - 1EEE4 E89 // 3721 in hex is E89 - 1EEE6 0 - - 1EEE8 E63 // 3683 in hex is E63 - 1EEEA 0 - - 1EEEC 3065 // 208997 in hex is 33065 - 1EEEE 3 diff --git a/tests/stack_machine_jump/instructions.s.tcl b/tests/stack_machine_jump/instructions.s.tcl deleted file mode 100755 index f681fc9..0000000 --- a/tests/stack_machine_jump/instructions.s.tcl +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -## Let there be 2 pieces of code - each one storing a different value in memory -## and halting afterwards. Jump instruction should cause the second piece of -## code to execute instead of the first. We'll verify that by checking, which -## value got written. - -## Ufortunately, our assembly currently doesn't compute label addresses for us. - -# Each of those 4 instructions should get encoded into 1 16-bit word, so they -# will take 8 bytes total. Hence jump to address 8 is needed to skip them. -jump 8 -const h12 -store@ h00100 -halt - -# address 8 here -const h34 -store@ h00100 -halt diff --git a/tests/stack_machine_jump/test.v b/tests/stack_machine_jump/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_jump/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_jump/words_to_verify.mem b/tests/stack_machine_jump/words_to_verify.mem deleted file mode 100644 index 4fded2b..0000000 --- a/tests/stack_machine_jump/words_to_verify.mem +++ /dev/null @@ -1,2 +0,0 @@ -// address value - 00100 34 diff --git a/tests/stack_machine_load_store/instructions.s.tcl b/tests/stack_machine_load_store/instructions.s.tcl deleted file mode 100755 index 13cabcb..0000000 --- a/tests/stack_machine_load_store/instructions.s.tcl +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### another simple test - set stack to h7FFFC, store 4 numbers on stack (only 2 -### will really get written to memory, other 2 will remain in r0 and r1), -### then pop all the numbers and write them to h57574 - - -## set sp to h7FFFC (actually, lowest bit is assumed 0 and not stored there) -# 7777 FFFF F -# bits 19:11 of h7FFFC are 0111 1111 1 -_immediate im=b011111111 -# FFf FFFF CCCC -# bits 10:0 of h7FFFC are 111 1111 1100 -_immediate im<<=b11111111100 - -_extended_instruction set_sp - -## get value h01010202 into r1 -# 0000 1111 00 -# bits 31:22 of h01010202 are 0000 0001 00 -_immediate im<<=b0000000100 -# 00 1111 0000 2 -# bits 21:11 of h01010202 are 00 0001 0000 0 -_immediate im<<=b00000100000 -# 222 0000 2222 -# bits 10:0 of h01010202 are 010 0000 0010 -_exchange_im im<<=b01000000010 - -## get value h03030404 into r1 -stack down -# 0000 3333 00 -# bits 31:22 of h03030404 are 0000 0011 00 -_immediate im<<=b0000001100 -# 00 3333 0000 4 -# bits 21:11 of h03030404 are 00 0011 0000 0 -_immediate im<<=b00001100000 -# 444 0000 4444 -# bits 10:0 of h03030404 are 100 0000 0100 -_exchange_im im<<=b10000000100 - -## get value h05050606 into r1 -stack down -# 0000 5555 00 -# bits 31:22 of h05050606 are 0000 0101 00 -_immediate im<<=b0000010100 -# 00 5555 0000 6 -# bits 21:11 of h05050606 are 00 0101 0000 0 -_immediate im<<=b00010100000 -# 666 0000 6666 -# bits 10:0 of h05050606 are 110 0000 0110 -_exchange_im im<<=b11000000110 - -## get value h07070808 into r1 -stack down -# 0000 7777 00 -# bits 31:22 of h07070808 are 0000 0111 00 -_immediate im<<=b0000011100 -# 00 7777 0000 8 -# bits 21:11 of h07070808 are 00 0111 0000 1 -_immediate im<<=b00011100001 -# 888 0000 8888 -# bits 10:0 of h07070808 are 000 0000 1000 -_exchange_im im<<=b00000001000 - -## get address h57574 into im and write r1 to that address -# 5555 7777 5 -# bits 19:11 of h57574 are 0101 0111 0 -_immediate im=b010101110 -# 555 7777 4444 -# bits 10:0 of h57574 are 101 0111 0100 -store im<<=b10101110100 - -# get r0 to r1 -stack up - -## get address h57578 into im and write r1 to that address -# 5555 7777 5 -# bits 19:11 of h57578 are 0101 0111 0 -_immediate im=b010101110 -# 555 7777 8888 -# bits 10:0 of h57578 are 101 0111 1000 -store im<<=b10101111000 - -# get r0 to r1 -stack up - -## get address h5757C into im and write r1 to that address -# 5555 7777 5 -# bits 19:11 of h5757C are 0101 0111 0 -_immediate im=b010101110 -# 555 7777 CCCC -# bits 10:0 of h5757C are 101 0111 1100 -store im<<=b10101111100 - -# get r0 to r1 -stack up - -## get address h57580 into im and write r1 to that address -# 5555 7777 5 -# bits 19:11 of h57580 are 0101 0111 0 -_immediate im=b010101110 -# 555 8888 0000 -# bits 10:0 of h57580 are 101 1000 0000 -store im<<=b10110000000 - -## finish test -halt diff --git a/tests/stack_machine_load_store/test.v b/tests/stack_machine_load_store/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_load_store/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_load_store/words_to_verify.mem b/tests/stack_machine_load_store/words_to_verify.mem deleted file mode 100644 index 349b213..0000000 --- a/tests/stack_machine_load_store/words_to_verify.mem +++ /dev/null @@ -1,12 +0,0 @@ -// address value - 57574 0808 - 57576 0707 - - 57578 0606 - 5757A 0505 - - 5757C 0404 - 5757E 0303 - - 57580 0202 - 57582 0101 diff --git a/tests/stack_machine_mul/instructions.s.tcl b/tests/stack_machine_mul/instructions.s.tcl deleted file mode 100755 index 8473aef..0000000 --- a/tests/stack_machine_mul/instructions.s.tcl +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### store 4 values to memory; load 2 of them back, multiply them and store the -### result; load another 2, multiply them and store the result; -### this is similar to addition and substraction tests - -set_sp h7FFFC - -## store first 2 factors -const 483091365 -store@ h1EEE0 -const 74683203 -store@ h1EEE4 - -## store other 2 factors -const 8436 -store@ h1EEEC -const -14020 -store@ h1EEF0 - -## perform the first multiplication -load@ h1EEE0 -stack down -load@ h1EEE4 -# multiplying 483091365 by 74683203 should yield 36078810479842095 -# if we take lowest 32 bits of 36078810479842095 we get 2861683503 -mul -stack up -store@ h1EEE8 - -## perform the second multiplication -load@ h1EEEC -stack down -load@ h1EEF0 -# multiplying 8436 by -14020 should yield -118272720 (which fits in 32 bits) -mul -stack up -store@ h1EEF4 - -halt diff --git a/tests/stack_machine_mul/test.v b/tests/stack_machine_mul/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_mul/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_mul/words_to_verify.mem b/tests/stack_machine_mul/words_to_verify.mem deleted file mode 100644 index 3095d6e..0000000 --- a/tests/stack_machine_mul/words_to_verify.mem +++ /dev/null @@ -1,19 +0,0 @@ -// address value - 1EEE0 63A5 // 483091365 in hex is 1CCB63A5 - 1EEE2 1CCB - - 1EEE4 9343 // 74683203 in hex is 4739343 - 1EEE6 473 - - 1EEE8 D32F // 2861683503 in hex is AA91D32F - 1EEEA AA91 - - - 1EEEC 20F4 // 8436 in hex is 20F4 - 1EEEE 0 - - 1EEF0 C93C // -14020 in hex is FFFFC93C - 1EEF2 FFFF - - 1EEF4 4D30 // -118272720 in hex is F8F34D30 - 1EEF6 F8F3 diff --git a/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl b/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl deleted file mode 100755 index 58792d3..0000000 --- a/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### do the same as in stack_machine_2 test, but use higher level instructions - -## set sp to h7FFFC -set_sp h7FFFC -## get value h01010202 into r1 -const h01010202 -## get value h03030404 into r1 -stack down -const h03030404 -## get value h05050606 into r1 -stack down -const h05050606 -## get value h07070808 into r1 -stack down -const h07070808 -## write r1 to address h57574 -store@ h57574 -stack up -## write r1 to address h57578 -store@ h57578 -stack up -## write r1 to address h5757C -store@ h5757C -stack up -## write r1 to address h57580 -store@ h57580 -## finish test -halt diff --git a/tests/stack_machine_multiinstructions_load_store/test.v b/tests/stack_machine_multiinstructions_load_store/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_multiinstructions_load_store/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_multiinstructions_load_store/words_to_verify.mem b/tests/stack_machine_multiinstructions_load_store/words_to_verify.mem deleted file mode 120000 index b2e490b..0000000 --- a/tests/stack_machine_multiinstructions_load_store/words_to_verify.mem +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_load_store/words_to_verify.mem \ No newline at end of file diff --git a/tests/stack_machine_old_add/instructions.s.tcl b/tests/stack_machine_old_add/instructions.s.tcl new file mode 100755 index 0000000..c3cfe4d --- /dev/null +++ b/tests/stack_machine_old_add/instructions.s.tcl @@ -0,0 +1,20 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### store 2 values to memory, load them back, add them and store the result + +set_sp h7FFFC +const 12345678 +store@ h1EEE0 +const 40302010 +store@ h1EEE4 + +load@ h1EEE0 +stack down +load@ h1EEE4 +# adding 40302010 to 12345678 should yield 52647688 +add +stack up +store@ h1EEE8 +halt diff --git a/tests/stack_machine_old_add/test.v b/tests/stack_machine_old_add/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_add/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_add/words_to_verify.mem b/tests/stack_machine_old_add/words_to_verify.mem new file mode 100644 index 0000000..db077bc --- /dev/null +++ b/tests/stack_machine_old_add/words_to_verify.mem @@ -0,0 +1,9 @@ +// address value + 1EEE0 614E // 12345678 in hex is BC614E + 1EEE2 BC + + 1EEE4 F5BA // 40302010 in hex is 266F5BA + 1EEE6 266 + + 1EEE8 5708 // 52647688 in hex is 3235708 + 1EEEA 323 diff --git a/tests/stack_machine_old_cond_jump/instructions.s.tcl b/tests/stack_machine_old_cond_jump/instructions.s.tcl new file mode 100755 index 0000000..467a719 --- /dev/null +++ b/tests/stack_machine_old_cond_jump/instructions.s.tcl @@ -0,0 +1,45 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +## also look at stack_machine_jump test + +## we're going to write numbers from 0 to 7 to addresses h400 - h41C + +# this will translate to 3 16-bit instructions +set_sp h7FFFC + +## set up the counter +# each of those 2 will translate to 1 16-bit instruction +const 0 +stack down + +## this is the point we later jump to, address 10 + +tee +## compute address: counter * 4 + h400 +stack down +const 4 +mul +const h400 +add +stack up +## load computed address to im +exchange_im +## save value of counter at address pointed by im +swap +store +swap +## increase counter by 1 +const 1 +add +## compare value of counter to 8 +tee +stack down +const 8 +sub +stack up +## loop if counter != 8 +cond_jump 10 + +halt diff --git a/tests/stack_machine_old_cond_jump/test.v b/tests/stack_machine_old_cond_jump/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_cond_jump/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_cond_jump/words_to_verify.mem b/tests/stack_machine_old_cond_jump/words_to_verify.mem new file mode 100644 index 0000000..4b77b8a --- /dev/null +++ b/tests/stack_machine_old_cond_jump/words_to_verify.mem @@ -0,0 +1,9 @@ +// address value + 00400 0 // verify the first number written + 00402 0 + + 00408 2 // verify a number in the middle + 0040A 0 + + 0041C 7 // verify the last number + 0041E 0 diff --git a/tests/stack_machine_old_div/instructions.s.tcl b/tests/stack_machine_old_div/instructions.s.tcl new file mode 100755 index 0000000..e2d55dc --- /dev/null +++ b/tests/stack_machine_old_div/instructions.s.tcl @@ -0,0 +1,23 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### store 2 values to memory, load them back, divide one by another and store +### the result (both quotient and remainder); this is analogous to addition +### and substraction tests + +set_sp h7FFFC +const 777681520 +store@ h1EEE0 +const 3721 +store@ h1EEE4 + +load@ h1EEE0 +stack down +load@ h1EEE4 +# dividing 777681520 by 3721 should yield 208997 r 3683 +div +store@ h1EEE8 +stack up +store@ h1EEEC +halt diff --git a/tests/stack_machine_old_div/test.v b/tests/stack_machine_old_div/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_div/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_div/words_to_verify.mem b/tests/stack_machine_old_div/words_to_verify.mem new file mode 100644 index 0000000..8543226 --- /dev/null +++ b/tests/stack_machine_old_div/words_to_verify.mem @@ -0,0 +1,12 @@ +// address value + 1EEE0 7A70 // 777681520 in hex is 2E5A7A70 + 1EEE2 2E5A + + 1EEE4 E89 // 3721 in hex is E89 + 1EEE6 0 + + 1EEE8 E63 // 3683 in hex is E63 + 1EEEA 0 + + 1EEEC 3065 // 208997 in hex is 33065 + 1EEEE 3 diff --git a/tests/stack_machine_old_jump/instructions.s.tcl b/tests/stack_machine_old_jump/instructions.s.tcl new file mode 100755 index 0000000..f681fc9 --- /dev/null +++ b/tests/stack_machine_old_jump/instructions.s.tcl @@ -0,0 +1,22 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +## Let there be 2 pieces of code - each one storing a different value in memory +## and halting afterwards. Jump instruction should cause the second piece of +## code to execute instead of the first. We'll verify that by checking, which +## value got written. + +## Ufortunately, our assembly currently doesn't compute label addresses for us. + +# Each of those 4 instructions should get encoded into 1 16-bit word, so they +# will take 8 bytes total. Hence jump to address 8 is needed to skip them. +jump 8 +const h12 +store@ h00100 +halt + +# address 8 here +const h34 +store@ h00100 +halt diff --git a/tests/stack_machine_old_jump/test.v b/tests/stack_machine_old_jump/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_jump/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_jump/words_to_verify.mem b/tests/stack_machine_old_jump/words_to_verify.mem new file mode 100644 index 0000000..4fded2b --- /dev/null +++ b/tests/stack_machine_old_jump/words_to_verify.mem @@ -0,0 +1,2 @@ +// address value + 00100 34 diff --git a/tests/stack_machine_old_load_store/instructions.s.tcl b/tests/stack_machine_old_load_store/instructions.s.tcl new file mode 100755 index 0000000..13cabcb --- /dev/null +++ b/tests/stack_machine_old_load_store/instructions.s.tcl @@ -0,0 +1,109 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### another simple test - set stack to h7FFFC, store 4 numbers on stack (only 2 +### will really get written to memory, other 2 will remain in r0 and r1), +### then pop all the numbers and write them to h57574 + + +## set sp to h7FFFC (actually, lowest bit is assumed 0 and not stored there) +# 7777 FFFF F +# bits 19:11 of h7FFFC are 0111 1111 1 +_immediate im=b011111111 +# FFf FFFF CCCC +# bits 10:0 of h7FFFC are 111 1111 1100 +_immediate im<<=b11111111100 + +_extended_instruction set_sp + +## get value h01010202 into r1 +# 0000 1111 00 +# bits 31:22 of h01010202 are 0000 0001 00 +_immediate im<<=b0000000100 +# 00 1111 0000 2 +# bits 21:11 of h01010202 are 00 0001 0000 0 +_immediate im<<=b00000100000 +# 222 0000 2222 +# bits 10:0 of h01010202 are 010 0000 0010 +_exchange_im im<<=b01000000010 + +## get value h03030404 into r1 +stack down +# 0000 3333 00 +# bits 31:22 of h03030404 are 0000 0011 00 +_immediate im<<=b0000001100 +# 00 3333 0000 4 +# bits 21:11 of h03030404 are 00 0011 0000 0 +_immediate im<<=b00001100000 +# 444 0000 4444 +# bits 10:0 of h03030404 are 100 0000 0100 +_exchange_im im<<=b10000000100 + +## get value h05050606 into r1 +stack down +# 0000 5555 00 +# bits 31:22 of h05050606 are 0000 0101 00 +_immediate im<<=b0000010100 +# 00 5555 0000 6 +# bits 21:11 of h05050606 are 00 0101 0000 0 +_immediate im<<=b00010100000 +# 666 0000 6666 +# bits 10:0 of h05050606 are 110 0000 0110 +_exchange_im im<<=b11000000110 + +## get value h07070808 into r1 +stack down +# 0000 7777 00 +# bits 31:22 of h07070808 are 0000 0111 00 +_immediate im<<=b0000011100 +# 00 7777 0000 8 +# bits 21:11 of h07070808 are 00 0111 0000 1 +_immediate im<<=b00011100001 +# 888 0000 8888 +# bits 10:0 of h07070808 are 000 0000 1000 +_exchange_im im<<=b00000001000 + +## get address h57574 into im and write r1 to that address +# 5555 7777 5 +# bits 19:11 of h57574 are 0101 0111 0 +_immediate im=b010101110 +# 555 7777 4444 +# bits 10:0 of h57574 are 101 0111 0100 +store im<<=b10101110100 + +# get r0 to r1 +stack up + +## get address h57578 into im and write r1 to that address +# 5555 7777 5 +# bits 19:11 of h57578 are 0101 0111 0 +_immediate im=b010101110 +# 555 7777 8888 +# bits 10:0 of h57578 are 101 0111 1000 +store im<<=b10101111000 + +# get r0 to r1 +stack up + +## get address h5757C into im and write r1 to that address +# 5555 7777 5 +# bits 19:11 of h5757C are 0101 0111 0 +_immediate im=b010101110 +# 555 7777 CCCC +# bits 10:0 of h5757C are 101 0111 1100 +store im<<=b10101111100 + +# get r0 to r1 +stack up + +## get address h57580 into im and write r1 to that address +# 5555 7777 5 +# bits 19:11 of h57580 are 0101 0111 0 +_immediate im=b010101110 +# 555 8888 0000 +# bits 10:0 of h57580 are 101 1000 0000 +store im<<=b10110000000 + +## finish test +halt diff --git a/tests/stack_machine_old_load_store/test.v b/tests/stack_machine_old_load_store/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_load_store/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_load_store/words_to_verify.mem b/tests/stack_machine_old_load_store/words_to_verify.mem new file mode 100644 index 0000000..349b213 --- /dev/null +++ b/tests/stack_machine_old_load_store/words_to_verify.mem @@ -0,0 +1,12 @@ +// address value + 57574 0808 + 57576 0707 + + 57578 0606 + 5757A 0505 + + 5757C 0404 + 5757E 0303 + + 57580 0202 + 57582 0101 diff --git a/tests/stack_machine_old_mul/instructions.s.tcl b/tests/stack_machine_old_mul/instructions.s.tcl new file mode 100755 index 0000000..8473aef --- /dev/null +++ b/tests/stack_machine_old_mul/instructions.s.tcl @@ -0,0 +1,42 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### store 4 values to memory; load 2 of them back, multiply them and store the +### result; load another 2, multiply them and store the result; +### this is similar to addition and substraction tests + +set_sp h7FFFC + +## store first 2 factors +const 483091365 +store@ h1EEE0 +const 74683203 +store@ h1EEE4 + +## store other 2 factors +const 8436 +store@ h1EEEC +const -14020 +store@ h1EEF0 + +## perform the first multiplication +load@ h1EEE0 +stack down +load@ h1EEE4 +# multiplying 483091365 by 74683203 should yield 36078810479842095 +# if we take lowest 32 bits of 36078810479842095 we get 2861683503 +mul +stack up +store@ h1EEE8 + +## perform the second multiplication +load@ h1EEEC +stack down +load@ h1EEF0 +# multiplying 8436 by -14020 should yield -118272720 (which fits in 32 bits) +mul +stack up +store@ h1EEF4 + +halt diff --git a/tests/stack_machine_old_mul/test.v b/tests/stack_machine_old_mul/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_mul/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_mul/words_to_verify.mem b/tests/stack_machine_old_mul/words_to_verify.mem new file mode 100644 index 0000000..3095d6e --- /dev/null +++ b/tests/stack_machine_old_mul/words_to_verify.mem @@ -0,0 +1,19 @@ +// address value + 1EEE0 63A5 // 483091365 in hex is 1CCB63A5 + 1EEE2 1CCB + + 1EEE4 9343 // 74683203 in hex is 4739343 + 1EEE6 473 + + 1EEE8 D32F // 2861683503 in hex is AA91D32F + 1EEEA AA91 + + + 1EEEC 20F4 // 8436 in hex is 20F4 + 1EEEE 0 + + 1EEF0 C93C // -14020 in hex is FFFFC93C + 1EEF2 FFFF + + 1EEF4 4D30 // -118272720 in hex is F8F34D30 + 1EEF6 F8F3 diff --git a/tests/stack_machine_old_multiinstructions_load_store/instructions.s.tcl b/tests/stack_machine_old_multiinstructions_load_store/instructions.s.tcl new file mode 100755 index 0000000..58792d3 --- /dev/null +++ b/tests/stack_machine_old_multiinstructions_load_store/instructions.s.tcl @@ -0,0 +1,32 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### do the same as in stack_machine_2 test, but use higher level instructions + +## set sp to h7FFFC +set_sp h7FFFC +## get value h01010202 into r1 +const h01010202 +## get value h03030404 into r1 +stack down +const h03030404 +## get value h05050606 into r1 +stack down +const h05050606 +## get value h07070808 into r1 +stack down +const h07070808 +## write r1 to address h57574 +store@ h57574 +stack up +## write r1 to address h57578 +store@ h57578 +stack up +## write r1 to address h5757C +store@ h5757C +stack up +## write r1 to address h57580 +store@ h57580 +## finish test +halt diff --git a/tests/stack_machine_old_multiinstructions_load_store/test.v b/tests/stack_machine_old_multiinstructions_load_store/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_multiinstructions_load_store/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_multiinstructions_load_store/words_to_verify.mem b/tests/stack_machine_old_multiinstructions_load_store/words_to_verify.mem new file mode 120000 index 0000000..e82687e --- /dev/null +++ b/tests/stack_machine_old_multiinstructions_load_store/words_to_verify.mem @@ -0,0 +1 @@ +../stack_machine_old_load_store/words_to_verify.mem \ No newline at end of file diff --git a/tests/stack_machine_old_store/instructions.s.tcl b/tests/stack_machine_old_store/instructions.s.tcl new file mode 100755 index 0000000..ddc3a8e --- /dev/null +++ b/tests/stack_machine_old_store/instructions.s.tcl @@ -0,0 +1,29 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### simple test - write value hDEADBEEF to address h3ABCD + +## get value hDEADBEEF into r1 + +# DDDD EEEE AA +# bits 31:22 of hDEADBEEF are 1101 1110 10 +_immediate im<<=b1101111010 +# AA DDDD BBBB E +# bits 21:11 of hDEADBEEF are 10 1101 1011 1 +_immediate im<<=b10110110111 +# EEE EEEE FFFF +# bits 10:0 of hDEADBEEF are 110 1110 1111 +_exchange_im im<<=b11011101111 + +## get address h7579A into im + +# 7777 5555 7 +# bits 19:11 of h7579A are 0111 0101 0 +_immediate im=b011101010 +# 777 9999 AAAA +# bits 10:0 of h7579A are 111 1001 1010 +store im<<=b11110011010 + +## finish test +halt diff --git a/tests/stack_machine_old_store/test.v b/tests/stack_machine_old_store/test.v new file mode 100644 index 0000000..7e7429f --- /dev/null +++ b/tests/stack_machine_old_store/test.v @@ -0,0 +1,140 @@ +`default_nettype none + +`include "messages.vh" + +`ifndef SIMULATION + `error_SIMULATION_not_defined +; /* Cause syntax error */ +`endif + +`ifndef INSTRUCTIONS_COUNT + `error_INSTRUCTIONS_COUNT_must_be_defined +; /* Cause syntax error */ +`endif + +`ifndef WORDS_TO_VERIFY_COUNT + `error_WORDS_TO_VERIFY_COUNT_must_be_defined +; /* Cause syntax error */ +`endif + +module stack_machine_test(); + wire M_ACK_I; + wire M_CLK_I; + wire [19:0] M_ADR_O; + wire [15:0] M_DAT_I; + wire [15:0] M_DAT_O; + wire M_RST_I; + wire M_STB_O; + wire M_CYC_O; + wire M_WE_O; + wire M_STALL_I; + + wire S_ACK_O; + wire S_CLK_I; + wire [17:0] S_ADR_I; + wire [15:0] S_DAT_I; + wire [15:0] S_DAT_O; + wire S_RST_I; + wire S_STB_I; + wire S_WE_I; + wire S_STALL_O; + + /* Non-wishbone */ + wire M_finished; + + stack_machine stack_machine + ( + .ACK_I(M_ACK_I), + .CLK_I(M_CLK_I), + .ADR_O(M_ADR_O), + .DAT_I(M_DAT_I), + .DAT_O(M_DAT_O), + .RST_I(M_RST_I), + .STB_O(M_STB_O), + .CYC_O(M_CYC_O), + .WE_O(M_WE_O), + .STALL_I(M_STALL_I), + + .finished(M_finished) + ); + + memory_slave_model + #( + .SLAVE_NR(0), + .WRITABLE(1), + .WORDS_TO_INITIALIZE(`INSTRUCTIONS_COUNT), + .INITIAL_CONTENTS_FILE("instructions.mem") + ) slave + ( + .ACK_O(S_ACK_O), + .CLK_I(S_CLK_I), + .ADR_I(S_ADR_I), + .DAT_I(S_DAT_I), + .DAT_O(S_DAT_O), + .RST_I(S_RST_I), + .STB_I(S_STB_I), + .WE_I(S_WE_I), + .STALL_O(S_STALL_O) + ); + + reg CLK; + reg RST; + + assign M_ACK_I = S_ACK_O; + assign M_CLK_I = CLK; + assign M_DAT_I = S_DAT_O; + assign M_RST_I = RST; + assign M_STALL_I = S_STALL_O; + + assign S_CLK_I = CLK; + assign S_ADR_I = M_ADR_O[17:0]; /* Ignore 2 topmost bits */ + assign S_DAT_I = M_DAT_O; + assign S_RST_I = RST; + assign S_STB_I = M_STB_O && M_CYC_O; + assign S_WE_I = M_WE_O; + + integer i, j; + reg [17:0] address; + reg [15:0] expected_value; + + reg [19:0] words_to_verify[`WORDS_TO_VERIFY_COUNT * 2 - 1 : 0]; + + initial begin + CLK <= 0; + RST <= 1; + + for (i = 0; i < 3500; i++) begin + #1; + + CLK <= ~CLK; + + if (CLK) + RST <= 0; + + if (M_finished) begin + $readmemh("words_to_verify.mem", words_to_verify, + 0, `WORDS_TO_VERIFY_COUNT * 2 - 1); + + for (j = 0; j < `WORDS_TO_VERIFY_COUNT; j++) begin + /* + * Byte-grained addresses are used in CPU, and we also use + * them in tclasm opcodes and in files with words for + * verification. Slaves and wishbone address 16-bit words, not + * single bytes. We need to drop the lowest bit here. + */ + address = words_to_verify[2 * j][19:1]; + expected_value = words_to_verify[2 * j + 1]; + if (slave.memory[address] !== expected_value) begin + `MSG(("error: expected h%x at h%x, but got h%x", + expected_value, address, slave.memory[address])); + end + end + + $finish; + end // if (M_finished) + end // for (i = 0; i < 3500; i++) + + $display("error: cpu hasn't finished its operations in 1750 ticks"); + $finish; + end // initial begin +endmodule // stack_machine_test diff --git a/tests/stack_machine_old_store/words_to_verify.mem b/tests/stack_machine_old_store/words_to_verify.mem new file mode 100644 index 0000000..9056a1b --- /dev/null +++ b/tests/stack_machine_old_store/words_to_verify.mem @@ -0,0 +1,3 @@ +// address value + 7579A BEEF + 7579C DEAD diff --git a/tests/stack_machine_old_sub/instructions.s.tcl b/tests/stack_machine_old_sub/instructions.s.tcl new file mode 100755 index 0000000..3f8fb48 --- /dev/null +++ b/tests/stack_machine_old_sub/instructions.s.tcl @@ -0,0 +1,21 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### store 2 values to memory, load them back, substract them and store the +### result; this is analogous to addition test + +set_sp h7FFFC +const 68996288 +store@ h1EEE0 +const 540904416 +store@ h1EEE4 + +load@ h1EEE0 +stack down +load@ h1EEE4 +# substracting 540904416 from 68996288 should yield -471908128 +sub +stack up +store@ h1EEE8 +halt diff --git a/tests/stack_machine_old_sub/test.v b/tests/stack_machine_old_sub/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_sub/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_sub/words_to_verify.mem b/tests/stack_machine_old_sub/words_to_verify.mem new file mode 100644 index 0000000..cc666fa --- /dev/null +++ b/tests/stack_machine_old_sub/words_to_verify.mem @@ -0,0 +1,9 @@ +// address value + 1EEE0 CCC0 // 68996288 in hex is 41CCCC0 + 1EEE2 41C + + 1EEE4 8BE0 // 540904416 in hex is 203D8BE0 + 1EEE6 203D + + 1EEE8 40E0 // -471908128 in hex is E3DF40E0 + 1EEEA E3DF diff --git a/tests/stack_machine_old_swap/instructions.s.tcl b/tests/stack_machine_old_swap/instructions.s.tcl new file mode 100755 index 0000000..c17314e --- /dev/null +++ b/tests/stack_machine_old_swap/instructions.s.tcl @@ -0,0 +1,15 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +set_sp h7FFFC +const h00AD00DE +stack down +const h00EF00BE +swap +## Because values were swapped, h00AD00DE should get written, first, at lower +## address (h100) and h00EF00BE should be written next (at h104) +store@ h00100 +stack down +store@ h00104 +halt diff --git a/tests/stack_machine_old_swap/test.v b/tests/stack_machine_old_swap/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_swap/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_swap/words_to_verify.mem b/tests/stack_machine_old_swap/words_to_verify.mem new file mode 100644 index 0000000..669219d --- /dev/null +++ b/tests/stack_machine_old_swap/words_to_verify.mem @@ -0,0 +1,5 @@ +// address value + 00100 DE + 00102 AD + 00104 BE + 00106 EF diff --git a/tests/stack_machine_old_tee/instructions.s.tcl b/tests/stack_machine_old_tee/instructions.s.tcl new file mode 100755 index 0000000..e75b564 --- /dev/null +++ b/tests/stack_machine_old_tee/instructions.s.tcl @@ -0,0 +1,15 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +set_sp h7FFFC +const hABCDEF +stack down +const hA98765 +tee +## hA98765 should now be replaced with hABCDEF - we should have +## two hABCDEF's on stack - let's store them for verification +store@ h00100 +stack up +store@ h00104 +halt diff --git a/tests/stack_machine_old_tee/test.v b/tests/stack_machine_old_tee/test.v new file mode 120000 index 0000000..f0c3cf9 --- /dev/null +++ b/tests/stack_machine_old_tee/test.v @@ -0,0 +1 @@ +../stack_machine_old_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_old_tee/words_to_verify.mem b/tests/stack_machine_old_tee/words_to_verify.mem new file mode 100644 index 0000000..961f9dc --- /dev/null +++ b/tests/stack_machine_old_tee/words_to_verify.mem @@ -0,0 +1,5 @@ +// address value + 00100 CDEF + 00102 AB + 00104 CDEF + 00106 AB diff --git a/tests/stack_machine_store/instructions.s.tcl b/tests/stack_machine_store/instructions.s.tcl deleted file mode 100755 index ddc3a8e..0000000 --- a/tests/stack_machine_store/instructions.s.tcl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### simple test - write value hDEADBEEF to address h3ABCD - -## get value hDEADBEEF into r1 - -# DDDD EEEE AA -# bits 31:22 of hDEADBEEF are 1101 1110 10 -_immediate im<<=b1101111010 -# AA DDDD BBBB E -# bits 21:11 of hDEADBEEF are 10 1101 1011 1 -_immediate im<<=b10110110111 -# EEE EEEE FFFF -# bits 10:0 of hDEADBEEF are 110 1110 1111 -_exchange_im im<<=b11011101111 - -## get address h7579A into im - -# 7777 5555 7 -# bits 19:11 of h7579A are 0111 0101 0 -_immediate im=b011101010 -# 777 9999 AAAA -# bits 10:0 of h7579A are 111 1001 1010 -store im<<=b11110011010 - -## finish test -halt diff --git a/tests/stack_machine_store/test.v b/tests/stack_machine_store/test.v deleted file mode 100644 index 7e7429f..0000000 --- a/tests/stack_machine_store/test.v +++ /dev/null @@ -1,140 +0,0 @@ -`default_nettype none - -`include "messages.vh" - -`ifndef SIMULATION - `error_SIMULATION_not_defined -; /* Cause syntax error */ -`endif - -`ifndef INSTRUCTIONS_COUNT - `error_INSTRUCTIONS_COUNT_must_be_defined -; /* Cause syntax error */ -`endif - -`ifndef WORDS_TO_VERIFY_COUNT - `error_WORDS_TO_VERIFY_COUNT_must_be_defined -; /* Cause syntax error */ -`endif - -module stack_machine_test(); - wire M_ACK_I; - wire M_CLK_I; - wire [19:0] M_ADR_O; - wire [15:0] M_DAT_I; - wire [15:0] M_DAT_O; - wire M_RST_I; - wire M_STB_O; - wire M_CYC_O; - wire M_WE_O; - wire M_STALL_I; - - wire S_ACK_O; - wire S_CLK_I; - wire [17:0] S_ADR_I; - wire [15:0] S_DAT_I; - wire [15:0] S_DAT_O; - wire S_RST_I; - wire S_STB_I; - wire S_WE_I; - wire S_STALL_O; - - /* Non-wishbone */ - wire M_finished; - - stack_machine stack_machine - ( - .ACK_I(M_ACK_I), - .CLK_I(M_CLK_I), - .ADR_O(M_ADR_O), - .DAT_I(M_DAT_I), - .DAT_O(M_DAT_O), - .RST_I(M_RST_I), - .STB_O(M_STB_O), - .CYC_O(M_CYC_O), - .WE_O(M_WE_O), - .STALL_I(M_STALL_I), - - .finished(M_finished) - ); - - memory_slave_model - #( - .SLAVE_NR(0), - .WRITABLE(1), - .WORDS_TO_INITIALIZE(`INSTRUCTIONS_COUNT), - .INITIAL_CONTENTS_FILE("instructions.mem") - ) slave - ( - .ACK_O(S_ACK_O), - .CLK_I(S_CLK_I), - .ADR_I(S_ADR_I), - .DAT_I(S_DAT_I), - .DAT_O(S_DAT_O), - .RST_I(S_RST_I), - .STB_I(S_STB_I), - .WE_I(S_WE_I), - .STALL_O(S_STALL_O) - ); - - reg CLK; - reg RST; - - assign M_ACK_I = S_ACK_O; - assign M_CLK_I = CLK; - assign M_DAT_I = S_DAT_O; - assign M_RST_I = RST; - assign M_STALL_I = S_STALL_O; - - assign S_CLK_I = CLK; - assign S_ADR_I = M_ADR_O[17:0]; /* Ignore 2 topmost bits */ - assign S_DAT_I = M_DAT_O; - assign S_RST_I = RST; - assign S_STB_I = M_STB_O && M_CYC_O; - assign S_WE_I = M_WE_O; - - integer i, j; - reg [17:0] address; - reg [15:0] expected_value; - - reg [19:0] words_to_verify[`WORDS_TO_VERIFY_COUNT * 2 - 1 : 0]; - - initial begin - CLK <= 0; - RST <= 1; - - for (i = 0; i < 3500; i++) begin - #1; - - CLK <= ~CLK; - - if (CLK) - RST <= 0; - - if (M_finished) begin - $readmemh("words_to_verify.mem", words_to_verify, - 0, `WORDS_TO_VERIFY_COUNT * 2 - 1); - - for (j = 0; j < `WORDS_TO_VERIFY_COUNT; j++) begin - /* - * Byte-grained addresses are used in CPU, and we also use - * them in tclasm opcodes and in files with words for - * verification. Slaves and wishbone address 16-bit words, not - * single bytes. We need to drop the lowest bit here. - */ - address = words_to_verify[2 * j][19:1]; - expected_value = words_to_verify[2 * j + 1]; - if (slave.memory[address] !== expected_value) begin - `MSG(("error: expected h%x at h%x, but got h%x", - expected_value, address, slave.memory[address])); - end - end - - $finish; - end // if (M_finished) - end // for (i = 0; i < 3500; i++) - - $display("error: cpu hasn't finished its operations in 1750 ticks"); - $finish; - end // initial begin -endmodule // stack_machine_test diff --git a/tests/stack_machine_store/words_to_verify.mem b/tests/stack_machine_store/words_to_verify.mem deleted file mode 100644 index 9056a1b..0000000 --- a/tests/stack_machine_store/words_to_verify.mem +++ /dev/null @@ -1,3 +0,0 @@ -// address value - 7579A BEEF - 7579C DEAD diff --git a/tests/stack_machine_sub/instructions.s.tcl b/tests/stack_machine_sub/instructions.s.tcl deleted file mode 100755 index 3f8fb48..0000000 --- a/tests/stack_machine_sub/instructions.s.tcl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -### store 2 values to memory, load them back, substract them and store the -### result; this is analogous to addition test - -set_sp h7FFFC -const 68996288 -store@ h1EEE0 -const 540904416 -store@ h1EEE4 - -load@ h1EEE0 -stack down -load@ h1EEE4 -# substracting 540904416 from 68996288 should yield -471908128 -sub -stack up -store@ h1EEE8 -halt diff --git a/tests/stack_machine_sub/test.v b/tests/stack_machine_sub/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_sub/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_sub/words_to_verify.mem b/tests/stack_machine_sub/words_to_verify.mem deleted file mode 100644 index cc666fa..0000000 --- a/tests/stack_machine_sub/words_to_verify.mem +++ /dev/null @@ -1,9 +0,0 @@ -// address value - 1EEE0 CCC0 // 68996288 in hex is 41CCCC0 - 1EEE2 41C - - 1EEE4 8BE0 // 540904416 in hex is 203D8BE0 - 1EEE6 203D - - 1EEE8 40E0 // -471908128 in hex is E3DF40E0 - 1EEEA E3DF diff --git a/tests/stack_machine_swap/instructions.s.tcl b/tests/stack_machine_swap/instructions.s.tcl deleted file mode 100755 index c17314e..0000000 --- a/tests/stack_machine_swap/instructions.s.tcl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -set_sp h7FFFC -const h00AD00DE -stack down -const h00EF00BE -swap -## Because values were swapped, h00AD00DE should get written, first, at lower -## address (h100) and h00EF00BE should be written next (at h104) -store@ h00100 -stack down -store@ h00104 -halt diff --git a/tests/stack_machine_swap/test.v b/tests/stack_machine_swap/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_swap/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_swap/words_to_verify.mem b/tests/stack_machine_swap/words_to_verify.mem deleted file mode 100644 index 669219d..0000000 --- a/tests/stack_machine_swap/words_to_verify.mem +++ /dev/null @@ -1,5 +0,0 @@ -// address value - 00100 DE - 00102 AD - 00104 BE - 00106 EF diff --git a/tests/stack_machine_tee/instructions.s.tcl b/tests/stack_machine_tee/instructions.s.tcl deleted file mode 100755 index e75b564..0000000 --- a/tests/stack_machine_tee/instructions.s.tcl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env tclsh - -source tclasm.tcl - -set_sp h7FFFC -const hABCDEF -stack down -const hA98765 -tee -## hA98765 should now be replaced with hABCDEF - we should have -## two hABCDEF's on stack - let's store them for verification -store@ h00100 -stack up -store@ h00104 -halt diff --git a/tests/stack_machine_tee/test.v b/tests/stack_machine_tee/test.v deleted file mode 120000 index f5b6a59..0000000 --- a/tests/stack_machine_tee/test.v +++ /dev/null @@ -1 +0,0 @@ -../stack_machine_store/test.v \ No newline at end of file diff --git a/tests/stack_machine_tee/words_to_verify.mem b/tests/stack_machine_tee/words_to_verify.mem deleted file mode 100644 index 961f9dc..0000000 --- a/tests/stack_machine_tee/words_to_verify.mem +++ /dev/null @@ -1,5 +0,0 @@ -// address value - 00100 CDEF - 00102 AB - 00104 CDEF - 00106 AB -- cgit v1.2.3