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

Subversion Repositories xgate

[/] [xgate/] [trunk/] [sw/] [tools/] [misc/] [test_assembler.pl] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 rehayes
#!/usr/bin/perl -w
2
 
3
sub test_for_keyword {
4
  foreach $keyword (@instruction_keyword_list) {
5
    if ($_[0] eq $keyword) {
6
      return 1;
7
    }
8
  }
9
  return 0;
10
}
11
 
12
sub print_symbol_table {
13
  while (($key, $value) = each %symbol_table) {
14
    print "Symbol Name $key => $value\n";
15
  }
16
}
17
 
18
sub do_expression {
19
  print "Do Expersion input = $_[0]\n";
20
  @expresion = split /([()+-])/, $_[0];
21
  $converted = 0;
22
  print "Do Expression - Expresion parts are: @expresion\n";
23
  $i = 0;
24
  foreach (@expresion) {
25
    print "Foreach value is: $_\n";
26
    s/ *$//g;     # get rid of trailing blanks
27
    s/^ *//g;     # get rid of all leading blanks
28
    if (/^\$/) {
29
      $temp = &hex_to_num;
30
      $expresion[$i] = $temp;
31
    } elsif (/^[0-9]/) {
32
      $temp = &dec_to_num;
33
      $expresion[$i] = $temp;
34
    } elsif (/^[a-zA-Z_]/) {
35
      $temp = &symbol_to_num;
36
      $expresion[$i] = $temp;
37
    }
38
    print "  -- Expression part is: $expresion[$i]\n";
39
    $i++;
40
  }
41
  $converted = @expresion[0];
42
  print "Final Do Expression is: $converted, expression = @expresion\n";
43
  return $converted;
44
}
45
 
46
sub hex_to_num {
47
  my ($i, $temp, $converted);
48
  s/^\$//;
49
  $i = 1;
50
  @chars = split //, $_;
51
  @chars = reverse @chars;
52
  $converted = 0;
53
  foreach $c (@chars) {
54
    if ($c =~ /[A-F]/) {
55
      $temp = ord($c) - ord("A") + 10;
56
    } elsif ($c =~ /[a-f]/) {
57
      $temp = ord($c) - ord("a") + 10;
58
    } elsif ($c =~ /[0-9]/) {
59
      $temp = ord($c) - ord("0");
60
    } else {
61
        print "ERROR - in hex number conversion\n";
62
    }
63
    $temp = $temp * $i;
64
    $converted = $converted + $temp;
65
    $i = $i*16;
66
  }
67
  return $converted;
68
}
69
 
70
sub dec_to_num {
71
  my ($i, $temp, $converted);
72
  s/^\$//;
73
  $i = 1;
74
  @chars = split //, $_;
75
  @chars = reverse @chars;
76
  $converted = 0;
77
  foreach $c (@chars) {
78
    if ($c =~ /[0-9]/) {
79
      $temp = ord($c) - ord("0");
80
    } else {
81
        print "ERROR - in dec number conversion\n";
82
    }
83
    $temp = $temp * $i;
84
    $converted = $converted + $temp;
85
    $i = $i*10;
86
  }
87
  return $converted;
88
}
89
 
90
sub symbol_to_num {
91
  my $converted;
92
  print "Symbol_convert - $_\n";
93
  $converted = $symbol_table{$_};
94
  if ($converted =~ /XXX/) {
95
    print "ERROR - Undefined Symbol Conversion => $_/n";
96
  }
97
  return $converted;
98
}
99
 
100
sub print_memory_image {
101
  $j = 0;
102
  foreach $i (@memory_image) {
103
    print "Address $j => $i\n";
104
    $j++;
105
  }
106
}
107
 
108
sub reg_to_num {
109
  my $register = $_;
110
  if ($register eq "R0") {
111
      $register = "000";
112
  } elsif ($register eq "R1") {
113
      $register = "001";
114
  } elsif ($register eq "R2") {
115
      $register = "010";
116
  } elsif ($register eq "R3") {
117
      $register = "011";
118
  } elsif ($register eq "R4") {
119
      $register = "100";
120
  } elsif ($register eq "R5") {
121
      $register = "101";
122
  } elsif ($register eq "R6") {
123
      $register = "110";
124
  } elsif ($register eq "R7") {
125
      $register = "111";
126
  } else {
127
      printf "Bad Register Name: %s\n", $register;
128
      $register = "";
129
  }
130
}
131
 
132
sub translate_RD {
133
  $rd_prototype = "00000???00000000";
134
  &fill_field($rd_prototype, &reg_to_num($_[0]));
135
}
136
 
137
sub do_compiler_command {
138
  if ($white_split[0] eq "EQU") {
139
    shift @white_split;
140
    print "\nStarting EQU - Symbol = $current_symbol, @white_split\n";
141
    $junk_temp = &do_expression(@white_split);
142
    print "Ending EQU - value is $junk_temp\n\n";
143
    $symbol_table{$current_symbol} = $junk_temp;
144
  } elsif ($white_split[0] eq "ORG") {
145
    $program_address = $white_split[1];
146
    $symbol_table{$current_symbol} = $program_address;
147
  } elsif ($white_split[0] eq "ALIGN") {
148
    $program_address = $white_split[1];
149
    $symbol_table{$current_symbol} = $program_address;
150
  } elsif ($white_split[0] eq "DW") {
151
    $symbol_table{$current_symbol} = $program_address;
152
    $program_address = $program_address + 1;
153
  } elsif ($white_split[0] eq "DB") {
154
    $symbol_table{$current_symbol} = $program_address;
155
    $program_address++;
156
  } elsif ($white_split[0] eq "FCC") {
157
    $program_address = $white_split[1];
158
    $symbol_table{$current_symbol} = $program_address;
159
  }
160
}
161
 
162
sub do_instruction {
163
  if ($white_split[0] eq "BRK") {
164
     $protype_op_code = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
165
     $xyzpp = "0000000000000000";
166
 
167
  } elsif ($white_split[0] eq "NOP") {
168
     $protype_op_code =  "0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0";
169
     $xyzpp = "0000000100000000";
170
 
171
  } elsif ($white_split[0] eq "RTS") {
172
     $protype_op_code =  "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0";
173
     $xyzpp = "0000001000000000";
174
 
175
  } elsif ($white_split[0] eq "SIF") {
176
     $protype_op_code =  "0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0";
177
     $xyzpp = "0000001100000000";
178
 
179
  } elsif ($white_split[0] eq "CSEM") {
180
     $protype_op_code =  "0 0 0 0 0 IMM3 1 1 1 1 0 0 0 0";
181
     $xyzpp = "00000???11110000";
182
 
183
     $protype_op_code =  "0 0 0 0 0 RS 1 1 1 1 0 0 0 1";
184
     $xyzpp = "00000???11110001";
185
 
186
 } elsif ($white_split[0] eq "SSEM") {
187
     $protype_op_code =  "0 0 0 0 0 IMM3 1 1 1 1 0 0 1 0";
188
     $xyzpp = "00000???11110010";
189
 
190
     $protype_op_code =  "0 0 0 0 0 RS 1 1 1 1 0 0 1 1";
191
     $xyzpp = "00000???11110011";
192
 
193
 
194
  } elsif ($white_split[0] eq "SEX") {
195
     $protype_op_code =  "0 0 0 0 0 RD 1 1 1 1 0 1 0 0";
196
     $xyzpp = "00000???11110100";
197
 
198
  } elsif ($white_split[0] eq "PAR") {
199
     $protype_op_code =  "0 0 0 0 0 RD 1 1 1 1 0 1 0 1";
200
     $xyzpp = "00000???11110101";
201
 
202
  } elsif ($white_split[0] eq "JAL") {
203
     $protype_op_code =  "0 0 0 0 0 RD 1 1 1 1 0 1 1 0";
204
     $xyzpp = "00000???11110110";
205
 
206
  } elsif ($white_split[0] eq "SIF") {
207
     $protype_op_code =  "0 0 0 0 0 RS 1 1 1 1 0 1 1 1";
208
     $xyzpp = "00000???11110111";
209
 
210
 
211
  } elsif ($white_split[0] eq "TFR") {
212
    # RD,CCR
213
     $protype_op_code =  "0 0 0 0 0 RD 1 1 1 1 1 0 0 0";
214
     $xyzpp = "00000???11111000";
215
 
216
  } elsif ($white_split[0] eq "TFR") {
217
    # CCR,RS
218
     $protype_op_code =  "0 0 0 0 0 RS 1 1 1 1 1 0 0 1";
219
     $xyzpp = "00000???11111001";
220
 
221
  } elsif ($white_split[0] eq "TFR") {
222
    # RD,PC
223
     $protype_op_code =  "0 0 0 0 0 RD 1 1 1 1 1 0 1 0";
224
     $xyzpp = "00000???11111010";
225
 
226
 
227
  } elsif ($white_split[0] eq "BFFO") {
228
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 0 0 0";
229
     $xyzpp = "00001??????10000";
230
 
231
  } elsif ($white_split[0] eq "ASR") {
232
     $_ = $white_space[2];
233
     if (/R[0-7]/) {
234
       $protype_op_code =  "0 0 0 0 1 RD RS 1 0 0 0 1";
235
       $xyzpp = "00001??????10001";
236
     } else {
237
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 0 0 1";
238
     $xyzpp = "00001???????1001";
239
     }
240
  } elsif ($white_split[0] eq "CSL") {
241
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 0 1 0";
242
     $xyzpp = "00001??????10010";
243
 
244
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 0 1 0";
245
     $xyzpp = "00001???????1010";
246
 
247
  } elsif ($white_split[0] eq "CSR") {
248
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 0 1 1";
249
     $xyzpp = "00001??????10011";
250
 
251
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 0 1 1";
252
     $xyzpp = "00001???????1011";
253
 
254
  } elsif ($white_split[0] eq "LSL") {
255
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 1 0 0";
256
     $xyzpp = "00001??????10100";
257
 
258
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 1 0 0";
259
     $xyzpp = "00001???????1100";
260
 
261
  } elsif ($white_split[0] eq "LSR") {
262
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 1 0 1";
263
     $xyzpp = "00001??????10101";
264
 
265
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 1 0 1";
266
     $xyzpp = "00001???????1101";
267
 
268
  } elsif ($white_split[0] eq "ROL") {
269
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 1 1 0";
270
     $xyzpp = "00001??????10110";
271
 
272
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 1 1 0";
273
     $xyzpp = "00001???????1110";
274
 
275
  } elsif ($white_split[0] eq "ROR") {
276
     $protype_op_code =  "0 0 0 0 1 RD RS 1 0 1 1 1";
277
     $xyzpp = "00001??????10111";
278
 
279
     $protype_op_code =  "0 0 0 0 1 RD IMM4 1 1 1 1";
280
     $xyzpp = "00001???????1111";
281
 
282
  } elsif ($white_split[0] eq "AND") {
283
     $protype_op_code =  "0 0 0 1 0 RD RS1 RS2 0 0";
284
     $xyzpp = "00010?????????00";
285
 
286
  } elsif ($white_split[0] eq "OR") {
287
     $protype_op_code =  "0 0 0 1 0 RD RS1 RS2 1 0";
288
     $xyzpp = "00010?????????10";
289
 
290
  } elsif ($white_split[0] eq "XNOR") {
291
     $protype_op_code =  "0 0 0 1 0 RD RS1 RS2 1 1";
292
     $xyzpp = "00010?????????11";
293
 
294
  } elsif ($white_split[0] eq "SUB") {
295
     $protype_op_code =  "0 0 0 1 1 RD RS1 RS2 0 0";
296
     $xyzpp = "00011?????????00";
297
 
298
  } elsif ($white_split[0] eq "SBC") {
299
     $protype_op_code =  "0 0 0 1 1 RD RS1 RS2 0 1";
300
     $xyzpp = "00011?????????01";
301
 
302
  } elsif ($white_split[0] eq "ADD") {
303
     $protype_op_code =  "0 0 0 1 1 RD RS1 RS2 1 0";
304
     $xyzpp = "00011?????????10";
305
 
306
  } elsif ($white_split[0] eq "ADC") {
307
     $protype_op_code =  "0 0 0 1 1 RD RS1 RS2 1 1";
308
     $xyzpp = "00011?????????11";
309
 
310
 
311
  } elsif ($white_split[0] eq "BCC") {
312
     $protype_op_code =  "0 0 1 0 0 0 0 REL9";
313
     $xyzpp = "0010000?????????";
314
 
315
  } elsif ($white_split[0] eq "BCS") {
316
     $protype_op_code =  "0 0 1 0 0 0 1 REL9";
317
     $xyzpp = "0010001?????????";
318
 
319
  } elsif ($white_split[0] eq "BNE") {
320
     $protype_op_code =  "0 0 1 0 0 1 0 REL9";
321
     $xyzpp = "0010010?????????";
322
 
323
  } elsif ($white_split[0] eq "BEQ") {
324
     $protype_op_code =  "0 0 1 0 0 1 1 REL9";
325
     $xyzpp = "0010011?????????";
326
 
327
  } elsif ($white_split[0] eq "BPL") {
328
     $protype_op_code =  "0 0 1 0 1 0 0 REL9";
329
     $xyzpp = "0010100?????????";
330
 
331
  } elsif ($white_split[0] eq "BMI") {
332
     $protype_op_code =  "0 0 1 0 1 0 1 REL9";
333
     $xyzpp = "0010101?????????";
334
 
335
  } elsif ($white_split[0] eq "BVC") {
336
     $protype_op_code =  "0 0 1 0 1 1 0 REL9";
337
     $xyzpp = "0010110?????????";
338
 
339
  } elsif ($white_split[0] eq "BVS") {
340
     $protype_op_code =  "0 0 1 0 1 1 1 REL9";
341
     $xyzpp = "0010111?????????";
342
 
343
  } elsif ($white_split[0] eq "BHI") {
344
     $protype_op_code =  "0 0 1 1 0 0 0 REL9";
345
     $xyzpp = "0011000?????????";
346
 
347
  } elsif ($white_split[0] eq "BLS") {
348
     $protype_op_code =  "0 0 1 1 0 0 1 REL9";
349
     $xyzpp = "0011001?????????";
350
 
351
  } elsif ($white_split[0] eq "BGE") {
352
     $protype_op_code =  "0 0 1 1 0 1 0 REL9";
353
     $xyzpp = "0011010?????????";
354
 
355
  } elsif ($white_split[0] eq "BLT") {
356
     $protype_op_code =  "0 0 1 1 0 1 1 REL9";
357
     $xyzpp = "0011011?????????";
358
 
359
  } elsif ($white_split[0] eq "BGT") {
360
     $protype_op_code =  "0 0 1 1 1 0 0 REL9";
361
     $xyzpp = "0011100?????????";
362
 
363
  } elsif ($white_split[0] eq "BLE") {
364
     $protype_op_code =  "0 0 1 1 1 0 1 REL9";
365
     $xyzpp = "0011101?????????";
366
 
367
  } elsif ($white_split[0] eq "BRA") {
368
     $protype_op_code =  "0 0 1 1 1 1 REL10";
369
     $xyzpp = "001111??????????";
370
 
371
 
372
  } elsif ($white_split[0] eq "LDB") {
373
     $_ = $white_space[3];
374
     if (/\#/) {
375
       $protype_op_code =  "0 1 0 0 0 RD RB #OFFS5";
376
       $xyzpp = "01000???????????";
377
     }
378
     $protype_op_code =  "0 1 1 0 0 RD RB RI 0 0";
379
     $xyzpp = "01100?????????00";
380
 
381
     $protype_op_code =  "0 1 1 0 0 RD RB RI+ 0 1";
382
     $xyzpp = "01100?????????01";
383
 
384
     $protype_op_code =  "0 1 1 0 0 RD RB -RI 1 0";
385
     $xyzpp = "01100?????????10";
386
 
387
  } elsif ($white_split[0] eq "LDW") {
388
     $protype_op_code =  "0 1 0 0 1 RD RB #OFFS5";
389
     $xyzpp = "01001???????????";
390
 
391
     $protype_op_code =  "0 1 1 0 1 RD RB RI 0 0";
392
     $xyzpp = "01101?????????00";
393
 
394
     $protype_op_code =  "0 1 1 0 1 RD RB RI+ 0 1";
395
     $xyzpp = "01101?????????01";
396
 
397
     $protype_op_code =  "0 1 1 0 1 RD RB -RI 1 0";
398
     $xyzpp = "01101?????????10";
399
 
400
  } elsif ($white_split[0] eq "STB") {
401
     $protype_op_code =  "0 1 0 1 0 RS RB #OFFS5";
402
     $xyzpp = "01010???????????";
403
 
404
     $protype_op_code =  "0 1 1 1 0 RS RB RI 0 0";
405
     $xyzpp = "01110?????????00";
406
 
407
     $protype_op_code =  "0 1 1 1 0 RS RB RI+ 0 1";
408
     $xyzpp = "01110?????????01";
409
 
410
     $protype_op_code =  "0 1 1 1 0 RS RB -RI 1 0";
411
     $xyzpp = "01110?????????10";
412
 
413
  } elsif ($white_split[0] eq "STW") {
414
     $protype_op_code =  "0 1 0 1 1 RS RB #OFFS5";
415
     $xyzpp = "01011???????????";
416
 
417
     $protype_op_code =  "0 1 1 1 1 RS RB RI 0 0";
418
     $xyzpp = "01111?????????00";
419
 
420
     $protype_op_code =  "0 1 1 1 1 RS RB RI+ 0 1";
421
     $xyzpp = "01111?????????01";
422
 
423
     $protype_op_code =  "0 1 1 1 1 RS RB -RI 1 0";
424
     $xyzpp = "01111?????????10";
425
 
426
 
427
  } elsif ($white_split[0] eq "BFEXT") {
428
     $protype_op_code =  "0 1 1 0 0 RD RS1 RS2 1 1";
429
     $xyzpp = "01100?????????11";
430
 
431
  } elsif ($white_split[0] eq "BFINS") {
432
     $protype_op_code =  "0 1 1 0 1 RD RS1 RS2 1 1";
433
     $xyzpp = "01101?????????11";
434
 
435
  } elsif ($white_split[0] eq "BFINSI") {
436
     $protype_op_code =  "0 1 1 1 0 RD RS1 RS2 1 1";
437
     $xyzpp = "01110?????????11";
438
 
439
  } elsif ($white_split[0] eq "BFINSX") {
440
     $protype_op_code =  "0 1 1 1 1 RD RS1 RS2 1 1";
441
     $xyzpp = "01111?????????11";
442
 
443
 
444
  } elsif ($white_split[0] eq "ANDL") {
445
     $protype_op_code =  "1 0 0 0 0 RD IMM8";
446
     $xyzpp = "10000???????????";
447
 
448
  } elsif ($white_split[0] eq "ANDH") {
449
     $protype_op_code =  "1 0 0 0 1 RD IMM8";
450
     $xyzpp = "10001???????????";
451
 
452
  } elsif ($white_split[0] eq "BITL") {
453
     $protype_op_code =  "1 0 0 1 0 RD IMM8";
454
     $xyzpp = "10010???????????";
455
 
456
  } elsif ($white_split[0] eq "BITH") {
457
     $protype_op_code =  "1 0 0 1 1 RD IMM8";
458
     $xyzpp = "10011???????????";
459
 
460
  } elsif ($white_split[0] eq "ORL") {
461
     $protype_op_code =  "1 0 1 0 0 RD IMM8";
462
     $xyzpp = "10100???????????";
463
 
464
  } elsif ($white_split[0] eq "ORH") {
465
     $protype_op_code =  "1 0 1 0 1 RD IMM8";
466
     $xyzpp = "10101???????????";
467
 
468
  } elsif ($white_split[0] eq "XNORL") {
469
     $protype_op_code =  "1 0 1 1 0 RD IMM8";
470
     $xyzpp = "10110???????????";
471
 
472
  } elsif ($white_split[0] eq "XNORH") {
473
     $protype_op_code =  "1 0 1 1 1 RD IMM8";
474
     $xyzpp = "10111???????????";
475
 
476
 
477
  } elsif ($white_split[0] eq "SUBL") {
478
     $protype_op_code =  "1 1 0 0 0 RD IMM8";
479
     $xyzpp = "11000???????????";
480
 
481
  } elsif ($white_split[0] eq "SUBH") {
482
     $protype_op_code =  "1 1 0 0 1 RD IMM8";
483
     $xyzpp = "11001???????????";
484
 
485
  } elsif ($white_split[0] eq "CMPL") {
486
     $protype_op_code =  "1 1 0 1 0 RS IMM8";
487
     $xyzpp = "11010???????????";
488
 
489
  } elsif ($white_split[0] eq "CPCH") {
490
     $protype_op_code =  "1 1 0 1 1 RS IMM8";
491
     $xyzpp = "11011???????????";
492
 
493
  } elsif ($white_split[0] eq "ADDL") {
494
     $protype_op_code =  "1 1 1 0 0 RD IMM8";
495
     $xyzpp = "11100???????????";
496
 
497
  } elsif ($white_split[0] eq "ADDH") {
498
     $protype_op_code =  "1 1 1 0 1 RD IMM8";
499
     $xyzpp = "11101???????????";
500
 
501
  } elsif ($white_split[0] eq "LDL") {
502
     $protype_op_code =  "1 1 1 1 0 RD IMM8";
503
     $xyzpp = "11110???????????";
504
 
505
  } elsif ($white_split[0] eq "LDH") {
506
     $protype_op_code =  "1 1 1 1 1 RD IMM8";
507
     $xyzpp = "11111???????????";
508
  }
509
 
510
  $memory_image[$program_address] = $xyzpp;
511
  $program_address = $program_address + 1;
512
}
513
 
514
################################################################################
515
# Main
516
################################################################################
517
 
518
if( @ARGV < 1 ) {
519
  $progname = `basename $0`;
520
  chomp($progname);
521
  print "Syntax: $progname <Infile> <Outfile>\n";
522
  die;
523
} elsif ( @ARGV < 2 ) {
524
  print "Using default output file \"temp.v\"\n";
525
  $Infile = shift @ARGV;
526
  $Outfile = 'temp.v';
527
} else {
528
  $Infile = shift @ARGV;
529
  $Outfile = shift @ARGV;
530
}
531
 
532
open( source_file,  "<$Infile" )  || die "Could not open Input file";
533
open( verilog_file, ">$Outfile" ) || die "Could not open Output file";
534
 
535
$source_line_number = 1;
536
$program_address = 0;
537
$cpu_type = "";
538
@memory_image = "";
539
@instruction_keyword_list = qw/ CPU ALIGN ORG EQU DW DB FCC /;
540
push @instruction_keyword_list, qw/ BRK NOP RTS SIF CSEM SSEM SEX PAR /;
541
push @instruction_keyword_list, qw/ JAL SIF TFR BFFO ASR CSL CSR LSL LSR /;
542
push @instruction_keyword_list, qw/ ROL ROR AND OR XNOR SUB SBC ADD BCC BCS /;
543
push @instruction_keyword_list, qw/ BNE BEQ BPL BMI BVC BVS BHI BLS BGE BLT /;
544
push @instruction_keyword_list, qw/ BGT BLE BRA LDB LDW STB STW BFEXT BFINS /;
545
push @instruction_keyword_list, qw/ BFINSI BFINSX ANDL ANDH BITL BITH ORL /;
546
push @instruction_keyword_list, qw/ ORH XNORL XNORH SUBL SUBH CMPL CPCH /;
547
push @instruction_keyword_list, qw/ ADDL ADDH LDL LDH /;
548
 
549
while (<source_file>) {
550
  chomp;
551
  s/;.*$//g;    # get rid of everything after ;
552
  s/ *$//g;     # get rid of trailing blanks
553
  s/^ *//g;     # get rid of all leading blanks
554
  if ($_) {
555
    print "Instruction Line = $_  number = $source_line_number\n";
556
    #@white_split = split; # Breakout fields on white space
557
    @white_split = split /\s+|,/; # Breakout fields on white space or ,
558
    $i = 0;
559
    foreach (@white_split) {
560
      s/\(R/R/;                   # Remove leading "(" if it is part of Register name
561
      s/\)\)/\)/;                 # Take of one of ")" of double "))"
562
      if (/^\$/) {                # Take care of the simple case of a hex number
563
        $white_split[$i] = &hex_to_num($white_split[$i]);
564
      }
565
      if (/^[0-9]/) {             # Take care of the simple case of a dec number
566
        $white_split[$i] = &dec_to_num($white_split[$i]);
567
      }
568
      $i++;
569
    }
570
    if (! &test_for_keyword($white_split[0])) {  # Line starts with a symbol name
571
      $current_symbol = $white_split[0];
572
      if ($symbol_table{$current_symbol}) {
573
        print "Error Reused Symbol - $current_symbol - Source Line Number $source_line_number\n";
574
      } else {
575
        $symbol_table{$current_symbol} = "XXX"; # initilize to junk
576
      }
577
      shift @white_split;
578
    }
579
    if (! @white_split) {  # The only thing in the line was a symbol
580
      $symbol_table{$current_symbol} = $program_address;
581
    } else {
582
      &do_compiler_command(@white_split);
583
      &do_instruction;
584
    }
585
  }
586
  $source_line_number++;
587
}
588
 
589
&print_symbol_table;
590
&print_memory_image;
591
 
592
close( source_file );
593
close( verilog_file );
594
 

powered by: WebSVN 2.1.0

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