mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Added "autoidx" statement to ilang file format
This commit is contained in:
parent
e035f1d886
commit
4147b55c23
|
@ -335,15 +335,26 @@ void ILANG_BACKEND::dump_module(FILE *f, std::string indent, const RTLIL::Module
|
||||||
|
|
||||||
void ILANG_BACKEND::dump_design(FILE *f, const RTLIL::Design *design, bool only_selected, bool flag_m, bool flag_n)
|
void ILANG_BACKEND::dump_design(FILE *f, const RTLIL::Design *design, bool only_selected, bool flag_m, bool flag_n)
|
||||||
{
|
{
|
||||||
|
int init_autoidx = RTLIL::autoidx;
|
||||||
|
|
||||||
if (!flag_m) {
|
if (!flag_m) {
|
||||||
int count_selected_mods = 0;
|
int count_selected_mods = 0;
|
||||||
for (auto it = design->modules.begin(); it != design->modules.end(); it++)
|
for (auto it = design->modules.begin(); it != design->modules.end(); it++) {
|
||||||
|
if (design->selected_whole_module(it->first))
|
||||||
|
flag_m = true;
|
||||||
if (design->selected(it->second))
|
if (design->selected(it->second))
|
||||||
count_selected_mods++;
|
count_selected_mods++;
|
||||||
|
}
|
||||||
if (count_selected_mods > 1)
|
if (count_selected_mods > 1)
|
||||||
flag_m = true;
|
flag_m = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!only_selected || flag_m) {
|
||||||
|
if (only_selected)
|
||||||
|
fprintf(f, "\n");
|
||||||
|
fprintf(f, "autoidx %d\n", RTLIL::autoidx);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = design->modules.begin(); it != design->modules.end(); it++) {
|
for (auto it = design->modules.begin(); it != design->modules.end(); it++) {
|
||||||
if (!only_selected || design->selected(it->second)) {
|
if (!only_selected || design->selected(it->second)) {
|
||||||
if (only_selected)
|
if (only_selected)
|
||||||
|
@ -351,6 +362,8 @@ void ILANG_BACKEND::dump_design(FILE *f, const RTLIL::Design *design, bool only_
|
||||||
dump_module(f, "", it->second, design, only_selected, flag_m, flag_n);
|
dump_module(f, "", it->second, design, only_selected, flag_m, flag_n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_assert(init_autoidx == RTLIL::autoidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IlangBackend : public Backend {
|
struct IlangBackend : public Backend {
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include "kernel/rtlil.h"
|
#include "kernel/rtlil.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
void update_autoidx(const char *p);
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -44,6 +43,7 @@ void update_autoidx(const char *p);
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
"autoidx" { return TOK_AUTOIDX; }
|
||||||
"module" { return TOK_MODULE; }
|
"module" { return TOK_MODULE; }
|
||||||
"attribute" { return TOK_ATTRIBUTE; }
|
"attribute" { return TOK_ATTRIBUTE; }
|
||||||
"parameter" { return TOK_PARAMETER; }
|
"parameter" { return TOK_PARAMETER; }
|
||||||
|
@ -76,11 +76,11 @@ void update_autoidx(const char *p);
|
||||||
[a-z]+ { return TOK_INVALID; }
|
[a-z]+ { return TOK_INVALID; }
|
||||||
|
|
||||||
"\\"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
|
"\\"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
|
||||||
"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); update_autoidx(yytext); return TOK_ID; }
|
"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
|
||||||
"."[0-9]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
|
"."[0-9]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
|
||||||
|
|
||||||
[0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
|
[0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
|
||||||
[0-9]+ { rtlil_frontend_ilang_yylval.integer = atoi(yytext); return TOK_INT; }
|
-?[0-9]+ { rtlil_frontend_ilang_yylval.integer = atoi(yytext); return TOK_INT; }
|
||||||
|
|
||||||
\" { BEGIN(STRING); }
|
\" { BEGIN(STRING); }
|
||||||
<STRING>\\. { yymore(); }
|
<STRING>\\. { yymore(); }
|
||||||
|
@ -124,27 +124,6 @@ void update_autoidx(const char *p);
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void update_autoidx(const char *p)
|
|
||||||
{
|
|
||||||
if (*p != '$')
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
if (*(p++) != '$')
|
|
||||||
continue;
|
|
||||||
if ('0' <= *p && *p <= '9') {
|
|
||||||
const char *q = p;
|
|
||||||
while ('0' <= *q && *q <= '9')
|
|
||||||
q++;
|
|
||||||
if ((q - p) < 10) {
|
|
||||||
int idx = atoi(p);
|
|
||||||
if (idx >= RTLIL::autoidx)
|
|
||||||
RTLIL::autoidx = idx+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is a hack to avoid the 'yyinput defined but not used' error msgs
|
// this is a hack to avoid the 'yyinput defined but not used' error msgs
|
||||||
void *rtlil_frontend_ilang_avoid_input_warnings() {
|
void *rtlil_frontend_ilang_avoid_input_warnings() {
|
||||||
return (void*)&yyinput;
|
return (void*)&yyinput;
|
||||||
|
|
|
@ -50,7 +50,7 @@ using namespace ILANG_FRONTEND;
|
||||||
|
|
||||||
%token <string> TOK_ID TOK_VALUE TOK_STRING
|
%token <string> TOK_ID TOK_VALUE TOK_STRING
|
||||||
%token <integer> TOK_INT
|
%token <integer> TOK_INT
|
||||||
%token TOK_MODULE TOK_WIRE TOK_WIDTH TOK_INPUT TOK_OUTPUT TOK_INOUT
|
%token TOK_AUTOIDX TOK_MODULE TOK_WIRE TOK_WIDTH TOK_INPUT TOK_OUTPUT TOK_INOUT
|
||||||
%token TOK_CELL TOK_CONNECT TOK_SWITCH TOK_CASE TOK_ASSIGN TOK_SYNC
|
%token TOK_CELL TOK_CONNECT TOK_SWITCH TOK_CASE TOK_ASSIGN TOK_SYNC
|
||||||
%token TOK_LOW TOK_HIGH TOK_POSEDGE TOK_NEGEDGE TOK_EDGE TOK_ALWAYS TOK_INIT
|
%token TOK_LOW TOK_HIGH TOK_POSEDGE TOK_NEGEDGE TOK_EDGE TOK_ALWAYS TOK_INIT
|
||||||
%token TOK_UPDATE TOK_PROCESS TOK_END TOK_INVALID TOK_EOL TOK_OFFSET
|
%token TOK_UPDATE TOK_PROCESS TOK_END TOK_INVALID TOK_EOL TOK_OFFSET
|
||||||
|
@ -82,6 +82,7 @@ optional_eol:
|
||||||
design:
|
design:
|
||||||
design module |
|
design module |
|
||||||
design attr_stmt |
|
design attr_stmt |
|
||||||
|
design autoidx_stmt |
|
||||||
/* empty */;
|
/* empty */;
|
||||||
|
|
||||||
module:
|
module:
|
||||||
|
@ -113,6 +114,11 @@ attr_stmt:
|
||||||
free($2);
|
free($2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
autoidx_stmt:
|
||||||
|
TOK_AUTOIDX TOK_INT EOL {
|
||||||
|
RTLIL::autoidx = std::max(RTLIL::autoidx, $2);
|
||||||
|
};
|
||||||
|
|
||||||
wire_stmt:
|
wire_stmt:
|
||||||
TOK_WIRE {
|
TOK_WIRE {
|
||||||
current_wire = new RTLIL::Wire;
|
current_wire = new RTLIL::Wire;
|
||||||
|
|
Loading…
Reference in a new issue