| 1 | #include "Vsystem.h" |
| 2 | #include <stdio.h> |
| 3 | #define _XOPEN_SOURCE |
| 4 | #include <stdlib.h> |
| 5 | #include <fcntl.h> |
| 6 | |
| 7 | Vsystem *top; |
| 8 | |
| 9 | void term_output(unsigned char d) |
| 10 | { |
| 11 | int fd = posix_openpt(O_RDWR); |
| 12 | static int fd2 = -1; |
| 13 | char b[128]; |
| 14 | |
| 15 | if (fd2 == -1) |
| 16 | { |
| 17 | grantpt(fd); |
| 18 | fcntl(fd, F_SETFD, 0); /* clear close-on-exec */ |
| 19 | sprintf(b, "rxvt -pty-fd %d -bg black -fg white -title \"Output terminal\" &", fd); |
| 20 | system(b); |
| 21 | unlockpt(fd); |
| 22 | fd2 = open(ptsname(fd), O_RDWR); |
| 23 | close(fd); |
| 24 | } |
| 25 | write(fd2, &d, 1); |
| 26 | } |
| 27 | |
| 28 | unsigned int main_time = 0; |
| 29 | |
| 30 | double sc_time_stamp () |
| 31 | { |
| 32 | return main_time; |
| 33 | } |
| 34 | |
| 35 | int main() |
| 36 | { |
| 37 | top = new Vsystem; |
| 38 | |
| 39 | top->clk = 0; |
| 40 | while (!Verilated::gotFinish()) |
| 41 | { |
| 42 | top->clk = !top->clk; |
| 43 | |
| 44 | top->eval(); |
| 45 | // if (top->clk == 1) |
| 46 | // printf("%d: Bubble: %d. PC: %08x. Ins'n: %08x\n", main_time/2, top->bubbleshield, top->pc, top->insn); |
| 47 | |
| 48 | main_time++; |
| 49 | } |
| 50 | } |