Commit 841f4296 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

partially corrected addressing

parent eee39d02
......@@ -176,8 +176,10 @@ bne(s:[16], t:[16], imm:[16], PC:[16]) = new_PC:[16] where
end where
j(label:[26], PC:[32]) = new_PC:[32] where
(* le compilateur assembleur rajoute 0x00400024 par défaut *)
new_PC = sub<32>(PC[0..3].label.00, 0x00400024)
(* le compilateur assembleur rajoute 0x00400024 par défaut
normalement on devrait enlever 0x00400024 mais ça enlève
1 en trop *)
new_PC = sub<32>(PC[0..3].label.00, 0x00400023)
end where
type_i(opcode:[6],
......@@ -199,11 +201,12 @@ type_i(opcode:[6],
new_PC_v1 = multi_mux<16>(opcode[5], o_bne, o_beq) ;
new_PC_v2 = multi_mux<16>(opcode[3], new_PC_v1, o_bltz) ;
(inc_PC, c) = add<16>(PC, 0b0000000000000001, 0) ;
write_enable = opcode[2] ;
write_address = multi_mux<5>(opcode[5], rs, rt) ;
write_value = multi_mux<16>(opcode[5], o_lui, o_addi) ;
new_PC = multi_mux<16>(opcode[2], PC, new_PC_v2)
new_PC = multi_mux<16>(opcode[2], inc_PC, new_PC_v2)
end where
type_r(s:[16],
......@@ -266,7 +269,9 @@ ops_to_do() = o:[ops_nbr_length] where
end where
ops_done() = ops:[ops_nbr_length] where
(ops, c) = add<ops_nbr_length>(ram<1, ops_nbr_length>(0, 1, 0, ops), 0b000000000, 1)
(ops, c) = add<ops_nbr_length>(ram<1, ops_nbr_length>(0, 1, 0, ops),
0b000000000,
1)
end where
(* -------------------------- PROGRAMME PRINCIPAL -------------------------- *)
......@@ -308,16 +313,21 @@ execute_command(command:[32], old_PC:[32]) = (t0:[16],
write_address,
write_value) ;
(PC, c) = add<32>(old_PC, 0b00000000000000000000000000000100, 0) ;
(* En théorie on devrait faire ça mais en pratique PC est décalé de 1 octet
(PC, c) = add<32>(old_PC, 0b00000000000000000000000000000100, 0) ; *)
(* la valeur ajoutée à PC dans les branchements est divisée par 4 dans le code
assembleur compilé pour gagner 2 bits *)
(* la valeur ajoutée à PC dans les branchements est divisée par 4 dans le
code assembleur compilé pour gagner 2 bits *)
(write_enable_I,
write_address_I,
write_value_I,
new_PC_I) = type_i(opcode, rs, rs_val, rt, rt_val, imm, PC[14..29]) ;
new_PC_I) = type_i(opcode,
rs, rs_val,
rt, rt_val,
imm,
old_PC[14..29]) ;
write_value_R = type_r(rs_val, rt_val, shamt, funct) ;
new_PC_J = j(pseudo_address, PC) ;
new_PC_J = j(pseudo_address, old_PC) ;
J = opcode[4] & not(opcode[5]) ;
......@@ -326,9 +336,12 @@ execute_command(command:[32], old_PC:[32]) = (t0:[16],
write_enable = mux(J, 0, mux(I, write_enable_I, 1)) ;
write_address = multi_mux<5>(I, write_address_I, rd) ;
write_value = multi_mux<16>(I, write_value_I, write_value_R) ;
(inc_PC, c) = add<32>(old_PC, 0b00000000000000000000000000000100, 0) ;
new_PC = multi_mux<32>(J + I,
multi_mux<32>(J, new_PC_J, PC[..13].new_PC_I.00),
PC)
multi_mux<32>(J,
new_PC_J,
old_PC[..13].new_PC_I.00),
inc_PC)
end where
main() = (t0:[16],
......
This diff is collapsed.
Supports Markdown
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