Update Verilator authored by Toru Koizumi's avatar Toru Koizumi
......@@ -36,18 +36,18 @@ $ sudo apt-get install verilator
#include "Vtop.h"
// Set the clock speed of your processor.
static constexpr size_t clock_Hz = 55000000;
static constexpr std::size_t clock_Hz = 55000000;
// UART baudrate
static constexpr size_t uart_Hz = 115200;
static constexpr std::size_t uart_Hz = 115200;
// The number of CoreMark iterations is depend on clock speed.
// Max: 30 seconds
static constexpr size_t max_cycle = 30 * clock_Hz;
static constexpr std::size_t max_cycle = 30 * clock_Hz;
size_t timer_ps = 0;
std::size_t timer_ps = 0;
void uart_rx(unsigned int u) {
static size_t s = 0;
static size_t b = 0;
static std::size_t s = 0;
static std::size_t b = 0;
static char c = 0;
if( s == 0 && u == 0 ) {
s = timer_ps;
......@@ -56,7 +56,7 @@ 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 ) {
putchar(c);
std::cout << c << std::flush;
s = 0;
}
}
......@@ -66,20 +66,17 @@ void uart_rx(unsigned int u) {
int main() {
Vtop top;
top.sysclk = 0;
top.eval();
top.sysclk = 1;
top.eval();
top.cpu_resetn = 0;
top.eval();
top.sysclk = 0;
top.eval();
top.sysclk = 1;
top.eval();
top.sysclk = 0;
top.eval();
top.cpu_resetn = 1;
for( size_t cycle = 0; cycle < max_cycle; ++cycle ) {
for( std::size_t cycle = 0; cycle < max_cycle; ++cycle ) {
top.sysclk = 0;
top.eval();
top.sysclk = 1;
......
......