mirror of
https://github.com/ParkerTenBroeck/hdl_sim.git
synced 2026-06-07 05:28:45 -04:00
added verilog support
This commit is contained in:
parent
5746846896
commit
c3a3e89082
20 changed files with 633 additions and 88 deletions
35
relay/shim/verilog.c
Normal file
35
relay/shim/verilog.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include <cstdint>
|
||||
#include "Vcircuit.h"
|
||||
#include "verilated.h"
|
||||
|
||||
extern "C" void ffi_init();
|
||||
extern "C" std::uint32_t ffi_get_sw();
|
||||
extern "C" std::uint32_t ffi_get_btn();
|
||||
extern "C" void ffi_set_outputs(std::uint32_t led, std::uint32_t segv, std::uint32_t segs);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Verilated::commandArgs(argc, argv);
|
||||
|
||||
Vcircuit top;
|
||||
top.clk = 0;
|
||||
top.btn = 0;
|
||||
top.sw = 0;
|
||||
|
||||
ffi_init();
|
||||
|
||||
while (true) {
|
||||
top.sw = ffi_get_sw();
|
||||
top.btn = ffi_get_btn();
|
||||
|
||||
top.clk = 0;
|
||||
top.eval();
|
||||
ffi_set_outputs(top.led, top.segv, top.segs);
|
||||
|
||||
top.sw = ffi_get_sw();
|
||||
top.btn = ffi_get_btn();
|
||||
|
||||
top.clk = 1;
|
||||
top.eval();
|
||||
ffi_set_outputs(top.led, top.segv, top.segs);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue