一、向量点积乘法器
算法:向量a = (a1, a2, a3, a4); b = (b1, b2, b3, b4),
a·b = a1b1+a2b2+a3b3+a4b4
原理图:
代码实现:
module vector(a1,a2,a3,a4,b1,b2,b3,b4,out);
input [3:0] a1,a2,a3,a4,b1,b2,b3,b4;
output [9:0] out;
wire [7:0] out1,out2,out3,out4;
wire [8:0] out5,out6;
wire [9:0] out;
//四个乘法器
mul_addtree U1(.a(a1), .b(b1), .out(out1));
mul_addtree U2(.a