2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 // ============================================================================
32 // Need to swap input ordering of wide LUTs, and fix init accordingly,
33 // to match ABC's expectation of LUT inputs in non-decreasing
35 function [WIDTH-1:0] permute_index;
40 permute_index = { i[5:0], i[6] };
42 permute_index = { i[5:0], i[6], i[7] };
48 function [2**WIDTH-1:0] permute_init;
52 for (i = 0; i < 2**WIDTH; i = i + 1)
53 permute_init[i] = LUT[permute_index(i)];
57 parameter [2**WIDTH-1:0] P_LUT = permute_init();
61 LUT1 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
65 LUT2 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
66 .I0(A[0]), .I1(A[1]));
69 LUT3 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
70 .I0(A[0]), .I1(A[1]), .I2(A[2]));
73 LUT4 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
74 .I0(A[0]), .I1(A[1]), .I2(A[2]),
78 LUT5 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
79 .I0(A[0]), .I1(A[1]), .I2(A[2]),
80 .I3(A[3]), .I4(A[4]));
83 LUT6 #(.INIT(P_LUT)) _TECHMAP_REPLACE_ (.O(Y),
84 .I0(A[0]), .I1(A[1]), .I2(A[2]),
85 .I3(A[3]), .I4(A[4]), .I5(A[5]));
89 LUT6 #(.INIT(P_LUT[63:0])) fpga_lut_0 (.O(T0),
90 .I0(A[1]), .I1(A[2]), .I2(A[3]),
91 .I3(A[4]), .I4(A[5]), .I5(A[6]));
92 LUT6 #(.INIT(P_LUT[127:64])) fpga_lut_1 (.O(T1),
93 .I0(A[1]), .I1(A[2]), .I2(A[3]),
94 .I3(A[4]), .I4(A[5]), .I5(A[6]));
95 MUXF7 fpga_mux_0 (.O(Y), .I0(T0), .I1(T1), .S(A[0]));
98 wire T0, T1, T2, T3, T4, T5;
99 LUT6 #(.INIT(P_LUT[63:0])) fpga_lut_0 (.O(T0),
100 .I0(A[2]), .I1(A[3]), .I2(A[4]),
101 .I3(A[5]), .I4(A[6]), .I5(A[7]));
102 LUT6 #(.INIT(P_LUT[127:64])) fpga_lut_1 (.O(T1),
103 .I0(A[2]), .I1(A[3]), .I2(A[4]),
104 .I3(A[5]), .I4(A[6]), .I5(A[7]));
105 LUT6 #(.INIT(P_LUT[191:128])) fpga_lut_2 (.O(T2),
106 .I0(A[2]), .I1(A[3]), .I2(A[4]),
107 .I3(A[5]), .I4(A[6]), .I5(A[7]));
108 LUT6 #(.INIT(P_LUT[255:192])) fpga_lut_3 (.O(T3),
109 .I0(A[2]), .I1(A[3]), .I2(A[4]),
110 .I3(A[5]), .I4(A[6]), .I5(A[7]));
111 MUXF7 fpga_mux_0 (.O(T4), .I0(T0), .I1(T1), .S(A[1]));
112 MUXF7 fpga_mux_1 (.O(T5), .I0(T2), .I1(T3), .S(A[1]));
113 MUXF8 fpga_mux_2 (.O(Y), .I0(T4), .I1(T5), .S(A[0]));
115 wire _TECHMAP_FAIL_ = 1;