Lösung des Praktikums Systementwurf
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.

SdfUnit2.v 3.4KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //----------------------------------------------------------------------
  2. // SdfUnit2: Radix-2 SDF Dedicated for Twiddle Resolution M = 2
  3. //----------------------------------------------------------------------
  4. module SdfUnit2 #(
  5. parameter WIDTH = 16, // Data Bit Length
  6. parameter BF_RH = 0 // Butterfly Round Half Up
  7. )(
  8. input clock, // Master Clock
  9. input reset, // Active High Asynchronous Reset
  10. input di_en, // Input Data Enable
  11. input [WIDTH-1:0] di_re, // Input Data (Real)
  12. input [WIDTH-1:0] di_im, // Input Data (Imag)
  13. output reg do_en, // Output Data Enable
  14. output reg [WIDTH-1:0] do_re, // Output Data (Real)
  15. output reg [WIDTH-1:0] do_im // Output Data (Imag)
  16. );
  17. //----------------------------------------------------------------------
  18. // Internal Regs and Nets
  19. //----------------------------------------------------------------------
  20. reg bf_en; // Butterfly Add/Sub Enable
  21. wire[WIDTH-1:0] x0_re; // Data #0 to Butterfly (Real)
  22. wire[WIDTH-1:0] x0_im; // Data #0 to Butterfly (Imag)
  23. wire[WIDTH-1:0] x1_re; // Data #1 to Butterfly (Real)
  24. wire[WIDTH-1:0] x1_im; // Data #1 to Butterfly (Imag)
  25. wire[WIDTH-1:0] y0_re; // Data #0 from Butterfly (Real)
  26. wire[WIDTH-1:0] y0_im; // Data #0 from Butterfly (Imag)
  27. wire[WIDTH-1:0] y1_re; // Data #1 from Butterfly (Real)
  28. wire[WIDTH-1:0] y1_im; // Data #1 from Butterfly (Imag)
  29. wire[WIDTH-1:0] db_di_re; // Data to DelayBuffer (Real)
  30. wire[WIDTH-1:0] db_di_im; // Data to DelayBuffer (Imag)
  31. wire[WIDTH-1:0] db_do_re; // Data from DelayBuffer (Real)
  32. wire[WIDTH-1:0] db_do_im; // Data from DelayBuffer (Imag)
  33. wire[WIDTH-1:0] bf_sp_re; // Single-Path Data Output (Real)
  34. wire[WIDTH-1:0] bf_sp_im; // Single-Path Data Output (Imag)
  35. reg bf_sp_en; // Single-Path Data Enable
  36. //----------------------------------------------------------------------
  37. // Butterfly Add/Sub
  38. //----------------------------------------------------------------------
  39. always @(posedge clock or posedge reset) begin
  40. if (reset) begin
  41. bf_en <= 1'b0;
  42. end else begin
  43. bf_en <= di_en ? ~bf_en : 1'b0;
  44. end
  45. end
  46. // Set unknown value x for verification
  47. assign x0_re = bf_en ? db_do_re : {WIDTH{1'bx}};
  48. assign x0_im = bf_en ? db_do_im : {WIDTH{1'bx}};
  49. assign x1_re = bf_en ? di_re : {WIDTH{1'bx}};
  50. assign x1_im = bf_en ? di_im : {WIDTH{1'bx}};
  51. Butterfly #(.WIDTH(WIDTH),.RH(BF_RH)) BF (
  52. .x0_re (x0_re ), // i
  53. .x0_im (x0_im ), // i
  54. .x1_re (x1_re ), // i
  55. .x1_im (x1_im ), // i
  56. .y0_re (y0_re ), // o
  57. .y0_im (y0_im ), // o
  58. .y1_re (y1_re ), // o
  59. .y1_im (y1_im ) // o
  60. );
  61. DelayBuffer #(.DEPTH(1),.WIDTH(WIDTH)) DB (
  62. .clock (clock ), // i
  63. .di_re (db_di_re ), // i
  64. .di_im (db_di_im ), // i
  65. .do_re (db_do_re ), // o
  66. .do_im (db_do_im ) // o
  67. );
  68. assign db_di_re = bf_en ? y1_re : di_re;
  69. assign db_di_im = bf_en ? y1_im : di_im;
  70. assign bf_sp_re = bf_en ? y0_re : db_do_re;
  71. assign bf_sp_im = bf_en ? y0_im : db_do_im;
  72. always @(posedge clock or posedge reset) begin
  73. if (reset) begin
  74. bf_sp_en <= 1'b0;
  75. do_en <= 1'b0;
  76. end else begin
  77. bf_sp_en <= di_en;
  78. do_en <= bf_sp_en;
  79. end
  80. end
  81. always @(posedge clock) begin
  82. do_re <= bf_sp_re;
  83. do_im <= bf_sp_im;
  84. end
  85. endmodule