2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2020-03-21 15:24:24 +00:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
// any use, without warranty, 2020 by Wilson Snyder.
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
2012-04-13 01:08:20 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#include <verilated.h>
|
|
|
|
#include "Vt_math_imm2.h"
|
|
|
|
|
2021-02-17 01:34:44 +00:00
|
|
|
double sc_time_stamp() { return 0; }
|
|
|
|
|
2018-08-25 13:52:45 +00:00
|
|
|
QData MaskVal(int lbit, int hbit) {
|
2006-08-26 11:35:28 +00:00
|
|
|
QData val;
|
2020-10-28 00:03:17 +00:00
|
|
|
for (val = 0; lbit <= hbit; lbit++) val |= (1ULL << lbit);
|
2006-08-26 11:35:28 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2006-08-26 11:35:28 +00:00
|
|
|
Verilated::debug(0);
|
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
Vt_math_imm2* sim = new Vt_math_imm2;
|
|
|
|
int lbit, hbit;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
int errs = 0;
|
2006-08-26 11:35:28 +00:00
|
|
|
for (lbit = 0; lbit < 32; lbit++) {
|
2019-05-08 02:34:09 +00:00
|
|
|
for (hbit = lbit; hbit < 32; hbit++) {
|
|
|
|
QData expected;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
sim->LowMaskSel_Bot = lbit;
|
|
|
|
sim->LowMaskSel_Top = lbit;
|
2019-05-08 02:34:09 +00:00
|
|
|
sim->HighMaskSel_Bot = hbit;
|
|
|
|
sim->HighMaskSel_Top = hbit;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-05-08 02:34:09 +00:00
|
|
|
sim->eval();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
expected = ((MaskVal(sim->LowMaskSel_Top, sim->HighMaskSel_Top) << 32ULL)
|
|
|
|
| MaskVal(sim->LowMaskSel_Bot, sim->HighMaskSel_Bot));
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-05-08 02:34:09 +00:00
|
|
|
if (sim->LogicImm != expected) {
|
2020-10-28 00:03:17 +00:00
|
|
|
printf("%%Error: %d.%d,%d.%d -> %016" VL_PRI64 "x/%016" VL_PRI64
|
|
|
|
"x -> %016" VL_PRI64 "x (expected %016" VL_PRI64 "x)\n",
|
|
|
|
sim->LowMaskSel_Top, sim->HighMaskSel_Top, sim->LowMaskSel_Bot,
|
|
|
|
sim->HighMaskSel_Bot, sim->LowLogicImm, sim->HighLogicImm, sim->LogicImm,
|
|
|
|
expected);
|
|
|
|
errs = 1;
|
2019-05-08 02:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-17 11:37:55 +00:00
|
|
|
sim->final();
|
|
|
|
VL_DO_DANGLING(delete sim, sim);
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
if (errs) {
|
2019-05-08 02:34:09 +00:00
|
|
|
vl_stop(__FILE__, __LINE__, "TOP-cpp");
|
|
|
|
exit(10);
|
2006-08-26 11:35:28 +00:00
|
|
|
} else {
|
2018-08-25 13:52:45 +00:00
|
|
|
printf("*-* All Finished *-*\n");
|
2019-05-08 02:34:09 +00:00
|
|
|
exit(0);
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
}
|