Commit cb6a528d authored by Noémie Fong's avatar Noémie Fong
Browse files

Fix logical shifts

parent efa54754
......@@ -32,22 +32,32 @@ extand_const_n<n, offset>(c:[n]) = (o:[n + offset]) where
end where
shift_by_shamt_n<n, m, shift_val>(input:[n], shamt:[m], is_right, keep_sign) =
(* logical shifts *)
shift_by_const_n<n, m, shift_val>(input:[n], const:[m], is_right, keep_sign) =
(out:[n]) where
aux = mux(shamt[m-1],
aux = mux(const[m-1],
mux(is_right,
extand_right_n<n - shift_val, shift_val>
(input[..(n-1) - shift_val], mux(keep_sign, input[0])),
extand_left_n<n - shift_val, shift_val>
(input[shift_val..])),
input);
out = shift_by_const_n<n, m-1, 2*m>(aux, shamt[..m-2], is_right, keep_sign);
if 2 * shift_val > n then
out = shift_by_const_n<n, m-1, n>(aux, const[..m-2], is_right, keep_sign);
else
out = shift_by_const_n<n, m-1, 2*shift_val>
(aux, const[..m-2], is_right, keep_sign);
end where
shift_by_shamt(input:[32], shamt:[5], is_right, keep_sign) = (out:[32]) where
out = shift_by_shamt_n<32, 5, 1>(input, shamt, is_right, keep_sign)
(* shift by shamt, either to the right or to the left. Arithmetic or not.*)
shift_by_shamt_ALU(input:[32], shamt:[5], is_right, keep_sign) = (out:[32]) where
out = shift_by_const_n<32, 5, 1>(input, shamt, is_right, keep_sign)
end where
(* shift by value stored in reg, to the right or left, arithmetic or not *)
shift_by_reg_ALU(input:[32], const:[32], is_right, keep_sign) = (out:[32]) where
out = shift_by_const_n<32, 32, 1>(input, const, is_right, keep_sign)
(* ------------------------------------------------------------------------- *)
(* Opérations booléennes *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment