[問題] 同步記數器初始值
小弟我最近有個問題
我試著利用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
推
10/07 10:26, , 1F
10/07 10:26, 1F
→
10/07 10:56, , 2F
10/07 10:56, 2F
→
10/07 10:56, , 3F
10/07 10:56, 3F
→
10/07 10:59, , 4F
10/07 10:59, 4F
→
10/07 10:59, , 5F
10/07 10:59, 5F
→
10/07 11:01, , 6F
10/07 11:01, 6F
→
10/07 11:01, , 7F
10/07 11:01, 7F
→
10/07 11:01, , 8F
10/07 11:01, 8F
→
10/07 11:09, , 9F
10/07 11:09, 9F
→
10/07 11:09, , 10F
10/07 11:09, 10F