ICache, Fetch: Re-pipe things such that the icache now has a one-cycle latency. ...
[firearm.git] / testbench.cpp
CommitLineData
3a57f3e5
JW
1#include "Vsystem.h"
2#include <stdio.h>
1d97a095
JW
3#define _XOPEN_SOURCE
4#include <stdlib.h>
5#include <fcntl.h>
7282e8f8 6#include <termios.h>
3a57f3e5
JW
7
8Vsystem *top;
9
7282e8f8
JW
10int ptyfd = -1;
11
12void openpty()
13{
14 int fd = posix_openpt(O_RDWR);
15 char b[128];
16 struct termios kbdios;
17
18 grantpt(fd);
19 fcntl(fd, F_SETFD, 0); /* clear close-on-exec */
20 tcgetattr(fd, &kbdios);
21 kbdios.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
22 tcsetattr(fd, TCSANOW, &kbdios);
b25fbdb1 23 sprintf(b, "urxvt -pty-fd %d -bg black -fg white -title \"Output terminal\" &", fd);
7282e8f8
JW
24 system(b);
25 unlockpt(fd);
26 ptyfd = open(ptsname(fd), O_RDWR | O_NONBLOCK);
27 close(fd);
28}
29
30unsigned int term_input()
31{
32 int rv;
33 unsigned char c;
34 if (ptyfd == -1)
35 openpty();
36 rv = read(ptyfd, &c, 1);
37 if (rv < 0)
38 return 0;
39 return 0x100 | c;
40}
41
1d97a095
JW
42void term_output(unsigned char d)
43{
44 int fd = posix_openpt(O_RDWR);
45 static int fd2 = -1;
46 char b[128];
47
7282e8f8
JW
48 if (ptyfd == -1)
49 openpty();
50 write(ptyfd, &d, 1);
1d97a095
JW
51}
52
3a57f3e5
JW
53unsigned int main_time = 0;
54
55double sc_time_stamp ()
56{
57 return main_time;
58}
59
60int main()
61{
62 top = new Vsystem;
63
64 top->clk = 0;
65 while (!Verilated::gotFinish())
66 {
67 top->clk = !top->clk;
a4f724e6 68 top->rst = 0;
3a57f3e5
JW
69 top->eval();
70// if (top->clk == 1)
71// printf("%d: Bubble: %d. PC: %08x. Ins'n: %08x\n", main_time/2, top->bubbleshield, top->pc, top->insn);
72
73 main_time++;
74 }
75}
This page took 0.0345839999999999 seconds and 4 git commands to generate.