From a0e9d28f2a21cc42dff7ed2fce3e52cb04bc5170 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Mon, 23 Nov 2020 11:22:19 +0100 Subject: add unsigned division remainder instruction --- design/stack_machine.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'design') diff --git a/design/stack_machine.v b/design/stack_machine.v index f68421e..13e55c1 100644 --- a/design/stack_machine.v +++ b/design/stack_machine.v @@ -286,6 +286,10 @@ module stack_machine_new assign instr_uge = !set_im && !use_im && stack_shrinks_by_1 && instruction[11:0] == 12'd15; + wire instr_urem; + assign instr_urem = !set_im && !use_im && stack_shrinks_by_1 && + instruction[11:0] == 12'd16; + wire instr_ret; assign instr_ret = !set_im && !use_im && stack_shrinks_by_1 && instruction[11:0] == 12'b000010000000; @@ -326,7 +330,7 @@ module stack_machine_new reg arithmetic_uncompleted; wire arithmetic_completes; - assign arithmetic_completes = instr_udiv ? div_done : + assign arithmetic_completes = instr_udiv || instr_urem ? div_done : instr_halt ? 0 : 1; @@ -611,6 +615,9 @@ module stack_machine_new if (instr_udiv && arithmetic_uncompleted) r1 <= div_quotient; + if (instr_urem && arithmetic_uncompleted) + r1 <= div_remainder; + if (instr_mul && arithmetic_uncompleted) r1 <= r0 * r1; @@ -687,6 +694,7 @@ module stack_machine_new instr_ugt ? "ugt" : instr_ge ? "ge" : instr_uge ? "uge" : + instr_urem ? "urem" : instr_ret ? "ret" : instr_cond_jump ? "cond_jump" : instr_cond_jump_n ? "cond_jump_n" : -- cgit v1.2.3