使用repeat循环语句及加法和移位操作实现应该乘法器
0赞
发表于 2/27/2012 9:00:59 PM
阅读(3727)
使用repeat循环语句及加法和移位操作实现应该乘法器
module fpgaceshi (opa or opb or result);
parameter size = 8; longsize = 16;
input [size:1] opa, opb;
output [longsize:1] result;
reg [size:1] opa, opb;
reg [longsize:1] result;
begin: mult
reg [longsize:1]shift_opa, shift_opb;
shift_opa = opa;
shift_opb = opb;
result = 0;
repeat(size)
begin
if(shift_opb[1])
result = result + shift_opa;
shift_opa = shift_opa << 1;
shift_opb = shift_opb >> 1;
end
end
endmodule
1100左移1位1000
1010右移1位0101
判断是否大于一,若是左移再与原来的数相加就实现了乘法的功能
编译不了??
