-
Notifications
You must be signed in to change notification settings - Fork 0
/
retro1.cpp
97 lines (79 loc) · 3.25 KB
/
retro1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "Vretro.h"
#include "Vretro_retro.h"
#include "verilated.h"
#include <iostream>
#include <iomanip>
#include <time.h>
unsigned char rom[] = {
/* 000x */ 0xB7, 0x07, 0x01, 0x00, 0x93, 0x87, 0x87, 0x07, 0x13, 0x07, 0x80, 0x04, 0xB7, 0x26, 0x00, 0x40,
/* 001x */ 0x23, 0x80, 0xE6, 0x00, 0x93, 0x87, 0x17, 0x00, 0x03, 0xC7, 0x07, 0x00, 0xE3, 0x1A, 0x07, 0xFE,
/* 002x */ 0x67, 0x80, 0x00, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x52, 0x49, 0x53, 0x43, 0x2D, 0x56,
/* 003x */ 0x21, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 004x */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 005x */ 0x00, 0x00, 0x00, 0x00, 0xB7, 0x07, 0x01, 0x00, 0x93, 0x87, 0x87, 0x07, 0x13, 0x07, 0x80, 0x04,
/* 006x */ 0xB7, 0x26, 0x00, 0x40, 0x23, 0x80, 0xE6, 0x00, 0x93, 0x87, 0x17, 0x00, 0x03, 0xC7, 0x07, 0x00,
/* 007x */ 0xE3, 0x1A, 0x07, 0xFE, 0x67, 0x80, 0x00, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x52, 0x49,
/* 008x */ 0x53, 0x43, 0x2D, 0x56, 0x21, 0x0A, 0x00, 0x00
};
int main(int argc, char** argv, char** env)
{
Verilated::commandArgs(argc,argv);
int adr=0, old_clk=0;
unsigned long t=0,tt=0,t1,t2;
Vretro* top = new Vretro();
cout << internal << setfill('0');
t1 = (unsigned long)clock();
while(!Verilated::gotFinish())
{
top->clk = t&1;
top->hold = 0;
if(top->address > sizeof(rom))
top->data_in = 1;
else top->data_in = rom[top->address];
if(t<10)
{
top->nres = 0;
}
else // t >= 10
{
top->nres = 1;
}
if(!old_clk && top->clk)
{
tt++;
t2 = clock();
if((t2-t1)*1000/CLOCKS_PER_SEC >= 1000)
{
cout << " dT=" << tt << endl; // print cycles per second
tt = 0;
t1 = t2;
}
}
top->eval(); // <<<<<<<<< EVAL
#if 1
t++;
#else
cout << t++ << " nres=" << (int)top->nres << " clk=" << (int)top->clk << " address=" << hex << setw(4) << (int)top->address
<< " din=" << setw(2) << (int)top->data_in << " dout=" << setw(2) << (int)top->data_out << " wren=" << (int)top->wren
<< " inst=" << setw(8) << (int)top->retro->inst << " rd=" << (int)top->retro->__PVT__rd
<< " arg1=" << setw(8) << (int)top->retro->arg1 << " arg2=" << setw(8) << (int)top->retro->arg2 << " imm=" << setw(8) << (int)top->retro->imm
<< " x13=" << setw(8) << (int)top->retro->__PVT__regs[13]
<< " x14=" << setw(8) << (int)top->retro->__PVT__regs[14]
<< " x15=" << setw(8) << (int)top->retro->__PVT__regs[15]
// << " |" << setw(8) << (int)top->retro->__PVT__counterh
// << "|" << setw(8) << (int)top->retro->__PVT__counterl << "|"
<< " extaddr=" << setw(8) << (int)top->retro->__PVT__extaddr
<< " res=" << setw(8) << (int)top->retro->__PVT__res
<< setw(4) << " op=" << (int)top->retro->__PVT__op << dec << " errop=" << (int)top->retro->errop
<< " lbytes=" << (int)top->retro->__PVT__lbytes << " sbytes=" << (int)top->retro->__PVT__sbytes
<< endl;
#endif
if(top->address==0xFFFF && !old_clk && top->clk)
{
cerr << (char)top->data_out;
}
old_clk = top->clk;
}
delete top;
exit(0);
}