Files
Basys3RiscV/bench/build.tcl
T
brad ArantandClaude Opus 5.5 71fd403294 Add a single-precision FPU (the F extension)
rtl/rv32_fpu.v: IEEE 754 single precision with all five rounding modes,
subnormals, the exception flags and the canonical NaN. Multiply-add
(DSPs, exact product, 77-bit sum) with add, subtract and multiply as its
special cases; divide and square root a bit a clock; one normalise-and-
round back end. 12 clocks for add/mul/fma, 36 for div/sqrt. About 3000
LUTs and 2 DSPs; the system still meets 90 MHz.

rv32_cpu.v: float registers, FLW/FSW, OP-FP and the R4 instructions,
fflags/frm/fcsr, mstatus.FS (Initial at reset), misa F.

tools/f32.py is an exact model (checked against x86 hardware) used by
scripts/fputest.sh (random vectors, every instruction and rounding mode)
and by tools/rv32emu.py, which now runs RV32IMF. cputest.sh adds rv32uf.

BASIC and the games are built for rv32imf/ilp32f (BASIC 36.4 -> 28.7 KB,
SIN about twice as fast); setjmp saves fs0-fs11; sqrtf is FSQRT.S. The
monitor saves and restores f0-f31 and fcsr, shows them (F), sets them
(R F1=...), and its disassembler and assembler know every F instruction
(checked against objdump and GNU as). Docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 20:29:08 -08:00

26 lines
1.2 KiB
Tcl

# Timing build of the core alone: vivado -mode batch -source bench/build.tcl
# MULT/DIV environment variables set the clock (default 9/10 = 90 MHz).
set root [file normalize [file dirname [info script]]/..]
set out $root/build/bench
file mkdir $out
set mult [expr {[info exists ::env(MULT)] ? $::env(MULT) : 9.0}]
set div [expr {[info exists ::env(DIV)] ? $::env(DIV) : 10.0}]
puts "CPU clock: [expr {100.0 * $mult / $div}] MHz"
read_verilog $root/rtl/rv32_cpu.v $root/rtl/rv32_fpu.v $root/bench/cpu_bench.v
read_mem $root/bench/bench.mem
read_xdc $root/bench/bench.xdc
synth_design -top cpu_bench -part xc7a35tcpg236-1 -generic MULT=$mult -generic DIV=$div
opt_design -directive Explore
place_design -directive ExtraTimingOpt
phys_opt_design -directive AggressiveExplore
route_design -directive Explore
phys_opt_design -directive AggressiveExplore
report_utilization -file $out/utilization.rpt
report_utilization -hierarchical -file $out/util_hier.rpt
report_timing_summary -file $out/timing.rpt
report_timing -max_paths 20 -nworst 1 -unique_pins -file $out/paths.rpt
write_bitstream -force $out/cpu_bench.bit
set wns [get_property SLACK [get_timing_paths -max_paths 1 -setup]]
puts "Worst setup slack: $wns ns"