mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
unify cycles counting and cleanup
This commit is contained in:
parent
820b2fdd65
commit
169ffcd2fb
|
@ -921,7 +921,8 @@ struct SimWorker : SimShared
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
log("\n===== %d =====\n", 10*cycle + 5);
|
log("\n===== %d =====\n", 10*cycle + 5);
|
||||||
|
else
|
||||||
|
log("Simulating cycle %d.\n", (cycle*2)+1);
|
||||||
set_inports(clock, State::S0);
|
set_inports(clock, State::S0);
|
||||||
set_inports(clockn, State::S1);
|
set_inports(clockn, State::S1);
|
||||||
|
|
||||||
|
@ -931,7 +932,7 @@ struct SimWorker : SimShared
|
||||||
if (debug)
|
if (debug)
|
||||||
log("\n===== %d =====\n", 10*cycle + 10);
|
log("\n===== %d =====\n", 10*cycle + 10);
|
||||||
else
|
else
|
||||||
log("Simulating cycle %d.\n", cycle+1);
|
log("Simulating cycle %d.\n", (cycle*2)+2);
|
||||||
|
|
||||||
set_inports(clock, State::S1);
|
set_inports(clock, State::S1);
|
||||||
set_inports(clockn, State::S0);
|
set_inports(clockn, State::S0);
|
||||||
|
@ -1034,42 +1035,40 @@ struct SimWorker : SimShared
|
||||||
if (stopCount<startCount) {
|
if (stopCount<startCount) {
|
||||||
log_error("Stop time is before start time\n");
|
log_error("Stop time is before start time\n");
|
||||||
}
|
}
|
||||||
auto edges = fst->getAllEdges(fst_clock, startCount, stopCount);
|
auto samples = fst->getAllEdges(fst_clock, startCount, stopCount);
|
||||||
if (cycles_set && ((size_t)(numcycles *2) < edges.size()))
|
|
||||||
edges.erase(edges.begin() + (numcycles*2), edges.end());
|
|
||||||
|
|
||||||
if ((startCount == stopCount) && writeback) {
|
// Limit to number of cycles if provided
|
||||||
log("Update initial state with values from [%zu%s]\n", startCount, fst->getTimescaleString());
|
if (cycles_set && ((size_t)(numcycles *2) < samples.size()))
|
||||||
if (edges.empty())
|
samples.erase(samples.begin() + (numcycles*2), samples.end());
|
||||||
edges.push_back(startCount);
|
|
||||||
fst->reconstructAllAtTimes(edges);
|
// Add setup time (start time)
|
||||||
top->setInitState(startCount);
|
if (samples.empty() || samples.front()!=startCount)
|
||||||
|
samples.insert(samples.begin(), startCount);
|
||||||
|
|
||||||
|
fst->reconstructAllAtTimes(samples);
|
||||||
|
bool initial = true;
|
||||||
|
int cycle = 0;
|
||||||
|
log("Co-simulation from %zu%s to %zu%s\n", startCount, fst->getTimescaleString(), stopCount, fst->getTimescaleString());
|
||||||
|
for(auto &time : samples) {
|
||||||
|
log("Co-simulating cycle %d [%zu%s].\n", cycle, time, fst->getTimescaleString());
|
||||||
|
for(auto &item : inputs) {
|
||||||
|
std::string v = fst->valueAt(item.second, time);
|
||||||
|
top->set_state(item.first, Const::from_string(v));
|
||||||
|
}
|
||||||
|
if (initial) {
|
||||||
|
top->setInitState(time);
|
||||||
|
initial = false;
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
|
||||||
|
bool status = top->checkSignals(time);
|
||||||
|
if (status)
|
||||||
|
log_error("Signal difference\n");
|
||||||
|
cycle++;
|
||||||
|
}
|
||||||
|
if (writeback) {
|
||||||
pool<Module*> wbmods;
|
pool<Module*> wbmods;
|
||||||
top->writeback(wbmods);
|
top->writeback(wbmods);
|
||||||
} else {
|
|
||||||
if (edges.empty())
|
|
||||||
log_error("No clock edges found in given time range\n");
|
|
||||||
fst->reconstructAllAtTimes(edges);
|
|
||||||
bool initial = false;
|
|
||||||
int cycle = 0;
|
|
||||||
log("Co-simulation from %zu%s to %zu%s\n", startCount, fst->getTimescaleString(), stopCount, fst->getTimescaleString());
|
|
||||||
for(auto &time : edges) {
|
|
||||||
log("Co-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));
|
|
||||||
}
|
|
||||||
if (!initial) {
|
|
||||||
top->setInitState(time);
|
|
||||||
initial = true;
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
|
|
||||||
bool status = top->checkSignals(time);
|
|
||||||
if (status)
|
|
||||||
log_error("Signal difference\n");
|
|
||||||
cycle++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue