OpenCores
URL https://opencores.org/ocsvn/potato/potato/trunk

Subversion Repositories potato

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /potato/trunk/benchmarks/sha256
    from Rev 19 to Rev 20
    Reverse comparison

Rev 19 → Rev 20

/main.c
16,23 → 16,42
static int led_status = 0;
static volatile int hashes_per_second = 0;
 
void exception_handler(uint32_t cause, void * epc)
// Handle an exception/interrupt.
// Arguments:
// - cause: exception cause, see potato.h for values
// - epc: exception return address
// - regbase: base of the stored context, can be used for printing all
// registers with regbase[0] = x1 and upwards.
void exception_handler(uint32_t cause, void * epc, void * regbase)
{
uart_puts(IO_ADDRESS(UART_BASE), "Hashes per second: ");
uart_puth(IO_ADDRESS(UART_BASE), hashes_per_second);
uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
if(cause == (CAUSE_IRQ_BASE + 5)) // Timer interrupt
{
uart_puts(IO_ADDRESS(UART_BASE), "Hashes per second: ");
uart_puth(IO_ADDRESS(UART_BASE), hashes_per_second);
uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
 
if(led_status == 0)
{
gpio_set_output(IO_ADDRESS(GPIO2_BASE), 1);
led_status = 1;
if(led_status == 0)
{
gpio_set_output(IO_ADDRESS(GPIO2_BASE), 1);
led_status = 1;
} else {
gpio_set_output(IO_ADDRESS(GPIO2_BASE), 0);
led_status = 0;
}
 
hashes_per_second = 0;
timer_reset(IO_ADDRESS(TIMER_BASE));
} else {
gpio_set_output(IO_ADDRESS(GPIO2_BASE), 0);
led_status = 0;
uart_puts(IO_ADDRESS(UART_BASE), "Unhandled exception!\n\r");
uart_puts(IO_ADDRESS(UART_BASE), "Cause: ");
uart_puth(IO_ADDRESS(UART_BASE), cause);
uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
uart_puts(IO_ADDRESS(UART_BASE), "EPC: ");
uart_puth(IO_ADDRESS(UART_BASE), (uint32_t) epc);
uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
 
while(1) asm volatile("nop\n");
}
 
timer_reset(IO_ADDRESS(TIMER_BASE));
hashes_per_second = 0;
}
 
int main(void)
42,7 → 61,7
gpio_set_direction(IO_ADDRESS(GPIO2_BASE), 0xffff); // LEDs
 
// Set up the timer:
timer_set(IO_ADDRESS(TIMER_BASE), 50000000);
timer_set(IO_ADDRESS(TIMER_BASE), SYSTEM_CLK_FREQ);
 
// Print a startup message:
uart_puts(IO_ADDRESS(UART_BASE), "The Potato Processor SHA256 Benchmark\n\r\n\r");
/Makefile
11,7 → 11,8
TARGET_OBJCOPY := $(TARGET_PREFIX)-objcopy
HEXDUMP ?= hexdump
 
TARGET_CFLAGS += -m32 -Wall -O3 -fomit-frame-pointer -ffreestanding -fno-builtin -I.. -std=gnu99
TARGET_CFLAGS += -m32 -march=RV32I -Wall -Os -fomit-frame-pointer \
-ffreestanding -fno-builtin -I.. -std=gnu99
TARGET_LDFLAGS += -m elf32lriscv -T../benchmark.ld
 
OBJECTS := gpio.o main.o sha256.o start.o timer.o uart.o utilities.o

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.