mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-14 09:56:16 +00:00
Coding style corrections in SatHelper::dump_model_to_vcd()
This commit is contained in:
parent
61a2bf57b4
commit
32af10fa9b
1 changed files with 31 additions and 31 deletions
|
@ -635,15 +635,15 @@ struct SatHelper
|
||||||
|
|
||||||
void dump_model_to_vcd(std::string vcd_file_name)
|
void dump_model_to_vcd(std::string vcd_file_name)
|
||||||
{
|
{
|
||||||
FILE* f = fopen(vcd_file_name.c_str(), "w");
|
FILE *f = fopen(vcd_file_name.c_str(), "w");
|
||||||
if(!f)
|
if (!f)
|
||||||
log_cmd_error("Can't open output file `%s' for writing: %s\n", vcd_file_name.c_str(), strerror(errno));
|
log_cmd_error("Can't open output file `%s' for writing: %s\n", vcd_file_name.c_str(), strerror(errno));
|
||||||
|
|
||||||
log("Dumping SAT model to VCD file %s\n", vcd_file_name.c_str());
|
log("Dumping SAT model to VCD file %s\n", vcd_file_name.c_str());
|
||||||
|
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
struct tm* now;
|
struct tm* now;
|
||||||
char stime[128] = {0};
|
char stime[128] = {};
|
||||||
time(×tamp);
|
time(×tamp);
|
||||||
now = localtime(×tamp);
|
now = localtime(×tamp);
|
||||||
strftime(stime, sizeof(stime), "%c", now);
|
strftime(stime, sizeof(stime), "%c", now);
|
||||||
|
@ -664,20 +664,21 @@ struct SatHelper
|
||||||
module->name.c_str(), module_fname.c_str());
|
module->name.c_str(), module_fname.c_str());
|
||||||
fprintf(f, "$end\n");
|
fprintf(f, "$end\n");
|
||||||
|
|
||||||
//VCD has some limits on internal (non-display) identifier names, so make legal ones
|
// VCD has some limits on internal (non-display) identifier names, so make legal ones
|
||||||
std::map<std::string, std::string> vcdnames;
|
std::map<std::string, std::string> vcdnames;
|
||||||
|
|
||||||
fprintf(f, "$timescale 1ns\n"); //arbitrary time scale since actual clock period is unknown/unimportant
|
fprintf(f, "$timescale 1ns\n"); // arbitrary time scale since actual clock period is unknown/unimportant
|
||||||
fprintf(f, "$scope module %s $end\n", module->name.c_str());
|
fprintf(f, "$scope module %s $end\n", module->name.c_str());
|
||||||
for (auto &info : modelInfo) {
|
for (auto &info : modelInfo)
|
||||||
if(vcdnames.find(info.description) != vcdnames.end())
|
{
|
||||||
|
if (vcdnames.find(info.description) != vcdnames.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char namebuf[16];
|
char namebuf[16];
|
||||||
snprintf(namebuf, sizeof(namebuf), "v%d", static_cast<int>(vcdnames.size()));
|
snprintf(namebuf, sizeof(namebuf), "v%d", static_cast<int>(vcdnames.size()));
|
||||||
vcdnames[info.description] = namebuf;
|
vcdnames[info.description] = namebuf;
|
||||||
|
|
||||||
//Even display identifiers can't use some special characters
|
// Even display identifiers can't use some special characters
|
||||||
std::string legal_desc = info.description.c_str();
|
std::string legal_desc = info.description.c_str();
|
||||||
for (auto &c : legal_desc) {
|
for (auto &c : legal_desc) {
|
||||||
if(c == '$')
|
if(c == '$')
|
||||||
|
@ -688,9 +689,9 @@ struct SatHelper
|
||||||
|
|
||||||
fprintf(f, "$var wire %d %s %s $end\n", info.width, namebuf, legal_desc.c_str());
|
fprintf(f, "$var wire %d %s %s $end\n", info.width, namebuf, legal_desc.c_str());
|
||||||
|
|
||||||
//Need to look at first *two* cycles!
|
// Need to look at first *two* cycles!
|
||||||
//We need to put a name on all variables but those without an initialization clause
|
// We need to put a name on all variables but those without an initialization clause
|
||||||
//have no value at timestep 0
|
// have no value at timestep 0
|
||||||
if(info.timestep > 1)
|
if(info.timestep > 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -716,13 +717,12 @@ struct SatHelper
|
||||||
fprintf(f, "$end\n");
|
fprintf(f, "$end\n");
|
||||||
else
|
else
|
||||||
fprintf(f, "#%d\n", info.timestep);
|
fprintf(f, "#%d\n", info.timestep);
|
||||||
|
|
||||||
last_timestep = info.timestep;
|
last_timestep = info.timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info.width == 1)
|
if(info.width == 1) {
|
||||||
fprintf(f, "%c%s\n", bitvals[value.bits[0]], vcdnames[info.description].c_str());
|
fprintf(f, "%c%s\n", bitvals[value.bits[0]], vcdnames[info.description].c_str());
|
||||||
else {
|
} else {
|
||||||
fprintf(f, "b");
|
fprintf(f, "b");
|
||||||
for(int k=info.width-1; k >= 0; k --) //need to flip bit ordering for VCD
|
for(int k=info.width-1; k >= 0; k --) //need to flip bit ordering for VCD
|
||||||
fprintf(f, "%c", bitvals[value.bits[k]]);
|
fprintf(f, "%c", bitvals[value.bits[k]]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue