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

add logical shift by shamt

parent 42265301
......@@ -32,6 +32,21 @@ 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) =
(out:[n]) where
aux = mux(shamt[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);
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)
end where
(* ------------------------------------------------------------------------- *)
(* Opérations booléennes *)
......@@ -126,14 +141,12 @@ end where
(* Fonction d'addition, qui fait la soustraction si le drapeau vaut 1 *)
(* flag est le drapeau d'overflow, sub le drapeau de soustraction *)
add_ALU(a:[32], b:[32], sub) = (o:[32], flag) where
add_ALU(a:[32], b:[32], sub) = (o:[32]) where
(o, flag) = adder_n<32>(a, mux(sub, change_sign_n<32>(b), b), 0);
zero = equal_zero_n<32>(o);
end where
addi_ALU(a:[32], c:[16], sub) = (o:[32], flag) where
addi_ALU(a:[32], c:[16], sub) = (o:[32]) where
(o, flag) = add_ALU(a, extand_const_n<16,16>(c), sub);
zero = equal_zero_n<32>(o);
end where
(* Une fonction multiplication absolument peu pratique *)
......
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