aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2022-01-31 10:52:47 +0100
committerMiodrag Milanovic <mmicko@gmail.com>2022-01-31 10:52:47 +0100
commit543feb75cb3765746ea865c11aa6ceccaf0adeac (patch)
tree4080c23526e8ff4e36388744f32b64af11ab3649
parenta6959d30df067c27da75d12bc0bd5233eb91d3ca (diff)
downloadyosys-543feb75cb3765746ea865c11aa6ceccaf0adeac.tar.gz
yosys-543feb75cb3765746ea865c11aa6ceccaf0adeac.tar.bz2
yosys-543feb75cb3765746ea865c11aa6ceccaf0adeac.zip
Display simulation time data
-rw-r--r--kernel/fstdata.cc22
-rw-r--r--kernel/fstdata.h2
-rw-r--r--passes/sat/sim.cc5
3 files changed, 27 insertions, 2 deletions
diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc
index 5d6d85ed8..a7a2c80f7 100644
--- a/kernel/fstdata.cc
+++ b/kernel/fstdata.cc
@@ -21,10 +21,30 @@
USING_YOSYS_NAMESPACE
+
FstData::FstData(std::string filename) : ctx(nullptr)
{
+ const std::vector<std::string> g_units = { "s", "ms", "us", "ns", "ps", "fs", "as", "zs" };
ctx = (fstReaderContext *)fstReaderOpen(filename.c_str());
- timescale = pow(10.0, (int)fstReaderGetTimescale(ctx));
+ int scale = (int)fstReaderGetTimescale(ctx);
+ timescale = pow(10.0, scale);
+ timescale_str = "";
+ int unit = 0;
+ int zeros = 0;
+ if (scale > 0) {
+ zeros = scale;
+ } else {
+ if ((scale % 3) == 0) {
+ zeros = (-scale % 3);
+ unit = (-scale / 3);
+ } else {
+ zeros = 3 - (-scale % 3);
+ unit = (-scale / 3) + 1;
+ }
+ }
+ for (int i=0;i<zeros; i++) timescale_str += "0";
+ if (zeros>0)timescale_str += " ";
+ timescale_str += g_units[unit];
extractVarNames();
}
diff --git a/kernel/fstdata.h b/kernel/fstdata.h
index 8095981a2..c069ff5e5 100644
--- a/kernel/fstdata.h
+++ b/kernel/fstdata.h
@@ -55,6 +55,7 @@ class FstData
std::string valueAt(fstHandle signal, uint64_t time);
fstHandle getHandle(std::string name);
double getTimescale() { return timescale; }
+ const char *getTimescaleString() { return timescale_str.c_str(); }
private:
void extractVarNames();
@@ -69,6 +70,7 @@ private:
std::vector<uint64_t> sample_times;
size_t sample_times_ndx;
double timescale;
+ std::string timescale_str;
uint64_t start_time;
uint64_t end_time;
std::vector<uint64_t> edges;
diff --git a/passes/sat/sim.cc b/passes/sat/sim.cc
index ff815b69a..05fe11201 100644
--- a/passes/sat/sim.cc
+++ b/passes/sat/sim.cc
@@ -1033,7 +1033,9 @@ struct SimWorker : SimShared
log_error("No clock edges found in given time range\n");
fst->reconstructAllAtTimes(edges);
bool initial = false;
+ int cycle = 0;
for(auto &time : edges) {
+ log("Simulating cycle %d [%zu %s].\n", cycle+1, time, fst->getTimescaleString());
for(auto &item : inputs) {
std::string v = fst->valueAt(item.second, time);
top->set_state(item.first, Const::from_string(v));
@@ -1046,7 +1048,8 @@ struct SimWorker : SimShared
bool status = top->checkSignals(time);
if (status)
- log_error("Signal difference at %zu\n", time);
+ log_error("Signal difference\n");
+ cycle++;
}
}
}
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422