module mul
tiple( clk, rst_n, ain, bin, start, qout, );input clk;input rst_n;input start;input [15:0] ain,bin;output [31:0] qout; reg [15:0] areg,breg;reg [31:0] qout_r; integer i; always @(posedge clk or negedge rst_n) begin if (!rst_n) begin areg<=16'h0000; breg<=16'h0000; qout_r<=32'h0000_0000; end else if (start) begin areg<=ain; breg<=bin; qout_r<=32'h0000_0000; for(i=0;i<=15;i=i+1) if(breg
) qout_r<=qout_r+(areg<<i); end end assign qout=qout_r; endmodule
一周热门 更多>