0
我正在爲陣列乘法器編寫一個展位編碼。這是模塊的一個:展臺編碼不起作用,包含仿真
module add_input (M,pos,neg,C);
parameter n=8;
input [n-1:0]M;
input pos,neg;
output [2*n-1:0]C;
reg [2*n-1:0]C;
integer k;
always @ (*)
begin
for (k=0;k<=n-1;k=k+1)
begin
C[k]=(pos& (M[k]))|((~M[k])&neg);
end
C[2*n-1:n]={n{C[n-1]}};
end
endmodule
測試平臺仿真此模塊是確定的:
a busy cat http://img39.imageshack.us/img39/3444/74546414.jpg !
但是,當我將此模塊放入頂層設計時,我看不到來自模塊add_input的任何輸出。真的想知道爲什麼,一直在調試整個晚上。
代碼:
module Array_Mutiplier (M,Q,outcome, t_pos, t_neg,t_Y1);
parameter n=8;
parameter m=16;
input [n-1:0]M,Q;
output [m-1:0]outcome;
//-----------------------------------------------------------
output [n-1:0] t_pos, t_neg;
output [m-1:0] t_Y1;
//-----------------------------------------------------------
//first part, got the booth code
wire [n-1:0]negative,positive;
booth_encode BE(Q,positive,negative);
//get the Y for the full adder
wire [m-1:0]Y1;
add_input row_1 (M,positive[0],negative[0],Y1);
wire [2*n-1:0]Y2;
add_input row_2 (M,positive[1],negative[1],Y2);
wire [2*n-1:0]Y3;
add_input row_3 (M,positive[2],negative[2],Y3);
wire [2*n-1:0]Y4;
add_input row_4 (M,positive[3],negative[3],Y4);
wire [2*n-1:0]Y5;
add_input row_5 (M,positive[4],negative[4],Y5);
wire [2*n-1:0]Y6;
add_input row_6 (M,positive[5],negative[5],Y6);
wire [2*n-1:0]Y7;
add_input row_7 (M,positive[6],negative[6],Y7);
wire [2*n-1:0]Y8;
add_input row_8 (M,positive[7],negative[7],Y8);
assign t_pos=positive;
assign t_neg=negative;
assign t_Y1=Y1;
endmodule
a busy cat http://img855.imageshack.us/img855/3361/28395154.png !
根據仿真可以看到booth編碼器工作正常,但爲什麼輸出t_Y1始終爲0?
謝謝你非常感謝你...我只專注於row_1,並忽略了事實row_1應該得到所有0 ...你救了我,男人 – fiftyplus 2012-02-17 21:47:28