请教verilog问题
时间:12-12
整理:3721RD
点击:
写了一段code 很简单的一个乘法器 如下
用$monitor 得到的结果是正确的
但是波形错误 每隔一个结果 左四位就变成X 这是怎么回事? glitch?
另外,是不是例化的描述不能够综合 还是说综合的效果不好
欢迎指教 欢迎拍砖
+++++++++++++++++++++++++++++++
module FourbitMultiplication(P,A,B);
output [7:0] P;
input [3:0] A,B;
wire [7:0] P;
wire [3:0] C3,C2,C1, S3,S2,S1;
assign P[0] = A[0] & B[0];
Full_Adder FAdder1(S1[0],C1[0],A[0]&B[1],A[1]&B[0],1'b0);
Full_Adder FAdder2(S1[1],C1[1],A[1]&B[1],A[2]&B[0],C1[0]);
Full_Adder FAdder3(S1[2],C1[2],A[2]&B[1],A[3]&B[0],C1[1]);
Full_Adder FAdder4(S1[3],C1[3],A[3]&B[1],C1[2],1'b0);
Full_Adder FAdder5(S2[0],C2[0],A[0]&B[2],S1[1],1'b0);
Full_Adder FAdder6(S2[1],C2[1],A[1]&B[2],S1[2],C2[0]);
Full_Adder FAdder7(S2[2],C2[2],A[2]&B[2],S1[3],C2[1]);
Full_Adder FAdder8(S2[3],C2[3],A[3]&B[2],C1[3],C2[2]);
Full_Adder FAdder9 (S3[0],C3[0],A[0]&B[3],S2[1],1'b0);
Full_Adder FAdder10(S3[1],C3[1],A[1]&B[3],S2[2],C3[0]);
Full_Adder FAdder11(S3[2],C3[2],A[2]&B[3],S2[3],C3[1]);
Full_Adder FAdder12(S3[3],C3[3],A[3]&B[3],C2[3],C3[2]);
assign P[1]=S1[0];
assign P[2]=S2[0];
assign P[3]=S3[0];
assign P[4]=S3[1];
assign P[5]=S3[2];
assign P[6]=S3[3];
assign P[7]=C3[3];
endmodule
(Full_Adder 略)
+++++++++++++++++++++
P = 8 00001000 a = 2 b = 4
P = 15 00001111 a = 3 b = 5
P = 24 00011000 a = 4 b = 6
P = 35 00100011 a = 5 b = 7
P = 48 00110000 a = 6 b = 8
P = 63 00111111 a = 7 b = 9
P = 80 01010000 a = 8 b = 10
P = 99 01100011 a = 9 b = 11
P = 120 01111000 a = 10 b = 12
P = 143 10001111 a = 11 b = 13
P = 168 10101000 a = 12 b = 14
P = 195 11000011 a = 13 b = 15
P = 0 00000000 a = 14 b = 0
P = 15 00001111 a = 15 b = 1
++++++++++++++
用$monitor 得到的结果是正确的
但是波形错误 每隔一个结果 左四位就变成X 这是怎么回事? glitch?
另外,是不是例化的描述不能够综合 还是说综合的效果不好
欢迎指教 欢迎拍砖
+++++++++++++++++++++++++++++++
module FourbitMultiplication(P,A,B);
output [7:0] P;
input [3:0] A,B;
wire [7:0] P;
wire [3:0] C3,C2,C1, S3,S2,S1;
assign P[0] = A[0] & B[0];
Full_Adder FAdder1(S1[0],C1[0],A[0]&B[1],A[1]&B[0],1'b0);
Full_Adder FAdder2(S1[1],C1[1],A[1]&B[1],A[2]&B[0],C1[0]);
Full_Adder FAdder3(S1[2],C1[2],A[2]&B[1],A[3]&B[0],C1[1]);
Full_Adder FAdder4(S1[3],C1[3],A[3]&B[1],C1[2],1'b0);
Full_Adder FAdder5(S2[0],C2[0],A[0]&B[2],S1[1],1'b0);
Full_Adder FAdder6(S2[1],C2[1],A[1]&B[2],S1[2],C2[0]);
Full_Adder FAdder7(S2[2],C2[2],A[2]&B[2],S1[3],C2[1]);
Full_Adder FAdder8(S2[3],C2[3],A[3]&B[2],C1[3],C2[2]);
Full_Adder FAdder9 (S3[0],C3[0],A[0]&B[3],S2[1],1'b0);
Full_Adder FAdder10(S3[1],C3[1],A[1]&B[3],S2[2],C3[0]);
Full_Adder FAdder11(S3[2],C3[2],A[2]&B[3],S2[3],C3[1]);
Full_Adder FAdder12(S3[3],C3[3],A[3]&B[3],C2[3],C3[2]);
assign P[1]=S1[0];
assign P[2]=S2[0];
assign P[3]=S3[0];
assign P[4]=S3[1];
assign P[5]=S3[2];
assign P[6]=S3[3];
assign P[7]=C3[3];
endmodule
(Full_Adder 略)
+++++++++++++++++++++
P = 8 00001000 a = 2 b = 4
P = 15 00001111 a = 3 b = 5
P = 24 00011000 a = 4 b = 6
P = 35 00100011 a = 5 b = 7
P = 48 00110000 a = 6 b = 8
P = 63 00111111 a = 7 b = 9
P = 80 01010000 a = 8 b = 10
P = 99 01100011 a = 9 b = 11
P = 120 01111000 a = 10 b = 12
P = 143 10001111 a = 11 b = 13
P = 168 10101000 a = 12 b = 14
P = 195 11000011 a = 13 b = 15
P = 0 00000000 a = 14 b = 0
P = 15 00001111 a = 15 b = 1
++++++++++++++
module Full_Adder(Sum,cout,a,b,cin);
output Sum,cout;
input a,b,cin;
wire p=a&b;
wire g=a^b;
assign Sum = g^cin;
assign cout = p|(g&cin);
endmodule