メニュー†過去の日記†kondoへのコメント†コメントはありません。 Comments/kondo 2009年01月27日(火)†inout信号のテストパタンについて†この辺が参考になりそう。 FPGA BBS [One Topic All View / Re[5]: inout信号のテストについて / Page: 0] 衝突しないようにするため、 例えば、参考リンク内で、 #30 BUS_reg <= 1'bz ; もしくは、入出力を切り替える制御信号がある場合 assign BUS = (RD==1) ? BUS_reg : 1'bz ; と書いてあげても良いのかな。 2009年01月26日(月)†(続き)BlockRAMを使って、FullPageBurstの動作を確認する†HDLを確認したり、シミュレーションをしたりするが、問題が見当たらない。 FullPageBurstで書き込んだデータを、FullPageBurstで読み込む。 困った時、
SDRAMの残りの作業(+問題点)†問題点
この問題を解決して、 2009年01月25日(日)†BlockRAMを使って、FullPageBurstの動作を確認する→失敗・・†レジスタ配列を使っていた部分を、ブロックRAMに変更した。 ロジアナで見ると、SDRAMへの書込と読込は正常に動作しているが・・ 2009年01月22日(木)†BlockRAMを使ってみる†出来て当然なんだけど、一応確認しておく。 module top( CLK , SW , TXD ); input CLK , SW ; output TXD; //UART wire CLK2 , xRST ; wire uo_RDY , uo_EN ; wire [7:0] uo_Dout; //UARTONの出力信号 wire ut_RDY ; //UARTTXの出力信号 reg EN; reg [7:0] DQ ; /*block RAM module*/ reg [7 : 0] dina; //Write Port reg [8 : 0] addra; reg [0 : 0] wea; reg [8 : 0] addrb; wire [7 : 0] doutb; //Read Port reg [9:0] q; //counter reg flag; //UARTONモジュールが読込時の時間稼ぎフラグ always @( posedge CLK or negedge xRST ) begin if( xRST == 0 ) begin q <= 0; flag <= 0; dina <= 0; addra <= 0; wea <= 0; addrb <= 0; end else begin if( q < 512 ) begin //Write dina <= q; addra <= q; wea <= 1; q <= q + 1; end else if( q == 512 ) begin //Write dina <= q; addra <= q; wea <= 1; q <= q + 1; addrb <= 0; end else if( q > 512 && q < 1024 ) begin //Read addrb <= q-513 ; wea <= 0; //UART呼び出し if( flag == 1 ) begin flag <= 0; q <= q + 1; EN <= 0; end else if( uo_RDY == 1 ) begin EN <= 1; DQ <= doutb ; flag <= 1; end end else begin //何もしない end end // else begin end //モジュール呼出 UARTON UARTON_0( .CLK(CLK) , .xRST(xRST) , .u_EN(EN) , .u_Dout(DQ) , .uo_RDY(uo_RDY) , //UART-Module .ut_RDY(ut_RDY) , .uo_EN(uo_EN) , .uo_Dout(uo_Dout) ); //UARTTX-Module UARTTX UARTTX_0( .CLK(CLK2) , .xRST(xRST) , .uo_EN(uo_EN), .uo_Dout(uo_Dout), .ut_TXD(TXD) , .ut_RDY(ut_RDY) ); SWgen SWgen( CLK , SW , xRST ); CLKgen CLKgen_1( .CLKi(CLK) , .CLKo(CLK2) , .Div(12'd108) ); //25M→231.48k=115.74k*2 BLOCKRAMTEST BLOCKRAMTEST( .clka(CLK), .dina(dina), .addra(addra), .wea(wea), .clkb(CLK), .addrb(addrb), .doutb(doutb) ); endmodule 2008年12月22日(月)†論理合成できない問題はDQBufが大きいためだった†秋田先生の指摘で分かった。 reg [7:0] DQBuf [511:0]; 使用しているFlipFlopの数は、 240/4896 (XC3S250Eが使用できるFlipFlopの数は、4896個 理論上は、ぎりぎり足りそうだけど、 実際先生の指摘通り、8バイトしかアクセスしていない時は、以下のような警告が出ていた。 WARNING:Xst:646 - Signal <DQBuf<511:108>> is assigned but never used. This unconnected signal will be trimmed during the optimization process. WARNING:Xst:646 - Signal <DQBuf<99:0>> is assigned but never used. This unconnected signal will be trimmed during the optimization process. DQBuf[変数]に変更すると、512バイト分のレジスタが作成されるそのため、DQBufが大きくなりすぎるようだ。 警告はしっかり読んで、理解しないといけないな。 CLBの代わりにブロックRAMを使う方針になった†どうやらSpartan-3EにもブロックRAMが用意されているようだ。 必要なビット数 reg [7:0] DQBuf [511:0]; なので、4096ビットあれば足りる。 CLBでメモリを構成するのは効率が悪いことを学んだ。 2008年12月21日(日)†まだ、レジスタ配列の添え字に変数が使えない問題が残っている。 レジスタ配列の添え字に算術演算した結果を入れることはできない?†これは論理合成可能 else if( q== 516)begin cnt <=0 end else if( q == 517 ) begin DQuart <= DQBuf[cnt]; cnt <= 1; end else if( q == 518 ) begin r_EN <= 1; DQuart <= DQBuf[cnt]; end これは論理合成できない cntは0で初期化されている。 else if( q == 517 ) begin DQuart <= DQBuf[cnt]; cnt <= cnt + 10'd1; end else if( q == 518 ) begin DQuart <= DQBuf[cnt]; end やっぱり変数が使えないようだ。 これじゃあ、結局全ての状態を書き出すしかないのかな。 2008年12月20日(土)†見直した結果、警告を減らすことができ、 ようやくFullPageBurstの8バイトを確認できた、出力も正常に一回のみ†2008-12-17-top_2 今までシミュレーションに頼りすぎていたな。 残ったWarning†CLKの分周に一番下の桁は使っていない WARNING:Xst:647 - Input <Div<0>> is never used. This port will be preserved and left unconnected if it belongs to a top-level block or it belongs to a sub-block and the hierarchy of this sub-block is preserved. HDLでは、8バイトしかアクセスしていないため WARNING:Xst:646 - Signal <DQBuf<511:108>> is assigned but never used. This unconnected signal will be trimmed during the optimization process. WARNING:Xst:646 - Signal <DQBuf<99:0>> is assigned but never used. This unconnected signal will be trimmed during the optimization process. これがよく分からない。 WARNING:Xst:2677 - Node <CAS> of sequential type is unconnected in block <REFRESHModule_0>. WARNING:Xst:2677 - Node <REFRESHModule_0/CAS> of sequential type is unconnected in block <top>. 2008年12月17日(水)†論理合成が終わらない問題、UARTが永遠に出力を送信してくる問題もあり、一行に進まない。。 こういう時は、もう一度最初からプログラムを見直していく。 リフレッシュ状態の前の状態を保持できない†always文を用いた組み合わせ回路の場合 REFRESH:begin if( ref_END == 1 )begin NXT <= preNXT; preNXT <= 3'd0; end else begin NXT <= REFRESH ; preNXT <= preNXT; end end 結局、状態数を増やして対応することにしよう。 RTLシミュレーションとゲートレベルシミュレーション†おそらく
always文の注意点†
2008年12月14日(日)†レジスタ配列に変数を使う→論理合成が終わらない†どうやらレジスタ配列に変数を使うと、論理合成が終わらないようだ。 else if( q == 516 ) begin//PRECHARGE(tRP=15n) RAS <= 0; CAS <= 1; WE <= 0; q <= 0 ; Address[10] <= 0; // 0 => single bank BA <= 2'b00; // Bank assign end /* UARTでPCに送信する */ else if( q > 516 && q < 645 ) begin //64回,8バイト送信 //常にNOPを出力 CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; if( q[0] == 1 ) begin UartState <= 1; //UARTを起動する r_DQ[7:0] <= DQBuf[q]; r_DQ[15:8] <= DQBuf[1]; r_DQ[23:16] <= DQBuf[2]; r_DQ[31:24] <= DQBuf[3]; r_DQ[39:32] <= DQBuf[4]; r_DQ[47:40] <= DQBuf[5]; r_DQ[55:48] <= DQBuf[6]; r_DQ[63:56] <= DQBuf[7]; q <= q + 1; end else if(q[0] == 0) begin //UARTモジュールがR_DQを読込 if( u_END == 1 ) begin q <= q + 1; UartState <= 0; //reset end end end 2008年12月11日(木)†ビット幅指定に変数は使えない†こりゃ、困った。 2008-12-11-test always @(posedge CLK or negedge xRST) begin if(xRST==0)begin q1<=7; q2<=0; end else begin out <= in[q2:q1]; q1 <= q1 + 8; q2 <= q2 + 8; end end レジスタ配列を使う方法があるのかな。 2008年12月04日(木)†FullPageBurstの内8バイトの読込確認†論理合成が出来ない問題は解決していない。 ただし、1回8バイトが送出されるはずが、 2008年12月03日(水)†論理シミュレーションは成功するが、論理合成できず。†やはり終わらない。 FullPageBurstで、書き込めているかどうか確認すらできない。 これを追加してからだな。 //UARTでDQBufを送信する if( ReadFlag == 1 ) begin /* SDRAMからの読込が始まったらReadFlag=1になる。 その後、DQBuf[DQBufCnt]をUARTで送信する。 送信後にReadEND=1にし、ReadFlag=0にする */ if( DQBufCnt == 512 ) begin ReadEND <= 1; end else if( uo_RDY == 1 )begin //UARTONが送信可能状態なら r_EN <= 1'b1; r_DQ <= DQBuf[DQBufCnt]; DQBufCnt <= DQBufCnt + 1; end else begin //送信待ち r_EN <= 1'b0; end end else begin //ReadFlagが立つまで初期化しておく DQBufCnt <= 0; ReadEND <= 0; end `timescale 1ns / 1ps //READモジュール module READModule(CLK , ReadState , ReadEND , CS , RAS , CAS , WE , DQM , Address , BA , DQ , uo_RDY , r_EN , r_DQ ); //, DQout ); //###################################### // Input-Output //###################################### input CLK , ReadState ; input uo_RDY ; output ReadEND , CS , RAS , CAS , WE , DQM ; output [11:0] Address ; output [1:0] BA ; output r_EN ; output [7:0] r_DQ ; input [7:0] DQ ; //###################################### // Internal Signal //###################################### reg CS , RAS , CAS , WE , ReadEND , DQM; reg [11:0] Address; reg [1:0] BA; reg [12:0] q ; // State Counter reg [7:0] DQBuf [511:0] ; //8ビット幅DQBuf 512ワード(バイト)のレジスタ配列 reg [9:0] DQBufCnt;//UARTの送信用カウンタ、次に送信するところを示す reg ReadFlag; //READの2CLK後・・・DQが返ってくるところでReadFlagを立てる。その後、UARTで送信する。 reg r_EN; reg [7:0] r_DQ; always @(posedge CLK) begin if( ReadState==1) begin if(q==0) begin //ACTIVE CS <= 0; RAS <= 0; CAS <= 1; WE <= 1; Address <= 12'b000000_000000; BA <= 2'b00; q <= q + 1 ; //ReadEND <= 0; DQM <= 1; //ReadFlag <= 0; end else if(q==1) begin //READ CS <= 0; RAS <= 1; CAS <= 0; WE <= 1; Address <= 12'b0_1_0_000000000; //FullpageBurstなのでAUTOPrechargeなし(A10:Don't Care) BA <= 2'b00 ; DQM <= 0; q <= q + 1; end else if( q == 2 ) begin //NOP //実際にREADを出力しているのはこの3CLK目のタイミング CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; DQM <= 0; end else if( q == 3 ) begin //NOP CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; DQM <= 0; end else if( q == 4 ) begin //NOP(READ Burst 1bit〜) CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; DQM <= 0; //Read DQBuf[q-4] <= DQ; //UART ReadFlag <= 1; //UARTの開始のためのフラグ end else if( q > 4 && q < 514 ) begin //NOP(READ Burst 2bit目〜) CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; DQM <= 0; //Read DQBuf[q-4] <= DQ; //debug DQoutを入れる時間があるので、1CLK遅く立ち上げ //UART_EN <= 1; end else if( q == 514 ) begin //Burst Terminate CS <= 0; RAS <= 1; CAS <= 1; WE <= 0; q <= q + 1; DQM <= 0; //Read DQBuf[q-4] <= DQ; end else if( q == 515 ) begin //NOP CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; DQM <= 1; //Read DQBuf[q-4] <= DQ; end else if( q == 516 ) begin //PRECHARGE(tRP=15n) RAS <= 0; CAS <= 1; WE <= 0; q <= q + 1 ; Address[10] <= 0; // 0 => single bank BA <= 2'b00; // Bank assign //ReadEND <= 1; //↑UART送信後にReadENDする end else if( q == 517 ) begin //UART送信中 //NOP CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; DQM <= 1; end else begin //例外処理 CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; q <= q + 1; //ReadEND <= 0; DQM <= 1; //UART //EnUART_ON <= 0; end //UARTでDQBufを送信する if( ReadFlag == 1 ) begin if( DQBufCnt == 512 ) begin ReadEND <= 1; end else if( uo_RDY == 1 )begin //UARTONが送信可能状態なら r_EN <= 1'b1; r_DQ <= DQBuf[DQBufCnt]; DQBufCnt <= DQBufCnt + 1; end else begin //送信待ち r_EN <= 1'b0; end end else begin //ReadFlagが立つまで初期化しておく DQBufCnt <= 0; ReadEND <= 0; end end //if( ReadState ) else begin CS <= 0; RAS <= 1; CAS <= 1; WE <= 1; Address <= 12'b000000_000000; BA <= 2'b00; DQM <= 1; ReadEND <= 0; //DQout <= 0; q <= 0; ReadFlag <= 0; DQBufCnt <= 0; end //else begin end // always end endmodule Consoleの表示結果は、 Reading design: READModule.prj ========================================================================= * HDL Compilation * ========================================================================= Compiling verilog file "READ.v" in library work Module <READModule> compiled No errors in compilation Analysis of file <"READModule.prj"> succeeded. ========================================================================= * Design Hierarchy Analysis * ========================================================================= Analyzing hierarchy for module <READModule> in library <work>. ========================================================================= * HDL Analysis * ========================================================================= Analyzing top module <READModule>. Module <READModule> is correct for synthesis. ========================================================================= * HDL Synthesis * ========================================================================= Performing bidirectional port resolution... INFO:Xst:2679 - Register <CS> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<11>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<9>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<8>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<7>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<6>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<5>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<4>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<3>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<2>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<1>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <Address<0>> in unit <READModule> has a constant value of 0 during circuit operation. The register is replaced by logic. INFO:Xst:2679 - Register <BA> in unit <READModule> has a constant value of 00 during circuit operation. The register is replaced by logic. Synthesizing Unit <READModule>. Related source file is "READ.v". Found 1-bit register for signal <Address<10>>. Found 1-bit register for signal <CAS>. Found 1-bit register for signal <DQM>. Found 1-bit register for signal <RAS>. Found 1-bit register for signal <ReadEND>. Found 1-bit register for signal <WE>. Found 8-bit register for signal <r_DQ>. Found 1-bit register for signal <r_EN>. Found 4096-bit register for signal <DQBuf>. Found 10-bit up counter for signal <DQBufCnt>. Found 13-bit register for signal <q>. Found 13-bit adder for signal <q$share0000>. Found 13-bit comparator greater for signal <RAS$cmp_gt0000> created at line 113. Found 13-bit comparator less for signal <RAS$cmp_lt0000> created at line 113. Found 1-bit register for signal <ReadFlag>. INFO:Xst:738 - HDL ADVISOR - 4096 flip-flops were inferred for signal <DQBuf>. You may be trying to describe a RAM in a way that is incompatible with block and distributed RAM resources available on Xilinx devices, or with a specific template that is not supported. Please review the Xilinx resources documentation and the XST user manual for coding guidelines. Taking advantage of RAM resources will lead to improved device usage and reduced synthesis time. Summary: inferred 1 Counter(s). inferred 4125 D-type flip-flop(s). inferred 1 Adder/Subtractor(s). inferred 2 Comparator(s). inferred 8 Multiplexer(s). Unit <READModule> synthesized. INFO:Xst:1767 - HDL ADVISOR - Resource sharing has identified that some arithmetic operations in this design can share the same physical resources for reduced device utilization. For improved clock frequency you may try to disable resource sharing. ========================================================================= HDL Synthesis Report Macro Statistics # Adders/Subtractors : 1 13-bit adder : 1 # Counters : 1 10-bit up counter : 1 # Registers : 522 1-bit register : 8 13-bit register : 1 8-bit register : 513 # Comparators : 2 13-bit comparator greater : 1 13-bit comparator less : 1 # Multiplexers : 1 8-bit 512-to-1 multiplexer : 1 ========================================================================= ========================================================================= * Advanced HDL Synthesis * ========================================================================= Loading device for application Rf_Device from file '3s250e.nph' in environment C:\Xilinx\10.1\ISE. 2008年12月02日(火)†ReadのFullPageBurstと並行して、UARTで送信する。→論理合成が終わらないorz†以下の文を、READモジュールに追加した。 //UARTでDQBufを送信する if( ReadFlag == 1 ) begin /* SDRAMからの読込が始まったらReadFlag=1になる。 その後、DQBuf[DQBufCnt]をUARTで送信する。 送信後にReadEND=1にし、ReadFlag=0にする */ if( DQBufCnt == 512 ) begin ReadEND <= 1; end else if( uo_RDY == 1 )begin //UARTONが送信可能状態なら r_EN <= 1; r_DQ <= DQBuf[DQBufCnt]; DQBufCnt <= DQBufCnt + 1; end else begin //送信待ち end end else begin //ReadFlagが立つまで初期化しておく DQBufCnt <= 0; ReadEND <= 0; end if,else if文とcase文の違い†if,else if文とcase文は、全く一緒だと思っていた。 if,else if文は上から順番に実行され該当したものが実行される。 RTL設計スタイルガイドで確認してみると、 if文はプライオリティを記述するもの、case文は並行動作を記述するものと考えて記述するとよいでしょう。 (参照元:RTL設計スタイルガイド Verilog HDL編 第2版 PP.2-50) レジスタ配列の添え字に算術演算可能†file name : 2008-12-02-registerArray_UseVariable module top( CLK , xRST , Dout0 , Dout1 , Dout2 , Dout3 ); input CLK , xRST ; output [7:0] Dout0 , Dout1 , Dout2 , Dout3; reg [7:0] RegArray [3:0] ; //レジスタ配列8バイト(1ワード1バイト) reg [10:0] q; //カウンタ assign Dout0 = RegArray[0]; assign Dout1 = RegArray[1]; assign Dout2 = RegArray[2]; assign Dout3 = RegArray[3]; always @(posedge CLK) begin if(xRST==0)begin //reset q <= 1; end else if(q==5) begin //initialize q <= 0; end else begin q <= q + 1 ; RegArray[q-1] <= q; end end endmodule とりあえず、これで確認できた。 この辺は、STARC2-68辺りが参考になる。 |