-
Notifications
You must be signed in to change notification settings - Fork 1
/
proj5.ucode
65 lines (65 loc) · 3.93 KB
/
proj5.ucode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fetch0: a_sel=7, b_sel=7, alu_sel=AND, r6_write, mar_sel=LOAD;
fetch1: a_sel=6, c_in, alu_sel=ADDA, r7_write, ir0_sel=LOAD, read, if wait then goto fetch1 endif;
fetch2: a_sel=7, b_sel=7, alu_sel=AND, r6_write, mar_sel=LOAD;
fetch3: a_sel=6, c_in, alu_sel=ADDA, r7_write, ir1_sel=LOAD, read, if wait then goto fetch3 endif;
switch: goto opcode[IR_OPCODE];
opcode[0]: goto fetch0;
opcode[1]: ri_sel, result_sel=IR_CONST8, goto fetch0;
opcode[2]: r7_write, rj_sel, alu_sel=ADDA, goto fetch0;
opcode[3]: ri_sel, rj_sel, rk_sel, alu_sel=ADD, goto fetch0;
opcode[4]: r6_write, rj_sel, rk_sel, alu_sel=SUB,c_in, goto opcodeBE.1;
opcode[5]: r6_write, result_sel=IR_CONST8, goto opcodeJI.1;
opcode[6]: goto opcode[6];
opcode[7]: r6_write, result_sel=IR_CONST4, goto opcodeLDM.1;
opcode[8]: r6_write, result_sel=IR_CONST4, goto opcodeSWM.1;
opcode[9]: r6_write, result_sel=IR_CONST4, goto opcodeADDM.1;
opcode[10]: r6_write, result_sel=IR_CONST4, goto opcodeSUBM.1;
opcode[11]: r6_write, result_sel=IR_CONST4, goto opcodeADDI.1;
opcode[12]: ri_sel, rj_sel, alu_sel=ADDA, goto fetch0;
opcode[13]: r6_write, a_sel=6, b_sel=6, alu_sel=XOR, goto opcodeDIV.1;
opcode[14]: r6_write, result_sel=IR_CONST4, goto opcodeDIV.2;
opcode[15]: r4_write, result_sel=IR_CONST8, goto fetch0;
opcode[16]: r6_write, result_sel=IR_CONST8, goto memr6readri;
opcode[17]: r6_write, result_sel=IR_CONST4, goto rkstorememr6;
opcode[18]: r6_write, result_sel=IR_CONST4, goto opcodeSUBI.1;
opcode[19]: rj_sel, alu_sel=SUBA, if c_out then goto fetch0 else goto branchconst4 endif;
opcode[20]: ri_sel, rj_sel, rk_sel, alu_sel=AND, goto fetch0;
opcode[21]: rj_sel, alu_sel=SUBA, if c_out then goto branchconst4 else goto fetch0 endif;
opcodeSUBI.1: ri_sel, rj_sel, b_sel=6, alu_sel=SUB,c_in, goto fetch0;
opcodeBE.1: a_sel=6, alu_sel=SUBA, if c_out then goto fetch0 else goto branchconst4 endif;
opcodeJI.1: r7_write, a_sel=7, b_sel=6, alu_sel=ADD, goto fetch0;
opcodeLDM.1: r6_write, rj_sel, b_sel=6, alu_sel=ADD, goto memr6readri;
opcodeSWM.1: r6_write, rj_sel, b_sel=6, alu_sel=ADD, goto rkstorememr6;
opcodeADDM.1: r6_write, a_sel=6, rk_sel, alu_sel=ADD;
mar_sel=LOAD,a_sel=6, b_sel=6, alu_sel=AND;
opcodeADDM.2: mdr_sel=LOAD_MEM, read, if wait then goto opcodeADDM.2 endif;
r6_write, result_sel=MDR;
ri_sel, rj_sel, b_sel=6, alu_sel=ADD, goto fetch0;
opcodeSUBM.1: r6_write, a_sel=6, rk_sel, alu_sel=ADD;
mar_sel=LOAD,a_sel=6,b_sel=6, alu_sel=AND, ;
opcodeSUBM.2: mdr_sel=LOAD_MEM, read, if wait then goto opcodeSUBM.2 endif;
r6_write, result_sel=MDR;
ri_sel, rj_sel, b_sel=6, alu_sel=SUB,c_in, goto fetch0;
opcodeADDI.1: ri_sel, rj_sel, b_sel=6, alu_sel=ADD, goto fetch0;
opcodeDIV.1: r6_write, a_sel=6, rk_sel, alu_sel=OR;
opcodeDIV.2: r6_write, a_sel=6, alu_sel=SUBA, if c_out then goto opcodeDIV.3 else goto opcode[6] endif;
opcodeDIV.3: r6_write, a_sel=6, alu_sel=SUBA, if c_out then goto opcodeDIV.4 else goto opcode[6] endif;
opcodeDIV.4: a_sel=6, alu_sel=SUBA, if c_out then goto opcodeDIV.5 else goto opcodeDIV.LOOKUP endif;
opcodeDIV.5: r6_write, a_sel=6, alu_sel=SUBA, if c_out then goto opcodeDIV.6 else goto opcode[6] endif;
opcodeDIV.6: r6_write, a_sel=6, alu_sel=SUBA, if c_out then goto opcodeDIV.7 else goto opcode[6] endif;
opcodeDIV.7: a_sel=6, alu_sel=SUBA, if c_out then goto opcode[6] else goto opcodeDIV.8 endif;
opcodeDIV.8: r6_write, a_sel=6, alu_sel=ADDA,c_in;
opcodeDIV.LOOKUP: r6_write, a_sel=6, b_sel=4, alu_sel=ADD;
r6_write, rj_sel, b_sel=6, alu_sel=ADD;
r6_write, rj_sel, b_sel=6, alu_sel=ADD;
goto memr6readri;
branchconst4: r6_write, result_sel=IR_CONST4;
r6_write, a_sel=6, b_sel=6, alu_sel=ADD;
r7_write, a_sel=7, b_sel=6, alu_sel=ADD, goto fetch0;
memr6readri: mar_sel=LOAD,a_sel=6,b_sel=6, alu_sel=AND;
memread: mdr_sel=LOAD_MEM, read, if wait then goto memread endif;
ri_sel, result_sel=MDR, goto fetch0;
rkstorememr6: mar_sel=LOAD,a_sel=6,b_sel=6, alu_sel=AND;
r5_write, a_sel=5, b_sel=5, alu_sel=XOR;
mdr_sel=LOAD_ALU,a_sel=5,rk_sel, alu_sel=OR;
memwrite: write, if wait then goto memwrite else goto fetch0 endif;