| 1 |
// LUT and DFF are combined to a GENERIC_SLICE |
| 2 |
|
| 3 |
module LUT #( |
| 4 |
parameter K = 4, |
| 5 |
parameter [2**K-1:0] INIT = 0, |
| 6 |
) ( |
| 7 |
input [K-1:0] I, |
| 8 |
output Q |
| 9 |
); |
| 10 |
assign Q = INIT[I]; |
| 11 |
endmodule |
| 12 |
|
| 13 |
module DFF ( |
| 14 |
input CLK, D, |
| 15 |
output reg Q |
| 16 |
); |
| 17 |
always @(posedge CLK) |
| 18 |
Q <= D; |
| 19 |
endmodule |
| 20 |
|
| 21 |
module GENERIC_SLICE #( |
| 22 |
parameter K = 4, |
| 23 |
parameter [2**K-1:0] INIT = 0, |
| 24 |
parameter FF_USED = 1'b0 |
| 25 |
) ( |
| 26 |
input CLK, |
| 27 |
input [K-1:0] I, |
| 28 |
output F, |
| 29 |
output Q |
| 30 |
); |
| 31 |
wire f_wire; |
| 32 |
|
| 33 |
LUT #(.K(K), .INIT(INIT)) lut_i(.I(I), .Q(f_wire)); |
| 34 |
|
| 35 |
DFF dff_i(.CLK(CLK), .D(f_wire), .Q(Q)); |
| 36 |
|
| 37 |
assign F = f_wire; |
| 38 |
endmodule |
| 39 |
|
| 40 |
module GENERIC_IOB #( |
| 41 |
parameter INPUT_USED = 1'b0, |
| 42 |
parameter OUTPUT_USED = 1'b0, |
| 43 |
parameter ENABLE_USED = 1'b0 |
| 44 |
) ( |
| 45 |
inout PAD, |
| 46 |
input I, EN, |
| 47 |
output O |
| 48 |
); |
| 49 |
generate if (OUTPUT_USED && ENABLE_USED) |
| 50 |
assign PAD = EN ? I : 1'bz; |
| 51 |
else if (OUTPUT_USED) |
| 52 |
assign PAD = I; |
| 53 |
endgenerate |
| 54 |
|
| 55 |
generate if (INPUT_USED) |
| 56 |
assign O = PAD; |
| 57 |
endgenerate |
| 58 |
endmodule |