Enable a bunch of PicoRV32 features in PicoSoC

This commit is contained in:
Clifford Wolf 2017-09-22 04:52:44 +02:00
parent 1c889ee3b5
commit 694b9390fd
6 changed files with 139 additions and 23 deletions

View File

@ -36,7 +36,7 @@ hx8kprog_fw: firmware.bin
# ---- Example Firmware ---- # ---- Example Firmware ----
firmware.elf: sections.lds start.s firmware.c firmware.elf: sections.lds start.s firmware.c
riscv32-unknown-elf-gcc -Wl,-Bstatic,-T,sections.lds,--strip-debug -ffreestanding -nostdlib -o firmware.elf start.s firmware.c riscv32-unknown-elf-gcc -march=rv32imc -Wl,-Bstatic,-T,sections.lds,--strip-debug -ffreestanding -nostdlib -o firmware.elf start.s firmware.c
firmware.hex: firmware.elf firmware.hex: firmware.elf
riscv32-unknown-elf-objcopy -O verilog firmware.elf /dev/stdout | sed -e '1 s/@00000000/@00100000/; 2,65537 d;' > firmware.hex riscv32-unknown-elf-objcopy -O verilog firmware.elf /dev/stdout | sed -e '1 s/@00000000/@00100000/; 2,65537 d;' > firmware.hex

View File

@ -179,7 +179,7 @@ void cmd_read_flash_regs()
// -------------------------------------------------------- // --------------------------------------------------------
uint32_t cmd_benchmark(bool verbose) uint32_t cmd_benchmark(bool verbose, uint32_t *instns_p)
{ {
uint8_t data[256]; uint8_t data[256];
uint32_t *words = (void*)data; uint32_t *words = (void*)data;
@ -231,6 +231,9 @@ uint32_t cmd_benchmark(bool verbose)
putchar('\n'); putchar('\n');
} }
if (instns_p)
*instns_p = instns_end - instns_begin;
return cycles_end - cycles_begin; return cycles_end - cycles_begin;
} }
@ -238,10 +241,12 @@ uint32_t cmd_benchmark(bool verbose)
void cmd_benchmark_all() void cmd_benchmark_all()
{ {
uint32_t instns = 0;
print("default "); print("default ");
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00000000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00000000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
for (int i = 8; i > 0; i--) for (int i = 8; i > 0; i--)
@ -254,7 +259,7 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00400000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00400000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
@ -268,7 +273,7 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00500000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00500000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
@ -282,7 +287,7 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00200000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00200000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
@ -296,7 +301,7 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00300000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00300000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
@ -310,7 +315,7 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00600000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00600000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
@ -324,9 +329,13 @@ void cmd_benchmark_all()
reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00700000; reg_spictrl = (reg_spictrl & ~0x00700000) | 0x00700000;
print(": "); print(": ");
print_hex(cmd_benchmark(false), 8); print_hex(cmd_benchmark(false, &instns), 8);
putchar('\n'); putchar('\n');
} }
print("instns : ");
print_hex(instns, 8);
putchar('\n');
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -419,7 +428,7 @@ void main()
reg_spictrl = reg_spictrl ^ 0x00100000; reg_spictrl = reg_spictrl ^ 0x00100000;
break; break;
case '9': case '9':
cmd_benchmark(true); cmd_benchmark(true, 0);
break; break;
case '0': case '0':
cmd_benchmark_all(); cmd_benchmark_all();

View File

@ -115,6 +115,10 @@ module hx8kdemo (
.flash_io2_di (flash_io2_di), .flash_io2_di (flash_io2_di),
.flash_io3_di (flash_io3_di), .flash_io3_di (flash_io3_di),
.irq_5 (1'b0 ),
.irq_6 (1'b0 ),
.irq_7 (1'b0 ),
.iomem_valid (iomem_valid ), .iomem_valid (iomem_valid ),
.iomem_ready (iomem_ready ), .iomem_ready (iomem_ready ),
.iomem_wstrb (iomem_wstrb ), .iomem_wstrb (iomem_wstrb ),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -3,7 +3,7 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
text = """ uncompr_text = """
default : 010f52ef default : 010f52ef
dspi-8 : 008dc82f dspi-8 : 008dc82f
dspi-7 : 008d6d63 dspi-7 : 008d6d63
@ -53,32 +53,110 @@ qspi-ddr-crm-4 : 00244a65
qspi-ddr-crm-3 : 0023ef99 qspi-ddr-crm-3 : 0023ef99
qspi-ddr-crm-2 : 002394cd qspi-ddr-crm-2 : 002394cd
qspi-ddr-crm-1 : 00233a01 qspi-ddr-crm-1 : 00233a01
instns : 0003df2d
"""
compr_text = """
default : 00f3d36d
dspi-8 : 008008ad
dspi-7 : 007fade1
dspi-6 : 007f5315
dspi-5 : 007ef849
dspi-4 : 007e9d7d
dspi-3 : 007e42b1
dspi-2 : 007de7e5
dspi-1 : 007d8d19
dspi-crm-8 : 007d324d
dspi-crm-7 : 007cd781
dspi-crm-6 : 007c7cb5
dspi-crm-5 : 007c21e9
dspi-crm-4 : 007bc71d
dspi-crm-3 : 007b6c51
dspi-crm-2 : 007b1185
dspi-crm-1 : 007ab6b9
qspi-8 : 00434ced
qspi-7 : 0042f221
qspi-6 : 00429755
qspi-5 : 00423c89
qspi-4 : 0041e1bd
qspi-3 : 004186f1
qspi-2 : 00412c25
qspi-1 : 0040d159
qspi-crm-8 : 0040768d
qspi-crm-7 : 00401bc1
qspi-crm-6 : 003fc0f5
qspi-crm-5 : 003f6629
qspi-crm-4 : 003f0b5d
qspi-crm-3 : 003eb091
qspi-crm-2 : 003e55c5
qspi-crm-1 : 003dfaf9
qspi-ddr-8 : 00255d87
qspi-ddr-7 : 002502bb
qspi-ddr-6 : 0024a7ef
qspi-ddr-5 : 00244d23
qspi-ddr-4 : 0023f257
qspi-ddr-3 : 0023978b
qspi-ddr-2 : 00233cbf
qspi-ddr-1 : 0022e1f3
qspi-ddr-crm-8 : 00228727
qspi-ddr-crm-7 : 00222c5b
qspi-ddr-crm-6 : 0021d18f
qspi-ddr-crm-5 : 002176c3
qspi-ddr-crm-4 : 00211bf7
qspi-ddr-crm-3 : 0020c12b
qspi-ddr-crm-2 : 0020665f
qspi-ddr-crm-1 : 00200b93
instns : 0003df2d
""" """
labels = list() labels = list()
values = list() uncompr_values = list()
compr_values = list()
for line in text.split("\n"): for line in uncompr_text.split("\n"):
if line != "": if line != "":
line = line.split() line = line.split()
labels.append(line[0]) if line[0] == "instns":
values.append(int(line[2], 16)) for i in range(len(uncompr_values)):
uncompr_values[i] = int(line[2], 16) / uncompr_values[i]
else:
labels.append(line[0])
uncompr_values.append(int(line[2], 16))
for line in compr_text.split("\n"):
if line != "":
line = line.split()
if line[0] == "instns":
for i in range(len(compr_values)):
compr_values[i] = int(line[2], 16) / compr_values[i]
else:
compr_values.append(int(line[2], 16))
print(np.array(compr_values) / np.array(uncompr_values))
values = list()
for i in range(len(compr_values)):
values.append(uncompr_values[i] / uncompr_values[0])
# values.append(compr_values[i] / compr_values[0])
values = np.array(values)
print(values)
plt.figure(figsize=(10, 5)) plt.figure(figsize=(10, 5))
plt.title("Performance comparison for different PicoSoC SPI flash configurations") plt.title("Performance comparison for different PicoSoC SPI flash configurations")
plt.plot(range(len(labels)), values[0] / np.array(values)) plt.plot(range(len(labels)), values)
plt.xticks(range(len(labels)), labels, rotation=80) plt.xticks(range(len(labels)), labels, rotation=80)
for color, x1, x2 in [["black", 0, 0], ["red", 1, 8], ["green", 9, 16], for color, x1, x2 in [["black", 0, 0], ["red", 1, 8], ["green", 9, 16],
["red", 17, 24], ["green", 25, 32], ["red", 33, 40], ["green", 41, 48]]: ["red", 17, 24], ["green", 25, 32], ["red", 33, 40], ["green", 41, 48]]:
for t in plt.axes().xaxis.get_ticklabels()[x1:x2+1]: for t in plt.axes().xaxis.get_ticklabels()[x1:x2+1]:
t.set_color(color) t.set_color(color)
plt.plot([x1, x1], [0, values[0] / values[x1] - 0.2], color=color) plt.plot([x1, x1], [0, values[x1] - 0.2], color=color)
plt.plot([x2, x2], [0, values[0] / values[x2] - 0.2], color=color) plt.plot([x2, x2], [0, values[x2] - 0.2], color=color)
plt.plot([x1], [values[0] / values[x1]], "k.") plt.plot([x1], [values[x1]], "k.")
plt.plot([x2], [values[0] / values[x2]], "k.") plt.plot([x2], [values[x2]], "k.")
plt.xlim(-1, len(values)) plt.xlim(-1, len(labels))
plt.ylim(0, 9) plt.ylim(0, 9)
plt.grid() plt.grid()

View File

@ -28,6 +28,10 @@ module picosoc (
output [31:0] iomem_wdata, output [31:0] iomem_wdata,
input [31:0] iomem_rdata, input [31:0] iomem_rdata,
input irq_5,
input irq_6,
input irq_7,
output ser_tx, output ser_tx,
input ser_rx, input ser_rx,
@ -53,6 +57,19 @@ module picosoc (
parameter [31:0] STACKADDR = (4*MEM_WORDS); // end of memory parameter [31:0] STACKADDR = (4*MEM_WORDS); // end of memory
parameter [31:0] PROGADDR_RESET = 32'h 0010_0000; // 1 MB into flash parameter [31:0] PROGADDR_RESET = 32'h 0010_0000; // 1 MB into flash
reg [31:0] irq;
wire irq_stall = 0;
wire irq_uart = 0;
always @* begin
irq = 0;
irq[3] = irq_stall;
irq[4] = irq_uart;
irq[5] = irq_5;
irq[6] = irq_6;
irq[7] = irq_7;
end
wire mem_valid; wire mem_valid;
wire mem_instr; wire mem_instr;
wire mem_ready; wire mem_ready;
@ -91,7 +108,14 @@ module picosoc (
picorv32 #( picorv32 #(
.STACKADDR(STACKADDR), .STACKADDR(STACKADDR),
.PROGADDR_RESET(PROGADDR_RESET) .PROGADDR_RESET(PROGADDR_RESET),
.PROGADDR_IRQ(32'h 0000_0000),
.BARREL_SHIFTER(1),
.COMPRESSED_ISA(1),
.ENABLE_MUL(1),
.ENABLE_DIV(1),
.ENABLE_IRQ(1),
.ENABLE_IRQ_QREGS(0)
) cpu ( ) cpu (
.clk (clk ), .clk (clk ),
.resetn (resetn ), .resetn (resetn ),
@ -101,7 +125,8 @@ module picosoc (
.mem_addr (mem_addr ), .mem_addr (mem_addr ),
.mem_wdata (mem_wdata ), .mem_wdata (mem_wdata ),
.mem_wstrb (mem_wstrb ), .mem_wstrb (mem_wstrb ),
.mem_rdata (mem_rdata ) .mem_rdata (mem_rdata ),
.irq (irq )
); );
spimemio spimemio ( spimemio spimemio (