From 7bf87502aa70052042cd2e9d8ff9da593a887aa6 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Mon, 29 Aug 2016 21:12:08 -0700 Subject: [PATCH 01/12] Clone vivado dir into quartus dir --- scripts/quartus/.gitignore | 18 ++++ scripts/quartus/Makefile | 65 ++++++++++++ scripts/quartus/firmware.S | 12 +++ scripts/quartus/firmware.c | 43 ++++++++ scripts/quartus/firmware.lds | 11 ++ scripts/quartus/synth_area.tcl | 8 ++ scripts/quartus/synth_area.xdc | 1 + scripts/quartus/synth_area_large.tcl | 10 ++ scripts/quartus/synth_area_regular.tcl | 10 ++ scripts/quartus/synth_area_small.tcl | 10 ++ scripts/quartus/synth_area_top.v | 140 +++++++++++++++++++++++++ scripts/quartus/synth_speed.tcl | 13 +++ scripts/quartus/synth_speed.xdc | 1 + scripts/quartus/synth_system.tcl | 17 +++ scripts/quartus/synth_system.xdc | 34 ++++++ scripts/quartus/system.v | 101 ++++++++++++++++++ scripts/quartus/system_tb.v | 38 +++++++ scripts/quartus/table.sh | 19 ++++ scripts/quartus/tabtest.sh | 92 ++++++++++++++++ scripts/quartus/tabtest.v | 118 +++++++++++++++++++++ 20 files changed, 761 insertions(+) create mode 100644 scripts/quartus/.gitignore create mode 100644 scripts/quartus/Makefile create mode 100644 scripts/quartus/firmware.S create mode 100644 scripts/quartus/firmware.c create mode 100644 scripts/quartus/firmware.lds create mode 100644 scripts/quartus/synth_area.tcl create mode 100644 scripts/quartus/synth_area.xdc create mode 100644 scripts/quartus/synth_area_large.tcl create mode 100644 scripts/quartus/synth_area_regular.tcl create mode 100644 scripts/quartus/synth_area_small.tcl create mode 100644 scripts/quartus/synth_area_top.v create mode 100644 scripts/quartus/synth_speed.tcl create mode 100644 scripts/quartus/synth_speed.xdc create mode 100644 scripts/quartus/synth_system.tcl create mode 100644 scripts/quartus/synth_system.xdc create mode 100644 scripts/quartus/system.v create mode 100644 scripts/quartus/system_tb.v create mode 100644 scripts/quartus/table.sh create mode 100644 scripts/quartus/tabtest.sh create mode 100644 scripts/quartus/tabtest.v diff --git a/scripts/quartus/.gitignore b/scripts/quartus/.gitignore new file mode 100644 index 0000000..2374269 --- /dev/null +++ b/scripts/quartus/.gitignore @@ -0,0 +1,18 @@ +.Xil/ +firmware.bin +firmware.elf +firmware.hex +firmware.map +synth_*.log +synth_*.mmi +synth_*.bit +synth_system.v +table.txt +tab_*/ +webtalk.jou +webtalk.log +webtalk_*.jou +webtalk_*.log +xelab.* +xsim.* +xvlog.* diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile new file mode 100644 index 0000000..4e109d2 --- /dev/null +++ b/scripts/quartus/Makefile @@ -0,0 +1,65 @@ + +VIVADO_BASE = /opt/Xilinx/Vivado/2016.1 +VIVADO = $(VIVADO_BASE)/bin/vivado +XVLOG = $(VIVADO_BASE)/bin/xvlog +XELAB = $(VIVADO_BASE)/bin/xelab +GLBL = $(VIVADO_BASE)/data/verilog/src/glbl.v +TOOLCHAIN_PREFIX = riscv64-unknown-elf- + +export VIVADO + +help: + @echo "" + @echo "Simple synthesis tests:" + @echo " make synth_area_{small|regular|large}" + @echo " make synth_speed" + @echo "" + @echo "Example system:" + @echo " make synth_system" + @echo " make sim_system" + @echo "" + @echo "Timing and Utilization Evaluation:" + @echo " make table.txt" + @echo " make area" + @echo "" + +synth_%: + rm -f $@.log + $(VIVADO) -nojournal -log $@.log -mode batch -source $@.tcl + rm -rf .Xil fsm_encoding.os synth_*.backup.log usage_statistics_webtalk.* + -grep -B4 -A10 'Slice LUTs' $@.log + -grep -B1 -A9 ^Slack $@.log && echo + +synth_system: firmware.hex + +sim_system: + $(XVLOG) system_tb.v synth_system.v + $(XVLOG) $(GLBL) + $(XELAB) -L unifast_ver -L unisims_ver -R system_tb glbl + +firmware.hex: firmware.S firmware.c firmware.lds + $(TOOLCHAIN_PREFIX)gcc -Os -m32 -ffreestanding -nostdlib -o firmware.elf firmware.S firmware.c \ + --std=gnu99 -Wl,-Bstatic,-T,firmware.lds,-Map,firmware.map,--strip-debug -lgcc + $(TOOLCHAIN_PREFIX)objcopy -O binary firmware.elf firmware.bin + python3 ../../firmware/makehex.py firmware.bin 4096 > firmware.hex + +tab_%/results.txt: + bash tabtest.sh $@ + +area: synth_area_small synth_area_regular synth_area_large + -grep -B4 -A10 'Slice LUTs' synth_area_small.log synth_area_regular.log synth_area_large.log + +table.txt: tab_small_xc7a_1/results.txt tab_small_xc7a_2/results.txt tab_small_xc7a_3/results.txt +table.txt: tab_small_xc7k_1/results.txt tab_small_xc7k_2/results.txt tab_small_xc7k_3/results.txt +table.txt: tab_small_xc7v_1/results.txt tab_small_xc7v_2/results.txt tab_small_xc7v_3/results.txt +table.txt: tab_small_xcku_1/results.txt tab_small_xcku_2/results.txt tab_small_xcku_3/results.txt +table.txt: tab_small_xcvu_1/results.txt tab_small_xcvu_2/results.txt tab_small_xcvu_3/results.txt + +table.txt: + bash table.sh > table.txt + +clean: + rm -rf .Xil/ firmware.bin firmware.elf firmware.hex firmware.map synth_*.log + rm -rf synth_*.mmi synth_*.bit synth_system.v table.txt tab_*/ webtalk.jou + rm -rf webtalk.log webtalk_*.jou webtalk_*.log xelab.* xsim[._]* xvlog.* + diff --git a/scripts/quartus/firmware.S b/scripts/quartus/firmware.S new file mode 100644 index 0000000..c55a3ba --- /dev/null +++ b/scripts/quartus/firmware.S @@ -0,0 +1,12 @@ +.section .init +.global main + +/* set stack pointer */ +lui sp, %hi(16*1024) +addi sp, sp, %lo(16*1024) + +/* call main */ +jal ra, main + +/* break */ +ebreak diff --git a/scripts/quartus/firmware.c b/scripts/quartus/firmware.c new file mode 100644 index 0000000..6c62169 --- /dev/null +++ b/scripts/quartus/firmware.c @@ -0,0 +1,43 @@ +void putc(char c) +{ + *(volatile char*)0x10000000 = c; +} + +void puts(const char *s) +{ + while (*s) putc(*s++); +} + +void *memcpy(void *dest, const void *src, int n) +{ + while (n) { + n--; + ((char*)dest)[n] = ((char*)src)[n]; + } + return dest; +} + +void main() +{ + char message[] = "$Uryyb+Jbeyq!+Vs+lbh+pna+ernq+guvf+zrffntr+gura$gur+CvpbEI32+PCH" + "+frrzf+gb+or+jbexvat+whfg+svar.$$++++++++++++++++GRFG+CNFFRQ!$$"; + for (int i = 0; message[i]; i++) + switch (message[i]) + { + case 'a' ... 'm': + case 'A' ... 'M': + message[i] += 13; + break; + case 'n' ... 'z': + case 'N' ... 'Z': + message[i] -= 13; + break; + case '$': + message[i] = '\n'; + break; + case '+': + message[i] = ' '; + break; + } + puts(message); +} diff --git a/scripts/quartus/firmware.lds b/scripts/quartus/firmware.lds new file mode 100644 index 0000000..970000a --- /dev/null +++ b/scripts/quartus/firmware.lds @@ -0,0 +1,11 @@ +SECTIONS { + .memory : { + . = 0x000000; + *(.init); + *(.text); + *(*); + . = ALIGN(4); + end = .; + } +} + diff --git a/scripts/quartus/synth_area.tcl b/scripts/quartus/synth_area.tcl new file mode 100644 index 0000000..c222a00 --- /dev/null +++ b/scripts/quartus/synth_area.tcl @@ -0,0 +1,8 @@ +read_verilog ../../picorv32.v +read_xdc synth_area.xdc + +synth_design -part xc7k70t-fbg676 -top picorv32_axi +opt_design -resynth_seq_area + +report_utilization +report_timing diff --git a/scripts/quartus/synth_area.xdc b/scripts/quartus/synth_area.xdc new file mode 100644 index 0000000..3c3d5a1 --- /dev/null +++ b/scripts/quartus/synth_area.xdc @@ -0,0 +1 @@ +create_clock -period 20.00 [get_ports clk] diff --git a/scripts/quartus/synth_area_large.tcl b/scripts/quartus/synth_area_large.tcl new file mode 100644 index 0000000..af611b5 --- /dev/null +++ b/scripts/quartus/synth_area_large.tcl @@ -0,0 +1,10 @@ +read_verilog ../../picorv32.v +read_verilog synth_area_top.v +read_xdc synth_area.xdc + +synth_design -part xc7k70t-fbg676 -top top_large +opt_design -sweep -propconst -resynth_seq_area +opt_design -directive ExploreSequentialArea + +report_utilization +report_timing diff --git a/scripts/quartus/synth_area_regular.tcl b/scripts/quartus/synth_area_regular.tcl new file mode 100644 index 0000000..2bf6b4c --- /dev/null +++ b/scripts/quartus/synth_area_regular.tcl @@ -0,0 +1,10 @@ +read_verilog ../../picorv32.v +read_verilog synth_area_top.v +read_xdc synth_area.xdc + +synth_design -part xc7k70t-fbg676 -top top_regular +opt_design -sweep -propconst -resynth_seq_area +opt_design -directive ExploreSequentialArea + +report_utilization +report_timing diff --git a/scripts/quartus/synth_area_small.tcl b/scripts/quartus/synth_area_small.tcl new file mode 100644 index 0000000..11d2104 --- /dev/null +++ b/scripts/quartus/synth_area_small.tcl @@ -0,0 +1,10 @@ +read_verilog ../../picorv32.v +read_verilog synth_area_top.v +read_xdc synth_area.xdc + +synth_design -part xc7k70t-fbg676 -top top_small +opt_design -sweep -propconst -resynth_seq_area +opt_design -directive ExploreSequentialArea + +report_utilization +report_timing diff --git a/scripts/quartus/synth_area_top.v b/scripts/quartus/synth_area_top.v new file mode 100644 index 0000000..6298a86 --- /dev/null +++ b/scripts/quartus/synth_area_top.v @@ -0,0 +1,140 @@ + +module top_small ( + input clk, resetn, + + output mem_valid, + output mem_instr, + input mem_ready, + + output [31:0] mem_addr, + output [31:0] mem_wdata, + output [ 3:0] mem_wstrb, + input [31:0] mem_rdata +); + picorv32 #( + .ENABLE_COUNTERS(0), + .LATCHED_MEM_RDATA(1), + .TWO_STAGE_SHIFT(0), + .CATCH_MISALIGN(0), + .CATCH_ILLINSN(0) + ) picorv32 ( + .clk (clk ), + .resetn (resetn ), + .mem_valid(mem_valid), + .mem_instr(mem_instr), + .mem_ready(mem_ready), + .mem_addr (mem_addr ), + .mem_wdata(mem_wdata), + .mem_wstrb(mem_wstrb), + .mem_rdata(mem_rdata) + ); +endmodule + +module top_regular ( + input clk, resetn, + output trap, + + output mem_valid, + output mem_instr, + input mem_ready, + + output [31:0] mem_addr, + output [31:0] mem_wdata, + output [ 3:0] mem_wstrb, + input [31:0] mem_rdata, + + // Look-Ahead Interface + output mem_la_read, + output mem_la_write, + output [31:0] mem_la_addr, + output [31:0] mem_la_wdata, + output [ 3:0] mem_la_wstrb +); + picorv32 picorv32 ( + .clk (clk ), + .resetn (resetn ), + .trap (trap ), + .mem_valid (mem_valid ), + .mem_instr (mem_instr ), + .mem_ready (mem_ready ), + .mem_addr (mem_addr ), + .mem_wdata (mem_wdata ), + .mem_wstrb (mem_wstrb ), + .mem_rdata (mem_rdata ), + .mem_la_read (mem_la_read ), + .mem_la_write(mem_la_write), + .mem_la_addr (mem_la_addr ), + .mem_la_wdata(mem_la_wdata), + .mem_la_wstrb(mem_la_wstrb) + ); +endmodule + +module top_large ( + input clk, resetn, + output trap, + + output mem_valid, + output mem_instr, + input mem_ready, + + output [31:0] mem_addr, + output [31:0] mem_wdata, + output [ 3:0] mem_wstrb, + input [31:0] mem_rdata, + + // Look-Ahead Interface + output mem_la_read, + output mem_la_write, + output [31:0] mem_la_addr, + output [31:0] mem_la_wdata, + output [ 3:0] mem_la_wstrb, + + // Pico Co-Processor Interface (PCPI) + output pcpi_valid, + output [31:0] pcpi_insn, + output [31:0] pcpi_rs1, + output [31:0] pcpi_rs2, + input pcpi_wr, + input [31:0] pcpi_rd, + input pcpi_wait, + input pcpi_ready, + + // IRQ Interface + input [31:0] irq, + output [31:0] eoi +); + picorv32 #( + .COMPRESSED_ISA(1), + .BARREL_SHIFTER(1), + .ENABLE_PCPI(1), + .ENABLE_MUL(1), + .ENABLE_IRQ(1) + ) picorv32 ( + .clk (clk ), + .resetn (resetn ), + .trap (trap ), + .mem_valid (mem_valid ), + .mem_instr (mem_instr ), + .mem_ready (mem_ready ), + .mem_addr (mem_addr ), + .mem_wdata (mem_wdata ), + .mem_wstrb (mem_wstrb ), + .mem_rdata (mem_rdata ), + .mem_la_read (mem_la_read ), + .mem_la_write (mem_la_write ), + .mem_la_addr (mem_la_addr ), + .mem_la_wdata (mem_la_wdata ), + .mem_la_wstrb (mem_la_wstrb ), + .pcpi_valid (pcpi_valid ), + .pcpi_insn (pcpi_insn ), + .pcpi_rs1 (pcpi_rs1 ), + .pcpi_rs2 (pcpi_rs2 ), + .pcpi_wr (pcpi_wr ), + .pcpi_rd (pcpi_rd ), + .pcpi_wait (pcpi_wait ), + .pcpi_ready (pcpi_ready ), + .irq (irq ), + .eoi (eoi ) + ); +endmodule + diff --git a/scripts/quartus/synth_speed.tcl b/scripts/quartus/synth_speed.tcl new file mode 100644 index 0000000..f3874e4 --- /dev/null +++ b/scripts/quartus/synth_speed.tcl @@ -0,0 +1,13 @@ + +read_verilog ../../picorv32.v +read_xdc synth_speed.xdc + +synth_design -part xc7k70t-fbg676 -top picorv32_axi +opt_design +place_design +phys_opt_design +route_design + +report_utilization +report_timing + diff --git a/scripts/quartus/synth_speed.xdc b/scripts/quartus/synth_speed.xdc new file mode 100644 index 0000000..877ec8d --- /dev/null +++ b/scripts/quartus/synth_speed.xdc @@ -0,0 +1 @@ +create_clock -period 2.50 [get_ports clk] diff --git a/scripts/quartus/synth_system.tcl b/scripts/quartus/synth_system.tcl new file mode 100644 index 0000000..26ea01c --- /dev/null +++ b/scripts/quartus/synth_system.tcl @@ -0,0 +1,17 @@ + +read_verilog system.v +read_verilog ../../picorv32.v +read_xdc synth_system.xdc + +synth_design -part xc7a35t-cpg236-1 -top system +opt_design +place_design +route_design + +report_utilization +report_timing + +write_verilog -force synth_system.v +write_bitstream -force synth_system.bit +# write_mem_info -force synth_system.mmi + diff --git a/scripts/quartus/synth_system.xdc b/scripts/quartus/synth_system.xdc new file mode 100644 index 0000000..5748466 --- /dev/null +++ b/scripts/quartus/synth_system.xdc @@ -0,0 +1,34 @@ + +# XDC File for Basys3 Board +########################### + +set_property PACKAGE_PIN W5 [get_ports clk] +set_property IOSTANDARD LVCMOS33 [get_ports clk] +create_clock -period 10.00 [get_ports clk] + +# Pmod Header JA (JA0..JA7) +set_property PACKAGE_PIN J1 [get_ports {out_byte[0]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[0]}] +set_property PACKAGE_PIN L2 [get_ports {out_byte[1]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[1]}] +set_property PACKAGE_PIN J2 [get_ports {out_byte[2]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[2]}] +set_property PACKAGE_PIN G2 [get_ports {out_byte[3]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[3]}] +set_property PACKAGE_PIN H1 [get_ports {out_byte[4]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[4]}] +set_property PACKAGE_PIN K2 [get_ports {out_byte[5]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[5]}] +set_property PACKAGE_PIN H2 [get_ports {out_byte[6]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[6]}] +set_property PACKAGE_PIN G3 [get_ports {out_byte[7]}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[7]}] + +# Pmod Header JB (JB0..JB2) +set_property PACKAGE_PIN A14 [get_ports {resetn}] +set_property IOSTANDARD LVCMOS33 [get_ports {resetn}] +set_property PACKAGE_PIN A16 [get_ports {trap}] +set_property IOSTANDARD LVCMOS33 [get_ports {trap}] +set_property PACKAGE_PIN B15 [get_ports {out_byte_en}] +set_property IOSTANDARD LVCMOS33 [get_ports {out_byte_en}] + diff --git a/scripts/quartus/system.v b/scripts/quartus/system.v new file mode 100644 index 0000000..c4882a1 --- /dev/null +++ b/scripts/quartus/system.v @@ -0,0 +1,101 @@ +`timescale 1 ns / 1 ps + +module system ( + input clk, + input resetn, + output trap, + output reg [7:0] out_byte, + output reg out_byte_en +); + // set this to 0 for better timing but less performance/MHz + parameter FAST_MEMORY = 1; + + // 4096 32bit words = 16kB memory + parameter MEM_SIZE = 4096; + + wire mem_valid; + wire mem_instr; + reg mem_ready; + wire [31:0] mem_addr; + wire [31:0] mem_wdata; + wire [3:0] mem_wstrb; + reg [31:0] mem_rdata; + + wire mem_la_read; + wire mem_la_write; + wire [31:0] mem_la_addr; + wire [31:0] mem_la_wdata; + wire [3:0] mem_la_wstrb; + + picorv32 picorv32_core ( + .clk (clk ), + .resetn (resetn ), + .trap (trap ), + .mem_valid (mem_valid ), + .mem_instr (mem_instr ), + .mem_ready (mem_ready ), + .mem_addr (mem_addr ), + .mem_wdata (mem_wdata ), + .mem_wstrb (mem_wstrb ), + .mem_rdata (mem_rdata ), + .mem_la_read (mem_la_read ), + .mem_la_write(mem_la_write), + .mem_la_addr (mem_la_addr ), + .mem_la_wdata(mem_la_wdata), + .mem_la_wstrb(mem_la_wstrb) + ); + + reg [31:0] memory [0:MEM_SIZE-1]; + initial $readmemh("firmware.hex", memory); + + reg [31:0] m_read_data; + reg m_read_en; + + generate if (FAST_MEMORY) begin + always @(posedge clk) begin + mem_ready <= 1; + out_byte_en <= 0; + mem_rdata <= memory[mem_la_addr >> 2]; + if (mem_la_write && (mem_la_addr >> 2) < MEM_SIZE) begin + if (mem_la_wstrb[0]) memory[mem_la_addr >> 2][ 7: 0] <= mem_la_wdata[ 7: 0]; + if (mem_la_wstrb[1]) memory[mem_la_addr >> 2][15: 8] <= mem_la_wdata[15: 8]; + if (mem_la_wstrb[2]) memory[mem_la_addr >> 2][23:16] <= mem_la_wdata[23:16]; + if (mem_la_wstrb[3]) memory[mem_la_addr >> 2][31:24] <= mem_la_wdata[31:24]; + end + else + if (mem_la_write && mem_la_addr == 32'h1000_0000) begin + out_byte_en <= 1; + out_byte <= mem_la_wdata; + end + end + end else begin + always @(posedge clk) begin + m_read_en <= 0; + mem_ready <= mem_valid && !mem_ready && m_read_en; + + m_read_data <= memory[mem_addr >> 2]; + mem_rdata <= m_read_data; + + out_byte_en <= 0; + + (* parallel_case *) + case (1) + mem_valid && !mem_ready && !mem_wstrb && (mem_addr >> 2) < MEM_SIZE: begin + m_read_en <= 1; + end + mem_valid && !mem_ready && |mem_wstrb && (mem_addr >> 2) < MEM_SIZE: begin + if (mem_wstrb[0]) memory[mem_addr >> 2][ 7: 0] <= mem_wdata[ 7: 0]; + if (mem_wstrb[1]) memory[mem_addr >> 2][15: 8] <= mem_wdata[15: 8]; + if (mem_wstrb[2]) memory[mem_addr >> 2][23:16] <= mem_wdata[23:16]; + if (mem_wstrb[3]) memory[mem_addr >> 2][31:24] <= mem_wdata[31:24]; + mem_ready <= 1; + end + mem_valid && !mem_ready && |mem_wstrb && mem_addr == 32'h1000_0000: begin + out_byte_en <= 1; + out_byte <= mem_wdata; + mem_ready <= 1; + end + endcase + end + end endgenerate +endmodule diff --git a/scripts/quartus/system_tb.v b/scripts/quartus/system_tb.v new file mode 100644 index 0000000..a66d612 --- /dev/null +++ b/scripts/quartus/system_tb.v @@ -0,0 +1,38 @@ +`timescale 1 ns / 1 ps + +module system_tb; + reg clk = 1; + always #5 clk = ~clk; + + reg resetn = 0; + initial begin + if ($test$plusargs("vcd")) begin + $dumpfile("system.vcd"); + $dumpvars(0, system_tb); + end + repeat (100) @(posedge clk); + resetn <= 1; + end + + wire trap; + wire [7:0] out_byte; + wire out_byte_en; + + system uut ( + .clk (clk ), + .resetn (resetn ), + .trap (trap ), + .out_byte (out_byte ), + .out_byte_en(out_byte_en) + ); + + always @(posedge clk) begin + if (resetn && out_byte_en) begin + $write("%c", out_byte); + $fflush; + end + if (resetn && trap) begin + $finish; + end + end +endmodule diff --git a/scripts/quartus/table.sh b/scripts/quartus/table.sh new file mode 100644 index 0000000..f81f586 --- /dev/null +++ b/scripts/quartus/table.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +dashes="----------------------------------------------------------------" +printf '| %-25s | %-10s | %-20s |\n' "Device" "Speedgrade" "Clock Period (Freq.)" +printf '|:%.25s |:%.10s:| %.20s:|\n' $dashes $dashes $dashes + +for x in $( grep -H . tab_*/results.txt ) +do + read _ size device grade _ speed < <( echo "$x" | tr _/: ' ' ) + case "$device" in + xc7a) d="Xilinx Artix-7T" ;; + xc7k) d="Xilinx Kintex-7T" ;; + xc7v) d="Xilinx Virtex-7T" ;; + xcku) d="Xilinx Kintex UltraScale" ;; + xcvu) d="Xilinx Virtex UltraScale" ;; + esac + speedtxt=$( printf '%s.%s ns (%d MHz)' ${speed%?} ${speed#?} $((10000 / speed)) ) + printf '| %-25s | %-10s | %20s |\n' "$d" "-$grade" "$speedtxt" +done diff --git a/scripts/quartus/tabtest.sh b/scripts/quartus/tabtest.sh new file mode 100644 index 0000000..fa43fc3 --- /dev/null +++ b/scripts/quartus/tabtest.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +set -e +read _ ip dev grade _ < <( echo $* | tr '_/' ' '; ) + +# rm -rf tab_${ip}_${dev}_${grade} +mkdir -p tab_${ip}_${dev}_${grade} +cd tab_${ip}_${dev}_${grade} + +best_speed=99 +speed=30 +step=16 + +synth_case() { + if [ -f test_${1}.txt ]; then + echo "Reusing cached tab_${ip}_${dev}_${grade}/test_${1}." + return + fi + + case "${dev}" in + xc7a) xl_device="xc7a15t-fgg484-${grade}" ;; + xc7k) xl_device="xc7k70t-fbg676-${grade}" ;; + xc7v) xl_device="xc7v585t-ffg1761-${grade}" ;; + xcku) xl_device="xcku035-fbva676-${grade}" ;; + xcvu) xl_device="xcvu065-ffvc1517-${grade}" ;; + esac + + case "${dev}-${grade}" in + xcku-1) xl_device="${xl_device}-c" ;; + xcvu-1) xl_device="${xl_device}-i" ;; + xcku-?|xcvu-?) xl_device="${xl_device}-e" ;; + esac + + cat > test_${1}.tcl <<- EOT + read_verilog ../tabtest.v + read_verilog ../../../picorv32.v + read_xdc test_${1}.xdc + synth_design -flatten_hierarchy full -part ${xl_device} -top top + opt_design -sweep -remap -propconst + opt_design -directive Explore + place_design -directive Explore + phys_opt_design -retime -rewire -critical_pin_opt -placement_opt -critical_cell_opt + route_design -directive Explore + place_design -post_place_opt + phys_opt_design -retime + route_design -directive NoTimingRelaxation + report_utilization + report_timing + EOT + + cat > test_${1}.xdc <<- EOT + create_clock -period ${speed%?}.${speed#?} [get_ports clk] + EOT + + echo "Running tab_${ip}_${dev}_${grade}/test_${1}.." + if ! $VIVADO -nojournal -log test_${1}.log -mode batch -source test_${1}.tcl > /dev/null 2>&1; then + cat test_${1}.log + exit 1 + fi + mv test_${1}.log test_${1}.txt +} + +countdown=2 +while [ $countdown -gt 0 ]; do + synth_case $speed + + if grep -q '^Slack.*(VIOLATED)' test_${speed}.txt; then + echo " tab_${ip}_${dev}_${grade}/test_${speed} VIOLATED" + [ $speed -eq 38 ] || step=$((step / 2)) + speed=$((speed + step)) + elif grep -q '^Slack.*(MET)' test_${speed}.txt; then + echo " tab_${ip}_${dev}_${grade}/test_${speed} MET" + [ $speed -lt $best_speed ] && best_speed=$speed + step=$((step / 2)) + speed=$((speed - step)) + else + echo "ERROR: No slack line found in $PWD/test_${speed}.txt!" + exit 1 + fi + + if [ $step -eq 0 ]; then + countdown=$((countdown - 1)) + speed=$((best_speed - 2)) + step=1 + fi +done + +echo "-----------------------" +echo "Best speed for tab_${ip}_${dev}_${grade}: $best_speed" +echo "-----------------------" +echo $best_speed > results.txt + diff --git a/scripts/quartus/tabtest.v b/scripts/quartus/tabtest.v new file mode 100644 index 0000000..cdf2057 --- /dev/null +++ b/scripts/quartus/tabtest.v @@ -0,0 +1,118 @@ + +module top ( + input clk, io_resetn, + output io_trap, + + output io_mem_axi_awvalid, + input io_mem_axi_awready, + output [31:0] io_mem_axi_awaddr, + output [ 2:0] io_mem_axi_awprot, + + output io_mem_axi_wvalid, + input io_mem_axi_wready, + output [31:0] io_mem_axi_wdata, + output [ 3:0] io_mem_axi_wstrb, + + input io_mem_axi_bvalid, + output io_mem_axi_bready, + + output io_mem_axi_arvalid, + input io_mem_axi_arready, + output [31:0] io_mem_axi_araddr, + output [ 2:0] io_mem_axi_arprot, + + input io_mem_axi_rvalid, + output io_mem_axi_rready, + input [31:0] io_mem_axi_rdata, + + input [31:0] io_irq, + output [31:0] io_eoi +); + wire resetn; + wire trap; + wire mem_axi_awvalid; + wire mem_axi_awready; + wire [31:0] mem_axi_awaddr; + wire [2:0] mem_axi_awprot; + wire mem_axi_wvalid; + wire mem_axi_wready; + wire [31:0] mem_axi_wdata; + wire [3:0] mem_axi_wstrb; + wire mem_axi_bvalid; + wire mem_axi_bready; + wire mem_axi_arvalid; + wire mem_axi_arready; + wire [31:0] mem_axi_araddr; + wire [2:0] mem_axi_arprot; + wire mem_axi_rvalid; + wire mem_axi_rready; + wire [31:0] mem_axi_rdata; + wire [31:0] irq; + wire [31:0] eoi; + + delay4 #( 1) delay_resetn (clk, io_resetn , resetn ); + delay4 #( 1) delay_trap (clk, trap , io_trap ); + delay4 #( 1) delay_mem_axi_awvalid (clk, mem_axi_awvalid, io_mem_axi_awvalid); + delay4 #( 1) delay_mem_axi_awready (clk, io_mem_axi_awready, mem_axi_awready); + delay4 #(32) delay_mem_axi_awaddr (clk, mem_axi_awaddr , io_mem_axi_awaddr ); + delay4 #( 3) delay_mem_axi_awprot (clk, mem_axi_awprot , io_mem_axi_awprot ); + delay4 #( 1) delay_mem_axi_wvalid (clk, mem_axi_wvalid , io_mem_axi_wvalid ); + delay4 #( 1) delay_mem_axi_wready (clk, io_mem_axi_wready , mem_axi_wready ); + delay4 #(32) delay_mem_axi_wdata (clk, mem_axi_wdata , io_mem_axi_wdata ); + delay4 #( 4) delay_mem_axi_wstrb (clk, mem_axi_wstrb , io_mem_axi_wstrb ); + delay4 #( 1) delay_mem_axi_bvalid (clk, io_mem_axi_bvalid , mem_axi_bvalid ); + delay4 #( 1) delay_mem_axi_bready (clk, mem_axi_bready , io_mem_axi_bready ); + delay4 #( 1) delay_mem_axi_arvalid (clk, mem_axi_arvalid, io_mem_axi_arvalid); + delay4 #( 1) delay_mem_axi_arready (clk, io_mem_axi_arready, mem_axi_arready); + delay4 #(32) delay_mem_axi_araddr (clk, mem_axi_araddr , io_mem_axi_araddr ); + delay4 #( 3) delay_mem_axi_arprot (clk, mem_axi_arprot , io_mem_axi_arprot ); + delay4 #( 1) delay_mem_axi_rvalid (clk, io_mem_axi_rvalid , mem_axi_rvalid ); + delay4 #( 1) delay_mem_axi_rready (clk, mem_axi_rready , io_mem_axi_rready ); + delay4 #(32) delay_mem_axi_rdata (clk, io_mem_axi_rdata , mem_axi_rdata ); + delay4 #(32) delay_irq (clk, io_irq , irq ); + delay4 #(32) delay_eoi (clk, eoi , io_eoi ); + + picorv32_axi #( + .TWO_CYCLE_ALU(1) + ) cpu ( + .clk (clk ), + .resetn (resetn ), + .trap (trap ), + .mem_axi_awvalid(mem_axi_awvalid), + .mem_axi_awready(mem_axi_awready), + .mem_axi_awaddr (mem_axi_awaddr ), + .mem_axi_awprot (mem_axi_awprot ), + .mem_axi_wvalid (mem_axi_wvalid ), + .mem_axi_wready (mem_axi_wready ), + .mem_axi_wdata (mem_axi_wdata ), + .mem_axi_wstrb (mem_axi_wstrb ), + .mem_axi_bvalid (mem_axi_bvalid ), + .mem_axi_bready (mem_axi_bready ), + .mem_axi_arvalid(mem_axi_arvalid), + .mem_axi_arready(mem_axi_arready), + .mem_axi_araddr (mem_axi_araddr ), + .mem_axi_arprot (mem_axi_arprot ), + .mem_axi_rvalid (mem_axi_rvalid ), + .mem_axi_rready (mem_axi_rready ), + .mem_axi_rdata (mem_axi_rdata ), + .irq (irq ), + .eoi (eoi ) + ); +endmodule + +module delay4 #( + parameter WIDTH = 1 +) ( + input clk, + input [WIDTH-1:0] in, + output reg [WIDTH-1:0] out +); + reg [WIDTH-1:0] q1, q2, q3; + always @(posedge clk) begin + q1 <= in; + q2 <= q1; + q3 <= q2; + out <= q3; + end +endmodule + From c96ed77c4db17ce1347553b92151a7ae85b91c01 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Mon, 29 Aug 2016 21:37:29 -0700 Subject: [PATCH 02/12] Make sim_system work --- scripts/quartus/.gitignore | 9 +-------- scripts/quartus/Makefile | 21 +++++++++------------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/scripts/quartus/.gitignore b/scripts/quartus/.gitignore index 2374269..d37ca0a 100644 --- a/scripts/quartus/.gitignore +++ b/scripts/quartus/.gitignore @@ -1,4 +1,3 @@ -.Xil/ firmware.bin firmware.elf firmware.hex @@ -9,10 +8,4 @@ synth_*.bit synth_system.v table.txt tab_*/ -webtalk.jou -webtalk.log -webtalk_*.jou -webtalk_*.log -xelab.* -xsim.* -xvlog.* +system_tb diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index 4e109d2..7af582f 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -1,10 +1,9 @@ -VIVADO_BASE = /opt/Xilinx/Vivado/2016.1 -VIVADO = $(VIVADO_BASE)/bin/vivado -XVLOG = $(VIVADO_BASE)/bin/xvlog -XELAB = $(VIVADO_BASE)/bin/xelab -GLBL = $(VIVADO_BASE)/data/verilog/src/glbl.v -TOOLCHAIN_PREFIX = riscv64-unknown-elf- +QUARTUS_ROOTDIR = /opt/altera_lite/16.0 +QUARTUS_BIN = $(QUARTUS_ROOTDIR)/quartus/bin + +VLOG = iverilog +TOOLCHAIN_PREFIX = /opt/riscv32i/bin/riscv32-unknown-elf- export VIVADO @@ -32,10 +31,9 @@ synth_%: synth_system: firmware.hex -sim_system: - $(XVLOG) system_tb.v synth_system.v - $(XVLOG) $(GLBL) - $(XELAB) -L unifast_ver -L unisims_ver -R system_tb glbl +sim_system: firmware.hex system_tb.v system.v ../../picorv32.v + $(VLOG) -o system_tb system_tb.v system.v ../../picorv32.v + ./system_tb firmware.hex: firmware.S firmware.c firmware.lds $(TOOLCHAIN_PREFIX)gcc -Os -m32 -ffreestanding -nostdlib -o firmware.elf firmware.S firmware.c \ @@ -59,7 +57,6 @@ table.txt: bash table.sh > table.txt clean: - rm -rf .Xil/ firmware.bin firmware.elf firmware.hex firmware.map synth_*.log + rm -rf firmware.bin firmware.elf firmware.hex firmware.map synth_*.log rm -rf synth_*.mmi synth_*.bit synth_system.v table.txt tab_*/ webtalk.jou - rm -rf webtalk.log webtalk_*.jou webtalk_*.log xelab.* xsim[._]* xvlog.* From 71a46afa791a642bd8de012f1c0b236d6066ab05 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Mon, 29 Aug 2016 22:14:39 -0700 Subject: [PATCH 03/12] Checkpoint: map, fit --- scripts/quartus/Makefile | 6 +---- scripts/quartus/tabtest.sh | 50 ++++++++++++++------------------------ 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index 7af582f..ab9357a 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -47,11 +47,7 @@ tab_%/results.txt: area: synth_area_small synth_area_regular synth_area_large -grep -B4 -A10 'Slice LUTs' synth_area_small.log synth_area_regular.log synth_area_large.log -table.txt: tab_small_xc7a_1/results.txt tab_small_xc7a_2/results.txt tab_small_xc7a_3/results.txt -table.txt: tab_small_xc7k_1/results.txt tab_small_xc7k_2/results.txt tab_small_xc7k_3/results.txt -table.txt: tab_small_xc7v_1/results.txt tab_small_xc7v_2/results.txt tab_small_xc7v_3/results.txt -table.txt: tab_small_xcku_1/results.txt tab_small_xcku_2/results.txt tab_small_xcku_3/results.txt -table.txt: tab_small_xcvu_1/results.txt tab_small_xcvu_2/results.txt tab_small_xcvu_3/results.txt +table.txt: tab_small_ep4ce_c7/results.txt table.txt: bash table.sh > table.txt diff --git a/scripts/quartus/tabtest.sh b/scripts/quartus/tabtest.sh index fa43fc3..2695368 100644 --- a/scripts/quartus/tabtest.sh +++ b/scripts/quartus/tabtest.sh @@ -18,46 +18,32 @@ synth_case() { fi case "${dev}" in - xc7a) xl_device="xc7a15t-fgg484-${grade}" ;; - xc7k) xl_device="xc7k70t-fbg676-${grade}" ;; - xc7v) xl_device="xc7v585t-ffg1761-${grade}" ;; - xcku) xl_device="xcku035-fbva676-${grade}" ;; - xcvu) xl_device="xcvu065-ffvc1517-${grade}" ;; + ep4ce) al_device="ep4ce30f23${grade}" ;; esac - case "${dev}-${grade}" in - xcku-1) xl_device="${xl_device}-c" ;; - xcvu-1) xl_device="${xl_device}-i" ;; - xcku-?|xcvu-?) xl_device="${xl_device}-e" ;; - esac - - cat > test_${1}.tcl <<- EOT - read_verilog ../tabtest.v - read_verilog ../../../picorv32.v - read_xdc test_${1}.xdc - synth_design -flatten_hierarchy full -part ${xl_device} -top top - opt_design -sweep -remap -propconst - opt_design -directive Explore - place_design -directive Explore - phys_opt_design -retime -rewire -critical_pin_opt -placement_opt -critical_cell_opt - route_design -directive Explore - place_design -post_place_opt - phys_opt_design -retime - route_design -directive NoTimingRelaxation - report_utilization - report_timing + cat > test_${1}.qsf <<- EOT +set_global_assignment -name DEVICE ${al_device} +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY top +set_global_assignment -name VERILOG_FILE ../tabtest.v +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE test_${1}.sdc EOT - cat > test_${1}.xdc <<- EOT + cat > test_${1}.sdc <<- EOT create_clock -period ${speed%?}.${speed#?} [get_ports clk] EOT echo "Running tab_${ip}_${dev}_${grade}/test_${1}.." - if ! $VIVADO -nojournal -log test_${1}.log -mode batch -source test_${1}.tcl > /dev/null 2>&1; then - cat test_${1}.log - exit 1 - fi - mv test_${1}.log test_${1}.txt + + quartus_map test_${1} + quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1} + +# if ! $VIVADO -nojournal -log test_${1}.log -mode batch -source test_${1}.tcl > /dev/null 2>&1; then +# cat test_${1}.log +# exit 1 +# fi +# mv test_${1}.log test_${1}.txt } countdown=2 From 248560c18d32bb11d73a9ecfb448581af6930c0c Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Mon, 29 Aug 2016 23:22:53 -0700 Subject: [PATCH 04/12] table.txt generation works --- scripts/quartus/Makefile | 2 ++ scripts/quartus/table.sh | 8 +++---- scripts/quartus/tabtest.sh | 44 +++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index ab9357a..31f26cd 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -48,6 +48,8 @@ area: synth_area_small synth_area_regular synth_area_large -grep -B4 -A10 'Slice LUTs' synth_area_small.log synth_area_regular.log synth_area_large.log table.txt: tab_small_ep4ce_c7/results.txt +table.txt: tab_small_ep4cgx_c7/results.txt +table.txt: tab_small_5cgx_c7/results.txt table.txt: bash table.sh > table.txt diff --git a/scripts/quartus/table.sh b/scripts/quartus/table.sh index f81f586..f5e6efe 100644 --- a/scripts/quartus/table.sh +++ b/scripts/quartus/table.sh @@ -8,11 +8,9 @@ for x in $( grep -H . tab_*/results.txt ) do read _ size device grade _ speed < <( echo "$x" | tr _/: ' ' ) case "$device" in - xc7a) d="Xilinx Artix-7T" ;; - xc7k) d="Xilinx Kintex-7T" ;; - xc7v) d="Xilinx Virtex-7T" ;; - xcku) d="Xilinx Kintex UltraScale" ;; - xcvu) d="Xilinx Virtex UltraScale" ;; + ep4ce) d="Altera Cyclone IV E" ;; + ep4cgx) d="Altera Cyclone IV GX" ;; + 5cgx) d="Altera Cyclone V GX" ;; esac speedtxt=$( printf '%s.%s ns (%d MHz)' ${speed%?} ${speed#?} $((10000 / speed)) ) printf '| %-25s | %-10s | %20s |\n' "$d" "-$grade" "$speedtxt" diff --git a/scripts/quartus/tabtest.sh b/scripts/quartus/tabtest.sh index 2695368..ad8cf10 100644 --- a/scripts/quartus/tabtest.sh +++ b/scripts/quartus/tabtest.sh @@ -7,9 +7,9 @@ read _ ip dev grade _ < <( echo $* | tr '_/' ' '; ) mkdir -p tab_${ip}_${dev}_${grade} cd tab_${ip}_${dev}_${grade} +max_speed=99 +min_speed=01 best_speed=99 -speed=30 -step=16 synth_case() { if [ -f test_${1}.txt ]; then @@ -18,7 +18,9 @@ synth_case() { fi case "${dev}" in - ep4ce) al_device="ep4ce30f23${grade}" ;; + ep4ce) al_device="ep4ce30f23${grade}" ;; + ep4cgx) al_device="ep4cgx50df27${grade}" ;; + 5cgx) al_device="5cgxbc9c6f23${grade}" ;; esac cat > test_${1}.qsf <<- EOT @@ -36,39 +38,37 @@ set_global_assignment -name SDC_FILE test_${1}.sdc echo "Running tab_${ip}_${dev}_${grade}/test_${1}.." - quartus_map test_${1} - quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1} + if ! quartus_map test_${1}; then + exit 1 + fi + if ! quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1}; then + exit 1 + fi + if ! quartus_sta test_${1} -c test_${1}; then + exit 1 + fi -# if ! $VIVADO -nojournal -log test_${1}.log -mode batch -source test_${1}.tcl > /dev/null 2>&1; then -# cat test_${1}.log -# exit 1 -# fi -# mv test_${1}.log test_${1}.txt + cp output_files/test_${1}.sta.summary test_${1}.txt } -countdown=2 +countdown=6 while [ $countdown -gt 0 ]; do + speed=$(((max_speed+min_speed)/2)) synth_case $speed - if grep -q '^Slack.*(VIOLATED)' test_${speed}.txt; then + if grep -q '^Slack : -' test_${speed}.txt; then echo " tab_${ip}_${dev}_${grade}/test_${speed} VIOLATED" - [ $speed -eq 38 ] || step=$((step / 2)) - speed=$((speed + step)) - elif grep -q '^Slack.*(MET)' test_${speed}.txt; then + min_speed=$((speed)) + elif grep -q '^Slack : [^-]' test_${speed}.txt; then echo " tab_${ip}_${dev}_${grade}/test_${speed} MET" [ $speed -lt $best_speed ] && best_speed=$speed - step=$((step / 2)) - speed=$((speed - step)) + max_speed=$((speed)) else echo "ERROR: No slack line found in $PWD/test_${speed}.txt!" exit 1 fi - if [ $step -eq 0 ]; then - countdown=$((countdown - 1)) - speed=$((best_speed - 2)) - step=1 - fi + countdown=$((countdown-1)) done echo "-----------------------" From 413a65e39a77d11ed7a54ccf46fd8e6e9f3baf62 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 08:08:10 -0700 Subject: [PATCH 05/12] Increase countdown by 1 --- scripts/quartus/tabtest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/quartus/tabtest.sh b/scripts/quartus/tabtest.sh index ad8cf10..2fee520 100644 --- a/scripts/quartus/tabtest.sh +++ b/scripts/quartus/tabtest.sh @@ -51,7 +51,7 @@ set_global_assignment -name SDC_FILE test_${1}.sdc cp output_files/test_${1}.sta.summary test_${1}.txt } -countdown=6 +countdown=7 while [ $countdown -gt 0 ]; do speed=$(((max_speed+min_speed)/2)) synth_case $speed From 29e90e4dff906f4cb5dedad78278cd07dd950060 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 22:23:50 -0700 Subject: [PATCH 06/12] Add QUARTUS_BIN prefix --- scripts/quartus/tabtest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/quartus/tabtest.sh b/scripts/quartus/tabtest.sh index 2fee520..d731f76 100644 --- a/scripts/quartus/tabtest.sh +++ b/scripts/quartus/tabtest.sh @@ -38,13 +38,13 @@ set_global_assignment -name SDC_FILE test_${1}.sdc echo "Running tab_${ip}_${dev}_${grade}/test_${1}.." - if ! quartus_map test_${1}; then + if ! $QUARTUS_BIN/quartus_map test_${1}; then exit 1 fi - if ! quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1}; then + if ! $QUARTUS_BIN/quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1}; then exit 1 fi - if ! quartus_sta test_${1} -c test_${1}; then + if ! $QUARTUS_BIN/quartus_sta test_${1} -c test_${1}; then exit 1 fi From 36152a568873864e9c980b9c62d73969f3900238 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 22:24:48 -0700 Subject: [PATCH 07/12] Make synth_area_small work --- scripts/quartus/Makefile | 19 ++++++++++--------- .../{synth_area.xdc => synth_area.sdc} | 0 scripts/quartus/synth_area_small.qsf | 6 ++++++ scripts/quartus/synth_area_small.tcl | 10 ---------- scripts/quartus/synth_speed.xdc | 1 - 5 files changed, 16 insertions(+), 20 deletions(-) rename scripts/quartus/{synth_area.xdc => synth_area.sdc} (100%) create mode 100644 scripts/quartus/synth_area_small.qsf delete mode 100644 scripts/quartus/synth_area_small.tcl delete mode 100644 scripts/quartus/synth_speed.xdc diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index 31f26cd..49be1ca 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -1,12 +1,10 @@ -QUARTUS_ROOTDIR = /opt/altera_lite/16.0 -QUARTUS_BIN = $(QUARTUS_ROOTDIR)/quartus/bin +export QUARTUS_ROOTDIR = /opt/altera_lite/16.0 +export QUARTUS_BIN = $(QUARTUS_ROOTDIR)/quartus/bin VLOG = iverilog TOOLCHAIN_PREFIX = /opt/riscv32i/bin/riscv32-unknown-elf- -export VIVADO - help: @echo "" @echo "Simple synthesis tests:" @@ -24,10 +22,13 @@ help: synth_%: rm -f $@.log - $(VIVADO) -nojournal -log $@.log -mode batch -source $@.tcl - rm -rf .Xil fsm_encoding.os synth_*.backup.log usage_statistics_webtalk.* - -grep -B4 -A10 'Slice LUTs' $@.log - -grep -B1 -A9 ^Slack $@.log && echo + mkdir -p $@_build + cp $@.qsf $@_build + cd $@_build && $(QUARTUS_BIN)/quartus_map $@.qsf + cd $@_build && $(QUARTUS_BIN)/quartus_fit --read_settings_files=off -write_settings_files=off $@ -c $@ + cd $@_build && $(QUARTUS_BIN)/quartus_sta $@ -c $@ + -cd $@_build && grep -A3 "Total logic elements" output_files/$@.fit.summary + -cd $@_build && grep -B1 "Slack" output_files/$@.sta.summary synth_system: firmware.hex @@ -56,5 +57,5 @@ table.txt: clean: rm -rf firmware.bin firmware.elf firmware.hex firmware.map synth_*.log - rm -rf synth_*.mmi synth_*.bit synth_system.v table.txt tab_*/ webtalk.jou + rm -rf synth_*.mmi synth_*.bit synth_system.v table.txt tab_*/ diff --git a/scripts/quartus/synth_area.xdc b/scripts/quartus/synth_area.sdc similarity index 100% rename from scripts/quartus/synth_area.xdc rename to scripts/quartus/synth_area.sdc diff --git a/scripts/quartus/synth_area_small.qsf b/scripts/quartus/synth_area_small.qsf new file mode 100644 index 0000000..7f151a8 --- /dev/null +++ b/scripts/quartus/synth_area_small.qsf @@ -0,0 +1,6 @@ +set_global_assignment -name DEVICE ep4ce30f23c7 +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY top_small +set_global_assignment -name VERILOG_FILE ../synth_area_top.v +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE ../synth_area.sdc diff --git a/scripts/quartus/synth_area_small.tcl b/scripts/quartus/synth_area_small.tcl deleted file mode 100644 index 11d2104..0000000 --- a/scripts/quartus/synth_area_small.tcl +++ /dev/null @@ -1,10 +0,0 @@ -read_verilog ../../picorv32.v -read_verilog synth_area_top.v -read_xdc synth_area.xdc - -synth_design -part xc7k70t-fbg676 -top top_small -opt_design -sweep -propconst -resynth_seq_area -opt_design -directive ExploreSequentialArea - -report_utilization -report_timing diff --git a/scripts/quartus/synth_speed.xdc b/scripts/quartus/synth_speed.xdc deleted file mode 100644 index 877ec8d..0000000 --- a/scripts/quartus/synth_speed.xdc +++ /dev/null @@ -1 +0,0 @@ -create_clock -period 2.50 [get_ports clk] From 209456a6c88c9460625c7fa7903f9561ba2005ad Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 22:36:06 -0700 Subject: [PATCH 08/12] synth_area_large and synth_area_regular --- scripts/quartus/Makefile | 3 ++- scripts/quartus/synth_area_large.qsf | 6 ++++++ scripts/quartus/synth_area_large.tcl | 10 ---------- scripts/quartus/synth_area_regular.qsf | 6 ++++++ scripts/quartus/synth_area_regular.tcl | 10 ---------- scripts/quartus/synth_area_small.qsf | 2 +- 6 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 scripts/quartus/synth_area_large.qsf delete mode 100644 scripts/quartus/synth_area_large.tcl create mode 100644 scripts/quartus/synth_area_regular.qsf delete mode 100644 scripts/quartus/synth_area_regular.tcl diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index 49be1ca..318f7b3 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -57,5 +57,6 @@ table.txt: clean: rm -rf firmware.bin firmware.elf firmware.hex firmware.map synth_*.log - rm -rf synth_*.mmi synth_*.bit synth_system.v table.txt tab_*/ + rm -rf synth_system.v table.txt tab_*/ + rm -rf synth_area_*_build diff --git a/scripts/quartus/synth_area_large.qsf b/scripts/quartus/synth_area_large.qsf new file mode 100644 index 0000000..c09700b --- /dev/null +++ b/scripts/quartus/synth_area_large.qsf @@ -0,0 +1,6 @@ +set_global_assignment -name DEVICE ep4ce40f29c7 +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY top_large +set_global_assignment -name VERILOG_FILE ../synth_area_top.v +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE ../synth_area.sdc diff --git a/scripts/quartus/synth_area_large.tcl b/scripts/quartus/synth_area_large.tcl deleted file mode 100644 index af611b5..0000000 --- a/scripts/quartus/synth_area_large.tcl +++ /dev/null @@ -1,10 +0,0 @@ -read_verilog ../../picorv32.v -read_verilog synth_area_top.v -read_xdc synth_area.xdc - -synth_design -part xc7k70t-fbg676 -top top_large -opt_design -sweep -propconst -resynth_seq_area -opt_design -directive ExploreSequentialArea - -report_utilization -report_timing diff --git a/scripts/quartus/synth_area_regular.qsf b/scripts/quartus/synth_area_regular.qsf new file mode 100644 index 0000000..8507413 --- /dev/null +++ b/scripts/quartus/synth_area_regular.qsf @@ -0,0 +1,6 @@ +set_global_assignment -name DEVICE ep4ce40f29c7 +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY top_regular +set_global_assignment -name VERILOG_FILE ../synth_area_top.v +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE ../synth_area.sdc diff --git a/scripts/quartus/synth_area_regular.tcl b/scripts/quartus/synth_area_regular.tcl deleted file mode 100644 index 2bf6b4c..0000000 --- a/scripts/quartus/synth_area_regular.tcl +++ /dev/null @@ -1,10 +0,0 @@ -read_verilog ../../picorv32.v -read_verilog synth_area_top.v -read_xdc synth_area.xdc - -synth_design -part xc7k70t-fbg676 -top top_regular -opt_design -sweep -propconst -resynth_seq_area -opt_design -directive ExploreSequentialArea - -report_utilization -report_timing diff --git a/scripts/quartus/synth_area_small.qsf b/scripts/quartus/synth_area_small.qsf index 7f151a8..048ff96 100644 --- a/scripts/quartus/synth_area_small.qsf +++ b/scripts/quartus/synth_area_small.qsf @@ -1,4 +1,4 @@ -set_global_assignment -name DEVICE ep4ce30f23c7 +set_global_assignment -name DEVICE ep4ce40f29c7 set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files set_global_assignment -name TOP_LEVEL_ENTITY top_small set_global_assignment -name VERILOG_FILE ../synth_area_top.v From e7f5d640cab596410cb21bab0ac7bc49c3ad87b7 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 22:54:14 -0700 Subject: [PATCH 09/12] synth_system --- scripts/quartus/Makefile | 2 +- scripts/quartus/synth_system.qsf | 6 ++++++ scripts/quartus/synth_system.sdc | 1 + scripts/quartus/synth_system.xdc | 34 -------------------------------- scripts/quartus/system.v | 2 +- 5 files changed, 9 insertions(+), 36 deletions(-) create mode 100644 scripts/quartus/synth_system.qsf create mode 100644 scripts/quartus/synth_system.sdc delete mode 100644 scripts/quartus/synth_system.xdc diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index 318f7b3..f626fc5 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -46,7 +46,7 @@ tab_%/results.txt: bash tabtest.sh $@ area: synth_area_small synth_area_regular synth_area_large - -grep -B4 -A10 'Slice LUTs' synth_area_small.log synth_area_regular.log synth_area_large.log + -grep -A3 "Total logic elements" synth_area_*_build/output_files/synth_area_*.fit.summary table.txt: tab_small_ep4ce_c7/results.txt table.txt: tab_small_ep4cgx_c7/results.txt diff --git a/scripts/quartus/synth_system.qsf b/scripts/quartus/synth_system.qsf new file mode 100644 index 0000000..1a84293 --- /dev/null +++ b/scripts/quartus/synth_system.qsf @@ -0,0 +1,6 @@ +set_global_assignment -name DEVICE ep4ce40f29c7 +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY system +set_global_assignment -name VERILOG_FILE ../system.v +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE ../synth_system.sdc diff --git a/scripts/quartus/synth_system.sdc b/scripts/quartus/synth_system.sdc new file mode 100644 index 0000000..90ee3a2 --- /dev/null +++ b/scripts/quartus/synth_system.sdc @@ -0,0 +1 @@ +create_clock -period 10.00 [get_ports clk] diff --git a/scripts/quartus/synth_system.xdc b/scripts/quartus/synth_system.xdc deleted file mode 100644 index 5748466..0000000 --- a/scripts/quartus/synth_system.xdc +++ /dev/null @@ -1,34 +0,0 @@ - -# XDC File for Basys3 Board -########################### - -set_property PACKAGE_PIN W5 [get_ports clk] -set_property IOSTANDARD LVCMOS33 [get_ports clk] -create_clock -period 10.00 [get_ports clk] - -# Pmod Header JA (JA0..JA7) -set_property PACKAGE_PIN J1 [get_ports {out_byte[0]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[0]}] -set_property PACKAGE_PIN L2 [get_ports {out_byte[1]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[1]}] -set_property PACKAGE_PIN J2 [get_ports {out_byte[2]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[2]}] -set_property PACKAGE_PIN G2 [get_ports {out_byte[3]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[3]}] -set_property PACKAGE_PIN H1 [get_ports {out_byte[4]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[4]}] -set_property PACKAGE_PIN K2 [get_ports {out_byte[5]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[5]}] -set_property PACKAGE_PIN H2 [get_ports {out_byte[6]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[6]}] -set_property PACKAGE_PIN G3 [get_ports {out_byte[7]}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte[7]}] - -# Pmod Header JB (JB0..JB2) -set_property PACKAGE_PIN A14 [get_ports {resetn}] -set_property IOSTANDARD LVCMOS33 [get_ports {resetn}] -set_property PACKAGE_PIN A16 [get_ports {trap}] -set_property IOSTANDARD LVCMOS33 [get_ports {trap}] -set_property PACKAGE_PIN B15 [get_ports {out_byte_en}] -set_property IOSTANDARD LVCMOS33 [get_ports {out_byte_en}] - diff --git a/scripts/quartus/system.v b/scripts/quartus/system.v index c4882a1..19a4b8d 100644 --- a/scripts/quartus/system.v +++ b/scripts/quartus/system.v @@ -8,7 +8,7 @@ module system ( output reg out_byte_en ); // set this to 0 for better timing but less performance/MHz - parameter FAST_MEMORY = 1; + parameter FAST_MEMORY = 0; // 4096 32bit words = 16kB memory parameter MEM_SIZE = 4096; From 91deccd3a18ad6edcb793424f7c56f2f724d4b3f Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 22:56:31 -0700 Subject: [PATCH 10/12] Don't delete non-existing files --- scripts/quartus/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/quartus/Makefile b/scripts/quartus/Makefile index f626fc5..8b994e0 100644 --- a/scripts/quartus/Makefile +++ b/scripts/quartus/Makefile @@ -57,6 +57,6 @@ table.txt: clean: rm -rf firmware.bin firmware.elf firmware.hex firmware.map synth_*.log - rm -rf synth_system.v table.txt tab_*/ - rm -rf synth_area_*_build + rm -rf table.txt tab_*/ + rm -rf synth_*_build From 41918ee26533daaf2b22dbbf79656cfad914b3f3 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Tue, 30 Aug 2016 23:02:31 -0700 Subject: [PATCH 11/12] synth_speed --- scripts/quartus/synth_speed.qsf | 5 +++++ scripts/quartus/synth_speed.sdc | 1 + scripts/quartus/synth_speed.tcl | 13 ------------- 3 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 scripts/quartus/synth_speed.qsf create mode 100644 scripts/quartus/synth_speed.sdc delete mode 100644 scripts/quartus/synth_speed.tcl diff --git a/scripts/quartus/synth_speed.qsf b/scripts/quartus/synth_speed.qsf new file mode 100644 index 0000000..64490d4 --- /dev/null +++ b/scripts/quartus/synth_speed.qsf @@ -0,0 +1,5 @@ +set_global_assignment -name DEVICE ep4ce40f29c7 +set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files +set_global_assignment -name TOP_LEVEL_ENTITY picorv32_axi +set_global_assignment -name VERILOG_FILE ../../../picorv32.v +set_global_assignment -name SDC_FILE ../synth_speed.sdc diff --git a/scripts/quartus/synth_speed.sdc b/scripts/quartus/synth_speed.sdc new file mode 100644 index 0000000..fef5704 --- /dev/null +++ b/scripts/quartus/synth_speed.sdc @@ -0,0 +1 @@ +create_clock -period 2.5 [get_ports clk] diff --git a/scripts/quartus/synth_speed.tcl b/scripts/quartus/synth_speed.tcl deleted file mode 100644 index f3874e4..0000000 --- a/scripts/quartus/synth_speed.tcl +++ /dev/null @@ -1,13 +0,0 @@ - -read_verilog ../../picorv32.v -read_xdc synth_speed.xdc - -synth_design -part xc7k70t-fbg676 -top picorv32_axi -opt_design -place_design -phys_opt_design -route_design - -report_utilization -report_timing - From 35b0a592e20f04b1f8954af06d019c351cbb3d20 Mon Sep 17 00:00:00 2001 From: Tom Verbeure Date: Wed, 31 Aug 2016 07:36:32 -0700 Subject: [PATCH 12/12] Delete unusused file --- scripts/quartus/synth_area.tcl | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 scripts/quartus/synth_area.tcl diff --git a/scripts/quartus/synth_area.tcl b/scripts/quartus/synth_area.tcl deleted file mode 100644 index c222a00..0000000 --- a/scripts/quartus/synth_area.tcl +++ /dev/null @@ -1,8 +0,0 @@ -read_verilog ../../picorv32.v -read_xdc synth_area.xdc - -synth_design -part xc7k70t-fbg676 -top picorv32_axi -opt_design -resynth_seq_area - -report_utilization -report_timing