aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/xilinx/cells.v
blob: 5bf8ccd86ae6e276bebbc0fea15da219c7ab55a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
module  \$_DFF_P_ (D, C, Q);

  input D, C;
  output Q;

  FDRE fpga_dff (
  	.D(D), .Q(Q), .C(C),
  	.CE(1'b1), .R(1'b0)
  );

endmodule

module \$lut (I, O);

  parameter WIDTH = 0;
  parameter LUT = 0;

  input [WIDTH-1:0] I;
  output O;

  generate
    if (WIDTH == 1) begin:lut1
      LUT1 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]));
    end else
    if (WIDTH == 2) begin:lut2
      LUT2 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]), .I1(I[1]));
    end else
    if (WIDTH == 3) begin:lut3
      LUT3 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]), .I1(I[1]), .I2(I[2]));
    end else
    if (WIDTH == 4) begin:lut4
      LUT4 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]), .I1(I[1]), .I2(I[2]),
        .I3(I[3]));
    end else
    if (WIDTH == 5) begin:lut5
      LUT5 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]), .I1(I[1]), .I2(I[2]),
        .I3(I[3]), .I4(I[4]));
    end else
    if (WIDTH == 6) begin:lut6
      LUT6 #(.INIT(LUT)) fpga_lut (.O(O),
        .I0(I[0]), .I1(I[1]), .I2(I[2]),
        .I3(I[3]), .I4(I[4]), .I5(I[5]));
    end else begin:error
      wire _TECHMAP_FAIL_ = 1;
    end
  endgenerate

endmodule
span> return False def __ne__(self, other): return not self.__eq__(other) def __hash__(self): return hash(frozenset(self.__dict__.items())) def set_state(self, state): for k, v in state.items(): if k == "headers": v = headers.Headers.from_state(v) setattr(self, k, v) def get_state(self): state = vars(self).copy() state["headers"] = state["headers"].get_state() return state @classmethod def from_state(cls, state): state["headers"] = headers.Headers.from_state(state["headers"]) return cls(**state) class Message(basetypes.Serializable): def __eq__(self, other): if isinstance(other, Message): return self.data == other.data return False def __ne__(self, other): return not self.__eq__(other) def __hash__(self): return hash(self.data) ^ 1 def get_state(self): return self.data.get_state() def set_state(self, state): self.data.set_state(state) @classmethod def from_state(cls, state): state["headers"] = headers.Headers.from_state(state["headers"]) return cls(**state) @property def headers(self): """ Message headers object Returns: netlib.http.Headers """ return self.data.headers @headers.setter def headers(self, h): self.data.headers = h @property def content(self): """ The raw (encoded) HTTP message body See also: :py:attr:`text` """ return self.data.content @content.setter def content(self, content): self.data.content = content if isinstance(content, bytes): self.headers["content-length"] = str(len(content)) @property def http_version(self): """ Version string, e.g. "HTTP/1.1" """ return _native(self.data.http_version) @http_version.setter def http_version(self, http_version): self.data.http_version = _always_bytes(http_version) @property def timestamp_start(self): """ First byte timestamp """ return self.data.timestamp_start @timestamp_start.setter def timestamp_start(self, timestamp_start): self.data.timestamp_start = timestamp_start @property def timestamp_end(self): """ Last byte timestamp """ return self.data.timestamp_end @timestamp_end.setter def timestamp_end(self, timestamp_end): self.data.timestamp_end = timestamp_end @property def text(self): """ The decoded HTTP message body. Decoded contents are not cached, so accessing this attribute repeatedly is relatively expensive. .. note:: This is not implemented yet. See also: :py:attr:`content`, :py:class:`decoded` """ # This attribute should be called text, because that's what requests does. raise NotImplementedError() @text.setter def text(self, text): raise NotImplementedError() def decode(self): """ Decodes body based on the current Content-Encoding header, then removes the header. If there is no Content-Encoding header, no action is taken. Returns: True, if decoding succeeded. False, otherwise. """ ce = self.headers.get("content-encoding") data = encoding.decode(ce, self.content) if data is None: return False self.content = data self.headers.pop("content-encoding", None) return True def encode(self, e): """ Encodes body with the encoding e, where e is "gzip", "deflate" or "identity". Returns: True, if decoding succeeded. False, otherwise. """ data = encoding.encode(e, self.content) if data is None: return False self.content = data self.headers["content-encoding"] = e return True def replace(self, pattern, repl, flags=0): """ Replaces a regular expression pattern with repl in both the headers and the body of the message. Encoded body will be decoded before replacement, and re-encoded afterwards. Returns: The number of replacements made. """ if isinstance(pattern, six.text_type): pattern = strutils.escaped_str_to_bytes(pattern) if isinstance(repl, six.text_type): repl = strutils.escaped_str_to_bytes(repl) replacements = 0 if self.content: with decoded(self): self.content, replacements = re.subn( pattern, repl, self.content, flags=flags ) replacements += self.headers.replace(pattern, repl, flags) return replacements # Legacy @property def body(self): # pragma: no cover warnings.warn(".body is deprecated, use .content instead.", DeprecationWarning) return self.content @body.setter def body(self, body): # pragma: no cover warnings.warn(".body is deprecated, use .content instead.", DeprecationWarning) self.content = body class decoded(object): """ A context manager that decodes a request or response, and then re-encodes it with the same encoding after execution of the block. Example: .. code-block:: python with decoded(request): request.content = request.content.replace("foo", "bar") """ def __init__(self, message): self.message = message ce = message.headers.get("content-encoding") if ce in encoding.ENCODINGS: self.ce = ce else: self.ce = None def __enter__(self): if self.ce: self.message.decode() def __exit__(self, type, value, tb): if self.ce: self.message.encode(self.ce)