OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [two-op_add.v] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
/*===========================================================================*/
2
/* Copyright (C) 2001 Authors                                                */
3
/*                                                                           */
4
/* This source file may be used and distributed without restriction provided */
5
/* that this copyright statement is not removed from the file and that any   */
6
/* derivative work contains the original copyright notice and the associated */
7
/* disclaimer.                                                               */
8
/*                                                                           */
9
/* This source file is free software; you can redistribute it and/or modify  */
10
/* it under the terms of the GNU Lesser General Public License as published  */
11
/* by the Free Software Foundation; either version 2.1 of the License, or    */
12
/* (at your option) any later version.                                       */
13
/*                                                                           */
14
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
15
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
16
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
17
/* License for more details.                                                 */
18
/*                                                                           */
19
/* You should have received a copy of the GNU Lesser General Public License  */
20
/* along with this source; if not, write to the Free Software Foundation,    */
21
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
22
/*                                                                           */
23
/*===========================================================================*/
24
/*                 TWO-OPERAND ARITHMETIC: ADD INSTRUCTION                   */
25
/*---------------------------------------------------------------------------*/
26
/* Test the ADD instruction with all addressing modes                        */
27
/*===========================================================================*/
28
 
29
initial
30
   begin
31
      $display(" ===============================================");
32
      $display("|                 START SIMULATION              |");
33
      $display(" ===============================================");
34
      repeat(5) @(posedge mclk);
35
      stimulus_done = 0;
36
 
37
      // Check reset values
38
      //--------------------------------------------------------
39
      if (r2 !==16'h0000) tb_error("R2  reset value");
40
      if (r3 !==16'h0000) tb_error("R3  reset value");
41
      if (r4 !==16'h0000) tb_error("R4  reset value");
42
      if (r5 !==16'h0000) tb_error("R5  reset value");
43
      if (r6 !==16'h0000) tb_error("R6  reset value");
44
      if (r7 !==16'h0000) tb_error("R7  reset value");
45
      if (r8 !==16'h0000) tb_error("R8  reset value");
46
      if (r9 !==16'h0000) tb_error("R9  reset value");
47
      if (r10!==16'h0000) tb_error("R10 reset value");
48
      if (r11!==16'h0000) tb_error("R11 reset value");
49
      if (r12!==16'h0000) tb_error("R12 reset value");
50
      if (r13!==16'h0000) tb_error("R13 reset value");
51
      if (r14!==16'h0000) tb_error("R14 reset value");
52
      if (r15!==16'h0000) tb_error("R15 reset value");
53
 
54
 
55
      // Make sure initialization worked fine
56
      //--------------------------------------------------------
57
      @(r15==16'h1000);
58
 
59
      if (r2 !==16'h0022) tb_error("R2  initialization");
60
      if (r3 !==16'h3333) tb_error("R3  initialization");
61
      if (r4 !==16'h4444) tb_error("R4  initialization");
62
      if (r5 !==16'h5555) tb_error("R5  initialization");
63
      if (r6 !==16'h6666) tb_error("R6  initialization");
64
      if (r7 !==16'h7777) tb_error("R7  initialization");
65
      if (r8 !==16'h8888) tb_error("R8  initialization");
66
      if (r9 !==16'h9999) tb_error("R9  initialization");
67
      if (r10!==16'haaaa) tb_error("R10 initialization");
68
      if (r11!==16'hbbbb) tb_error("R11 initialization");
69
      if (r12!==16'hcccc) tb_error("R12 initialization");
70
      if (r13!==16'hdddd) tb_error("R13 initialization");
71
      if (r14!==16'heeee) tb_error("R14 initialization");
72
 
73
 
74
      // ADD: Check when source is Rn
75
      //--------------------------------------------------------
76
      @(r15==16'h2000);
77
 
78
      if (r5     !==16'h9999) tb_error("====== ADD Rn Rm    =====");
79
      if (r4     ===16'h1234) tb_error("====== ADD Rn PC    =====");
80
      if (mem210 !==16'h5555) tb_error("====== ADD Rn x(Rm) =====");
81
      if (mem212 !==16'h9abc) tb_error("====== ADD Rn EDE   =====");
82
      if (mem214 !==16'h6789) tb_error("====== ADD Rn &EDE  =====");
83
 
84
 
85
      // ADD: Check when source is @Rn
86
      //--------------------------------------------------------
87
      @(r15==16'h3000);
88
 
89
      if (r5     !==16'h7777) tb_error("====== ADD @Rn Rm    =====");
90
      if (r4     ===16'h0000) tb_error("====== ADD @Rn PC    =====");
91
      if (mem210 !==16'h6666) tb_error("====== ADD @Rn x(Rm) =====");
92
      if (mem212 !==16'hed2e) tb_error("====== ADD @Rn EDE   =====");
93
      if (mem214 !==16'h4653) tb_error("====== ADD @Rn &EDE  =====");
94
 
95
 
96
      // ADD: Check when source is @Rn+
97
      //--------------------------------------------------------
98
      @(r15==16'h4000);
99
 
100
      if (r4     !==16'h0202) tb_error("====== ADD @Rn+ Rm    =====");
101
      if (r5     !==16'haaaa) tb_error("====== ADD @Rn+ Rm    =====");
102
 
103
      if (r6     !==16'h0206) tb_error("====== ADD @Rn+ PC    =====");
104
 
105
      if (r7     !==16'h0210) tb_error("====== ADD @Rn+ x(Rm) =====");
106
      if (mem210 !==16'h6666) tb_error("====== ADD @Rn+ x(Rm) =====");
107
 
108
      if (r8     !==16'h0208) tb_error("====== ADD @Rn+ EDE =====");
109
      if (mem212 !==16'hed2e) tb_error("====== ADD @Rn+ EDE   =====");
110
 
111
      if (r9     !==16'h0204) tb_error("====== ADD @Rn+ &EDE =====");
112
      if (mem214 !==16'h4653) tb_error("====== ADD @Rn+ &EDE  =====");
113
 
114
      // ADD: Check when source is #N
115
      //--------------------------------------------------------
116
      @(r15==16'h5000);
117
 
118
      if (r4     !==16'h4444) tb_error("====== ADD #N  Rm    =====");
119
      if (r5     !==16'h0000) tb_error("====== ADD #N  PC    =====");
120
      if (mem230 !==16'hae8c) tb_error("====== ADD #N  x(Rm) =====");
121
      if (mem210 !==16'h5d50) tb_error("====== ADD #N  EDE   =====");
122
      if (mem206 !==16'h6ea1) tb_error("====== ADD #N  &EDE  =====");
123
 
124
 
125
      // ADD: Check when source is x(Rn)
126
      //--------------------------------------------------------
127
      @(r15==16'h6000);
128
 
129
      if (r5     !==16'h957b) tb_error("====== ADD x(Rn) Rm    =====");
130
      if (r6     ===16'h0000) tb_error("====== ADD x(Rn) PC    =====");
131
      if (mem214 !==16'h5776) tb_error("====== ADD x(Rn) x(Rm) =====");
132
      if (mem220 !==16'h937b) tb_error("====== ADD x(Rn) EDE   =====");
133
      if (mem208 !==16'hace4) tb_error("====== ADD x(Rn) &EDE  =====");
134
 
135
 
136
      // ADD: Check when source is EDE
137
      //--------------------------------------------------------
138
      @(r15==16'h7000);
139
 
140
      if (r4     !==16'h06f7) tb_error("====== ADD EDE Rm    =====");
141
      if (r6     ===16'h0000) tb_error("====== ADD EDE PC    =====");
142
      if (mem214 !==16'h0946) tb_error("====== ADD EDE x(Rm) =====");
143
      if (mem216 !==16'hb933) tb_error("====== ADD EDE EDE   =====");
144
      if (mem212 !==16'h2ab2) tb_error("====== ADD EDE &EDE  =====");
145
 
146
 
147
      // ADD: Check when source is &EDE
148
      //--------------------------------------------------------
149
      @(r15==16'h8000);
150
 
151
      if (r4     !==16'h66f5) tb_error("====== ADD &EDE Rm    =====");
152
      if (r6     ===16'h0000) tb_error("====== ADD &EDE PC    =====");
153
      if (mem214 !==16'h82d1) tb_error("====== ADD &EDE x(Rm) =====");
154
      if (mem218 !==16'hca4e) tb_error("====== ADD &EDE EDE   =====");
155
      if (mem202 !==16'h1338) tb_error("====== ADD &EDE &EDE  =====");
156
 
157
 
158
      // ADD: Check when source is CONST
159
      //--------------------------------------------------------
160
      @(r15==16'h9000);
161
 
162
      if (r4     !==16'h4444) tb_error("====== ADD #+0 Rm    =====");
163
      if (r5     !==16'h5556) tb_error("====== ADD #+1 Rm    =====");
164
      if (r6     !==16'h6668) tb_error("====== ADD #+2 Rm    =====");
165
      if (r7     !==16'h777b) tb_error("====== ADD #+4 Rm    =====");
166
      if (r8     !==16'h8890) tb_error("====== ADD #+8 Rm    =====");
167
      if (r9     !==16'h9998) tb_error("====== ADD #-1 Rm    =====");
168
 
169
      if (r11    !==16'h1234) tb_error("====== ADD #+4 PC    =====");
170
 
171
      if (mem210 !==16'h4444) tb_error("====== ADD #+0 x(Rm) =====");
172
      if (mem212 !==16'h5556) tb_error("====== ADD #+1 x(Rm) =====");
173
      if (mem214 !==16'h6668) tb_error("====== ADD #+2 x(Rm) =====");
174
      if (mem216 !==16'h777b) tb_error("====== ADD #+4 x(Rm) =====");
175
      if (mem218 !==16'h8890) tb_error("====== ADD #+8 x(Rm) =====");
176
      if (mem21A !==16'h9998) tb_error("====== ADD #-1 x(Rm) =====");
177
 
178
      if (mem220 !==16'h4444) tb_error("====== ADD #+0 EDE   =====");
179
      if (mem222 !==16'h5556) tb_error("====== ADD #+1 EDE   =====");
180
      if (mem224 !==16'h6668) tb_error("====== ADD #+2 EDE   =====");
181
      if (mem226 !==16'h777b) tb_error("====== ADD #+4 EDE   =====");
182
      if (mem228 !==16'h8890) tb_error("====== ADD #+8 EDE   =====");
183
      if (mem22A !==16'h9998) tb_error("====== ADD #-1 EDE   =====");
184
 
185
      if (mem230 !==16'h4444) tb_error("====== ADD #+0 &EDE  =====");
186
      if (mem232 !==16'h5556) tb_error("====== ADD #+1 &EDE  =====");
187
      if (mem234 !==16'h6668) tb_error("====== ADD #+2 &EDE  =====");
188
      if (mem236 !==16'h777b) tb_error("====== ADD #+4 &EDE  =====");
189
      if (mem238 !==16'h8890) tb_error("====== ADD #+8 &EDE  =====");
190
      if (mem23A !==16'h9998) tb_error("====== ADD #-1 &EDE  =====");
191
 
192
 
193
      // ADD: Check Flags
194
      //--------------------------------------------------------
195
 
196
      @(r15==16'hA000);
197
      if (r2    !==16'h0000) tb_error("====== ADD FLAG: Flag   check error: V=0, N=0, Z=0, C=0 =====");
198
      if (r5    !==16'h0999) tb_error("====== ADD FLAG: Result check error: V=0, N=0, Z=0, C=0 =====");
199
 
200
      @(r15==16'hA001);
201
      if (r2    !==16'h0001) tb_error("====== ADD FLAG: Flag   check error: V=0, N=0, Z=0, C=1 =====");
202
      if (r5    !==16'h0001) tb_error("====== ADD FLAG: Result check error: V=0, N=0, Z=0, C=1 =====");
203
 
204
      @(r15==16'hA002);
205
      if (r2    !==16'h0002) tb_error("====== ADD FLAG: Flag   check error: V=0, N=0, Z=1, C=0 =====");
206
      if (r5    !==16'h0000) tb_error("====== ADD FLAG: Result check error: V=0, N=0, Z=1, C=0 =====");
207
 
208
      @(r15==16'hA003);
209
      if (r2    !==16'h0004) tb_error("====== ADD FLAG: Flag   check error: V=0, N=1, Z=0, C=0 =====");
210
      if (r5    !==16'hff10) tb_error("====== ADD FLAG: Result check error: V=0, N=1, Z=0, C=0 =====");
211
 
212
      @(r15==16'hA004);
213
      if (r2    !==16'h0104) tb_error("====== ADD FLAG: Flag   check error: V=1, N=1, Z=0, C=0 =====");
214
      if (r5    !==16'h800f) tb_error("====== ADD FLAG: Result check error: V=1, N=1, Z=0, C=0 =====");
215
 
216
      @(r15==16'hA005);
217
      if (r2    !==16'h0101) tb_error("====== ADD FLAG: Flag   check error: V=1, N=0, Z=0, C=1 =====");
218
      if (r5    !==16'h7f00) tb_error("====== ADD FLAG: Result check error: V=1, N=0, Z=0, C=1 =====");
219
 
220
//    ---------------- TEST WHEN SOURCE IS CONSTANT IN BYTE MODE ------ */
221
//    #
222
//    # NOTE: The following section would not fit in the smallest ROM
223
//    #       configuration for the "two-op_add-b.v" pattern.
224
//    #       It is therefore executed here.
225
//    #
226
      @(r15==16'hB000);
227
 
228
 
229
      if (mem250 !==16'haa44) tb_error("====== ADD.B #+0 &EDE =====");
230
      if (mem252 !==16'haa56) tb_error("====== ADD.B #+1 &EDE =====");
231
      if (mem254 !==16'haa68) tb_error("====== ADD.B #+2 &EDE =====");
232
      if (mem256 !==16'haa7b) tb_error("====== ADD.B #+4 &EDE =====");
233
      if (mem258 !==16'haa3d) tb_error("====== ADD.B #+8 &EDE =====");
234
      if (mem25A !==16'haa98) tb_error("====== ADD.B #-1 &EDE =====");
235
      if (mem25C !==16'haa55) tb_error("====== ADD.B #+0 &EDE =====");
236
      if (mem25E !==16'hbc55) tb_error("====== ADD.B #+1 &EDE =====");
237
      if (mem260 !==16'hce55) tb_error("====== ADD.B #+2 &EDE =====");
238
      if (mem262 !==16'he155) tb_error("====== ADD.B #+4 &EDE =====");
239
      if (mem264 !==16'hf655) tb_error("====== ADD.B #+8 &EDE =====");
240
      if (mem266 !==16'h3255) tb_error("====== ADD.B #-1 &EDE =====");
241
 
242
 
243
      // ADD.B: Check Flags
244
      //--------------------------------------------------------
245
 
246
      @(r15==16'hC000);
247
      if (r2    !==16'h0000) tb_error("====== ADD.B FLAG: Flag   check error: V=0, N=0, Z=0, C=0 =====");
248
      if (r5    !==16'h0009) tb_error("====== ADD.B FLAG: Result check error: V=0, N=0, Z=0, C=0 =====");
249
 
250
      @(r15==16'hC001);
251
      if (r2    !==16'h0001) tb_error("====== ADD.B FLAG: Flag   check error: V=0, N=0, Z=0, C=1 =====");
252
      if (r5    !==16'h0001) tb_error("====== ADD.B FLAG: Result check error: V=0, N=0, Z=0, C=1 =====");
253
 
254
      @(r15==16'hC002);
255
      if (r2    !==16'h0002) tb_error("====== ADD.B FLAG: Flag   check error: V=0, N=0, Z=1, C=0 =====");
256
      if (r5    !==16'h0000) tb_error("====== ADD.B FLAG: Result check error: V=0, N=0, Z=1, C=0 =====");
257
 
258
      @(r15==16'hC003);
259
      if (r2    !==16'h0004) tb_error("====== ADD.B FLAG: Flag   check error: V=0, N=1, Z=0, C=0 =====");
260
      if (r5    !==16'h00f3) tb_error("====== ADD.B FLAG: Result check error: V=0, N=1, Z=0, C=0 =====");
261
 
262
      @(r15==16'hC004);
263
      if (r2    !==16'h0104) tb_error("====== ADD.B FLAG: Flag   check error: V=1, N=1, Z=0, C=0 =====");
264
      if (r5    !==16'h008f) tb_error("====== ADD.B FLAG: Result check error: V=1, N=1, Z=0, C=0 =====");
265
 
266
      @(r15==16'hC005);
267
      if (r2    !==16'h0101) tb_error("====== ADD.B FLAG: Flag   check error: V=1, N=0, Z=0, C=1 =====");
268
      if (r5    !==16'h007f) tb_error("====== ADD.B FLAG: Result check error: V=1, N=0, Z=0, C=1 =====");
269
 
270
      stimulus_done = 1;
271
   end
272
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.