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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gen_or1k_isa/] [sources/] [gen_or1k_isa.c] - Blame information for rev 496

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

Line No. Rev Author Line
1 14 lampret
 
2
#include <stdio.h>
3 95 lampret
#include <stdlib.h>
4 496 ivang
#include <string.h>
5 14 lampret
 
6
#define NO_RELOC 20
7
#define RELOC_32 1
8
#define RELOC_8 2
9
#define RELOC_CONST 3
10
#define RELOC_CONSTH 4
11
 
12 496 ivang
#define EX_NONE         "None"
13
#define EX_NA_N         "N"
14
#define EX_NA_A         "A"
15
#define EX_RANGE        "Range Exception"
16
#define EX_TRAP         "Trap Exception"
17
#define EX_TLB          "TLB miss"
18
#define EX_PAGE         "Page fault"
19
#define EX_BUSER        "Bus error"
20
 
21 155 simons
#include "opcode/or32.h"
22 14 lampret
#include "or1k_isadesc.h"
23
 
24
/* types of data in encoding field. */
25
typedef enum { opcode, reserved, operand } encfld_types;
26
 
27
/* encoding transformed for TeX output */
28
struct {
29
        int bitpos[33];
30
        int fldcnt;
31
        int insn_size;
32
        struct {
33
                encfld_types type;
34
                int value;
35
                int bitsize;
36
        } field[50];
37
} decoded;
38
 
39 87 lampret
struct info {
40
        struct or1k_isa *desc;
41
        struct or32_opcode *opcode;
42
} info;
43
 
44
void transform_tex(char *input, char *output)
45
{
46
        while (*input != '\0') {
47
                if (*input == '[') {
48
                        *output++ = '{';
49
                        *output++ = '[';
50
                        *output++ = '}';
51
                } else if (*input == ']') {
52
                        *output++ = '{';
53
                        *output++ = ']';
54
                        *output++ = '}';
55
                } else if (*input == '%') {
56
                        *output++ = '\\';
57
                        *output++ = '%';
58
                } else if (*input == '\\') {
59
                        *output++ = '\\';
60
                        *output++ = '\\';
61
                } else if (*input == '_') {
62
                        *output++ = '\\';
63
                        *output++ = '_';
64
                } else if (*input == '\t') {
65
                        *output++ = '\\';
66
                        *output++ = 'i';
67
                        *output++ = 'n';
68
                        *output++ = 'd';
69
                        *output++ = 'e';
70
                        *output++ = 'n';
71
                        *output++ = 't';
72
                        *output++ = ' ';
73 496 ivang
                } else if (*input == '<') {
74
                        *output++ = '$';
75
                        *output++ = '<';
76
                        *output++ = '$';
77 87 lampret
                } else
78
                        *output++ = *input;
79
                input++;
80
        }
81
        *output = '\0';
82
}
83 496 ivang
void eliminate_slash(char *input, char *output)
84
{
85
        while (*input != '\0') {
86
                if (*input == '\\') {
87
                        *output++ = '\n';
88
                        *output++ = '\n';
89
                }
90
                else
91
                        *output++ = *input;
92
                input++;
93
        }
94
        *output = '\0';
95
}
96 95 lampret
void eliminate_crcr(char *input, char *output)
97
{
98
        while (*input != '\0') {
99
                if (*input == '\\') {
100
/*                      *output++ = '{';
101
                        *output++ = '[';*/
102
                } else
103
                        *output++ = *input;
104
                input++;
105
        }
106
        *output = '\0';
107
}
108
 
109 14 lampret
void print_encoding()
110
{
111
        int i, j;
112
 
113
        printf("\\vspace{10mm}\n");
114
        printf("{\\centering \\begin{tabular}{");
115
 
116
        /* organization of the table */
117
        for(i = 1; i <= decoded.fldcnt; i++) {
118
                printf("|");
119
                for(j = 0; j < decoded.field[i].bitsize; j++)
120 87 lampret
                        if (j == 0)
121
                                printf("l");
122
                        else if (j+1 == decoded.field[i].bitsize)
123
                                printf("r");
124
                        else
125
                                printf("c");
126 14 lampret
        }
127
        printf("|}\n\\hline\n");
128
 
129
        /* print first row of the table */
130
        for(i = decoded.insn_size - 1; i > 0; i--)
131 155 simons
                if (decoded.bitpos[i])
132
                        printf("{\\footnotesize\\hspace{-0.5mm}\\hfil%d\\hfil}&\n", i);
133 14 lampret
                else
134 155 simons
                        printf("{\\footnotesize\\hspace{-1.5mm}\\hfil.\\hfil}&\n");
135 14 lampret
        printf("0\\\\\n\\hline\n");
136
 
137
        /* print second row of the table */
138
        for(i = 1; i <= decoded.fldcnt; i++) {
139
                if (decoded.field[i].type == opcode) {
140
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
141
                        printf("%s", (i == 1 ? "|":""));
142 155 simons
                        printf("c|}{\\small{opcode 0x%x}}", decoded.field[i].value);
143 14 lampret
                } else if (decoded.field[i].type == operand) {
144
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
145
                        printf("%s", (i == 1 ? "|":""));
146 155 simons
                        printf("c|}{\\small{%c }}", decoded.field[i].value);
147 14 lampret
                } else if (decoded.field[i].type == reserved) {
148
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
149
                        printf("%s", (i == 1 ? "|":""));
150 155 simons
                        printf("c|}{\\small{reserved}}", decoded.field[i].value);
151 14 lampret
                }
152
                if (i == decoded.fldcnt)
153
                        printf("\\\\\n");
154
                else
155
                        printf("&\n");
156
        }
157
        printf("\n\\hline\n");
158
 
159
        /* print third row of the table */
160
        for(i = 1; i < decoded.fldcnt; i++) {
161
                printf("\\multicolumn{%d}", decoded.field[i].bitsize);
162 155 simons
                printf("{%sc|}{\\small{%d bits}}&\n", (i == 1 ? "|":""), decoded.field[i].bitsize);
163 14 lampret
        }
164
        printf("\\multicolumn{%d}", decoded.field[i].bitsize);
165 155 simons
        printf("{%sc|}{\\small{%d}bits}\\\\\n", (i == 1 ? "|":""), decoded.field[i].bitsize);
166
        printf("\n\\hline\n");
167 87 lampret
/*      printf("\\multicolumn{32}");
168
/*      printf("{|c|}{\\textcolor{white}{XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX ");
169
        printf("XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX}}\\\\\n");*/
170
        printf("\\end{tabular}\\par}\n");
171 14 lampret
}
172
 
173 496 ivang
void transform_except(char *input, char *output)
174
{
175
        char *pTmp = NULL;
176 95 lampret
 
177 496 ivang
        pTmp = (char*)strtok(input, "\\");
178
        while (pTmp) {
179
                if (strcmp(pTmp, EX_RANGE) == 0) *output++ = 'R';
180
                if (strcmp(pTmp, EX_NA_N)  == 0) *output++ = '-';
181
                if (strcmp(pTmp, EX_NA_A)  == 0) *output++ = '-';
182
                if (strcmp(pTmp, EX_TRAP)  == 0) *output++ = 'T';
183
                if (strcmp(pTmp, EX_TLB)   == 0) *output++ = 'M';
184
                if (strcmp(pTmp, EX_PAGE)  == 0) *output++ = 'P';
185
                if (strcmp(pTmp, EX_BUSER) == 0) *output++ = 'B';
186
 
187
                pTmp = (char*)strtok(NULL, "\\");
188
        }
189
        *output = '\0';
190
}
191
 
192
void print_reference(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
193
{
194
        char tmp[2000];
195
        char tmp2[2000];
196
        int i,j;
197
 
198
        if (newtable) {
199
                printf("\\footnotesize\n");
200
                printf("\\begin{longtable}[t]{|p{2.3cm}|p{2cm}|p{6cm}|p{6cm}|p{0.6cm}|}\n");
201
                printf("\\hline\n");
202
                printf("\\normalsize ISN &\n");
203
                printf("\\normalsize Name &\n");
204
                printf("\\normalsize Description &\n");
205
                /*printf("\\normalsize Usage &\n");*/
206
                printf("\\normalsize Action &\n");
207
                printf("\\normalsize ex. \\\\\n");
208
                printf("\\hline\n");
209
                printf("\\endhead\n");
210
                printf("\\hline\n");
211
                printf("\\endfoot\n");
212
        }
213
        else {
214
                transform_tex(insn->name, tmp);
215
                transform_tex(insn->args, tmp2);
216
                printf("{\n\n\\raggedright %s %s} &\n", tmp, tmp2);
217
                transform_tex(info->title, tmp);
218
                printf("\\raggedright %s &\n", tmp);
219
                transform_tex(info->desc, tmp);
220
                printf("%s &\n", tmp);
221
                /*
222
                  transform_tex(insn->args, tmp);
223
                  transform_tex(insn->name, tmp2);
224
                  printf("%s %s &\n", tmp2, tmp);
225
                */
226
                eliminate_slash(info->oper32, tmp);
227
                transform_tex(tmp, tmp2);
228
                printf("{\n");
229
                printf("%s} &\n", tmp2);
230
                /*
231
                transform_tex(info->oper64, tmp);
232
                printf("{\n");
233
                printf("%s} &\n", tmp);
234
                */
235
                tmp[0] = 0;
236
                strcpy(tmp2, info->except);
237
                transform_except(tmp2, tmp);
238
                printf("%s \\\\\n", tmp);
239
 
240
                printf("\\hline\n");
241
        }
242
}
243
 
244 95 lampret
void print_summary(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
245
{
246
        char tmp[2000];
247
        char tmp2[2000];
248
        int i, j, k;
249
 
250
 
251
        if (newtable) {
252
 
253
                printf("{\\centering \\begin{tabular}{|l");
254
 
255
                /* organization of the table */
256
                for(i = 1; i <= decoded.fldcnt; i++) {
257
                        printf("|");
258
                        for(j = 0; j < decoded.field[i].bitsize; j++)
259
                                if (j == 0)
260
                                        printf("l");
261
                                else if (j+1 == decoded.field[i].bitsize)
262
                                        printf("r");
263
                                else
264
                                        printf("c");
265
                }
266
                printf("|}\n");
267
                printf("Insn&\n");
268
 
269
                /* print first row of the table */
270
                for(i = decoded.insn_size - 1; i > 0; i--)
271
                        if (decoded.bitpos[i])
272
                                printf("%d&\n", i);
273
                        else
274
                                printf("%d&\n");
275
                printf("0\\\\\n");
276
        }
277
        else {
278
                printf("\\multicolumn{1}{|c}{}&\n");
279
                k = 31;
280
                for(i = 1; i <= decoded.fldcnt; i++) {
281
                        for(j = 0; j < decoded.field[i].bitsize; j++) {
282
                                if (j == 0)
283
                                        printf("\\multicolumn{1}{|l");
284
                                else if (j+1 == decoded.field[i].bitsize)
285
                                        printf("\\multicolumn{1}{|r");
286
                                else
287
                                        printf("\\multicolumn{1}{|c");
288
                                if (k)
289
                                        printf("}{%d}&\n", k);
290
                                else
291
                                        printf("}{%d}\\\\\n", k);
292
                                k--;
293
                        }
294
                }
295
        }
296
 
297
        printf("\\multicolumn{1}{|l|}{");
298
        transform_tex(info->name, tmp);
299
        printf("%s}&\n", tmp);
300
 
301
        /* print second row of the table */
302
        for(i = 1; i <= decoded.fldcnt; i++) {
303
                if (decoded.field[i].type == opcode) {
304
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
305
                        printf("%s", (i == 1 ? "|":""));
306
                        printf("c|}{opcode 0x%x}", decoded.field[i].value);
307
                } else if (decoded.field[i].type == operand) {
308
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
309
                        printf("%s", (i == 1 ? "|":""));
310
                        printf("c|}{%c}", decoded.field[i].value);
311
                } else if (decoded.field[i].type == reserved) {
312
                        printf("\\multicolumn{%d}{", decoded.field[i].bitsize);
313
                        printf("%s", (i == 1 ? "|":""));
314
                        printf("c|}{reserved}", decoded.field[i].value);
315
                }
316
                if (i == decoded.fldcnt)
317
                        printf("\\\\\n");
318
                else
319
                        printf("&\n");
320
        }
321
        printf("\n");
322
 
323
        /* print third row of the table */
324
/*      printf("\\multicolumn{10}{|c|}{");
325
        transform_tex(info->name, tmp);
326
        printf("%s ", tmp);
327
        transform_tex(insn->args, tmp);
328
        printf("%s}&\n", tmp);
329
        printf("\\multicolumn{22}{c|}{");
330
        eliminate_crcr(info->desc, tmp2);
331
        transform_tex(tmp2, tmp);
332
        printf("%s}\\\\\n", tmp); */
333
 
334
 
335
}
336
 
337 87 lampret
void decode(struct or32_opcode *insn)
338 14 lampret
{
339
        int opc_pos = 0;
340
        char *enc;
341
        encfld_types last;
342
        char lastoperand;
343
        int tmp;
344
 
345
        if (!insn) {
346
                printf("internal error: insn pointer NULL\n");
347
                return;
348
        }
349
 
350
        memset(&decoded, 0, sizeof(decoded));
351
 
352
        if ((insn->name[0] == 'h') && (insn->name[1] == '.'))
353
                decoded.insn_size = opc_pos = 16;
354
        else
355
                decoded.insn_size = opc_pos = 32;
356
 
357
        last = -1;
358
 
359
        for (enc = insn->encoding; *enc != '\0'; )
360
                if ((*enc == '0') && (*(enc+1) == 'x')) {
361
                        int tmp = strtol(enc, NULL, 16);
362
                        if (last != opcode) {
363
                                decoded.bitpos[opc_pos] = 1;
364
                                decoded.bitpos[opc_pos - 1] = 1;
365
                                decoded.field[++decoded.fldcnt].type = opcode;
366
                        }
367
                        decoded.field[decoded.fldcnt].value <<= 4;
368
                        decoded.field[decoded.fldcnt].value += tmp;
369
                        decoded.field[decoded.fldcnt].bitsize += 4;
370
                        opc_pos -= 4;
371
                        enc += 3;
372
                        last = opcode;
373
                }
374
                else if (*enc == '0') {
375
                       if (last != opcode) {
376
                                decoded.bitpos[opc_pos] = 1;
377
                                decoded.bitpos[opc_pos - 1] = 1;
378
                                decoded.field[++decoded.fldcnt].type = opcode;
379
                        }
380
                        decoded.field[decoded.fldcnt].value <<= 1;
381
                        decoded.field[decoded.fldcnt].bitsize += 1;
382
                        opc_pos--;
383
                        enc++;
384
                        last = opcode;
385
                }
386
                else if (*enc == '-') {
387
                       if (last != reserved) {
388
                                decoded.bitpos[opc_pos] = 1;
389
                                decoded.bitpos[opc_pos - 1] = 1;
390
                                decoded.field[++decoded.fldcnt].type = reserved;
391
                        }
392
                        decoded.field[decoded.fldcnt].value <<= 1;
393
                        decoded.field[decoded.fldcnt].bitsize += 1;
394
                        opc_pos--;
395
                        enc++;
396
                        last = reserved;
397
                }
398
                else if (*enc == '1') {
399
                       if (last != opcode) {
400
                                decoded.bitpos[opc_pos] = 1;
401
                                decoded.bitpos[opc_pos - 1] = 1;
402
                                decoded.field[++decoded.fldcnt].type = opcode;
403
                        }
404
                        decoded.field[decoded.fldcnt].value <<= 1;
405
                        decoded.field[decoded.fldcnt].value += 1;
406
                        decoded.field[decoded.fldcnt].bitsize += 1;
407
                        opc_pos--;
408
                        enc++;
409
                        last = opcode;
410
                }
411
                else if (isalpha(*enc)) {
412
                       if ((last != operand) || (lastoperand != *enc)) {
413
                                decoded.bitpos[opc_pos] = 1;
414
                                decoded.bitpos[opc_pos - 1] = 1;
415
                                decoded.field[++decoded.fldcnt].type = operand;
416
                        }
417
                        decoded.field[decoded.fldcnt].value = *enc;
418
                        decoded.field[decoded.fldcnt].bitsize += 1;
419
                        opc_pos--;
420
                        lastoperand = *enc;
421
                        enc++;
422
                        last = operand;
423
                }
424
                else
425
                        enc++;
426
}
427
 
428 87 lampret
void print_header(struct or32_opcode *insn, struct or1k_isa *info)
429 14 lampret
{
430 87 lampret
        char tmp[2000];
431
 
432
        printf("\n\n\\pagebreak\n");
433 14 lampret
        printf("\\vspace{10mm}\n");
434
        /* printf("\\section{Appendix A}\n"); */
435
        printf("\\lyxline{\\small}\\vspace{-1\\parskip}\n");
436
        printf("\\vspace{10mm}\n");
437 87 lampret
        printf("{\\centering \\begin{tabular}{ccc}\n");
438 14 lampret
        printf("\\textbf{\\textcolor{white}{\\small Left}}\\textcolor{white}{\\small }&\n");
439 87 lampret
        printf("\\textcolor{white}{\\small }\\textbf{\\textcolor{white}{\\small Middle \n");
440 155 simons
        printf("Middle Middle Middle Middle ");
441
        printf("Middle Middle Middle Middle ");
442
        printf("Middle}} \\textcolor{white}{\\small }&\n");
443 14 lampret
        printf("\\textcolor{white}{\\small }\\textbf{\\textcolor{white}{\\small Right}}\\\\\n");
444 87 lampret
        transform_tex(insn->name, tmp);
445
        printf("\\textbf{\\Large %s}&\n", tmp);
446
        transform_tex(info->title, tmp);
447
        printf("\\multicolumn{1}{c}{\\textbf{\\Large %s}}&\n", tmp);
448
        transform_tex(insn->name, tmp);
449
        printf("\\textbf{\\Large %s}\\\\\n", tmp);
450 14 lampret
        printf("\\end{tabular}\\par}\n\\bigskip{}\n\n");
451
}
452
 
453 87 lampret
struct or1k_isa *get_or1k_isa(unsigned long classes, struct info *info)
454 14 lampret
{
455
        int i;
456 87 lampret
        struct or1k_isa *tmp;
457
 
458
        while (1) {
459
                /* Pick first instruction that wasn't printed yet and meets current class constraint */
460
                for (i = 0; strlen(or1k_isa_info[i].name); i++)
461
                        if ((!or1k_isa_info[i].printed) && ((1<<or1k_isa_info[i].class)>>1 & classes))
462
                                break;
463
 
464
                /* Don't return any instruction if they were all already processed or don't meet
465
                   class constraint. */
466
                if (strlen(or1k_isa_info[i].name) == 0) {
467
                        fprintf(stderr, "All instructions that meet class constraint %x were processed.\n", classes);
468
                        return NULL;
469
                }
470 14 lampret
 
471 87 lampret
                tmp = &or1k_isa_info[i];
472 14 lampret
 
473 87 lampret
                /* Check if tmp instruction is first in order to be processed. If preceeding
474
                   instructions are found, they are used instead. */
475
                for (i = 0; strlen(or1k_isa_info[i].name); i++)
476
                        if ((!or1k_isa_info[i].printed) && ((1<<or1k_isa_info[i].class)>>1 & classes) &&
477
                            (strcmp(or1k_isa_info[i].name, tmp->name) < 0))
478
                                tmp = &or1k_isa_info[i];
479
 
480
                tmp->printed = 1;
481
 
482
                /* Find matching encoding. */
483
                for (i = 0; strlen(or32_opcodes[i].name); i++)
484
                        if (strcmp(tmp->name, or32_opcodes[i].name) == 0) {
485
                                fprintf(stderr, "PROCESSING: %s\n", tmp->name);
486
                                info->desc = tmp;
487 155 simons
                                info->opcode = (struct or32_opcode *) &or32_opcodes[i];
488 87 lampret
                                return tmp;
489
                        }
490
        }
491
 
492
        return NULL;
493 14 lampret
}
494
 
495 87 lampret
void cross_ref_check()
496 14 lampret
{
497 87 lampret
        int i, j;
498
 
499
        for (i = 0; strlen(or32_opcodes[i].name); i++) {
500
                for (j = 0; strlen(or1k_isa_info[j].name); j++)
501
                        if (strcmp(or32_opcodes[i].name, or1k_isa_info[j].name) == 0)
502
                                break;
503
                if (strlen(or1k_isa_info[j].name) == 0)
504
                        fprintf(stderr, "Description for %s missing.\n", or32_opcodes[i].name);
505 14 lampret
        }
506 87 lampret
 
507
        for (i = 0; strlen(or1k_isa_info[i].name); i++) {
508
                for (j = 0; strlen(or32_opcodes[j].name); j++)
509
                        if (strcmp(or1k_isa_info[i].name, or32_opcodes[j].name) == 0)
510
                                break;
511
                if (strlen(or32_opcodes[j].name) == 0)
512
                        fprintf(stderr, "Encoding for %s missing.\n", or1k_isa_info[i].name);
513
        }
514 14 lampret
}
515
 
516 87 lampret
void print_body(struct or32_opcode *insn, struct or1k_isa *info)
517 14 lampret
{
518
        char tmp[2000];
519
 
520
        printf("\\vspace{15mm}\n");
521
 
522 155 simons
        printf("{\\par \\raggedright \\textbf{\\large Format:}\\large \\par}\n");
523 14 lampret
        printf("\\vspace{5mm}\n");
524
        printf("\\begin{quotation}\n");
525 87 lampret
        transform_tex(info->name, tmp);
526
        printf("\\texttt{\\large %s\\ ", tmp);
527
        transform_tex(insn->args, tmp);
528
        printf("%s}{\\large \\par}\n", tmp);
529 14 lampret
        printf("\\end{quotation}\n");
530
        printf("\\vspace{10mm}\n");
531
 
532 155 simons
        printf("\\textbf{\\large Description:}{\\large \\par}\n");
533 14 lampret
        printf("\\vspace{5mm}\n");
534
        printf("\\begin{quotation}\n");
535 87 lampret
        transform_tex(info->desc, tmp);
536
        printf("%s\n", tmp);
537 14 lampret
        printf("\\end{quotation}\n");
538
        printf("\\vspace{10mm}\n");
539
 
540 155 simons
        printf("\\textbf{\\large 32-bit Implementation:}{\\large \\par}\n");
541 14 lampret
        printf("\\vspace{5mm}\n");
542 155 simons
        /*printf("\\begin{flushleft}\n");*/
543 14 lampret
        printf("\\begin{quotation}\n");
544 87 lampret
        transform_tex(info->oper32, tmp);
545
        printf("\\texttt{\\large %s}{\\large \\par}\n", tmp);
546 14 lampret
        printf("\\end{quotation}\n");
547 155 simons
        /*printf("\\end{flushleft}\n");*/
548 14 lampret
        printf("\\vspace{10mm}\n");
549
 
550 155 simons
        printf("\\textbf{\\large 64-bit Implementation:}{\\large \\par}\n");
551 14 lampret
        printf("\\vspace{5mm}\n");
552 155 simons
        /*printf("\\begin{flushleft}\n");*/
553 14 lampret
        printf("\\begin{quotation}\n");
554 87 lampret
        transform_tex(info->oper64, tmp);
555
        printf("\\texttt{\\large %s}{\\large \\par}\n", tmp);
556
        printf("\\end{quotation}\n");
557 155 simons
        /*printf("\\end{flushleft}\n");*/
558 87 lampret
        printf("\\vspace{10mm}\n");
559
 
560 155 simons
        printf("\\textbf{\\large Exceptions:}{\\large \\par}\n");
561 87 lampret
        printf("\\vspace{5mm}\n");
562 155 simons
        /*printf("\\begin{flushleft}\n");*/
563 87 lampret
        printf("\\begin{quotation}\n");
564
        transform_tex(info->except, tmp);
565
        printf("\\texttt{\\large %s}{\\large \\par}\n",tmp);
566
        printf("\\end{quotation}\n");
567 155 simons
        /*printf("\\end{flushleft}\n");*/
568 87 lampret
        printf("\\vspace{10mm}\n");
569
 
570 155 simons
        /*printf("\\textbf{\\large Notes:}{\\large \\par}\n");
571 87 lampret
        printf("\\vspace{5mm}\n");
572
        printf("\\begin{quotation}\n");
573 14 lampret
        printf("\n");
574
        printf("\\end{quotation}\n");
575 155 simons
        printf("\\vspace{10mm}\n");*/
576 14 lampret
 
577
        printf("\\vfill\n");
578 87 lampret
        printf("{\\centering \\begin{tabular}{|c|c|}\n");
579 14 lampret
        printf("\\hline\n");
580 89 lampret
        printf("Instruction Class&\n");
581 14 lampret
        printf("Implementation\\\\\n");
582
        printf("\\hline\n");
583 87 lampret
        transform_tex(or1k_isa_classes[info->class].table, tmp);
584 155 simons
        printf("%s\\hline\n", tmp);
585 14 lampret
        printf("\\end{tabular}\\par}\n");
586 87 lampret
 
587 14 lampret
        printf("\n");
588
}
589
 
590 95 lampret
int main(int argc, char *argv[])
591 14 lampret
{
592 95 lampret
        int i, j;
593 496 ivang
        int mode = 0;
594 95 lampret
        long classes = -1;
595
 
596
        if ((argc >= 2) && (strcmp(argv[1], "-s") == 0))
597 496 ivang
                mode = 1;
598 14 lampret
 
599 496 ivang
        if ((argc >= 2) && (strcmp(argv[1], "-r") == 0))
600
                mode = 2;
601
 
602 95 lampret
        if (argc == 3)
603
                classes = strtol(argv[2], NULL, 0);
604
 
605 87 lampret
        cross_ref_check();
606 496 ivang
        switch (mode) {
607
        case 0:
608
        case 1:
609
          printf("\n\\begin{document}\n\\vspace{50mm}");
610
          break;
611
        case 2:
612
          printf("\\documentclass[10pt,a4paper,onepage]{article}\n");
613
          printf("\\setlength{\\topmargin}{-0.5in}\n");
614
          printf("\\setlength{\\textheight}{9.5in}\n");
615
          printf("\\setlength{\\evensidemargin}{-1.5cm}\n");
616
          printf("\\setlength{\\oddsidemargin}{-1.5cm}\n");
617
          printf("\\usepackage{longtable}\n");
618
          printf("\\begin{document}\n");
619
          printf("\\pagestyle{empty}\n");
620
          printf("\\hspace{-3cm}\\noindent\n");
621
        }
622 14 lampret
 
623 87 lampret
        for(i = 0; strlen(or1k_order[i].title); i++) {
624 496 ivang
                printf("\\section{%s}\n \n \n", or1k_order[i].title);
625 95 lampret
                j= 0;
626
 
627
                while (get_or1k_isa(or1k_order[i].classes, &info)) {
628
                        if (((1 << info.desc->class) & classes) == 0)
629
                                continue;
630 87 lampret
 
631 496 ivang
                        switch (mode) {
632
                        case 1:
633 95 lampret
                                decode(info.opcode);
634
                                if (j && ((j % 100) == 0))
635
                                        printf("\\end{tabular}\\par}\n");
636
                                print_summary(((j % 100) == 0), info.opcode, info.desc);
637 496 ivang
                                break;
638
                        case 2:
639
                                decode(info.opcode);
640
                                print_reference((j == 0), info.opcode, info.desc);
641
                                break;
642
                        case 0:
643 95 lampret
                                print_header(info.opcode, info.desc);
644
                                decode(info.opcode);
645
                                print_encoding();
646
                                print_body(info.opcode, info.desc);
647
                        }
648
                        j++;
649 87 lampret
                }
650 496 ivang
                if ( (mode == 1) && j)
651 95 lampret
                        printf("\\end{tabular}\\par}\n");
652 496 ivang
                if ( (mode == 2) && j)
653
                        printf("\\end{longtable}\n");
654 87 lampret
        }
655 14 lampret
 
656 496 ivang
        printf("\n\\end{document}\n");
657 14 lampret
        return 0;
658
}

powered by: WebSVN 2.1.0

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