Multiplier1.v.html 787 B

12345678910111213141516171819202122232425262728
  1. `timescale 1ns / 1ps // NW 29.4.2011
  2. module Multiplier1(
  3. input clk, run, u,
  4. output stall,
  5. input [31:0] x, y,
  6. output [63:0] z);
  7. reg S; // state
  8. reg [15:0] z0;
  9. reg [47:0] z1, z2;
  10. wire [35:0] p0, p1, p2, p3;
  11. assign stall = run & ~S;
  12. assign z[15:0] = z0;
  13. assign z[63:16] = z1 + z2;
  14. MULT18X18 mult0(.P(p0), .A({2'b0, x[15:0]}), .B({2'b0, y[15:0]}));
  15. MULT18X18 mult1(.P(p1), .A({{2{u&x[31]}}, x[31:16]}), .B({2'b0, y[15:0]}));
  16. MULT18X18 mult2(.P(p2), .A({2'b0, x[15:0]}), .B({{2{u&y[31]}}, y[31:16]}));
  17. MULT18X18 mult3(.P(p3), .A({{2{u&x[31]}}, x[31:16]}), .B({{2{u&y[31]}}, y[31:16]}));
  18. always @(posedge clk) begin
  19. S <= stall;
  20. z0 <= p0[15:0];
  21. z1 <= {{32'b0}, p0[31:16]} + {{16{u&p1[31]}}, p1[31:0]};
  22. z2 <= {{16{u&p2[31]}}, p2[31:0]} + {p3[31:0], 16'b0};
  23. end
  24. endmodule