upsilon/firmware/rtl/control_loop/intsat_sim.cpp

56 lines
973 B
C++
Raw Normal View History

2022-09-16 18:01:34 -04:00
#include <memory>
#include <limits>
#include <cstdint>
#include <iostream>
#include <verilated.h>
#include "Vintsat.h"
using dword = int16_t;
using word = int8_t;
double sc_time_stamp() {
return 0;
}
Vintsat *mod;
static void
run(dword i)
{
const auto max = std::numeric_limits<word>::max();
const auto min = std::numeric_limits<word>::min();
mod->inp = i;
mod->eval();
int in = (dword) mod->inp;
int out = (word) mod->outp;
if (i <= max && i >= min) {
if (in != out)
std::cout << in << "->" << out << std::endl;
} else {
if (i < min && out != min)
std::cout << in << "->" << out << std::endl;
else if (i > max && out != max)
std::cout << in << "->" << out << std::endl;
}
}
int main(int argc, char **argv) {
Verilated::commandArgs(argc, argv);
mod = new Vintsat;
dword i;
for (i = std::numeric_limits<dword>::min();
i < std::numeric_limits<dword>::max();
i++)
run(i);
run(i);
mod->final();
delete mod;
return 0;
}