generic: Add simple primitive library
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
50fd8aa01f
commit
f88ddf85b2
12
generic/synth/cells_map.v
Normal file
12
generic/synth/cells_map.v
Normal file
@ -0,0 +1,12 @@
|
||||
module \$lut (A, Y);
|
||||
parameter WIDTH = 0;
|
||||
parameter LUT = 0;
|
||||
input [WIDTH-1:0] A;
|
||||
output Y;
|
||||
|
||||
LUT #(.K(`LUT_K), .INIT(LUT)) _TECHMAP_REPLACE_ (.I(A), .Q(Y));
|
||||
endmodule
|
||||
|
||||
|
||||
module \$_DFF_N_ (input D, C, output Q); DFF _TECHMAP_REPLACE_ (.D(D), .Q(Q), .CLK(C)); endmodule
|
||||
module \$_DFF_P_ (input D, C, output Q); DFF _TECHMAP_REPLACE_ (.D(D), .Q(Q), .CLK(!C)); endmodule
|
59
generic/synth/prims.v
Normal file
59
generic/synth/prims.v
Normal file
@ -0,0 +1,59 @@
|
||||
// LUT and DFF are combined to a GENERIC_SLICE
|
||||
|
||||
module LUT #(
|
||||
parameter K = 4,
|
||||
parameter [2**K-1:0] INIT = 0,
|
||||
) (
|
||||
input [K-1:0] I,
|
||||
output Q
|
||||
);
|
||||
assign Q = INIT[I];
|
||||
endmodule
|
||||
|
||||
module DFF (
|
||||
input CLK, D,
|
||||
output reg Q
|
||||
);
|
||||
always @(posedge CLK)
|
||||
Q <= D;
|
||||
endmodule
|
||||
|
||||
module GENERIC_SLICE #(
|
||||
parameter K = 4,
|
||||
parameter [2**K-1:0] INIT = 0,
|
||||
parameter FF_USED = 1'b0
|
||||
) (
|
||||
input CLK,
|
||||
input [K-1:0] I,
|
||||
output Q
|
||||
);
|
||||
|
||||
wire lut_q;
|
||||
LUT #(.K(K), .INIT(INIT)) lut_i(.I(I), .Q(lut_q));
|
||||
|
||||
generate if (FF_USED)
|
||||
DFF dff_i(.CLK(CLK), .D(lut_q), .Q(Q));
|
||||
else
|
||||
assign Q = lut_q;
|
||||
endgenerate
|
||||
endmodule
|
||||
|
||||
module GENERIC_IOB #(
|
||||
parameter INPUT_USED = 1'b0,
|
||||
parameter OUTPUT_USED = 1'b0,
|
||||
parameter ENABLE_USED = 1'b0
|
||||
) (
|
||||
inout PAD,
|
||||
input I, EN,
|
||||
output O
|
||||
);
|
||||
generate if (OUTPUT_USED && ENABLE_USED)
|
||||
assign PAD = EN ? I : 1'bz;
|
||||
else if (OUTPUT_USED)
|
||||
assign PAD = I;
|
||||
endgenerate
|
||||
|
||||
generate if (INPUT_USED)
|
||||
assign O = PAD;
|
||||
endgenerate
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user