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

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 495 to Rev 496
    Reverse comparison

Rev 495 → Rev 496

/trunk/gen_or1k_isa/sources/gen_or1k_isa.c
1,6 → 1,7
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define NO_RELOC 20
#define RELOC_32 1
8,6 → 9,15
#define RELOC_CONST 3
#define RELOC_CONSTH 4
 
#define EX_NONE "None"
#define EX_NA_N "N"
#define EX_NA_A "A"
#define EX_RANGE "Range Exception"
#define EX_TRAP "Trap Exception"
#define EX_TLB "TLB miss"
#define EX_PAGE "Page fault"
#define EX_BUSER "Bus error"
 
#include "opcode/or32.h"
#include "or1k_isadesc.h"
 
45,9 → 55,6
} else if (*input == '%') {
*output++ = '\\';
*output++ = '%';
} else if (*input == '&') {
*output++ = '\\';
*output++ = '&';
} else if (*input == '\\') {
*output++ = '\\';
*output++ = '\\';
63,6 → 70,10
*output++ = 'n';
*output++ = 't';
*output++ = ' ';
} else if (*input == '<') {
*output++ = '$';
*output++ = '<';
*output++ = '$';
} else
*output++ = *input;
input++;
69,7 → 80,19
}
*output = '\0';
}
 
void eliminate_slash(char *input, char *output)
{
while (*input != '\0') {
if (*input == '\\') {
*output++ = '\n';
*output++ = '\n';
}
else
*output++ = *input;
input++;
}
*output = '\0';
}
void eliminate_crcr(char *input, char *output)
{
while (*input != '\0') {
147,7 → 170,77
printf("\\end{tabular}\\par}\n");
}
 
void transform_except(char *input, char *output)
{
char *pTmp = NULL;
 
pTmp = (char*)strtok(input, "\\");
while (pTmp) {
if (strcmp(pTmp, EX_RANGE) == 0) *output++ = 'R';
if (strcmp(pTmp, EX_NA_N) == 0) *output++ = '-';
if (strcmp(pTmp, EX_NA_A) == 0) *output++ = '-';
if (strcmp(pTmp, EX_TRAP) == 0) *output++ = 'T';
if (strcmp(pTmp, EX_TLB) == 0) *output++ = 'M';
if (strcmp(pTmp, EX_PAGE) == 0) *output++ = 'P';
if (strcmp(pTmp, EX_BUSER) == 0) *output++ = 'B';
 
pTmp = (char*)strtok(NULL, "\\");
}
*output = '\0';
}
 
void print_reference(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
{
char tmp[2000];
char tmp2[2000];
int i,j;
 
if (newtable) {
printf("\\footnotesize\n");
printf("\\begin{longtable}[t]{|p{2.3cm}|p{2cm}|p{6cm}|p{6cm}|p{0.6cm}|}\n");
printf("\\hline\n");
printf("\\normalsize ISN &\n");
printf("\\normalsize Name &\n");
printf("\\normalsize Description &\n");
/*printf("\\normalsize Usage &\n");*/
printf("\\normalsize Action &\n");
printf("\\normalsize ex. \\\\\n");
printf("\\hline\n");
printf("\\endhead\n");
printf("\\hline\n");
printf("\\endfoot\n");
}
else {
transform_tex(insn->name, tmp);
transform_tex(insn->args, tmp2);
printf("{\n\n\\raggedright %s %s} &\n", tmp, tmp2);
transform_tex(info->title, tmp);
printf("\\raggedright %s &\n", tmp);
transform_tex(info->desc, tmp);
printf("%s &\n", tmp);
/*
transform_tex(insn->args, tmp);
transform_tex(insn->name, tmp2);
printf("%s %s &\n", tmp2, tmp);
*/
eliminate_slash(info->oper32, tmp);
transform_tex(tmp, tmp2);
printf("{\n");
printf("%s} &\n", tmp2);
/*
transform_tex(info->oper64, tmp);
printf("{\n");
printf("%s} &\n", tmp);
*/
tmp[0] = 0;
strcpy(tmp2, info->except);
transform_except(tmp2, tmp);
printf("%s \\\\\n", tmp);
 
printf("\\hline\n");
}
}
 
void print_summary(int newtable, struct or32_opcode *insn, struct or1k_isa *info)
{
char tmp[2000];
497,20 → 590,38
int main(int argc, char *argv[])
{
int i, j;
int summary = 0;
int mode = 0;
long classes = -1;
if ((argc >= 2) && (strcmp(argv[1], "-s") == 0))
summary = 1;
mode = 1;
 
if ((argc >= 2) && (strcmp(argv[1], "-r") == 0))
mode = 2;
if (argc == 3)
classes = strtol(argv[2], NULL, 0);
cross_ref_check();
printf("\n\\begin{document}\n\\thispagestyle{empty}\\hfil\\vfil\\newpage\\vspace{50mm}\n");
switch (mode) {
case 0:
case 1:
printf("\n\\begin{document}\n\\vspace{50mm}");
break;
case 2:
printf("\\documentclass[10pt,a4paper,onepage]{article}\n");
printf("\\setlength{\\topmargin}{-0.5in}\n");
printf("\\setlength{\\textheight}{9.5in}\n");
printf("\\setlength{\\evensidemargin}{-1.5cm}\n");
printf("\\setlength{\\oddsidemargin}{-1.5cm}\n");
printf("\\usepackage{longtable}\n");
printf("\\begin{document}\n");
printf("\\pagestyle{empty}\n");
printf("\\hspace{-3cm}\\noindent\n");
}
 
for(i = 0; strlen(or1k_order[i].title); i++) {
printf("\\section{%s}\n", or1k_order[i].title);
printf("\\section{%s}\n \n \n", or1k_order[i].title);
j= 0;
while (get_or1k_isa(or1k_order[i].classes, &info)) {
517,12 → 628,18
if (((1 << info.desc->class) & classes) == 0)
continue;
 
if (summary) {
switch (mode) {
case 1:
decode(info.opcode);
if (j && ((j % 100) == 0))
printf("\\end{tabular}\\par}\n");
print_summary(((j % 100) == 0), info.opcode, info.desc);
} else {
break;
case 2:
decode(info.opcode);
print_reference((j == 0), info.opcode, info.desc);
break;
case 0:
print_header(info.opcode, info.desc);
decode(info.opcode);
print_encoding();
530,10 → 647,12
}
j++;
}
if (summary && j)
if ( (mode == 1) && j)
printf("\\end{tabular}\\par}\n");
if ( (mode == 2) && j)
printf("\\end{longtable}\n");
}
printf("\n\\newpage\\thispagestyle{empty}\\hfil\\vfil\\end{document}\n");
printf("\n\\end{document}\n");
return 0;
}
/trunk/gen_or1k_isa/Makefile
7,6 → 7,12
chop_html: sources/chop_html.c Makefile
gcc -O2 -o chop_html sources/chop_html.c
 
generate_ref: gen_or1k_isa
./gen_or1k_isa -r 2 > tmp/body.tex
latex tmp/body.tex; mv body.* tmp; dvips -o result/or1k_isa_ref.ps tmp/body.dvi
rm -f texput.log
pdflatex tmp/body.tex; mv body.* tmp; mv tmp/body.pdf result/or1k_isa_ref.pdf
 
generate_isa: gen_or1k_isa chop_html sources/header.tex
./gen_or1k_isa > tmp/body.tex
cat sources/header.tex tmp/body.tex > tmp/isa.tex

powered by: WebSVN 2.1.0

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