Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Pepin
sysdig
Commits
efa54754
Commit
efa54754
authored
Jan 14, 2017
by
Noémie Fong
Browse files
add logical shift by shamt
parent
42265301
Changes
1
Hide whitespace changes
Inline
Side-by-side
cpu/src/alu/utils.mj
View file @
efa54754
...
...
@@ -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 *)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment