フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
webadm | 投稿日時: 2008-9-23 8:56 |
Webmaster 登録日: 2004-11-7 居住地: 投稿: 3088 |
RTL: DISPLAY 遂に最後のDISPLAYブロック。
基本的には蛍光表示管のダイナミック点灯制御が主になるが、それ以外に機能によって異なる小数点表示などの小細工が必要。 これを記述すれば入力から出力までのパスが通るのでやっとPlace & Routeが行われることになる。 やっとここまできたよママン(ノ∀`) bcddec.v: BCD to 7segデコーダー module bcddec(bcd, seg); // Input Port(s) input [3:0] bcd; // Output Port(s) output reg [6:0] seg; always@(bcd) begin case(bcd) 4'b0000: seg <= 7'b1000000; // a,b,c,d,e,f 4'b0001: seg <= 7'b1111001; // b,c 4'b0010: seg <= 7'b0100100; // a, b, d, e, g 4'b0011: seg <= 7'b0110000; // a, b, c, d, g 4'b0100: seg <= 7'b0011001; // b, c, f, g 4'b0101: seg <= 7'b0010010; // a, c, d, f, g 4'b0110: seg <= 7'b0000010; // a, c, d, e, f, g 4'b0111: seg <= 7'b1111000; // a, b, c 4'b1000: seg <= 7'b0000000; // a, b, c, d, e, f, g 4'b1001: seg <= 7'b0010000; // a, b, c, d, f, g default: seg <= 7'b1111111; endcase end endmodule disp.v: DISPLAYブロックRTLインプリメンテーション module disp(c3200hz, s, fcounter, clcounter, ontimer, offtimer, sleeptimer, oncmpout, offcmpout, sleep, duty, strobe, ac, blanking, stopwatch, ambcout, pmfmout, sega, segb, segc, segd, sege, segf, segg, point, io, signalout, timerout, sleepout); // Input Port(s) input c3200hz, oncmpout, offcmpout, sleep, duty, strobe, ac, blanking; input [2:0] s; input [19:0] fcounter; input [16:0] clcounter, ontimer, offtimer, sleeptimer; // Output Port(s) output stopwatch, ambcout, pmfmout, sega, segb, segc, segd, sege, segf, segg, point, signalout, timerout, sleepout; output [4:0] io; // Inout Port(s) // Parameter Declaration(s) // Additional Module Item(s) reg [4:0] div16; wire c200hz; reg [19:0] counter; reg ampm; reg [3:0] bcd; reg dot; wire [6:0] seg; reg [2:0] scan; reg timer; assign c200hz = div16[4]; always@(posedge c3200hz or negedge ac) begin if(!ac) div16 <= 0; else if(c3200hz) div16 <= div16 + 1'b1; end always@(posedge c200hz or negedge ac) begin if(!ac) scan <= 0; else if(c200hz) begin if(scan == 3'b100) scan <= 0; else scan <= scan + 1'b1; end end always@(fcounter or clcounter or ontimer or offtimer or sleeptimer or s) begin case(s) 3'b111: begin counter <= {4'b1111,clcounter[15:0]}; ampm <= clcounter[16:16]; end 3'b101: begin counter <= {4'b1111,ontimer[15:0]}; ampm <= ontimer[16:16]; end 3'b100: begin counter <= {4'b1111,offtimer[15:0]}; ampm <= offtimer[16:16]; end 3'b110: begin counter <= {4'b1111,sleeptimer[15:0]}; ampm <= 0; end default: begin counter <= fcounter; ampm <= 0; end endcase end always@(scan or counter or s) begin case(scan) 3'b000: begin bcd <= counter[3:0]; dot <= 0; end 3'b001: begin bcd <= counter[7:4]; dot <= 0; end 3'b010: begin bcd <= counter[11:8]; if(s[2]) dot <= 1'b1; else dot <= 0; end 3'b011: begin bcd <= counter[15:12]; dot <= 0; end 3'b100: begin bcd <= counter[19:16]; if(s[2]==0) dot <= 1'b1; else dot <= 0; end default: begin bcd <= 4'b1111; dot <= 0; end endcase end always@(posedge oncmpout or posedge offcmpout or negedge ac) begin if(!ac) timer <= 0; else if(oncmpout) timer <= ~timer; else if(offcmpout) timer <= ~timer; end bcddec bcddec(bcd, seg); assign sega = (blanking)?1'bz:(~duty | seg[0]); assign segb = (blanking)?1'bz:(~duty | seg[1]); assign segc = (blanking)?1'bz:(~duty | seg[2]); assign segd = (blanking)?1'bz:(~duty | seg[3]); assign sege = (blanking)?1'bz:(~duty | seg[4]); assign segf = (blanking)?1'bz:(~duty | seg[5]); assign segg = (blanking)?1'bz:(~duty | seg[6]); assign point = (blanking)?1'bz:~(duty & dot); assign ambcout = (blanking)?1'b0:~ampm; assign pmfmout = (blanking)?1'b0:ampm; assign io = (blanking)?{5{1'bz}}:~({5{duty}} & 1<<scan); assign timerout = ~timer; endmodule あまりじっくり考えずに書いたので汚いコードになってしまっている。一応コンパイルとPlace & Routeは出来たけど規模がトラ技付録のMAXII基板には入らなかった(;´Д`) BCDデコーダー以外は全部ひとつのソースに入れてしまったのでRTL Viewerで見ると2ページにまたがってしまった。もっと細かくサブブロックにわけて全体が1ページに収まるようにすると見通しが良くなると思う。 さてあとは適当に入力信号を設定して3.2768MHzのクロックを与えてリセットしてあげれば何らかの動きをするはず。シミュレーションが楽しみ。 |
フラット表示 | 前のトピック | 次のトピック |
投稿するにはまず登録を | |