Lösung des ESY6/A Praktikums "signal_processing".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Multiply.v 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. //----------------------------------------------------------------------
  2. // Multiply: Complex Multiplier
  3. //----------------------------------------------------------------------
  4. module Multiply #(
  5. parameter WIDTH = 16
  6. )(
  7. input signed [WIDTH-1:0] a_re,
  8. input signed [WIDTH-1:0] a_im,
  9. input signed [WIDTH-1:0] b_re,
  10. input signed [WIDTH-1:0] b_im,
  11. output signed [WIDTH-1:0] m_re,
  12. output signed [WIDTH-1:0] m_im
  13. );
  14. wire signed [WIDTH*2-1:0] arbr, arbi, aibr, aibi;
  15. wire signed [WIDTH-1:0] sc_arbr, sc_arbi, sc_aibr, sc_aibi;
  16. // Signed Multiplication
  17. assign arbr = a_re * b_re;
  18. assign arbi = a_re * b_im;
  19. assign aibr = a_im * b_re;
  20. assign aibi = a_im * b_im;
  21. // Scaling
  22. assign sc_arbr = arbr >>> (WIDTH-1);
  23. assign sc_arbi = arbi >>> (WIDTH-1);
  24. assign sc_aibr = aibr >>> (WIDTH-1);
  25. assign sc_aibi = aibi >>> (WIDTH-1);
  26. // Sub/Add
  27. // These sub/add may overflow if unnormalized data is input.
  28. assign m_re = sc_arbr - sc_aibi;
  29. assign m_im = sc_arbi + sc_aibr;
  30. endmodule