module \$_DFF_N_ (input D, C, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(!C), .EN(1'b1), .ALn(1'b1), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_P_ (input D, C, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(C), .EN(1'b1), .ALn(1'b1), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_NN0_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(!C), .EN(1'b1), .ALn(R), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_NN1_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(!C), .EN(1'b1), .ALn(R), .ADn(1'b0), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_NP0_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(!C), .EN(1'b1), .ALn(!R), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_NP1_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(!C), .EN(1'b1), .ALn(!R), .ADn(1'b0), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_PN0_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(C), .EN(1'b1), .ALn(R), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_PN1_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(C), .EN(1'b1), .ALn(R), .ADn(1'b0), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_PP0_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(C), .EN(1'b1), .ALn(!R), .ADn(1'b1), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule module \$_DFF_PP1_ (input D, C, R, output Q); SLE _TECHMAP_REPLACE_ (.D(D), .CLK(C), .EN(1'b1), .ALn(!R), .ADn(1'b0), .SLn(1'b1), .SD(1'b0), .LAT(1'b0), .Q(Q)); endmodule // module \$_DFFE_NN_ (input D, C, E, output Q); SB_DFFNE _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(!E)); endmodule // module \$_DFFE_PN_ (input D, C, E, output Q); SB_DFFE _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(!E)); endmodule // // module \$_DFFE_NP_ (input D, C, E, output Q); SB_DFFNE _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E)); endmodule // module \$_DFFE_PP_ (input D, C, E, output Q); SB_DFFE _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E)); endmodule // // module \$__DFFE_NN0 (input D, C, E, R, output Q); SB_DFFNER _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .R(!R)); endmodule // module \$__DFFE_NN1 (input D, C, E, R, output Q); SB_DFFNES _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .S(!R)); endmodule // module \$__DFFE_PN0 (input D, C, E, R, output Q); SB_DFFER _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .R(!R)); endmodule // module \$__DFFE_PN1 (input D, C, E, R, output Q); SB_DFFES _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .S(!R)); endmodule // // module \$__DFFE_NP0 (input D, C, E, R, output Q); SB_DFFNER _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .R(R)); endmodule // module \$__DFFE_NP1 (input D, C, E, R, output Q); SB_DFFNES _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .S(R)); endmodule // module \$__DFFE_PP0 (input D, C, E, R, output Q); SB_DFFER _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .R(R)); endmodule // module \$__DFFE_PP1 (input D, C, E, R, output Q); SB_DFFES _TECHMAP_REPLACE_ (.D(D), .Q(Q), .C(C), .E(E), .S(R)); endmodule `ifndef NO_LUT module \$lut (A, Y); parameter WIDTH = 0; parameter LUT = 0; input [WIDTH-1:0] A; output Y; generate if (WIDTH == 1) begin CFG1 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.Y(Y), .A(A[0])); end else if (WIDTH == 2) begin CFG2 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.Y(Y), .A(A[0]), .B(A[1])); end else if (WIDTH == 3) begin CFG3 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.Y(Y), .A(A[0]), .B(A[1]), .C(A[2])); end else if (WIDTH == 4) begin CFG4 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.Y(Y), .A(A[0]), .B(A[1]), .C(A[2]), .D(A[3])); end else begin wire _TECHMAP_FAIL_ = 1; end endgenerate endmodule `endif href='#n28'>28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
# =============================================================================
# ____ _ _ ____ _ _ _ _ _ _ _
# _ __ _ _ / ___| | | | _ \| | | (_) |__ __ _| |__ __| | |
# | '_ \| | | | | _| |_| | | | | | | | | '_ \ / _` | '_ \ / _` | |
# | |_) | |_| | |_| | _ | |_| | |___ _| | | |_) | (_| | | | | (_| | |
# | .__/ \__, |\____|_| |_|____/|_____(_)_|_|_.__/ \__, |_| |_|\__,_|_|
# |_| |___/ |___/
# =============================================================================
# Authors:
# Tristan Gingold
# Patrick Lehmann
#
# Package module: Python binding and low-level API for shared library 'libghdl'.
#
# License:
# ============================================================================
# Copyright (C) 2019-2021 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
from ctypes import c_int32, c_char_p, c_bool, c_uint32
from pyTooling.Decorators import export
from pyGHDL.libghdl import libghdl, ENCODING
from pyGHDL.libghdl._decorator import BindToLibGHDL
from pyGHDL.libghdl._types import SourceFileEntry
# @export
@BindToLibGHDL("files_map__editor__replace_text_ptr")
def _Replace_Text(
File: SourceFileEntry,
Start_Line: int,
Start_Offset: int,
End_Line: int,
End_Offset: int,
Text_Pointer: c_char_p,
Text_Length: int,
) -> bool:
"""Replace [START; END) by TEXT.
:param File: File where to replace a text section.
:param Start_Line:
:param Start_Offset:
:param End_Line:
:param End_Offset:
:param Text_Pointer: Type: ``File_Buffer_Ptr``
:param Text_Length: Type: ``Source_Ptr``
:return: Return True in case of success, False in case of failure (the gap is too small).
"""
return False
@export
def Replace_Text(
File: SourceFileEntry,
Start_Line: int,
Start_Offset: int,
End_Line: int,
End_Offset: int,
Text: str,
) -> bool:
"""Replace [START; END) by TEXT.
:param File: File where to replace a text section.
:param Start_Line: undocumented
:param Start_Offset: undocumented
:param End_Line: undocumented
:param End_Offset: undocumented
:param Text: undocumented
:return: Return True in case of success, False in case of failure (the gap is too small).
"""
buffer = Text.encode(ENCODING)
return _Replace_Text(
File,
Start_Line,
Start_Offset,
End_Line,
End_Offset,
c_char_p(buffer),
len(buffer),
)
@export
# @BindToLibGHDL("files_map__editor__fill_text_ptr")
def Fill_Text(File: SourceFileEntry, Text_Pointer, Text_Length: int) -> None:
"""Replace the content of :obj:`File` with TEXT.
.. todo:: Replace ``Text_Pointer`` and ``Text_Length`` with Python string
:param File: File where to replace the content.
:param Text_Pointer: Type: ``File_Buffer_Ptr``
:param Text_Length: Type: ``Source_Ptr``
"""
libghdl.files_map__editor__fill_text_ptr(File, Text_Pointer, Text_Length)
@export
# @BindToLibGHDL("files_map__editor__check_buffer_content")
def Check_Buffer_Content(File: SourceFileEntry, String_Pointer: c_char_p, String_Length: c_uint32) -> None:
"""
Check that content of :obj:`File` is STR[1 .. STR_LEN].
.. todo:: Replace ``String_Pointer`` and ``String_Length`` with Python string
:param File: File to check the content.
:param String_Pointer: Type: ``File_Buffer_Ptr``
:param String_Length: Type: ``Source_Ptr``
"""
libghdl.files_map__editor__check_buffer_content(File, String_Pointer, String_Length)
@export
@BindToLibGHDL("files_map__editor__copy_source_file")
def Copy_Source_File(Dest: SourceFileEntry, Src: SourceFileEntry) -> None:
"""
Copy content of :obj:`Src` to :obj:`Dest`.
.. warning:: The size of :obj:`Dest` must be large enough.
Clear lines table of :obj:`Dest`.
"""