aboutsummaryrefslogtreecommitdiffstats
path: root/picosoc/firmware.c
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2017-09-20 23:53:53 +0200
committerClifford Wolf <clifford@clifford.at>2017-09-20 23:53:53 +0200
commitc00811e8e45d535f6a260b2e78fa7f68df3d91f5 (patch)
treec655a7a042cc41457e9d37b6b753cefcafcffd3e /picosoc/firmware.c
parentdea9b88249f9ad6946211ace129193677483d2f4 (diff)
downloadpicorv32-c00811e8e45d535f6a260b2e78fa7f68df3d91f5.tar.gz
picorv32-c00811e8e45d535f6a260b2e78fa7f68df3d91f5.zip
Improve PicoSoC example firmware
Diffstat (limited to 'picosoc/firmware.c')
-rw-r--r--picosoc/firmware.c65
1 files changed, 54 insertions, 11 deletions
diff --git a/picosoc/firmware.c b/picosoc/firmware.c
index 1e1fcb3..ae99d30 100644
--- a/picosoc/firmware.c
+++ b/picosoc/firmware.c
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include <stdbool.h>
// a pointer to this is a null pointer, but the compiler does not
// know that because "sram" is a linker symbol from sections.lds.
@@ -167,7 +168,7 @@ void cmd_read_flash_regs()
// --------------------------------------------------------
-void cmd_benchmark()
+uint32_t cmd_benchmark(bool verbose)
{
uint8_t data[256];
uint32_t *words = (void*)data;
@@ -204,16 +205,56 @@ void cmd_benchmark()
__asm__ volatile ("rdcycle %0" : "=r"(cycles_end));
__asm__ volatile ("rdinstret %0" : "=r"(instns_end));
- print("Cycles: 0x");
- print_hex(cycles_end - cycles_begin, 8);
+ if (verbose)
+ {
+ print("Cycles: 0x");
+ print_hex(cycles_end - cycles_begin, 8);
+ putchar('\n');
+
+ print("Instns: 0x");
+ print_hex(instns_end - instns_begin, 8);
+ putchar('\n');
+
+ print("Chksum: 0x");
+ print_hex(x32, 8);
+ putchar('\n');
+ }
+
+ return cycles_end - cycles_begin;
+}
+
+// --------------------------------------------------------
+
+void cmd_benchmark_all()
+{
+ print("default ");
+ reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00000000;
+ print(": ");
+ print_hex(cmd_benchmark(false), 8);
+ putchar('\n');
+
+ print("qspi-8 ");
+ reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00200000;
+ print(": ");
+ print_hex(cmd_benchmark(false), 8);
putchar('\n');
- print("Instns: 0x");
- print_hex(instns_end - instns_begin, 8);
+ print("qspi-xip-8 ");
+ reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00300000;
+ print(": ");
+ print_hex(cmd_benchmark(false), 8);
putchar('\n');
- print("Chksum: 0x");
- print_hex(x32, 8);
+ print("qspi-ddr-8 ");
+ reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00600000;
+ print(": ");
+ print_hex(cmd_benchmark(false), 8);
+ putchar('\n');
+
+ print("qspi-ddr-xip-8 ");
+ reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00700000;
+ print(": ");
+ print_hex(cmd_benchmark(false), 8);
putchar('\n');
}
@@ -222,9 +263,7 @@ void cmd_benchmark()
void main()
{
reg_uart_clkdiv = 104;
-
set_quad_spi_flag();
- // reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00600000;
while (getchar_prompt("Press ENTER to continue..\n") != '\r') { /* wait */ }
@@ -273,7 +312,8 @@ void main()
print(" [5] Switch to QSPI XIP mode\n");
print(" [6] Switch to QSPI mode\n");
print(" [7] Switch to default mode\n");
- print(" [0] Run simplistic benchmark\n");
+ print(" [9] Run simplistic benchmark\n");
+ print(" [0] Benchmark all configs\n");
print("\n");
for (int rep = 10; rep > 0; rep--)
@@ -307,8 +347,11 @@ void main()
case '7':
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00000000;
break;
+ case '9':
+ cmd_benchmark(true);
+ break;
case '0':
- cmd_benchmark();
+ cmd_benchmark_all();
break;
default:
continue;