-
-
Save gocreating/7bb8b3bbf47f57535457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module multiplier(load, clk, m1, m2, ready, P); | |
input [7:0] m1, m2; | |
input load, clk; | |
output [15:0] P; | |
output ready; | |
reg [7:0] A, B; | |
reg [15:0] pp, P; | |
reg ready; | |
always@(posedge clk or load) begin | |
if (load) begin | |
{A, B} = {m1, m2}; | |
ready = 0; | |
P = {8'b0, B}; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
pp = B[0]? {A, 8'b0}: 16'b0; | |
P = P + pp; | |
P = P >> 1; | |
end else begin | |
#9 ready = 1; | |
{A, B} = {A, B}; | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment