> build_npc_VSegHandler_nvboard
ysyx_22040000 李心杨 Linux calcite 6.1.69 #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 20 16:00:29 UTC 2023 x86_64 GNU/Linux 15:20:50 up 2 days 14:21, 2 users, load average: 0.89, 1.09, 1.23
This commit is contained in:
parent
df20ddd658
commit
aaf894d5e6
1 changed files with 36 additions and 21 deletions
|
@ -1,40 +1,55 @@
|
||||||
#include <cstdlib>
|
#include <VSegHandler.h>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <nvboard.h>
|
||||||
#include <verilated.h>
|
#include <verilated.h>
|
||||||
#include <verilated_vcd_c.h>
|
#include <verilated_vcd_c.h>
|
||||||
#include <nvboard.h>
|
|
||||||
#include <VSegHandler.h>
|
|
||||||
|
|
||||||
#ifndef VERILATOR_TOPMODULE
|
#ifndef VERILATOR_TOPMODULE
|
||||||
#define VERILATOR_TOPMODULE VSegHandler
|
#define VERILATOR_TOPMODULE VSegHandler
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int MAX_SIM_TIME=100;
|
const int MAX_SIM_TIME = 100;
|
||||||
|
int keycode = 0;
|
||||||
|
|
||||||
void nvboard_bind_all_pins(VERILATOR_TOPMODULE* top);
|
template <class F> void cycle(VERILATOR_TOPMODULE *top, F &&f) {
|
||||||
|
top->clock = 0;
|
||||||
static void single_cycle(VERILATOR_TOPMODULE* top) {
|
top->eval();
|
||||||
top->clock = 0; top->eval();
|
f();
|
||||||
top->clock = 1; top->eval();
|
top->clock = 1;
|
||||||
|
top->eval();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reset(VERILATOR_TOPMODULE* top, int n) {
|
void nvboard_bind_all_pins(VERILATOR_TOPMODULE *top);
|
||||||
|
|
||||||
|
static void single_cycle(VERILATOR_TOPMODULE *top) {
|
||||||
|
top->clock = 0;
|
||||||
|
top->eval();
|
||||||
|
top->clock = 1;
|
||||||
|
top->eval();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reset(VERILATOR_TOPMODULE *top, int n) {
|
||||||
top->reset = 1;
|
top->reset = 1;
|
||||||
while (n -- > 0) single_cycle(top);
|
while (n-- > 0)
|
||||||
|
single_cycle(top);
|
||||||
top->reset = 0;
|
top->reset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv, char **env) {
|
int main(int argc, char **argv, char **env) {
|
||||||
VERILATOR_TOPMODULE *top = new VERILATOR_TOPMODULE;
|
VERILATOR_TOPMODULE *top = new VERILATOR_TOPMODULE;
|
||||||
|
|
||||||
nvboard_bind_all_pins(top);
|
nvboard_bind_all_pins(top);
|
||||||
nvboard_init();
|
nvboard_init();
|
||||||
reset(top, 10);
|
reset(top, 10);
|
||||||
while (true) {
|
while (true) {
|
||||||
nvboard_update();
|
nvboard_update();
|
||||||
top->eval();
|
cycle(top, [&] {
|
||||||
single_cycle(top);
|
if (keycode != top->io_keycode_bits) {
|
||||||
}
|
printf("%d\n", top->io_keycode_bits);
|
||||||
delete top;
|
keycode = top->io_keycode_bits;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
delete top;
|
||||||
}
|
}
|
Loading…
Reference in a new issue