Changes
Page history
Update Verilator
authored
Nov 18, 2020
by
Toru Koizumi
Show whitespace changes
Inline
Side-by-side
Verilator.md
View page @
5558a696
...
...
@@ -31,7 +31,7 @@ $ sudo apt-get install verilator
これを実行する(
`$ obj_dir/Vtop`
)ことで、シミュレーションが行われます。
```
#include <
iostream
>
#include <
cstdio
>
#include <verilated.h>
#include "Vtop.h"
...
...
@@ -56,7 +56,8 @@ void uart_rx(unsigned int u) {
} else if( s != 0 && s + 1000000000000 / uart_Hz / 2 * (2*b+3) < timer_ps ) {
c |= u << b;
if( ++b == 8 ) {
std::cout << c << std::flush;
std::putchar(c);
std::fflush(stdout);
s = 0;
}
}
...
...
@@ -66,7 +67,6 @@ void uart_rx(unsigned int u) {
int main() {
Vtop top;
top.sysclk = 0;
top.sysclk = 1;
top.eval();
top.cpu_resetn = 0;
top.eval();
...
...
@@ -75,13 +75,14 @@ int main() {
top.sysclk = 0;
top.eval();
top.cpu_resetn = 1;
top.eval();
for( std::size_t cycle = 0; cycle < max_cycle; ++cycle ) {
top.sysclk = 0;
top.eval();
top.sysclk = 1;
top.eval();
uart_rx(top.uart_t
x
);
uart_rx(top.uart_
rx_ou
t);
timer_ps += 1000000000000 / clock_Hz;
}
}
...
...
...
...