Line 19... |
Line 19... |
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdarg.h>
|
#include <stdarg.h>
|
#include <assert.h>
|
#include <assert.h>
|
|
|
|
#include "abstract.h"
|
#include "cuc.h"
|
#include "cuc.h"
|
#include "insn.h"
|
#include "insn.h"
|
#include "profiler.h"
|
#include "profiler.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
|
|
Line 60... |
Line 62... |
while (t) {
|
while (t) {
|
if (f->INSN(t->ref).type & IT_MEMORY) {
|
if (f->INSN(t->ref).type & IT_MEMORY) {
|
GEN ("%s%c_end[%i]", first ? " && " : "",
|
GEN ("%s%c_end[%i]", first ? " && " : "",
|
II_IS_LOAD (f->INSN(t->ref).index) ? 'l' : 's', find_lsc_index (f, t->ref));
|
II_IS_LOAD (f->INSN(t->ref).index) ? 'l' : 's', find_lsc_index (f, t->ref));
|
} else if (f->INSN(t->ref).index == II_CALL) {
|
} else if (f->INSN(t->ref).index == II_CALL) {
|
int x;
|
|
GEN ("%sf_end[%i]", first ? " && " : "", find_lsc_index (f, t->ref));
|
GEN ("%sf_end[%i]", first ? " && " : "", find_lsc_index (f, t->ref));
|
} else {
|
} else {
|
PRINTF ("print_deps: err %x\n", t->ref);
|
PRINTF ("print_deps: err %lx\n", t->ref);
|
assert (0);
|
assert (0);
|
}
|
}
|
first = 1;
|
first = 1;
|
t = t->next;
|
t = t->next;
|
}
|
}
|
Line 84... |
Line 85... |
switch (opt & ~OPT_DEST) {
|
switch (opt & ~OPT_DEST) {
|
case OPT_NONE: assert (0); break;
|
case OPT_NONE: assert (0); break;
|
case OPT_CONST: if (f->INSN(ref).type & IT_COND && (f->INSN(ref).index == II_CMOV
|
case OPT_CONST: if (f->INSN(ref).type & IT_COND && (f->INSN(ref).index == II_CMOV
|
|| f->INSN(ref).index == II_ADD)) {
|
|| f->INSN(ref).index == II_ADD)) {
|
assert (op == 0 || op == 1);
|
assert (op == 0 || op == 1);
|
sprintf (s, "1'b%x", op);
|
sprintf (s, "1'b%lx", op);
|
} else sprintf (s, "32'h%x", op);
|
} else sprintf (s, "32'h%lx", op);
|
break;
|
break;
|
case OPT_REGISTER:
|
case OPT_REGISTER:
|
if (opt & OPT_DEST) sprintf (s, "t%x_%x", REF_BB(ref), REF_I(ref));
|
if (opt & OPT_DEST) sprintf (s, "t%x_%x", REF_BB(ref), REF_I(ref));
|
else sprintf (s, "r%i_%c", op, opt & OPT_DEST ? 'o' : 'i');
|
else sprintf (s, "r%li_%c", op, opt & OPT_DEST ? 'o' : 'i');
|
break;
|
break;
|
#if 0
|
#if 0
|
case OPT_FREG: assert (opt & OPT_DEST);
|
case OPT_FREG: assert (opt & OPT_DEST);
|
sprintf (s, "fr%i_o", op);
|
sprintf (s, "fr%i_o", op);
|
break;
|
break;
|
#endif
|
#endif
|
case OPT_REF: sprintf (s, "t%x_%x", REF_BB(op), REF_I(op)); break;
|
case OPT_REF: sprintf (s, "t%lx_%lx", REF_BB(op), REF_I(op)); break;
|
}
|
}
|
return s;
|
return s;
|
}
|
}
|
|
|
/* Prints out specified instruction */
|
/* Prints out specified instruction */
|
Line 119... |
Line 120... |
else sprintf (tmp, "%s%c", tmp, *s);
|
else sprintf (tmp, "%s%c", tmp, *s);
|
s++;
|
s++;
|
}
|
}
|
GEN ("%-40s /* %s */\n", tmp, ii->disasm);
|
GEN ("%-40s /* %s */\n", tmp, ii->disasm);
|
if (ii->type & IT_MEMORY) {
|
if (ii->type & IT_MEMORY) {
|
int j, nls = find_lsc_index (f, REF (b, i));
|
int nls = find_lsc_index (f, REF (b, i));
|
if (II_IS_LOAD (ii->index)) {
|
if (II_IS_LOAD (ii->index)) {
|
int nm;
|
int nm;
|
for (nm = 0; nm < f->nmsched; nm++) if (f->msched[nm] == REF (b, i)) break;
|
for (nm = 0; nm < f->nmsched; nm++) if (f->msched[nm] == REF (b, i)) break;
|
assert (nm < f->nmsched);
|
assert (nm < f->nmsched);
|
|
|
Line 155... |
Line 156... |
} else if (ii->index == II_REG) {
|
} else if (ii->index == II_REG) {
|
assert (ii->opt[1] == OPT_REF);
|
assert (ii->opt[1] == OPT_REF);
|
GEN (" if (");
|
GEN (" if (");
|
if (f->bb[b].mdep) print_deps (fo, f, b, f->bb[b].mdep, 0);
|
if (f->bb[b].mdep) print_deps (fo, f, b, f->bb[b].mdep, 0);
|
else GEN ("bb_stb[%i]", b);
|
else GEN ("bb_stb[%i]", b);
|
GEN (") t%x_%x <= #Tp t%x_%x;\n", b, i,
|
GEN (") t%x_%x <= #Tp t%lx_%lx;\n", b, i,
|
REF_BB (ii->op[1]), REF_I (ii->op[1]));
|
REF_BB (ii->op[1]), REF_I (ii->op[1]));
|
}
|
}
|
}
|
}
|
|
|
/* Outputs binary number */
|
/* Outputs binary number */
|
Line 223... |
Line 224... |
|
|
/* output header */
|
/* output header */
|
GEN ("/* %s -- generated by Custom Unit Compiler\n", tmp);
|
GEN ("/* %s -- generated by Custom Unit Compiler\n", tmp);
|
GEN (" (C) 2002 Opencores\n");
|
GEN (" (C) 2002 Opencores\n");
|
GEN (" function \"%s\"\n", funcname);
|
GEN (" function \"%s\"\n", funcname);
|
GEN (" at %08x - %08x\n", f->start_addr, f->end_addr);
|
GEN (" at %08lx - %08lx\n", f->start_addr, f->end_addr);
|
GEN (" num BBs %i */\n\n", f->num_bb);
|
GEN (" num BBs %i */\n\n", f->num_bb);
|
|
|
GEN ("`include \"timescale.v\"\n\n");
|
GEN ("`include \"timescale.v\"\n\n");
|
GEN ("module %s (clk, rst,\n", filename);
|
GEN ("module %s (clk, rst,\n", filename);
|
GEN (" l_adr_o, l_dat_i, l_req_o,\n");
|
GEN (" l_adr_o, l_dat_i, l_req_o,\n");
|
Line 603... |
Line 604... |
cucdebug (1, "%s\n", s);
|
cucdebug (1, "%s\n", s);
|
for (i = 0; i < f->nmsched; i++)
|
for (i = 0; i < f->nmsched; i++)
|
if (j == 0 && f->mtype[i] & MT_LOAD
|
if (j == 0 && f->mtype[i] & MT_LOAD
|
|| j == 1 && f->mtype[i] & MT_STORE
|
|| j == 1 && f->mtype[i] & MT_STORE
|
|| j == 2 && f->mtype[i] & MT_CALL) {
|
|| j == 2 && f->mtype[i] & MT_CALL) {
|
dep_list *dep = f->INSN(f->msched[i]).dep;
|
|
cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
|
cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
|
assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
|
assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
|
GEN ("if (");
|
GEN ("if (");
|
print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
|
print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
|
GEN (") begin\n");
|
GEN (") begin\n");
|
Line 621... |
Line 621... |
case 4: GEN ("1111;\n"); break;
|
case 4: GEN ("1111;\n"); break;
|
default: assert (0);
|
default: assert (0);
|
}
|
}
|
GEN (" %c_linbrst_o = 1'b%i;\n", c,
|
GEN (" %c_linbrst_o = 1'b%i;\n", c,
|
(f->mtype[i] & MT_BURST) && !(f->mtype[i] & MT_BURSTE) ? 1 : 0);
|
(f->mtype[i] & MT_BURST) && !(f->mtype[i] & MT_BURSTE) ? 1 : 0);
|
GEN (" %c_adr_o = t%x_%x & ~32'h3;\n", c,
|
GEN (" %c_adr_o = t%lx_%lx & ~32'h3;\n", c,
|
REF_BB(f->INSN(f->msched[i]).op[1]), REF_I(f->INSN(f->msched[i]).op[1]));
|
REF_BB(f->INSN(f->msched[i]).op[1]), REF_I(f->INSN(f->msched[i]).op[1]));
|
GEN (" end else ");
|
GEN (" end else ");
|
}
|
}
|
GEN ("if (%c_end[%i]) begin\n", c, cur - 1);
|
GEN ("if (%c_end[%i]) begin\n", c, cur - 1);
|
GEN (" %c_req_o = 1'b0;\n", c);
|
GEN (" %c_req_o = 1'b0;\n", c);
|
Line 654... |
Line 654... |
GEN (" fstart_o <= #Tp 1'b0;\n");
|
GEN (" fstart_o <= #Tp 1'b0;\n");
|
//GEN (" f11_r <= #Tp 32'h0;\n");
|
//GEN (" f11_r <= #Tp 32'h0;\n");
|
GEN (" end else begin\n");
|
GEN (" end else begin\n");
|
cucdebug (1, "calls \n");
|
cucdebug (1, "calls \n");
|
for (i = 0; i < f->nmsched; i++) if (f->mtype[i] & MT_CALL) {
|
for (i = 0; i < f->nmsched; i++) if (f->mtype[i] & MT_CALL) {
|
char t[30];
|
|
dep_list *dep = f->INSN(f->msched[i]).dep;
|
dep_list *dep = f->INSN(f->msched[i]).dep;
|
cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
|
cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
|
assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
|
assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
|
GEN (" if (");
|
GEN (" if (");
|
print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
|
print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
|
Line 990... |
Line 989... |
GEN ("\n");
|
GEN ("\n");
|
|
|
for (i = 0; i < nfuncs; i++) if (f[i]) {
|
for (i = 0; i < nfuncs; i++) if (f[i]) {
|
int nf = f[i]->tmp;
|
int nf = f[i]->tmp;
|
GEN ("\n%s%s i%i(.clk(clk), .rst(rst),\n", filename, prof_func[i].name, nf);
|
GEN ("\n%s%s i%i(.clk(clk), .rst(rst),\n", filename, prof_func[i].name, nf);
|
GEN ("");
|
|
GEN (" .l_adr_o(i%i_l_adr), .l_dat_i(i%i_l_dat), .l_req_o(i_l_req[%i]),\n",
|
GEN (" .l_adr_o(i%i_l_adr), .l_dat_i(i%i_l_dat), .l_req_o(i_l_req[%i]),\n",
|
nf, nf, nf);
|
nf, nf, nf);
|
GEN (" .l_sel_o(i%i_l_sel), .l_linbrst_o(i%i_l_linbrst), .l_rdy_i(i%i_l_rdy),\n",
|
GEN (" .l_sel_o(i%i_l_sel), .l_linbrst_o(i%i_l_linbrst), .l_rdy_i(i%i_l_rdy),\n",
|
nf, nf, nf);
|
nf, nf, nf);
|
GEN (" .s_adr_o(i%i_s_adr), .s_dat_o(i%i_s_dat), .s_req_o(i_s_req[%i]),\n",
|
GEN (" .s_adr_o(i%i_s_adr), .s_dat_o(i%i_s_dat), .s_req_o(i_s_req[%i]),\n",
|