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 1114

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

powered by: WebSVN 2.1.0

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