From df20ddd658136f6b4eca44c6e858736bb38f0820 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Wed, 10 Jan 2024 15:07:02 +0800 Subject: [PATCH] =?UTF-8?q?>=20build=5Fnpc=5FVSegHandler=5Fnvboard=20=20ys?= =?UTF-8?q?yx=5F22040000=20=E6=9D=8E=E5=BF=83=E6=9D=A8=20=20Linux=20calcit?= =?UTF-8?q?e=206.1.69=20#1-NixOS=20SMP=20PREEMPT=5FDYNAMIC=20Wed=20Dec=202?= =?UTF-8?q?0=2016:00:29=20UTC=202023=20x86=5F64=20GNU/Linux=20=20=2015:07:?= =?UTF-8?q?02=20=20up=202=20days=2014:07,=20=202=20users,=20=20load=20aver?= =?UTF-8?q?age:=201.00,=201.26,=201.42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npc/csrc_nvboard/main.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/npc/csrc_nvboard/main.cpp b/npc/csrc_nvboard/main.cpp index ec80786..c1165d4 100644 --- a/npc/csrc_nvboard/main.cpp +++ b/npc/csrc_nvboard/main.cpp @@ -6,20 +6,35 @@ #include #include +#ifndef VERILATOR_TOPMODULE +#define VERILATOR_TOPMODULE VSegHandler +#endif + const int MAX_SIM_TIME=100; -void nvboard_bind_all_pins(VSegHandler* top); +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; + while (n -- > 0) single_cycle(top); + top->reset = 0; +} int main(int argc, char **argv, char **env) { - VSegHandler *top = new VSegHandler; + VERILATOR_TOPMODULE *top = new VERILATOR_TOPMODULE; nvboard_bind_all_pins(top); nvboard_init(); + reset(top, 10); while (true) { nvboard_update(); top->eval(); - printf("%d\n", top->clock); - // printf("%d, %d, %d", top->io_segs_0, top->io_segs_1, top->io_segs_2); + single_cycle(top); } delete top; } \ No newline at end of file