Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. module recursion #(parameter SIZE = 8)(
  2. input wire [32*SIZE - 1:0] a ,
  3. output reg [31: 0] out,
  4. input wire clk
  5. );
  6. wire [31:0] out0,out1;
  7.  
  8. generate
  9. if(SIZE == 1) begin
  10. assign out0[31:0] = a[31:0];
  11. assign out1[31:0] = 32'b0;
  12. end else if(SIZE == 2) begin
  13. assign out0[31:0] = a[31:0];
  14. assign out1[31:0] = a[63:32];
  15. end else begin
  16. recursion #(SIZE / 2) re0(
  17. .a(a[32*(SIZE / 2) - 1:0]),
  18. .clk( clk),
  19. .out(out0));
  20. recursion #(SIZE - SIZE / 2) re1 (
  21. .a(a[32*SIZE - 1:32*(SIZE / 2)]) ,
  22. .clk( clk),
  23. .out(out1) );
  24. end
  25. endgenerate
  26.  
  27. always @ (posedge clk) begin
  28. out <= out0 + out1;
  29. end
  30. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement