作者syuan08 (syuan)
看板Electronics
標題[問題] 同步記數器初始值
時間Fri Oct 7 09:54:35 2016
小弟我最近有個問題
我試著利用verilog邏輯閘拚出一個同步記數器
發現功能如果分開測的話應該是正常的
但是現在發現我DFF的初始值,不知道怎麼給導致功能無法正常運作
想請問一下大大有沒有啥建議?
module counter_3b (rst_n, clk, cnt);
input rst_n, clk;
output [2:0]cnt;
assign d2 = cnt[0] ^ cnt [1];
assign d3 = (cnt[0] & cnt[1]) ^ cnt[2];
assign clk_r = clk & rst_n; //rst功能
assign init_d = 1'b0 | cnt[0];
D_type DFF1(.CP(clk_r), .D(init_d), .Q(cnt[0]), .Q_bar(dff1b_out));
D_type DFF2(.CP(clk_r), .D(d2), .Q(cnt[1]), .Q_bar(dff2b_out));
D_type DFF3(.CP(clk_r), .D(d3), .Q(cnt[2]), .Q_bar(dff3b_out));
module D_type (CP_clk, D, Q, Q_bar);
input CP_clk, D;
output Q, Q_bar;
nand nand_1 (out_1, out_4, out_2);
nand nand_2 (out_2, out_1, CP_clk);
nand nand_3 (out_3, out_2, CP_clk, out_4);
nand nand_4 (out_4, out_3, D);
nand nand_5 (Q, out_2, Q_bar);
nand nand_6 (Q_bar, Q, out_3);
endmodule
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.75.124.162
※ 文章網址: https://www.ptt.cc/bbs/Electronics/M.1475805278.A.D70.html
推 tkhan: none.. 10/07 10:26
→ amistad: 1. DFF1 的 Q 要接到 DFF2 的 D 10/07 10:56
→ amistad: 2. 通常會用 set / reset的機制進行初始化設計 10/07 10:56
→ amistad: 習慣上會用 behavior model 取代 instantiate cell 的寫 10/07 10:59
→ amistad: 法 10/07 10:59
→ amistad: 3. 除非限用 cell library / full customer 的流程, 10/07 11:01
→ amistad: 習慣上會用 behavior model 取代 instantiate cell 的寫 10/07 11:01
→ amistad: 法。X 10/07 11:01
→ syuan08: 因為我想用cell lib的方式寫看看,下部的dff不做更改,只 10/07 11:09
→ syuan08: 能在外部電路設計! 10/07 11:09