-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimem.mif
145 lines (143 loc) · 6.45 KB
/
imem.mif
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
-- null
DEPTH = 4096;
WIDTH = 32;
ADDRESS_RADIX = DEC;
DATA_RADIX = BIN;
CONTENT
BEGIN
-- nop # 0
0000 : 00000000000000000000000000000000;
-- nop # 1
0001 : 00000000000000000000000000000000;
-- addi $1, $0, 1 # 2, r1 = 1
0002 : 00101000010000000000000000000001;
-- j 5 # 3
0003 : 00001000000000000000000000000101;
-- addi $1, $1, 1 # 4, r1 = r1 + 1
0004 : 00101000010000100000000000000001;
-- addi $1, $1, 2 # 5, r1 = r1 + 2
0005 : 00101000010000100000000000000010;
-- addi $5, $0, 0 # 6, r5 = 0
0006 : 00101001010000000000000000000000;
-- j 9 # 7
0007 : 00001000000000000000000000001001;
-- add $5, $5, $1 # 8, r5 = r5 + r1 = 3, or r5 = 4
0008 : 00000001010010100001000000000000;
-- add $5, $5, $1 # 9, if correct, r5 = 3 , else error Check r5 = 3
0009 : 00000001010010100001000000000000;
-- addi $2, $0, 1 # 10, r2 = 1
0010 : 00101000100000000000000000000001;
-- addi $3, $0, 1 # 11, r3 = 1
0011 : 00101000110000000000000000000001;
-- addi $4, $0, 0 # 12, r4 = 0
0012 : 00101001000000000000000000000000;
-- bne $2, $3, 1 # 13, r2 == r3, no branch(correct)
0013 : 00010000100001100000000000000001;
-- addi $4, $4, 1 # 14, r4 = r4 + 1 = 1
0014 : 00101001000010000000000000000001;
-- addi $4, $4, 1 # 15, if r4 = r4 + 1 = 2(correct), else r4 = 1 (error) Check r4 = 2
0015 : 00101001000010000000000000000001;
-- addi $6, $0, 0 # 16, r4 = 0
0016 : 00101001100000000000000000000000;
-- bne $2, $0, 1 # 17, r2 != r0, branch
0017 : 00010000100000000000000000000001;
-- addi $6, $6, 1 # 18, r6 = r6 + 1 (error)
0018 : 00101001100011000000000000000001;
-- addi $6, $6, 1 # 19, if r6 = 1 (correct), else r6 = 2 (error) Check r6 = 1
0019 : 00101001100011000000000000000001;
-- addi $12, $0, 0 # 20
0020 : 00101011000000000000000000000000;
-- addi $13, $0, 0 # 21
0021 : 00101011010000000000000000000000;
-- jal 24 # 22
0022 : 00011000000000000000000000011000;
-- addi $12, $12, 1 # 23
0023 : 00101011000110000000000000000001;
-- addi $12, $12, 1 # 24, if r12 = 1(correct), else r12 = 2(error) Check r12 = 1
0024 : 00101011000110000000000000000001;
-- add $13, $0, $31 # 25, r13 = r31 = 23. r13 shoule be 23 Check r13 = 23
0025 : 00000011010000011111000000000000;
-- addi $14, $0, 0 # 26
0026 : 00101011100000000000000000000000;
-- addi $15, $0, 30 # 27
0027 : 00101011110000000000000000011110;
-- jr $15 # 28
0028 : 00100011110000000000000000000000;
-- addi $14, $14, 1 # 29
0029 : 00101011100111000000000000000001;
-- addi $14, $14, 1 # 30, r14 = 1 (correct), r14 = 2(error) Check r14 = 1
0030 : 00101011100111000000000000000001;
-- addi $8, $0, 0 # 31, r8 = 0
0031 : 00101010000000000000000000000000;
-- addi $9, $0, 1 # 32, r9 = 1
0032 : 00101010010000000000000000000001;
-- addi $11, $0, 2 # 33, r11 = 2
0033 : 00101010110000000000000000000010;
-- jal 39 # 34, suppose correct
0034 : 00011000000000000000000000100111;
-- addi $7, $0, 43 # 35
0035 : 00101001110000000000000000101011;
-- sub $8, $8, $9 # 36
0036 : 00000010000100001001000000000100;
-- add $10, $8, $9 # 37
0037 : 00000010100100001001000000000000;
-- jr $7 # 38
0038 : 00100001110000000000000000000000;
-- addi $8, $8, 1 # 39
0039 : 00101010000100000000000000000001;
-- addi $9, $9, 1 # 40
0040 : 00101010010100100000000000000001;
-- add $10, $8, $9 # 41
0041 : 00000010100100001001000000000000;
-- jr $31 # 42 Check r8 = -1, r10 = 1
0042 : 00100111110000000000000000000000;
-- addi $16, $0, 1 # 43, r16 = 1
0043 : 00101100000000000000000000000001;
-- addi $17, $0, 1 # 44, r17 = 1
0044 : 00101100010000000000000000000001;
-- addi $18, $0, 0 # 45, r18 = 0
0045 : 00101100100000000000000000000000;
-- blt $16, $17, 1 # 46, r16 == r17, no branch(correct)
0046 : 00110100001000100000000000000001;
-- addi $18, $18, 1 # 47, r18 = r18 + 1 = 1
0047 : 00101100101001000000000000000001;
-- addi $18, $18, 1 # 48, if r18 = r18 + 1 = 2(correct), else r18 = 1 (error) Check r18 = 2
0048 : 00101100101001000000000000000001;
-- addi $19, $0, 0 # 49, r19 = 0
0049 : 00101100110000000000000000000000;
-- blt $0, $16, 1 # 50, r0 < r16, branch
0050 : 00110000001000000000000000000001;
-- addi $19, $19, 1 # 51, r19 = r19 + 1 (error)
0051 : 00101100111001100000000000000001;
-- addi $19, $19, 1 # 52, if r19 = 1 (correct), else r19 = 2 (error) Check r19 = 1
0052 : 00101100111001100000000000000001;
-- addi $20, $0, 0 # 53, r20 = 0
0053 : 00101101000000000000000000000000;
-- blt $16, $0, 1 # 54, r0 < r16, branch
0054 : 00110100000000000000000000000001;
-- addi $20, $20, 1 # 55, r20 = r20 + 1 (correct)
0055 : 00101101001010000000000000000001;
-- addi $20, $20, 1 # 56, if r20 = 2 (correct), else r20 = 1 (error) Check r20 = 2
0056 : 00101101001010000000000000000001;
-- setx 1 # 57, rstatus = 1
0057 : 10101000000000000000000000000001;
-- addi $21, $0, 1 # 58, r21 = 1
0058 : 00101101010000000000000000000001;
-- bex 61 # 59, rstatus != 0 , PC = 61
0059 : 10110000000000000000000000111101;
-- addi $21, $21, 1 # 60, r21 = 1 + 1 = 2
0060 : 00101101011010100000000000000001;
-- addi $21, $21, 1 # 61, if r21 = 1 + 1 = 2(correct) else r21 = 2 + 1 = 3 Check r21 = 2
0061 : 00101101011010100000000000000001;
-- setx 0 # 62, rstatus = 0
0062 : 10101000000000000000000000000000;
-- addi $22, $0, 1 # 63, r22 = 1
0063 : 00101101100000000000000000000001;
-- bex 66 # 64, rstatus == 0, no branch
0064 : 10110000000000000000000001000010;
-- addi $22, $22, 1 # 65, r22 = 2
0065 : 00101101101011000000000000000001;
-- addi $22, $22, 1 # 66, r22 = 3(correct) Check r22 = 3
0066 : 00101101101011000000000000000001;
[0067 .. 4095] : 00000000000000000000000000000000;
END;