Changes
Page history
Update Verilator
authored
Nov 18, 2020
by
Toru Koizumi
Show whitespace changes
Inline
Side-by-side
Verilator.md
View page @
bc31e0a4
...
@@ -36,18 +36,18 @@ $ sudo apt-get install verilator
...
@@ -36,18 +36,18 @@ $ sudo apt-get install verilator
#include "Vtop.h"
#include "Vtop.h"
// Set the clock speed of your processor.
// Set the clock speed of your processor.
static constexpr size_t clock_Hz = 55000000;
static constexpr
std::
size_t clock_Hz = 55000000;
// UART baudrate
// 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.
// The number of CoreMark iterations is depend on clock speed.
// Max: 30 seconds
// 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) {
void uart_rx(unsigned int u) {
static size_t s = 0;
static
std::
size_t s = 0;
static size_t b = 0;
static
std::
size_t b = 0;
static char c = 0;
static char c = 0;
if( s == 0 && u == 0 ) {
if( s == 0 && u == 0 ) {
s = timer_ps;
s = timer_ps;
...
@@ -56,7 +56,7 @@ void uart_rx(unsigned int u) {
...
@@ -56,7 +56,7 @@ void uart_rx(unsigned int u) {
} else if( s != 0 && s + 1000000000000 / uart_Hz / 2 * (2*b+3) < timer_ps ) {
} else if( s != 0 && s + 1000000000000 / uart_Hz / 2 * (2*b+3) < timer_ps ) {
c |= u << b;
c |= u << b;
if( ++b == 8 ) {
if( ++b == 8 ) {
putchar(c)
;
std::cout << c << std::flush
;
s = 0;
s = 0;
}
}
}
}
...
@@ -66,20 +66,17 @@ void uart_rx(unsigned int u) {
...
@@ -66,20 +66,17 @@ void uart_rx(unsigned int u) {
int main() {
int main() {
Vtop top;
Vtop top;
top.sysclk = 0;
top.sysclk = 0;
top.eval();
top.sysclk = 1;
top.sysclk = 1;
top.eval();
top.eval();
top.cpu_resetn = 0;
top.cpu_resetn = 0;
top.eval();
top.eval();
top.sysclk = 0;
top.eval();
top.sysclk = 1;
top.sysclk = 1;
top.eval();
top.eval();
top.sysclk = 0;
top.sysclk = 0;
top.eval();
top.eval();
top.cpu_resetn = 1;
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.sysclk = 0;
top.eval();
top.eval();
top.sysclk = 1;
top.sysclk = 1;
...
...
...
...