-2
我正在使用結構創建加法器和累加器。下面是我做的遠:加法器和累加器在verilog中。如何將觸發器的輸出重新加入到加法器的輸入中?
module adder_and_accum(add, clb, clc, iac, x2, in, acc, carry, carrynot, qn2, qn3, qn4, qn5);
input add, clb, clc, iac, x2;
input [3:0] in;
output [3:0] acc;
output carry, carrynot, qn2, qn3, qn4, qn5;
wire adder1in2, adder2in2, adder3in2, adder4in2;
wire sum1, sum2, sum3, sum4;
wire ffin1;
wire cinadder1, cinadder2, cinadder3;
wire carrynot, clearcarry;
four_to_one_mux mux1(0, 0, in[3], 0, add, iac, adder1in2);
four_to_one_mux mux2(0, 0, in[2], 0, add, iac, adder2in2);
four_to_one_mux mux3(0, 0, in[1], 0, add, iac, adder3in2);
four_to_one_mux mux4(0, 1, in[0], 0, add, iac, adder4in2);
full_adder f1(sum1, ffin1, cinadder1, acc[3], adder1in2);
full_adder f2(sum2, cinadder1, cinadder2, acc[2], adder2in2);
full_adder f3(sum3, cinadder2, cinadder3, acc[1], adder3in2);
full_adder f4(sum4, cinadder3, 0, acc[0], adder4in2);
or(clearcarry, clc, clb);
d_flip_flop dff1(ffin1, x2, carry, carrynot, clc);
d_flip_flop dff2(sum1, x2, acc[3], qn2, clearcarry);
d_flip_flop dff3(sum2, x2, acc[2], qn3, clearcarry);
d_flip_flop dff4(sum3, x2, acc[1], qn4, clearcarry);
d_flip_flop dff5(sum4, x2, acc[0], qn5, clearcarry);
endmodule
這裏有觸發器,多路複用器和全加器標題:
module full_adder(sum, cout, cin, inp1, inp2);
module four_to_one_mux(in0, in1, in2, in3, select0, select1, out);
module d_flip_flop(d, clk, q, qn, reset);
觸發器,複用器,和全加器是我創建的模塊,我知道他們工作,因爲我已經單獨測試他們。它們都顯示正確的波形。
我已經縮小了問題的範圍,觸發器Q輸出被纏回到我的加法器輸入中。我的ACC總線輸出只顯示XXXX。
如何將我的拖鞋的輸出作爲輸入連接到我的加法器?
下面是我參考的加法器和累加器的原理圖。