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 1775

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

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

powered by: WebSVN 2.1.0

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