Fix for LOGICAL_LEFT/RIGHT_SHIFT shift values

Added missing reference model REQUIRE check for shift value (0-31)
Make sure result of LOGICAL_SHIFT_LEFT is masked to input size
Fixed test generation to produce shift values in that range

Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: Id511de0d989ea954fc1afd18dc2051341bce2cd0
diff --git a/reference_model/src/ops/ewise_binary.cc b/reference_model/src/ops/ewise_binary.cc
index 287ad92..7f30e30 100644
--- a/reference_model/src/ops/ewise_binary.cc
+++ b/reference_model/src/ops/ewise_binary.cc
@@ -281,16 +281,27 @@
 template <int Rank, DType Dtype>
 int OpLogicalLeftShift<Rank, Dtype>::register_fcn()
 {
+    int32_t num_bits = 0;
     switch (Dtype)
     {
         case DType_INT8:
+            num_bits = 8;
+            break;
         case DType_INT16:
+            num_bits = 16;
+            break;
         case DType_INT32:
-            this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a << b; };
+            num_bits = 32;
             break;
         default:
             ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
     }
+    this->fcn = [this, num_bits](InEigenType a, InEigenType b) -> OutEigenType {
+        uint32_t mask = ONES_MASK(num_bits);
+        REQUIRE(b >= 0 && b <= 31, "OpLogicalLeftShift: shift value %d is out of valid range [0, 31]",
+        (int32_t)b);
+        return (a << b) & mask;
+    };
 
     return 0;
 }
@@ -314,8 +325,10 @@
             ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
     }
 
-    this->fcn = [num_bits](InEigenType a, InEigenType b) -> OutEigenType {
+    this->fcn = [this, num_bits](InEigenType a, InEigenType b) -> OutEigenType {
         uint32_t mask = ONES_MASK(num_bits) >> b;
+        REQUIRE(b >= 0 && b <= 31, "OpLogicalRightShift: shift value %d is out of valid range [0, 31]",
+        (int32_t)b);
         return (a >> b) & mask;
     };