From 40a11a7155bc474d85ded1fef183baae2007f101 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Sat, 5 Sep 2020 16:43:32 +0200 Subject: add tee instruction together with bench --- Makefile | 3 ++- design/stack_machine.v | 12 ++++++++++-- tclasm.tcl | 5 +++++ tests/stack_machine_tee/instructions.s.tcl | 14 ++++++++++++++ tests/stack_machine_tee/test.v | 1 + tests/stack_machine_tee/words_to_verify.mem | 4 ++++ 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100755 tests/stack_machine_tee/instructions.s.tcl create mode 120000 tests/stack_machine_tee/test.v create mode 100644 tests/stack_machine_tee/words_to_verify.mem diff --git a/Makefile b/Makefile index dfc8aab..8f4e729 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ STACK_MACHINE_OLD_TESTS := \ STACK_MACHINE_TESTS := \ store \ load_store \ - multiinstructions_load_store + multiinstructions_load_store \ + tee # Add other tests here if You need TESTS := \ diff --git a/design/stack_machine.v b/design/stack_machine.v index d0ca36b..04b1285 100644 --- a/design/stack_machine.v +++ b/design/stack_machine.v @@ -183,9 +183,14 @@ module stack_machine_new assign instr_set_sp = use_im && stack_same_size && instruction[11:7] == 5'd0; - /* Instructions, that grom stack */ + /* Instructions, that grow stack */ + wire instr_tee; + assign instr_tee = !set_im && !use_im && stack_grows && + instruction[11:0] == 12'd0; + wire instr_const; - assign instr_const = use_im && stack_grows && instruction[11:7] == 5'd0; + assign instr_const = use_im && stack_grows && + instruction[11:7] == 5'd0; /* Instructions, that shrink stack */ /* none now */ @@ -423,6 +428,9 @@ module stack_machine_new if (instr_const && first_execution_tick) r1 <= im_effective; + if (instr_tee) + r1 <= r1; + if (instr_set_sp) `SET_SP(im_effective); end // case: STEP_EXECUTING diff --git a/tclasm.tcl b/tclasm.tcl index fd45456..c00fe18 100644 --- a/tclasm.tcl +++ b/tclasm.tcl @@ -91,6 +91,11 @@ proc const {value} { } +proc tee {} { + puts 0001000000000000 +} + + proc _store {address_part} { puts 011111100[__to_binary $address_part 7] } diff --git a/tests/stack_machine_tee/instructions.s.tcl b/tests/stack_machine_tee/instructions.s.tcl new file mode 100755 index 0000000..98117c7 --- /dev/null +++ b/tests/stack_machine_tee/instructions.s.tcl @@ -0,0 +1,14 @@ +#!/usr/bin/env tclsh + +source tclasm.tcl + +### All three stores should write the hABCDEF + +set_sp 0 +const hABCDEF +tee +store h000100 +tee +store h000200 +store h000300 +halt diff --git a/tests/stack_machine_tee/test.v b/tests/stack_machine_tee/test.v new file mode 120000 index 0000000..f5b6a59 --- /dev/null +++ b/tests/stack_machine_tee/test.v @@ -0,0 +1 @@ +../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 new file mode 100644 index 0000000..6be240d --- /dev/null +++ b/tests/stack_machine_tee/words_to_verify.mem @@ -0,0 +1,4 @@ +// address value + 00100 ABCDEF + 00200 ABCDEF + 00300 ABCDEF -- cgit v1.2.3