自作RISC-Vプロセッサの設計もおおよそ完了してきたので、FPGA向けに論理合成する環境を構築している。
GUIを立ち上げてボタンをポチポチ押すのはあまり好きではないので、VivadoをCUIで立ち上げて動作させる環境を構築した。
VivadoのtclはDesign Compilerなどの一般の論理合成ツールのtclと非常に似ているが、フローは全く異なるので注意が必要だ。 正しく構築するためには、まずはGUIのVivadoの操作が記録されたVivadoのLogを採取し、それをtclに落としておくのが良いと思う。
Vivadoでの論理合成用tcl
以下のような論理合成用tclを作成した。先頭のPROJ_NAME
とTOP_NAME
、 RTL_ROOT_DIR
などは好きに変更して欲しい。
set PROJ_NAME project_synth set PROJ_DIR . set RTL_ROOT_DIR ../../rtl set TOP_NAME project set dump 1 set checkpoint 1 create_project -in_memory -part xc7z020clg484-1 set_property parent.project_path ${PROJ_DIR}/${PROJ_NAME}.xpr [current_project] set_property default_lib xil_defaultlib [current_project] set_property target_language Verilog [current_project] set_property board_part em.avnet.com:zed:part0:1.3 [current_project] set_property vhdl_version vhdl_2k [current_fileset] source filelist.tcl read_xdc ${TOP_NAME}.xdc synth_design -top ${TOP_NAME} -part xc7z020clg484-1 -verilog_define PP_BUSWIDTH_64=1 -include_dirs {../../../common/include} -fanout_limit 10000 -flatten_hierarchy rebuilt write_checkpoint -force ${TOP_NAME}.dcp report_utilization -file ${TOP_NAME}_utilization_synth.rpt -pb ${TOP_NAME}_utilization_synth.pb if {$checkpoint} {write_checkpoint -force ${TOP_NAME}.synth.dcp} if {$checkpoint} {write_verilog -force ${TOP_NAME}.synth.v} if {$dump} {report_io -file ${TOP_NAME}.io.rpt} if {$dump} {report_timing_summary -file ${TOP_NAME}.timing_summary.rpt} if {$dump} {report_timing -delay_type min_max -sort_by group -max_paths 10 -path_type full -input_pins -file ${TOP_NAME}.timing_detail.rpt} if {$dump} {report_route_status -show_all -file ${TOP_NAME}.route.rpt} if {$dump} {report_utilization -file ${TOP_NAME}.util.rpt}
Vivado起動用CMakeLists.txt
別にcmakeで無くても良いのだが、cmakeが好きなので。filelist.fは自動生成するか、自分で作成する必要があるのだが、ここでは非公開。
project (mag_top) set(CMAKE_VERBOSE_MAKEFILE true) add_custom_target (mag_top ALL vivado -m64 -mode batch -source vivado_synth.tcl DEPENDS filelist.f)
自作RISC-Vプロセッサを論理合成した時のタイミング結果
自作RISC-Vプロセッサを論理合成した場合、50MHzのクロックを当てると以下のようなtiming_summaryがレポートされた。
------------------------------------------------------------------------------------------------ | Design Timing Summary | --------------------- ------------------------------------------------------------------------------------------------ WNS(ns) TNS(ns) TNS Failing Endpoints TNS Total Endpoints WHS(ns) THS(ns) THS Failing Endpoints THS Total Endpoints WPWS(ns) TPWS(ns) TPWS Failing Endpoints TPWS Total Endpoints ------- ------- --------------------- ------------------- ------- ------- --------------------- ------------------- -------- -------- ---------------------- -------------------- 6.648 0.000 0 100940 0.245 0.000 0 100940 8.750 0.000 0 36712
Metした。調子になって100MHzにクロック周波数を上げてみる。
create_clock -period 10.0 [get_ports CPU_CLK] set_input_jitter [get_clocks -of_objects [get_ports CPU_CLK]] 0.05
結果はViolatedとなってしまった。
------------------------------------------------------------------------------------------------ | Design Timing Summary | --------------------- ------------------------------------------------------------------------------------------------ WNS(ns) TNS(ns) TNS Failing Endpoints TNS Total Endpoints WHS(ns) THS(ns) THS Failing Endpoints THS Total Endpoints WPWS(ns) TPWS(ns) TPWS Failing Endpoints TPWS Total Endpoints ------- ------- --------------------- ------------------- ------- ------- --------------------- ------------------- -------- -------- ---------------------- -------------------- -3.352 -878.515 508 100940 0.245 0.000 0 100940 3.750 0.000 0 36712
一番辛いのは、ALUとALU用のReservation Stationとの間にあるReadyとValidの信号か。。。
Location Delay type Incr(ns) Path(ns) Netlist Resource(s) ------------------------------------------------------------------- ------------------- (clock CPU_CLK rise edge) 0.000 0.000 r 0.000 0.000 r CPU_CLK (IN) net (fo=0) 0.000 0.000 CPU_CLK IBUF (Prop_ibuf_I_O) 0.921 0.921 r CPU_CLK_IBUF_inst/O net (fo=1, unplaced) 0.800 1.721 CPU_CLK_IBUF BUFG (Prop_bufg_I_O) 0.101 1.822 r CPU_CLK_IBUF_BUFG_inst/O net (fo=36711, unplaced) 0.800 2.622 u_mag_exu_1/ex_latch_0/CPU_CLK_IBUF_BUFG FDRE r u_mag_exu_1/ex_latch_0/alu_inst_vld_r_reg/C ------------------------------------------------------------------- ------------------- FDRE (Prop_fdre_C_Q) 0.478 3.100 f u_mag_exu_1/ex_latch_0/alu_inst_vld_r_reg/Q net (fo=61, unplaced) 0.828 3.928 u_mag_exu_1/int_mult_unit_0/alu_inst_vld_r LUT4 (Prop_lut4_I1_O) 0.295 4.223 r u_mag_exu_1/int_mult_unit_0/inst_en_i_4__0/O net (fo=4, unplaced) 0.473 4.696 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_3/RS_EX_INST_READY_1 LUT5 (Prop_lut5_I0_O) 0.116 4.812 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_3/inst_en_i_3__1/O net (fo=2, unplaced) 0.460 5.272 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/p_10_in LUT6 (Prop_lut6_I5_O) 0.124 5.396 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/inst_en_i_2/O net (fo=119, unplaced) 0.553 5.949 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/rs_entry_bottom_idx_vld[0] LUT4 (Prop_lut4_I3_O) 0.124 6.073 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[31]_i_14/O net (fo=3, unplaced) 0.467 6.540 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[31]_i_14_n_5 LUT5 (Prop_lut5_I4_O) 0.124 6.664 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[31]_i_6/O net (fo=156, unplaced) 1.013 7.677 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[31]_i_6_n_5 LUT4 (Prop_lut4_I1_O) 0.124 7.801 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[3]_i_7/O net (fo=1, unplaced) 0.000 7.801 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[3]_i_7_n_5 CARRY4 (Prop_carry4_S[1]_CO[3]) 0.533 8.334 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[3]_i_2/CO[3] net (fo=1, unplaced) 0.009 8.343 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[3]_i_2_n_5 CARRY4 (Prop_carry4_CI_CO[3]) 0.117 8.460 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[7]_i_2/CO[3] net (fo=1, unplaced) 0.000 8.460 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[7]_i_2_n_5 CARRY4 (Prop_carry4_CI_CO[3]) 0.117 8.577 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[11]_i_2/CO[3] net (fo=1, unplaced) 0.000 8.577 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[11]_i_2_n_5 CARRY4 (Prop_carry4_CI_O[3]) 0.331 8.908 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf_reg[15]_i_2/O[3] net (fo=1, unplaced) 0.618 9.526 u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/u_mag_exu_1/unsign_op1_data0[15] LUT6 (Prop_lut6_I0_O) 0.307 9.833 r u_mag_rsu/u_rs_ex_unit_1/rs_alu_entry_0/alu_op1_data_buf[15]_i_1/O net (fo=2, unplaced) 0.460 10.293 u_mag_exu_1/int_mult_unit_0/imm_reg[31][15] LUT5 (Prop_lut5_I3_O) 0.124 10.417 r u_mag_exu_1/int_mult_unit_0/p_0_out_i_17/O net (fo=1, unplaced) 0.800 11.217 u_mag_exu_1/int_mult_unit_0/A[15] DSP48E1 (Prop_dsp48e1_A[15]_P[0]) 3.841 15.058 r u_mag_exu_1/int_mult_unit_0/p_0_out/P[0] net (fo=3, unplaced) 0.800 15.858 u_mag_exu_1/int_mult_unit_0/p_0_out__0[0] FDRE r u_mag_exu_1/int_mult_unit_0/part_mult0_buf_reg[0]/D ------------------------------------------------------------------- -------------------