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
1d615620
Commit
1d615620
authored
Jan 17, 2017
by
Daru13
Browse files
Commented away useless code to make the ALU netlist much smaller!
parent
e43a6bc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
cpu/src/alu/main.mj
View file @
1d615620
...
...
@@ -8,7 +8,7 @@ require alu/utils
*)
ALU(input1:[32], input2:[32], alu_control:[4]) = (alu_zero, result:[32]) where
result
_aux
=
result =
mux_n<word>(alu_control[0], (* if 1 then shift or HI/Lo, else logical or artih*)
(* 1... *)
mux_n<word>(alu_control[2], (* if 1 then HI/LO, else logical shift *)
...
...
@@ -50,6 +50,8 @@ ALU(input1:[32], input2:[32], alu_control:[4]) = (alu_zero, result:[32]) where
)
)
);
(* Inutilisée par l'ALU
(* Traitement de la multiplication *)
write_hilo = equal_n<3>(0.0.1, alu_control[..2]);
read_hilo = alu_control[0] & alu_control[2];
...
...
@@ -61,6 +63,10 @@ ALU(input1:[32], input2:[32], alu_control:[4]) = (alu_zero, result:[32]) where
result_aux,
mux_n<word>(alu_control[3], hi_val, lo_val)
);
(* Signal pour les branchements *)
alu_zero = equal_zero_n<32>(result);
*)
(* Signal pour les branchements *)
alu_zero = equal_zero_n<32>(result);
end where
cpu/src/alu/utils.mj
View file @
1d615620
...
...
@@ -61,6 +61,7 @@ end where
(* ------------------------------------------------------------------------- *)
(* Opérations booléennes *)
(*
or_n<n>(a:[n], b:[n]) = (o:[n]) where
if n = 0 then
o = []
...
...
@@ -68,15 +69,17 @@ or_n<n>(a:[n], b:[n]) = (o:[n]) where
o = (a[0] or b[0]).(or_n<n-1>(a[1..], b[1..]))
end if
end where
*)
or_ALU(a:[32], b:[32]) = (o:[32]) where
o = or_n<32>(a, b)
end where
(* Inutilisée par l'ALU
ori_ALU(a:[32], c:[16]) = (o:[32]) where
o = a[..15].(or_n<16>(a[16..], c))
end where
*)
and_n<n>(a:[n], b:[n]) = (o:[n]) where
if n = 0 then
...
...
@@ -90,10 +93,11 @@ and_ALU(a:[32], b:[32]) = (o:[32]) where
o = and_n<32>(a, b)
end where
(* Inutilisée par l'ALU
andi_ALU(a:[32], c:[16]) = (o:[32]) where
o = a[..15].(and_n<16>(a[16..], c))
end where
*)
xor_n<n>(a:[n], b:[n]) = (o:[n]) where
if n = 0 then
...
...
@@ -107,10 +111,11 @@ xor_ALU(a:[32], b:[32]) = (o:[32]) where
o = xor_n<32>(a, b)
end where
(* Inutilisée par l'ALU
xori_ALU(a:[32], c:[16]) = (o:[32]) where
o = a[..15].(xor_n<16>(a[16..], c))
end where
*)
(* Négation d'une nappe de n fils *)
not_n<n>(a:[n]) = (o:[n]) where
...
...
@@ -126,7 +131,7 @@ nor_ALU(a:[32], b:[32]) = (o:[32]) where
end where
(* ------------------------------------------------------------------------- *)
(*Opérations arithmétiques *)
(*
Opérations arithmétiques *)
fulladder(a,b,c) = (s, r) where
s = (a xor b) xor c;
...
...
@@ -150,13 +155,13 @@ change_sign_n<n>(input:[n]) = (out:[n]) where
(out, flag) = adder_n<n>(value, extend_left_n<1,n-1>(1, 0), 0);
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]) where
(o, flag) = adder_n<32>(a, mux_n<32>(sub, change_sign_n<32>(b), b), 0);
end where
(* Inutilisée par l'ALU
(* Une fonction multiplication absolument peu pratique *)
mul_n<n,m>(a:[n], b:[m], carry:[n-1]) = (o:[n+m]) where
if m = 1 then
...
...
@@ -170,8 +175,7 @@ mul_n<n,m>(a:[n], b:[m], carry:[n-1]) = (o:[n+m]) where
o = (mul_n<n, m-1>(a, b[..m-2], carry_bis)).r;
end if
end where
*)
(* ------------------------------------------------------------------------- *)
(* Comparaisons*)
...
...
@@ -193,6 +197,8 @@ slt_ALU(a:[32], b:[32]) = (o) where
o = mux(a[0]^b[0], a[0], res & fin)
end where
(* Inutilisée par l'ALU
slti_ALU(a:[32], c:[16]) = (o) where
o = slt_ALU(a, extend_const_n<16,16>(c))
end where
*)
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