build: add nvboard support to led light
This commit is contained in:
parent
8e861a43fb
commit
38818f6f66
5 changed files with 108 additions and 28 deletions
|
@ -3,9 +3,9 @@
|
|||
#include <cstdlib>
|
||||
#include <verilated.h>
|
||||
#include <verilated_vcd_c.h>
|
||||
#include "Vexample.h"
|
||||
#include <Vexample.h>
|
||||
|
||||
#define MAX_SIM_TIME 100
|
||||
const int MAX_SIM_TIME=100;
|
||||
|
||||
int main(int argc, char **argv, char **env) {
|
||||
int sim_time = 0;
|
||||
|
@ -14,19 +14,23 @@ int main(int argc, char **argv, char **env) {
|
|||
|
||||
Verilated::traceEverOn(true);
|
||||
VerilatedVcdC *m_trace = new VerilatedVcdC;
|
||||
#ifdef VERILATOR_TRACE
|
||||
top->trace(m_trace, 5);
|
||||
m_trace->open("waveform.vcd");
|
||||
#endif
|
||||
for (sim_time = 0; sim_time < MAX_SIM_TIME; sim_time++) {
|
||||
int a = rand() & 1;
|
||||
int b = rand() & 1;
|
||||
top->a = a;
|
||||
top->b = b;
|
||||
CData sw = rand() & 0b11;
|
||||
top->sw = sw;
|
||||
top->eval();
|
||||
printf("a = %d, b = %d, f = %d\n", a, b, top->f);
|
||||
assert(top->f == (a ^ b));
|
||||
printf("sw0 = %d, sw1 = %d, ledr = %d\n", sw & 0b1, sw >> 1, top->ledr);
|
||||
assert(top->ledr == ((sw >> 1) ^ (sw & 0b1)) );
|
||||
#ifdef VERILATOR_TRACE
|
||||
m_trace->dump(sim_time);
|
||||
#endif
|
||||
}
|
||||
#ifdef VERILATOR_TRACE
|
||||
m_trace->close();
|
||||
#endif
|
||||
delete top;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue