# Untitled

Jun 16th, 2019
641
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. (* techmap_celltype = "\$add" *)
2. module _80_74283_add (A, B, Y);
3.
4. parameter A_SIGNED = 0;
5. parameter B_SIGNED = 0;
6. parameter A_WIDTH = 4;
7. parameter B_WIDTH = 4;
8. parameter Y_WIDTH = 4;
9.
10. input [A_WIDTH-1:0] A;
11. input [B_WIDTH-1:0] B;
12. output [Y_WIDTH-1:0] Y;
13.
14. wire _TECHMAP_FAIL_ = Y_WIDTH <= 1;
15.
16. localparam WIDTH = ((Y_WIDTH + 3) / 4) * 4;
17.
18. wire [Y_WIDTH-1:0] A_buf, B_buf;
19. wire [WIDTH-1:0] Y_buf;
20. \\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
21. \\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
22.
23. wire [Y_WIDTH-1:0] AA = A_buf;
24. wire [Y_WIDTH-1:0] BB = B_buf;
25. wire [WIDTH-1:0] YY = Y_buf;
26. wire [Y_WIDTH:0] C;
27.
28. assign C[0] = 0;
29.
30. genvar i;
31. generate for (i = 0; i < WIDTH; i = i + 4) begin:slice
33.         .A(AA[i+3:i]),
34.         .B(BB[i+3:i]),
35.         .CI(C[i]),
36.         .S(YY[i+3:i]),
37.         .CO(C[i+4]),
38.     );
39. end
40. endgenerate
41.
42. assign Y = YY[Y_WIDTH-1:0];
43.
44. endmodule
RAW Paste Data