Commit d93a7b80 authored by Martin Pépin's avatar Martin Pépin
Browse files

tabs -> spaces

parent 44b8d48f
......@@ -7,57 +7,57 @@ require ALU/utils
*)
ALU(input1:[32], input2:[32], alu_control:[4], alu_op:[3], use_shamt,
shamt:[5], constant:[16]) = (alu_zero, result:[32]) where
shamt:[5], constant:[16]) = (alu_zero, result:[32]) where
R_format = equal_zero_n<3>(alu_op);
result =
mux(R_format,
mux(alu_control[0], (* if 1 then shift or HI/Lo, else logical or artih*)
mux(alu_control[2], (* if 1 then HI/LO, else logical shift *)
mux(alu_control[3], (* Case HI/LO *)
read_HI(), (*TODO*)
read_LO()
), (*TODO*)
mux(alu_control[1], (* Case logical shift *) (*TODO : optimiser use_shamt ?*)
mux(use_shamt,
shift_by_shamt_ALU(input1, shamt, 1, alu_control[3]),
shift:_by_reg_ALU(input1, input2, 1, alu_control[3])
),
mux(use_shamt, (* Case logical shift left *)
shift_by_shamt_ALU(input1, shamt, 0, 0),
shift_by_reg_ALU(input1, input2, 0, 0)
)
)
),
mux(alu_control[1], (*if 1 then logical else arihtmetical *)
mux(alu_control[2],
mux(alu_control[3],
xor_ALU(input1, input2),
nor_ALU(input1, input2)
),
mux(alu_control[3],
or_ALU(input1, input2),
and_ALU(input1, input2)
)
),
mux(alu_control[2],
mux(alu_control[3],
(*TODO : multiplication et division*)
zero_n<32>(),
zero_n<32>()
),
add_ALU(input1, input2, alu_control[3]),
)
)
),
(*TODO : opérations pas format R *)
zero_n<32>()
);
alu_zero = equal_zero_n<32>(result);
result =
mux(R_format,
mux(alu_control[0], (* if 1 then shift or HI/Lo, else logical or artih*)
mux(alu_control[2], (* if 1 then HI/LO, else logical shift *)
mux(alu_control[3], (* Case HI/LO *)
read_HI(), (*TODO*)
read_LO()
), (*TODO*)
mux(alu_control[1], (* Case logical shift *) (*TODO : optimiser use_shamt ?*)
mux(use_shamt,
shift_by_shamt_ALU(input1, shamt, 1, alu_control[3]),
shift:_by_reg_ALU(input1, input2, 1, alu_control[3])
),
mux(use_shamt, (* Case logical shift left *)
shift_by_shamt_ALU(input1, shamt, 0, 0),
shift_by_reg_ALU(input1, input2, 0, 0)
)
)
),
mux(alu_control[1], (*if 1 then logical else arihtmetical *)
mux(alu_control[2],
mux(alu_control[3],
xor_ALU(input1, input2),
nor_ALU(input1, input2)
),
mux(alu_control[3],
or_ALU(input1, input2),
and_ALU(input1, input2)
)
),
mux(alu_control[2],
mux(alu_control[3],
(*TODO : multiplication et division*)
zero_n<32>(),
zero_n<32>()
),
add_ALU(input1, input2, alu_control[3]),
)
)
),
(*TODO : opérations pas format R *)
zero_n<32>()
);
alu_zero = equal_zero_n<32>(result);
end where
......@@ -34,37 +34,37 @@ end where
(* logical shifts *)
shift_by_const_n<n, m, shift_val>(input:[n], cst:[m], is_right, keep_sign) =
(out:[n]) where
if n + 1 <= (2 * shift_val) then (* remarque : seul <= est implémenté... *)
aux = mux(cst[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, n>(aux, cst[..m-2], is_right, keep_sign);
(out:[n]) where
if n + 1 <= (2 * shift_val) then (* remarque : seul <= est implémenté... *)
aux = mux(cst[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, n>(aux, cst[..m-2], is_right, keep_sign);
else
aux = mux(cst[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*shift_val>
(aux, cst[..m-2], is_right, keep_sign);
end if
aux = mux(cst[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*shift_val>
(aux, cst[..m-2], is_right, keep_sign);
end if
end where
(* 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)
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], cst:[32], is_right, keep_sign) = (out:[32]) where
out = shift_by_const_n<32, 32, 1>(input, cst, is_right, keep_sign)
out = shift_by_const_n<32, 32, 1>(input, cst, is_right, keep_sign)
end where
(* ------------------------------------------------------------------------- *)
(* Opérations booléennes *)
......@@ -130,7 +130,7 @@ not_n<n>(a:[n]) = (o:[n]) where
end where
nor_ALU(a:[32], b:[32]) = (o:[32]) where
o = not_n<32>(or_ALU(a, b));
o = not_n<32>(or_ALU(a, b));
end where
(* ------------------------------------------------------------------------- *)
......@@ -154,15 +154,15 @@ end where
(* Une fonction pour changer le signe d'une nappe *)
change_sign_n<n>(input:[n]) = (out:[n]) where
value = not_n<n>(input);
(out, flag) = adder_n<n>(value, extand_left_n<1,n-1>(1, 0), 0);
value = not_n<n>(input);
(out, flag) = adder_n<n>(value, extand_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(sub, change_sign_n<32>(b), b), 0);
(o, flag) = adder_n<32>(a, mux(sub, change_sign_n<32>(b), b), 0);
end where
addi_ALU(a:[32], c:[16], sub) = (o:[32]) where
......@@ -190,10 +190,10 @@ end where
(*TODO : changer le calcul pour utiliser la soustraction ?*)
slt_n<n>(a:[n], b:[n]) = (out, fin) where
if n = 1 then
if n = 1 then
fin = a[0]^b[0];
out = b[0]
else
else
(res, e) = slt_n<n-1>(a[..(n-2)], b[..(n-2)]);
fin = mux(e, 1, a[n-1]^b[n-1]);
out = mux(e, res, b[n-1])
......
......@@ -36,17 +36,17 @@ control(instruction:[6]) = (reg_dst, jump, branch, mem_read, mem_to_reg,
mem_to_reg = mem_read;
(* alu_op => cf google doc pour savoir quelles valeurs sont associées avec
quelles instructions
Remarque : la gestion actuelle fait que 000 est attribué aux R-format*)
alu_op =
mux(instruction[0], 1,
mux(instruction[2] & (not instruction[3])), 1, 0) .
mux((instruction[2] & instruction[3]) & (instruction[4] xor instruction[5]),
1, 0) .
mux((instruction[2] xor instruction[5]) &
not(instruction[0]) &
instruction[3] or instruction[4],
1, 0);
quelles instructions
Remarque : la gestion actuelle fait que 000 est attribué aux R-format*)
alu_op =
mux(instruction[0], 1,
mux(instruction[2] & (not instruction[3])), 1, 0) .
mux((instruction[2] & instruction[3]) & (instruction[4] xor instruction[5]),
1, 0) .
mux((instruction[2] xor instruction[5]) &
not(instruction[0]) &
instruction[3] or instruction[4],
1, 0);
(* mem_write à 1 => mémoire RAM accédée en écriture
......
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