Line 210... |
Line 210... |
FILE *fo;
|
FILE *fo;
|
int b, i, j;
|
int b, i, j;
|
int ci = 0, co = 0;
|
int ci = 0, co = 0;
|
int nloads = 0, nstores = 0, ncalls = 0;
|
int nloads = 0, nstores = 0, ncalls = 0;
|
char tmp[256];
|
char tmp[256];
|
cuc_bb *end_bb = NULL;
|
|
int end_bb_no = -1;
|
|
sprintf (tmp, "%s.v", filename);
|
sprintf (tmp, "%s.v", filename);
|
|
|
log ("Generating verilog file \"%s\"\n", tmp);
|
log ("Generating verilog file \"%s\"\n", tmp);
|
PRINTF ("Generating verilog file \"%s\"\n", tmp);
|
PRINTF ("Generating verilog file \"%s\"\n", tmp);
|
if ((fo = fopen (tmp, "wt+")) == NULL) {
|
if ((fo = fopen (tmp, "wt+")) == NULL) {
|
fprintf (stderr, "Cannot open '%s'\n", tmp);
|
fprintf (stderr, "Cannot open '%s'\n", tmp);
|
exit (1);
|
exit (1);
|
}
|
}
|
|
|
for (b = 0; b < f->num_bb; b++)
|
|
if (f->bb[b].type & BB_END) end_bb = &f->bb[end_bb_no = b];
|
|
assert (end_bb && end_bb->type & BB_END);
|
|
|
|
/* output header */
|
/* output header */
|
GEN ("/* %s -- generated by OpenRISC Custom Unit Compiler\n", tmp);
|
GEN ("/* %s -- generated by OpenRISC Custom Unit Compiler\n", tmp);
|
GEN (" (C) 2002 OpenCores http://www.opencores.org/\n");
|
GEN (" (C) 2002 OpenCores http://www.opencores.org/\n");
|
GEN (" function \"%s\"\n", funcname);
|
GEN (" function \"%s\"\n", funcname);
|
GEN (" at %08x - %08x\n", f->start_addr, f->end_addr);
|
GEN (" at %08x - %08x\n", f->start_addr, f->end_addr);
|
Line 446... |
Line 440... |
nstores - 1, nstores);
|
nstores - 1, nstores);
|
if (ncalls) GEN ("wire [%i:0] f_end = f_stb & {%i{fend_i}};\n",
|
if (ncalls) GEN ("wire [%i:0] f_end = f_stb & {%i{fend_i}};\n",
|
ncalls - 1, ncalls);
|
ncalls - 1, ncalls);
|
|
|
GEN ("\n/* last dependency */\n");
|
GEN ("\n/* last dependency */\n");
|
GEN ("wire end_o = bb_stb[%i]", end_bb_no);
|
GEN ("wire end_o = ");
|
if (end_bb->mdep) {
|
for (b = 0; b < f->num_bb; b++) {
|
|
for (i = 0; i < 2; i++) if (f->bb[b].next[i] == BBID_END) {
|
|
GEN ("bb_stb[%i]", b);
|
|
if (f->bb[b].mdep) {
|
GEN (" && ");
|
GEN (" && ");
|
print_deps (fo, f, end_bb_no, end_bb->mdep, 0);
|
print_deps (fo, f, b, f->bb[b].mdep, 0);
|
}
|
}
|
|
/* Is branch to BBID_END conditional? */
|
/* Is there a loop right at the end? */
|
if (f->bb[b].next[1 - i] >= 0) {
|
if (end_bb->next[0] != BBID_END || end_bb->next[1] != BBID_END && end_bb->next[1] >= 0) {
|
int bidx = branch_index (&f->bb[b]);
|
int bidx = branch_index (end_bb);
|
|
char t[30];
|
char t[30];
|
print_op_v (f, t, REF (end_bb_no, bidx), 1);
|
print_op_v (f, t, REF (b, bidx), 1);
|
GEN (" && !%s", t);
|
GEN (" && %s%s", i ? "" : "!", t);
|
|
}
|
|
}
|
}
|
}
|
GEN (";\n");
|
GEN (";\n");
|
GEN ("wire busy_o = |bb_stb;\n");
|
GEN ("wire busy_o = |bb_stb;\n");
|
|
|
|
|
Line 704... |
Line 702... |
int i, j, nrf, first;
|
int i, j, nrf, first;
|
char tmp[256];
|
char tmp[256];
|
int ncallees[MAX_FUNCS];
|
int ncallees[MAX_FUNCS];
|
int nl[MAX_FUNCS], ns[MAX_FUNCS];
|
int nl[MAX_FUNCS], ns[MAX_FUNCS];
|
int maxncallees = 0;
|
int maxncallees = 0;
|
sprintf (tmp, "%s.v", filename);
|
sprintf (tmp, "%s_top.v", filename);
|
|
|
for (i = 0, nrf = 0; i < nfuncs; i++) {
|
for (i = 0, nrf = 0; i < nfuncs; i++) {
|
nl[i] = ns[i] = 0;
|
nl[i] = ns[i] = 0;
|
ncallees[i] = 0;
|
ncallees[i] = 0;
|
if (f[i]) {
|
if (f[i]) {
|