From e601b9315384792b82517ba3ab30cee316295558 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sun, 8 Jan 2017 19:33:35 -0600 Subject: add ALU test for shift operations --- alu_tb.v | 8 ++++++++ tests/alu | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/alu_tb.v b/alu_tb.v index 7418ea3..31141ce 100644 --- a/alu_tb.v +++ b/alu_tb.v @@ -32,6 +32,14 @@ module alu_tb (); "&" : op = 4; "|" : op = 5; "^" : op = 6; + "<<" : op = 8; + "<<1" : op = 9; + "<<-" : op = 10; + "<<<" : op = 11; + ">>" : op = 12; + "1>>" : op = 13; + "->>" : op = 14; + ">>>" : op = 15; default : op = 0; endcase diff --git a/tests/alu b/tests/alu index 7496359..474acbb 100644 --- a/tests/alu +++ b/tests/alu @@ -8,6 +8,14 @@ # & : and # | : or # ^ : xor +# << : left shift extended with zeros +# <<1 : left shift extended with ones +# <<- : left shift extended with least significant bit +# <<< : left rotate +# >> : right shift extended with zeros +# 1>> : right shift extended with ones +# ->> : right shift extended with most significant bit +# >>> : right rotate 0x0123 + 0x1234 = 0x1357 Z=0 C=0 0x0123 - 0x1234 = 0xeeef Z=0 C=1 @@ -17,3 +25,19 @@ 0xaf74 & 0x7cc7 = 0x2c44 Z=0 C=0 0xaf74 | 0x7cc7 = 0xfff7 Z=0 C=0 0xaf74 ^ 0x7cc7 = 0xd3b3 Z=0 C=0 +0xfa0a << 0x01 = 0xf414 Z=0 C=0 +0xfa0a << 0x02 = 0xe828 Z=0 C=0 +0xfa0a >> 0x02 = 0x3e82 Z=0 C=0 +0xfa0a >> 0x04 = 0x0fa0 Z=0 C=0 +0xfa0a << 0x04 = 0xa0a0 Z=0 C=0 +0xfa0a <<1 0x04 = 0xa0af Z=0 C=0 +0xfa0a 1>> 0x04 = 0xffa0 Z=0 C=0 +0xfa0a <<- 0x04 = 0xa0a0 Z=0 C=0 +0xfa0a ->> 0x04 = 0xffa0 Z=0 C=0 +0xfa0a >>> 0x04 = 0xafa0 Z=0 C=0 +0xfa0a <<< 0x04 = 0xa0af Z=0 C=0 +0x0001 <<- 0x0e = 0x7fff Z=0 C=0 +0x0001 <<- 0x10 = 0xffff Z=0 C=0 +0x0001 ->> 0x10 = 0x0000 Z=1 C=0 +0x0001 <<- 0xff = 0xffff Z=0 C=0 +0x0001 ->> 0xff = 0x0000 Z=1 C=0 -- cgit v1.2.3