FPGAの非同期リセットと同期リセットの比較は終わって、同期リセットの方がよいということになった。PCI-Xテスト・モジュールも大体完成したので、これを同期リセットに直すことにした。 それで、直したのだが、どうもタイミング制約が満足できない。 まずはADが満足できない。それは、出力バッファのイネーブル制御がIOBのFFに入らなくなってしまったためのようだ。元の(非同期リセットの)ADの宣言や関係している部分を抜き出すと、下のようになる。 ちなみに使っている論理合成ツールはSynplify Pro 8.5, ISEは9.1SP3。
ad : inout std_logic_vector(63 downto 0); -- アドレスとデータ
signal pcix_dout_ena, master_dout_ena : std_logic;
attribute syn_useioff of pcix_dout_ena : signal is true;
process(reset, pcix_clk) begin -- ADのイネーブルをIOBに入れる if reset='1' then pcix_dout_ena <= '0'; elsif pcix_clk'event and pcix_clk='1' then pcix_dout_ena <= target_dout_ena or master_dout_ena; end if; end process; process(pcix_dout, pcix_dout_ena) begin -- PCIX_ADへの出力トライステート・バッファ if pcix_dout_ena='1' then ad <= pcix_dout; else ad <= (others => 'Z'); end if; end process;
signal pcix_dout_ena : std_logic_vector(63 downto 0);
attribute syn_useioff of pcix_dout_ena : signal is true; attribute syn_keep of pcix_dout_ena : signal is true;
process(pcix_clk) begin -- ADのイネーブルをIOBに入れる if pcix_clk'event and pcix_clk='1' then for i in 63 downto 0 loop if reset='1' then pcix_dout_ena(i) <= '0'; else pcix_dout_ena(i) <= target_dout_ena or master_dout_ena; end if; end loop; end if; end process; process(pcix_dout, pcix_dout_ena) begin -- PCIX_ADへの出力トライステート・バッファ for i in 63 downto 0 loop if pcix_dout_ena(i)='1' then ad(i) <= pcix_dout(i); else ad(i) <= 'Z'; end if; end loop; end process;
Timing Analyzerでの解析結果はこれ。
Timing constraint: COMP "pcix_ad(10)" OFFSET = OUT 3.8 ns AFTER COMP "pcix_clk";
2 items analyzed, 1 timing error detected. Minimum allowable offset is 3.946ns. -------------------------------------------------------------------------------- Slack: -0.146ns (requirement - (clock arrival + clock path + data path + uncertainty)) Source: pcix_inst/pcix_dout_ena[0] (FF) Destination: pcix_ad(10) (PAD) Source Clock: clk_dcm rising at 0.645ns Requirement: 3.800ns Data Path Delay: 3.588ns (Levels of Logic = 1) Clock Path Delay: -0.287ns (Levels of Logic = 3) Clock Uncertainty: 0.000ns Timing Improvement Wizard Clock Path: pcix_clk to pcix_inst/pcix_dout_ena[0] Delay type Delay(ns) Logical Resource(s) ---------------------------- ------------------- Tiopi 0.921 pcix_clk dcm_pcix_inst/CLKIN_IBUFG_INST net (fanout=1) 0.431 dcm_pcix_inst/CLKIN_IBUFG Tdcmino -4.145 dcm_pcix_inst/DCM_INST net (fanout=1) 1.185 dcm_pcix_inst/CLK0_BUF Tgi0o 0.057 dcm_pcix_inst/CLK0_BUFG_INST net (fanout=687) 1.264 clk_dcm ---------------------------- --------------------------- Total -0.287ns (-3.167ns logic, 2.880ns route)
Data Path: pcix_inst/pcix_dout_ena[0] to pcix_ad(10) Delay type Delay(ns) Logical Resource(s) ---------------------------- ------------------- Tcko 0.374 pcix_inst/pcix_dout_ena[0] net (fanout=64) 0.629 pcix_inst/pcix_dout_ena_1(0) Tiotp 2.585 pcix_ad_iobuf[10]/OBUFT pcix_ad(10) ---------------------------- --------------------------- Total 3.588ns (2.959ns logic, 0.629ns route) (82.5% logic, 17.5% route)
PCI-Xスプリット完了のバグが解決した。 1つ目の”ホストPCがNMIを受信してしまい、You probably have a hardware problem with your RAM chipsと表示が出る”というのは、パリティが間違っていて、パリティエラーが起こると、この表示が出るようだ。パリティのHDLコードを見直したところ、バグがあったので修正したら、このメッセージは出なくなった。 2つ目の”ダンプデータが0番地(ボードのアクセス番地は4)は0、4番地(ボードのアクセス番地は0)は6、8番地は0、C番地は8。1つおきにデータが取れていない”というのは、スプリット完了の際にアドレスフェーズのAD[6:0]でスプリット応答したときのLow Addressを返していたのだが、よくよく仕様書を読んでみるとDWORD読み出しのときのアドレスフェーズのAD[6:0]は0にしろと書いてあった。それで0のときしかだめだったのか?AD[2]は何か他の事に使っているようだ?0に修正したところ、全部データが読めるようになった。 下の図は、ちゃんと読みだせたときの波形。
ホストPCからPCI-Xターゲット・アクセスをしてきたときに、内部レジスタ以外はスプリット応答で返すことにした。その際に、PCIマスタ・モジュールを用いて、スプリット完了を64ビットアクセスで返したところ、ホストPCがNMIを受信してしまい、You probably have a hardware problem with your RAM chipsと表示が出てしまった。 ダンプデータも0番地(ボードのアクセス番地は4)は0、4番地(ボードのアクセス番地は0)は6、8番地は0、C番地は8。1つおきにデータが取れていない。 これがChipscopeで撮った波形。
Design Summary -------------- Number of errors: 0 Number of warnings: 2 Logic Utilization: Number of Slice Flip Flops: 575 out of 9,312 6% Number of 4 input LUTs: 512 out of 9,312 5% Logic Distribution: Number of occupied Slices: 582 out of 4,656 12% Number of Slices containing only related logic: 582 out of 582 100% Number of Slices containing unrelated logic: 0 out of 582 0% *See NOTES below for an explanation of the effects of unrelated logic Total Number of 4 input LUTs: 800 out of 9,312 8% Number used as logic: 512 Number used as a route-thru: 64 Number used for Dual Port RAMs: 172 (Two LUTs used per Dual Port RAM) Number used for 32x1 RAMs: 52 (Two LUTs used per 32x1 RAM) Number of bonded IOBs: 66 out of 232 28% IOB Flip Flops: 49 Number of ODDR2s used: 38 Number of DDR_ALIGNMENT = NONE 38 Number of Block RAMs: 1 out of 20 5% Number of GCLKs: 6 out of 24 25% Number of DCMs: 3 out of 4 75%
Total equivalent gate count for design: 113,940 Additional JTAG gate count for IOBs: 3,168 Peak Memory Usage: 161 MB Total REAL time to MAP completion: 20 secs Total CPU time to MAP completion: 19 secs
つぎは同期リセットのマップリポート。
Design Summary -------------- Number of errors: 0 Number of warnings: 2 Logic Utilization: Number of Slice Flip Flops: 576 out of 9,312 6% Number of 4 input LUTs: 459 out of 9,312 4% Logic Distribution: Number of occupied Slices: 576 out of 4,656 12% Number of Slices containing only related logic: 576 out of 576 100% Number of Slices containing unrelated logic: 0 out of 576 0% *See NOTES below for an explanation of the effects of unrelated logic Total Number of 4 input LUTs: 747 out of 9,312 8% Number used as logic: 459 Number used as a route-thru: 64 Number used for Dual Port RAMs: 172 (Two LUTs used per Dual Port RAM) Number used for 32x1 RAMs: 52 (Two LUTs used per 32x1 RAM) Number of bonded IOBs: 66 out of 232 28% IOB Flip Flops: 49 Number of ODDR2s used: 38 Number of DDR_ALIGNMENT = NONE 38 Number of Block RAMs: 1 out of 20 5% Number of GCLKs: 6 out of 24 25% Number of DCMs: 3 out of 4 75%
Total equivalent gate count for design: 113,633 Additional JTAG gate count for IOBs: 3,168 Peak Memory Usage: 160 MB Total REAL time to MAP completion: 20 secs Total CPU time to MAP completion: 19 secs
Number of Slice Flip Flops:は非同期リセットが575に対して、同期リセットが576で1つ多い。 Number of 4 input LUTs: は非同期リセットが512に対して、同期リセットが459で53少ない。 Number of occupied Slices:は非同期リセットは582に対して、同期リセットは576で6少ない。 Number of Slice Flip Flops:が同期リセットの方が1つ増えているが、全体的には同期リセットのほうが使用リソースが低いという結果になった。 なお、ツールのデフォルトから、以下の項目を変更してある。 1.XSTのプロパティのOptimization EffortをHigh 2.MAPのプロパティのOptimization Strategy (Cover Mode)をSpeed 3.Place & RouteのプロパティのPlace & Route Effort Level (Overall)をHigh 4.Place & RouteのプロパティのExtra Effort (Highest PAR level only) をContinue on Impossible
always @(posedge clk) begin if (reset) begin pre_cnt[PRE_CNT_WIDTH-1 : 1] <= 0; pre_cnt[0] <= 1'b1; // 最初に0だとint_cntがダウンカウントするので end else begin if (int_cnt != 0) // int_cntが0までカウント pre_cnt <= pre_cnt + 1; else begin pre_cnt[PRE_CNT_WIDTH-1 : 1] <= 0; pre_cnt[0] <= 1'b1; // 最初に0だとint_cntがダウンカウントするので end end end
always @(posedge clk) begin if (reset) begin pre_cnt[PRE_CNT_WIDTH-1 : 1] <= 0; pre_cnt[0] <= 1'b1; // 最初に0だとint_cntがダウンカウントするので else if (int_cnt != 0) // int_cntが0までカウント pre_cnt <= pre_cnt + 1; else begin pre_cnt[PRE_CNT_WIDTH-1 : 1] <= 0; pre_cnt[0] <= 1'b1; // 最初に0だとint_cntがダウンカウントするので end end
これを論理合成して、"View RTL Schematic"で見るとこうなる。
FDCは非同期リセット付きFFで、FDPは非同期セット付きFFだ。つまりどちらも非同期セット、リセットしている。どうしたら同期セット、リセットになるのだろうか? ちなみにXSTのプロパティのXilinx Specific Options の Use Synchronous Set と Use Synchronous Reset オプションは両方ともYes になっている。 しょうがないので、XSTのプロパティの HDL Options の Asynchronous To Synchronous オプションをチェックしたら、同期セット、リセットとなった。 これを論理合成して、"View RTL Schematic"で見るとこうなる。
process(reset, clk) begin -- Lighting frequency is 1KHz if reset='1' then lcnt <= (others => '0'); elsif clk'event and clk='1' then if lcnt = conv_std_logic_vector(clk_frequency, 16) then lcnt <= (others => '0'); else lcnt <= lcnt + 1; end if; end if; end process;
こうした。
process(clk) begin -- Lighting frequency is 1KHz if clk'event and clk='1' then if reset='1' then lcnt <= (others => '0'); elsif lcnt = conv_std_logic_vector(clk_frequency, 16) then lcnt <= (others => '0'); else lcnt <= lcnt + 1; end if; end if; end process;
この結果、非同期リセットのMAPの結果は以下の通り。
Design Summary -------------- Number of errors: 0 Number of warnings: 2 Logic Utilization: Number of Slice Flip Flops: 22 out of 3,840 1% Number of 4 input LUTs: 72 out of 3,840 1% Logic Distribution: Number of occupied Slices: 46 out of 1,920 2% Number of Slices containing only related logic: 46 out of 46 100% Number of Slices containing unrelated logic: 0 out of 46 0% *See NOTES below for an explanation of the effects of unrelated logic Total Number of 4 input LUTs: 87 out of 3,840 2% Number used as logic: 72 Number used as a route-thru: 15 Number of bonded IOBs: 19 out of 173 10% IOB Flip Flops: 5 Number of GCLKs: 1 out of 8 12%
Total equivalent gate count for design: 750 Additional JTAG gate count for IOBs: 912 Peak Memory Usage: 135 MB Total REAL time to MAP completion: 10 secs Total CPU time to MAP completion: 6 secs
次に、同期リセットに修正したMAP結果は以下の通り。
Design Summary -------------- Number of errors: 0 Number of warnings: 2 Logic Utilization: Number of Slice Flip Flops: 22 out of 3,840 1% Number of 4 input LUTs: 33 out of 3,840 1% Logic Distribution: Number of occupied Slices: 27 out of 1,920 1% Number of Slices containing only related logic: 27 out of 27 100% Number of Slices containing unrelated logic: 0 out of 27 0% *See NOTES below for an explanation of the effects of unrelated logic Total Number of 4 input LUTs: 48 out of 3,840 1% Number used as logic: 33 Number used as a route-thru: 15 Number of bonded IOBs: 19 out of 173 10% IOB Flip Flops: 5 Number of GCLKs: 1 out of 8 12%
Total equivalent gate count for design: 507 Additional JTAG gate count for IOBs: 912 Peak Memory Usage: 135 MB Total REAL time to MAP completion: 11 secs Total CPU time to MAP completion: 7 secs
Number of Slice Flip Flops:は22で同じだけれども、Number of 4 input LUTs: は非同期リセットが72、同期リセットが33で、同期リセットのほうが半分以下になっている。 さらにFloorplanerでも比較してみた。右が非同期リセット、左が同期リセットだ。