> configure(npc)

ysyx_22040000 李心杨
 Linux calcite 6.1.69 #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 20 16:00:29 UTC 2023 x86_64 GNU/Linux
  17:24:32  up 2 days 16:25,  2 users,  load average: 0.46, 0.75, 0.74
This commit is contained in:
tracer-ysyx 2024-01-10 17:24:32 +08:00 committed by xinyangli
parent 0f74d13b9e
commit e13fd327e5
No known key found for this signature in database
2 changed files with 60 additions and 1 deletions

View file

@ -17,7 +17,7 @@ find_package(verilator REQUIRED)
find_library(NVBOARD_LIBRARY NAMES nvboard)
find_path(NVBOARD_INCLUDE_DIR NAMES nvboard.h)
set(TOPMODULE "SegHandler")
set(TOPMODULE "Keyboard")
set(SCALA_CORE "${CMAKE_CURRENT_SOURCE_DIR}/core")
set(CHISEL_MODULE_CLASS "${CMAKE_PROJECT_NAME}.${TOPMODULE}")
file(GLOB_RECURSE SCALA_CORE_SOURCES "${SCALA_CORE}/src/main/scala/*.scala")

View file

@ -0,0 +1,59 @@
#include <cassert>
#include <cstdlib>
#include <nvboard.h>
#include <verilated.h>
#include <verilated_vcd_c.h>
#ifndef VERILATOR_TOPMODULE
#define VERILATOR_TOPMODULE VKeyboard
#endif
#define CLASS_SYSTEM_HEADER_NAME(name) CLASS_SYSTEM_HEADER_NAME_IMPL(name)
#define CLASS_SYSTEM_HEADER_NAME_IMPL(name) <name.h>
#include CLASS_SYSTEM_HEADER_NAME(VERILATOR_TOPMODULE)
const int MAX_SIM_TIME = 100;
int keycode = 0;
template <class F> void cycle(VERILATOR_TOPMODULE *top, F &&f) {
top->clock = 0;
top->eval();
top->clock = 1;
top->eval();
f();
}
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) {
VERILATOR_TOPMODULE *top = new VERILATOR_TOPMODULE;
nvboard_bind_all_pins(top);
nvboard_init();
reset(top, 10);
while (true) {
nvboard_update();
cycle(top, [&] {
if (keycode != top->io_keycode_bits){
keycode = top->io_keycode_bits;
printf("%d\n", keycode);
}
});
}
delete top;
}