partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Cmd.do_REVERSE | Do a reverse search. Args: lat lon.
REVERSE 48.1234 2.9876 | addok/shell.py | def do_REVERSE(self, latlon):
"""Do a reverse search. Args: lat lon.
REVERSE 48.1234 2.9876"""
lat, lon = latlon.split()
for r in reverse(float(lat), float(lon)):
print('{} ({} | {} km | {})'.format(white(r), blue(r.score),
blue... | def do_REVERSE(self, latlon):
"""Do a reverse search. Args: lat lon.
REVERSE 48.1234 2.9876"""
lat, lon = latlon.split()
for r in reverse(float(lat), float(lon)):
print('{} ({} | {} km | {})'.format(white(r), blue(r.score),
blue... | [
"Do",
"a",
"reverse",
"search",
".",
"Args",
":",
"lat",
"lon",
".",
"REVERSE",
"48",
".",
"1234",
"2",
".",
"9876"
] | addok/addok | python | https://github.com/addok/addok/blob/46a270d76ec778d2b445c2be753e5c6ba070a9b2/addok/shell.py#L394-L400 | [
"def",
"do_REVERSE",
"(",
"self",
",",
"latlon",
")",
":",
"lat",
",",
"lon",
"=",
"latlon",
".",
"split",
"(",
")",
"for",
"r",
"in",
"reverse",
"(",
"float",
"(",
"lat",
")",
",",
"float",
"(",
"lon",
")",
")",
":",
"print",
"(",
"'{} ({} | {} ... | 46a270d76ec778d2b445c2be753e5c6ba070a9b2 |
test | Cmd.do_STRDISTANCE | Print the distance score between two strings. Use | as separator.
STRDISTANCE rue des lilas|porte des lilas | addok/shell.py | def do_STRDISTANCE(self, s):
"""Print the distance score between two strings. Use | as separator.
STRDISTANCE rue des lilas|porte des lilas"""
s = s.split('|')
if not len(s) == 2:
print(red('Malformed string. Use | between the two strings.'))
return
one, t... | def do_STRDISTANCE(self, s):
"""Print the distance score between two strings. Use | as separator.
STRDISTANCE rue des lilas|porte des lilas"""
s = s.split('|')
if not len(s) == 2:
print(red('Malformed string. Use | between the two strings.'))
return
one, t... | [
"Print",
"the",
"distance",
"score",
"between",
"two",
"strings",
".",
"Use",
"|",
"as",
"separator",
".",
"STRDISTANCE",
"rue",
"des",
"lilas|porte",
"des",
"lilas"
] | addok/addok | python | https://github.com/addok/addok/blob/46a270d76ec778d2b445c2be753e5c6ba070a9b2/addok/shell.py#L407-L415 | [
"def",
"do_STRDISTANCE",
"(",
"self",
",",
"s",
")",
":",
"s",
"=",
"s",
".",
"split",
"(",
"'|'",
")",
"if",
"not",
"len",
"(",
"s",
")",
"==",
"2",
":",
"print",
"(",
"red",
"(",
"'Malformed string. Use | between the two strings.'",
")",
")",
"return... | 46a270d76ec778d2b445c2be753e5c6ba070a9b2 |
test | Cmd.do_CONFIG | Inspect loaded Addok config. Output all config without argument.
CONFIG [CONFIG_KEY] | addok/shell.py | def do_CONFIG(self, name):
"""Inspect loaded Addok config. Output all config without argument.
CONFIG [CONFIG_KEY]"""
if not name:
for name in self.complete_CONFIG():
self.do_CONFIG(name)
return
value = getattr(config, name.upper(), 'Not found.')
... | def do_CONFIG(self, name):
"""Inspect loaded Addok config. Output all config without argument.
CONFIG [CONFIG_KEY]"""
if not name:
for name in self.complete_CONFIG():
self.do_CONFIG(name)
return
value = getattr(config, name.upper(), 'Not found.')
... | [
"Inspect",
"loaded",
"Addok",
"config",
".",
"Output",
"all",
"config",
"without",
"argument",
".",
"CONFIG",
"[",
"CONFIG_KEY",
"]"
] | addok/addok | python | https://github.com/addok/addok/blob/46a270d76ec778d2b445c2be753e5c6ba070a9b2/addok/shell.py#L417-L425 | [
"def",
"do_CONFIG",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"for",
"name",
"in",
"self",
".",
"complete_CONFIG",
"(",
")",
":",
"self",
".",
"do_CONFIG",
"(",
"name",
")",
"return",
"value",
"=",
"getattr",
"(",
"config",
",",
... | 46a270d76ec778d2b445c2be753e5c6ba070a9b2 |
test | Cmd.do_SCRIPT | Run a Lua script. Takes the raw Redis arguments.
SCRIPT script_name number_of_keys key1 key2… arg1 arg2 | addok/shell.py | def do_SCRIPT(self, args):
"""Run a Lua script. Takes the raw Redis arguments.
SCRIPT script_name number_of_keys key1 key2… arg1 arg2
"""
try:
name, keys_count, *args = args.split()
except ValueError:
print(red('Not enough arguments'))
return
... | def do_SCRIPT(self, args):
"""Run a Lua script. Takes the raw Redis arguments.
SCRIPT script_name number_of_keys key1 key2… arg1 arg2
"""
try:
name, keys_count, *args = args.split()
except ValueError:
print(red('Not enough arguments'))
return
... | [
"Run",
"a",
"Lua",
"script",
".",
"Takes",
"the",
"raw",
"Redis",
"arguments",
".",
"SCRIPT",
"script_name",
"number_of_keys",
"key1",
"key2…",
"arg1",
"arg2"
] | addok/addok | python | https://github.com/addok/addok/blob/46a270d76ec778d2b445c2be753e5c6ba070a9b2/addok/shell.py#L431-L460 | [
"def",
"do_SCRIPT",
"(",
"self",
",",
"args",
")",
":",
"try",
":",
"name",
",",
"keys_count",
",",
"",
"*",
"args",
"=",
"args",
".",
"split",
"(",
")",
"except",
"ValueError",
":",
"print",
"(",
"red",
"(",
"'Not enough arguments'",
")",
")",
"retu... | 46a270d76ec778d2b445c2be753e5c6ba070a9b2 |
test | send | Just sends the request using its send method and returns its response. | dcard/prequests.py | def send(r, stream=False):
"""Just sends the request using its send method and returns its response. """
r.send(stream=stream)
return r.response | def send(r, stream=False):
"""Just sends the request using its send method and returns its response. """
r.send(stream=stream)
return r.response | [
"Just",
"sends",
"the",
"request",
"using",
"its",
"send",
"method",
"and",
"returns",
"its",
"response",
"."
] | leVirve/dcard-spider | python | https://github.com/leVirve/dcard-spider/blob/ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46/dcard/prequests.py#L80-L83 | [
"def",
"send",
"(",
"r",
",",
"stream",
"=",
"False",
")",
":",
"r",
".",
"send",
"(",
"stream",
"=",
"stream",
")",
"return",
"r",
".",
"response"
] | ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46 |
test | map | Concurrently converts a list of Requests to Responses.
:param requests: a collection of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Specifies the number of workers to run at a time. If 1, no parallel processing.
:param exception_handler: Callba... | dcard/prequests.py | def map(requests, stream=True, pool=None, size=1, exception_handler=None):
"""Concurrently converts a list of Requests to Responses.
:param requests: a collection of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Specifies the number of workers to... | def map(requests, stream=True, pool=None, size=1, exception_handler=None):
"""Concurrently converts a list of Requests to Responses.
:param requests: a collection of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Specifies the number of workers to... | [
"Concurrently",
"converts",
"a",
"list",
"of",
"Requests",
"to",
"Responses",
"."
] | leVirve/dcard-spider | python | https://github.com/leVirve/dcard-spider/blob/ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46/dcard/prequests.py#L101-L127 | [
"def",
"map",
"(",
"requests",
",",
"stream",
"=",
"True",
",",
"pool",
"=",
"None",
",",
"size",
"=",
"1",
",",
"exception_handler",
"=",
"None",
")",
":",
"pool",
"=",
"pool",
"if",
"pool",
"else",
"Pool",
"(",
"size",
")",
"requests",
"=",
"list... | ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46 |
test | imap | Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Specifies the number of requests to make at a time. default is 2
:param exception_... | dcard/prequests.py | def imap(requests, stream=True, pool=None, size=2, exception_handler=None):
"""Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Spe... | def imap(requests, stream=True, pool=None, size=2, exception_handler=None):
"""Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Spe... | [
"Concurrently",
"converts",
"a",
"generator",
"object",
"of",
"Requests",
"to",
"a",
"generator",
"of",
"Responses",
"."
] | leVirve/dcard-spider | python | https://github.com/leVirve/dcard-spider/blob/ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46/dcard/prequests.py#L130-L152 | [
"def",
"imap",
"(",
"requests",
",",
"stream",
"=",
"True",
",",
"pool",
"=",
"None",
",",
"size",
"=",
"2",
",",
"exception_handler",
"=",
"None",
")",
":",
"def",
"send",
"(",
"r",
")",
":",
"return",
"r",
".",
"send",
"(",
"stream",
"=",
"stre... | ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46 |
test | imap_unordered | Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param size: Specifies the number of requests to make at a time. default is 2
:param exception_... | dcard/prequests.py | def imap_unordered(requests, stream=True, pool=None, size=2, exception_handler=None):
"""Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param... | def imap_unordered(requests, stream=True, pool=None, size=2, exception_handler=None):
"""Concurrently converts a generator object of Requests to
a generator of Responses.
:param requests: a generator of Request objects.
:param stream: If False, the content will not be downloaded immediately.
:param... | [
"Concurrently",
"converts",
"a",
"generator",
"object",
"of",
"Requests",
"to",
"a",
"generator",
"of",
"Responses",
"."
] | leVirve/dcard-spider | python | https://github.com/leVirve/dcard-spider/blob/ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46/dcard/prequests.py#L155-L178 | [
"def",
"imap_unordered",
"(",
"requests",
",",
"stream",
"=",
"True",
",",
"pool",
"=",
"None",
",",
"size",
"=",
"2",
",",
"exception_handler",
"=",
"None",
")",
":",
"def",
"send",
"(",
"r",
")",
":",
"return",
"r",
".",
"send",
"(",
"stream",
"=... | ac64cbcfe7ef6be7e554cef422b1a8a6bb968d46 |
test | getBits_from_array | Gets value of bits between selected range from memory
:param start: bit address of start of bit of bits
:param end: bit address of first bit behind bits
:return: instance of BitsVal (derived from SimBits type) which contains
copy of selected bits | hwt/hdl/types/arrayCast.py | def getBits_from_array(array, wordWidth, start, end,
reinterpretElmToType=None):
"""
Gets value of bits between selected range from memory
:param start: bit address of start of bit of bits
:param end: bit address of first bit behind bits
:return: instance of BitsVal (derived ... | def getBits_from_array(array, wordWidth, start, end,
reinterpretElmToType=None):
"""
Gets value of bits between selected range from memory
:param start: bit address of start of bit of bits
:param end: bit address of first bit behind bits
:return: instance of BitsVal (derived ... | [
"Gets",
"value",
"of",
"bits",
"between",
"selected",
"range",
"from",
"memory"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/arrayCast.py#L11-L49 | [
"def",
"getBits_from_array",
"(",
"array",
",",
"wordWidth",
",",
"start",
",",
"end",
",",
"reinterpretElmToType",
"=",
"None",
")",
":",
"inPartOffset",
"=",
"0",
"value",
"=",
"Bits",
"(",
"end",
"-",
"start",
",",
"None",
")",
".",
"fromPy",
"(",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | reinterptet_harray_to_bits | Cast HArray signal or value to signal or value of type Bits | hwt/hdl/types/arrayCast.py | def reinterptet_harray_to_bits(typeFrom, sigOrVal, bitsT):
"""
Cast HArray signal or value to signal or value of type Bits
"""
size = int(typeFrom.size)
widthOfElm = typeFrom.elmType.bit_length()
w = bitsT.bit_length()
if size * widthOfElm != w:
raise TypeConversionErr(
"... | def reinterptet_harray_to_bits(typeFrom, sigOrVal, bitsT):
"""
Cast HArray signal or value to signal or value of type Bits
"""
size = int(typeFrom.size)
widthOfElm = typeFrom.elmType.bit_length()
w = bitsT.bit_length()
if size * widthOfElm != w:
raise TypeConversionErr(
"... | [
"Cast",
"HArray",
"signal",
"or",
"value",
"to",
"signal",
"or",
"value",
"of",
"type",
"Bits"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/arrayCast.py#L52-L66 | [
"def",
"reinterptet_harray_to_bits",
"(",
"typeFrom",
",",
"sigOrVal",
",",
"bitsT",
")",
":",
"size",
"=",
"int",
"(",
"typeFrom",
".",
"size",
")",
"widthOfElm",
"=",
"typeFrom",
".",
"elmType",
".",
"bit_length",
"(",
")",
"w",
"=",
"bitsT",
".",
"bit... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | slice_to_SLICE | convert python slice to value of SLICE hdl type | hwt/hdl/types/sliceUtils.py | def slice_to_SLICE(sliceVals, width):
"""convert python slice to value of SLICE hdl type"""
if sliceVals.step is not None:
raise NotImplementedError()
start = sliceVals.start
stop = sliceVals.stop
if sliceVals.start is None:
start = INT.fromPy(width)
else:
start = toHVa... | def slice_to_SLICE(sliceVals, width):
"""convert python slice to value of SLICE hdl type"""
if sliceVals.step is not None:
raise NotImplementedError()
start = sliceVals.start
stop = sliceVals.stop
if sliceVals.start is None:
start = INT.fromPy(width)
else:
start = toHVa... | [
"convert",
"python",
"slice",
"to",
"value",
"of",
"SLICE",
"hdl",
"type"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/sliceUtils.py#L9-L36 | [
"def",
"slice_to_SLICE",
"(",
"sliceVals",
",",
"width",
")",
":",
"if",
"sliceVals",
".",
"step",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"(",
")",
"start",
"=",
"sliceVals",
".",
"start",
"stop",
"=",
"sliceVals",
".",
"stop",
"if",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | TransPart.getBusWordBitRange | :return: bit range which contains data of this part on bus data signal | hwt/hdl/transPart.py | def getBusWordBitRange(self) -> Tuple[int, int]:
"""
:return: bit range which contains data of this part on bus data signal
"""
offset = self.startOfPart % self.parent.wordWidth
return (offset + self.bit_length(), offset) | def getBusWordBitRange(self) -> Tuple[int, int]:
"""
:return: bit range which contains data of this part on bus data signal
"""
offset = self.startOfPart % self.parent.wordWidth
return (offset + self.bit_length(), offset) | [
":",
"return",
":",
"bit",
"range",
"which",
"contains",
"data",
"of",
"this",
"part",
"on",
"bus",
"data",
"signal"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/transPart.py#L38-L43 | [
"def",
"getBusWordBitRange",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"offset",
"=",
"self",
".",
"startOfPart",
"%",
"self",
".",
"parent",
".",
"wordWidth",
"return",
"(",
"offset",
"+",
"self",
".",
"bit_length",
"(",
")",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | TransPart.getFieldBitRange | :return: bit range which contains data of this part on interface
of field | hwt/hdl/transPart.py | def getFieldBitRange(self) -> Tuple[int, int]:
"""
:return: bit range which contains data of this part on interface
of field
"""
offset = self.inFieldOffset
return (self.bit_length() + offset, offset) | def getFieldBitRange(self) -> Tuple[int, int]:
"""
:return: bit range which contains data of this part on interface
of field
"""
offset = self.inFieldOffset
return (self.bit_length() + offset, offset) | [
":",
"return",
":",
"bit",
"range",
"which",
"contains",
"data",
"of",
"this",
"part",
"on",
"interface",
"of",
"field"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/transPart.py#L45-L51 | [
"def",
"getFieldBitRange",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"offset",
"=",
"self",
".",
"inFieldOffset",
"return",
"(",
"self",
".",
"bit_length",
"(",
")",
"+",
"offset",
",",
"offset",
")"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | fill_stm_list_with_enclosure | Apply enclosure on list of statements
(fill all unused code branches with assignments from value specified by enclosure)
:param parentStm: optional parent statement where this list is some branch
:param current_enclosure: list of signals for which this statement list is enclosed
:param statements: list... | hwt/hdl/statementUtils.py | def fill_stm_list_with_enclosure(parentStm: Optional[HdlStatement],
current_enclosure: Set[RtlSignalBase],
statements: List["HdlStatement"],
do_enclose_for: List[RtlSignalBase],
enclosure:... | def fill_stm_list_with_enclosure(parentStm: Optional[HdlStatement],
current_enclosure: Set[RtlSignalBase],
statements: List["HdlStatement"],
do_enclose_for: List[RtlSignalBase],
enclosure:... | [
"Apply",
"enclosure",
"on",
"list",
"of",
"statements",
"(",
"fill",
"all",
"unused",
"code",
"branches",
"with",
"assignments",
"from",
"value",
"specified",
"by",
"enclosure",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/statementUtils.py#L10-L51 | [
"def",
"fill_stm_list_with_enclosure",
"(",
"parentStm",
":",
"Optional",
"[",
"HdlStatement",
"]",
",",
"current_enclosure",
":",
"Set",
"[",
"RtlSignalBase",
"]",
",",
"statements",
":",
"List",
"[",
"\"HdlStatement\"",
"]",
",",
"do_enclose_for",
":",
"List",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | find_files | Find files by pattern in directory | hwt/pyUtils/fileHelpers.py | def find_files(directory, pattern, recursive=True):
"""
Find files by pattern in directory
"""
if not os.path.isdir(directory):
if os.path.exists(directory):
raise IOError(directory + ' is not directory')
else:
raise IOError(directory + " does not exists")
if ... | def find_files(directory, pattern, recursive=True):
"""
Find files by pattern in directory
"""
if not os.path.isdir(directory):
if os.path.exists(directory):
raise IOError(directory + ' is not directory')
else:
raise IOError(directory + " does not exists")
if ... | [
"Find",
"files",
"by",
"pattern",
"in",
"directory"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/fileHelpers.py#L5-L26 | [
"def",
"find_files",
"(",
"directory",
",",
"pattern",
",",
"recursive",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"raise",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | SwitchLogic | Generate if tree for cases like (syntax shugar for large elifs)
..code-block:: python
if cond0:
statements0
elif cond1:
statements1
else:
default
:param case: iterable of tuples (condition, statements)
:param default: default statements | hwt/code.py | def SwitchLogic(cases, default=None):
"""
Generate if tree for cases like (syntax shugar for large elifs)
..code-block:: python
if cond0:
statements0
elif cond1:
statements1
else:
default
:param case: iterable of tuples (condition, statements... | def SwitchLogic(cases, default=None):
"""
Generate if tree for cases like (syntax shugar for large elifs)
..code-block:: python
if cond0:
statements0
elif cond1:
statements1
else:
default
:param case: iterable of tuples (condition, statements... | [
"Generate",
"if",
"tree",
"for",
"cases",
"like",
"(",
"syntax",
"shugar",
"for",
"large",
"elifs",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L149-L176 | [
"def",
"SwitchLogic",
"(",
"cases",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"not",
"None",
":",
"assigTop",
"=",
"default",
"else",
":",
"assigTop",
"=",
"[",
"]",
"for",
"cond",
",",
"statements",
"in",
"reversed",
"(",
"cases",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | In | Hdl convertible in operator, check if any of items
in "iterable" equals "sigOrVal" | hwt/code.py | def In(sigOrVal, iterable):
"""
Hdl convertible in operator, check if any of items
in "iterable" equals "sigOrVal"
"""
res = None
for i in iterable:
i = toHVal(i)
if res is None:
res = sigOrVal._eq(i)
else:
res = res | sigOrVal._eq(i)
assert r... | def In(sigOrVal, iterable):
"""
Hdl convertible in operator, check if any of items
in "iterable" equals "sigOrVal"
"""
res = None
for i in iterable:
i = toHVal(i)
if res is None:
res = sigOrVal._eq(i)
else:
res = res | sigOrVal._eq(i)
assert r... | [
"Hdl",
"convertible",
"in",
"operator",
"check",
"if",
"any",
"of",
"items",
"in",
"iterable",
"equals",
"sigOrVal"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L179-L193 | [
"def",
"In",
"(",
"sigOrVal",
",",
"iterable",
")",
":",
"res",
"=",
"None",
"for",
"i",
"in",
"iterable",
":",
"i",
"=",
"toHVal",
"(",
"i",
")",
"if",
"res",
"is",
"None",
":",
"res",
"=",
"sigOrVal",
".",
"_eq",
"(",
"i",
")",
"else",
":",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | StaticForEach | Generate for loop for static items
:param parentUnit: unit where this code should be instantiated
:param items: items which this "for" itering on
:param bodyFn: function which fn(item, index) or fn(item)
returns (statementList, ack).
It's content is performed in every iteration.
Whe... | hwt/code.py | def StaticForEach(parentUnit, items, bodyFn, name=""):
"""
Generate for loop for static items
:param parentUnit: unit where this code should be instantiated
:param items: items which this "for" itering on
:param bodyFn: function which fn(item, index) or fn(item)
returns (statementList, ack)... | def StaticForEach(parentUnit, items, bodyFn, name=""):
"""
Generate for loop for static items
:param parentUnit: unit where this code should be instantiated
:param items: items which this "for" itering on
:param bodyFn: function which fn(item, index) or fn(item)
returns (statementList, ack)... | [
"Generate",
"for",
"loop",
"for",
"static",
"items"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L196-L242 | [
"def",
"StaticForEach",
"(",
"parentUnit",
",",
"items",
",",
"bodyFn",
",",
"name",
"=",
"\"\"",
")",
":",
"items",
"=",
"list",
"(",
"items",
")",
"itemsCnt",
"=",
"len",
"(",
"items",
")",
"if",
"itemsCnt",
"==",
"0",
":",
"# if there are no items the... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | connect | Connect src (signals/interfaces/values) to all destinations
:param exclude: interfaces on any level on src or destinations
which should be excluded from connection process
:param fit: auto fit source width to destination width | hwt/code.py | def connect(src, *destinations, exclude: set=None, fit=False):
"""
Connect src (signals/interfaces/values) to all destinations
:param exclude: interfaces on any level on src or destinations
which should be excluded from connection process
:param fit: auto fit source width to destination width
... | def connect(src, *destinations, exclude: set=None, fit=False):
"""
Connect src (signals/interfaces/values) to all destinations
:param exclude: interfaces on any level on src or destinations
which should be excluded from connection process
:param fit: auto fit source width to destination width
... | [
"Connect",
"src",
"(",
"signals",
"/",
"interfaces",
"/",
"values",
")",
"to",
"all",
"destinations"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L308-L329 | [
"def",
"connect",
"(",
"src",
",",
"*",
"destinations",
",",
"exclude",
":",
"set",
"=",
"None",
",",
"fit",
"=",
"False",
")",
":",
"assignemnts",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"src",
",",
"HObjList",
")",
":",
"for",
"dst",
"in",
"desti... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | rol | Rotate left | hwt/code.py | def rol(sig, howMany) -> RtlSignalBase:
"Rotate left"
width = sig._dtype.bit_length()
return sig[(width - howMany):]._concat(sig[:(width - howMany)]) | def rol(sig, howMany) -> RtlSignalBase:
"Rotate left"
width = sig._dtype.bit_length()
return sig[(width - howMany):]._concat(sig[:(width - howMany)]) | [
"Rotate",
"left"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L349-L352 | [
"def",
"rol",
"(",
"sig",
",",
"howMany",
")",
"->",
"RtlSignalBase",
":",
"width",
"=",
"sig",
".",
"_dtype",
".",
"bit_length",
"(",
")",
"return",
"sig",
"[",
"(",
"width",
"-",
"howMany",
")",
":",
"]",
".",
"_concat",
"(",
"sig",
"[",
":",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | sll | Logical shift left | hwt/code.py | def sll(sig, howMany) -> RtlSignalBase:
"Logical shift left"
width = sig._dtype.bit_length()
return sig[(width - howMany):]._concat(vec(0, howMany)) | def sll(sig, howMany) -> RtlSignalBase:
"Logical shift left"
width = sig._dtype.bit_length()
return sig[(width - howMany):]._concat(vec(0, howMany)) | [
"Logical",
"shift",
"left"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L355-L358 | [
"def",
"sll",
"(",
"sig",
",",
"howMany",
")",
"->",
"RtlSignalBase",
":",
"width",
"=",
"sig",
".",
"_dtype",
".",
"bit_length",
"(",
")",
"return",
"sig",
"[",
"(",
"width",
"-",
"howMany",
")",
":",
"]",
".",
"_concat",
"(",
"vec",
"(",
"0",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | log2ceil | Returns no of bits required to store x-1
for example x=8 returns 3 | hwt/code.py | def log2ceil(x):
"""
Returns no of bits required to store x-1
for example x=8 returns 3
"""
if not isinstance(x, (int, float)):
x = int(x)
if x == 0 or x == 1:
res = 1
else:
res = math.ceil(math.log2(x))
return hInt(res) | def log2ceil(x):
"""
Returns no of bits required to store x-1
for example x=8 returns 3
"""
if not isinstance(x, (int, float)):
x = int(x)
if x == 0 or x == 1:
res = 1
else:
res = math.ceil(math.log2(x))
return hInt(res) | [
"Returns",
"no",
"of",
"bits",
"required",
"to",
"store",
"x",
"-",
"1",
"for",
"example",
"x",
"=",
"8",
"returns",
"3"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L366-L380 | [
"def",
"log2ceil",
"(",
"x",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"x",
"=",
"int",
"(",
"x",
")",
"if",
"x",
"==",
"0",
"or",
"x",
"==",
"1",
":",
"res",
"=",
"1",
"else",
":",
"res"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | isPow2 | Check if number or constant is power of two | hwt/code.py | def isPow2(num) -> bool:
"""
Check if number or constant is power of two
"""
if not isinstance(num, int):
num = int(num)
return num != 0 and ((num & (num - 1)) == 0) | def isPow2(num) -> bool:
"""
Check if number or constant is power of two
"""
if not isinstance(num, int):
num = int(num)
return num != 0 and ((num & (num - 1)) == 0) | [
"Check",
"if",
"number",
"or",
"constant",
"is",
"power",
"of",
"two"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L383-L389 | [
"def",
"isPow2",
"(",
"num",
")",
"->",
"bool",
":",
"if",
"not",
"isinstance",
"(",
"num",
",",
"int",
")",
":",
"num",
"=",
"int",
"(",
"num",
")",
"return",
"num",
"!=",
"0",
"and",
"(",
"(",
"num",
"&",
"(",
"num",
"-",
"1",
")",
")",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Switch.addCases | Add multiple case statements from iterable of tuleles
(caseVal, statements) | hwt/code.py | def addCases(self, tupesValStmnts):
"""
Add multiple case statements from iterable of tuleles
(caseVal, statements)
"""
s = self
for val, statements in tupesValStmnts:
s = s.Case(val, statements)
return s | def addCases(self, tupesValStmnts):
"""
Add multiple case statements from iterable of tuleles
(caseVal, statements)
"""
s = self
for val, statements in tupesValStmnts:
s = s.Case(val, statements)
return s | [
"Add",
"multiple",
"case",
"statements",
"from",
"iterable",
"of",
"tuleles",
"(",
"caseVal",
"statements",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L106-L114 | [
"def",
"addCases",
"(",
"self",
",",
"tupesValStmnts",
")",
":",
"s",
"=",
"self",
"for",
"val",
",",
"statements",
"in",
"tupesValStmnts",
":",
"s",
"=",
"s",
".",
"Case",
"(",
"val",
",",
"statements",
")",
"return",
"s"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Switch.Case | c-like case of switch statement | hwt/code.py | def Case(self, caseVal, *statements):
"c-like case of switch statement"
assert self.parentStm is None
caseVal = toHVal(caseVal, self.switchOn._dtype)
assert isinstance(caseVal, Value), caseVal
assert caseVal._isFullVld(), "Cmp with invalid value"
assert caseVal not in se... | def Case(self, caseVal, *statements):
"c-like case of switch statement"
assert self.parentStm is None
caseVal = toHVal(caseVal, self.switchOn._dtype)
assert isinstance(caseVal, Value), caseVal
assert caseVal._isFullVld(), "Cmp with invalid value"
assert caseVal not in se... | [
"c",
"-",
"like",
"case",
"of",
"switch",
"statement"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L116-L137 | [
"def",
"Case",
"(",
"self",
",",
"caseVal",
",",
"*",
"statements",
")",
":",
"assert",
"self",
".",
"parentStm",
"is",
"None",
"caseVal",
"=",
"toHVal",
"(",
"caseVal",
",",
"self",
".",
"switchOn",
".",
"_dtype",
")",
"assert",
"isinstance",
"(",
"ca... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Switch.Default | c-like default of switch statement | hwt/code.py | def Default(self, *statements):
"""c-like default of switch statement
"""
assert self.parentStm is None
self.rank += 1
self.default = []
self._register_stements(statements, self.default)
return self | def Default(self, *statements):
"""c-like default of switch statement
"""
assert self.parentStm is None
self.rank += 1
self.default = []
self._register_stements(statements, self.default)
return self | [
"c",
"-",
"like",
"default",
"of",
"switch",
"statement"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L139-L146 | [
"def",
"Default",
"(",
"self",
",",
"*",
"statements",
")",
":",
"assert",
"self",
".",
"parentStm",
"is",
"None",
"self",
".",
"rank",
"+=",
"1",
"self",
".",
"default",
"=",
"[",
"]",
"self",
".",
"_register_stements",
"(",
"statements",
",",
"self",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | FsmBuilder.Trans | :param stateFrom: apply when FSM is in this state
:param condAndNextState: tupes (condition, newState),
last does not to have condition
:attention: transitions has priority, first has the biggest
:attention: if stateFrom is None it is evaluated as default | hwt/code.py | def Trans(self, stateFrom, *condAndNextState):
"""
:param stateFrom: apply when FSM is in this state
:param condAndNextState: tupes (condition, newState),
last does not to have condition
:attention: transitions has priority, first has the biggest
:attention: if state... | def Trans(self, stateFrom, *condAndNextState):
"""
:param stateFrom: apply when FSM is in this state
:param condAndNextState: tupes (condition, newState),
last does not to have condition
:attention: transitions has priority, first has the biggest
:attention: if state... | [
":",
"param",
"stateFrom",
":",
"apply",
"when",
"FSM",
"is",
"in",
"this",
"state",
":",
"param",
"condAndNextState",
":",
"tupes",
"(",
"condition",
"newState",
")",
"last",
"does",
"not",
"to",
"have",
"condition"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/code.py#L264-L300 | [
"def",
"Trans",
"(",
"self",
",",
"stateFrom",
",",
"*",
"condAndNextState",
")",
":",
"top",
"=",
"[",
"]",
"last",
"=",
"True",
"for",
"cAndS",
"in",
"reversed",
"(",
"condAndNextState",
")",
":",
"if",
"last",
"is",
"True",
":",
"last",
"=",
"Fals... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | vcdTypeInfoForHType | :return: (vcd type name, vcd width) | hwt/simulator/vcdHdlSimConfig.py | def vcdTypeInfoForHType(t) -> Tuple[str, int, Callable[[RtlSignalBase, Value], str]]:
"""
:return: (vcd type name, vcd width)
"""
if isinstance(t, (SimBitsT, Bits, HBool)):
return (VCD_SIG_TYPE.WIRE, t.bit_length(), vcdBitsFormatter)
elif isinstance(t, HEnum):
return (VCD_SIG_TYPE.RE... | def vcdTypeInfoForHType(t) -> Tuple[str, int, Callable[[RtlSignalBase, Value], str]]:
"""
:return: (vcd type name, vcd width)
"""
if isinstance(t, (SimBitsT, Bits, HBool)):
return (VCD_SIG_TYPE.WIRE, t.bit_length(), vcdBitsFormatter)
elif isinstance(t, HEnum):
return (VCD_SIG_TYPE.RE... | [
":",
"return",
":",
"(",
"vcd",
"type",
"name",
"vcd",
"width",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/vcdHdlSimConfig.py#L24-L33 | [
"def",
"vcdTypeInfoForHType",
"(",
"t",
")",
"->",
"Tuple",
"[",
"str",
",",
"int",
",",
"Callable",
"[",
"[",
"RtlSignalBase",
",",
"Value",
"]",
",",
"str",
"]",
"]",
":",
"if",
"isinstance",
"(",
"t",
",",
"(",
"SimBitsT",
",",
"Bits",
",",
"HBo... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | VcdHdlSimConfig.vcdRegisterInterfaces | Register signals from interfaces for Interface or Unit instances | hwt/simulator/vcdHdlSimConfig.py | def vcdRegisterInterfaces(self, obj: Union[Interface, Unit],
parent: Optional[VcdVarWritingScope]):
"""
Register signals from interfaces for Interface or Unit instances
"""
if hasattr(obj, "_interfaces") and obj._interfaces:
name = obj._name
... | def vcdRegisterInterfaces(self, obj: Union[Interface, Unit],
parent: Optional[VcdVarWritingScope]):
"""
Register signals from interfaces for Interface or Unit instances
"""
if hasattr(obj, "_interfaces") and obj._interfaces:
name = obj._name
... | [
"Register",
"signals",
"from",
"interfaces",
"for",
"Interface",
"or",
"Unit",
"instances"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/vcdHdlSimConfig.py#L45-L76 | [
"def",
"vcdRegisterInterfaces",
"(",
"self",
",",
"obj",
":",
"Union",
"[",
"Interface",
",",
"Unit",
"]",
",",
"parent",
":",
"Optional",
"[",
"VcdVarWritingScope",
"]",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"\"_interfaces\"",
")",
"and",
"obj",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | VcdHdlSimConfig.beforeSim | This method is called before first step of simulation. | hwt/simulator/vcdHdlSimConfig.py | def beforeSim(self, simulator, synthesisedUnit):
"""
This method is called before first step of simulation.
"""
vcd = self.vcdWriter
vcd.date(datetime.now())
vcd.timescale(1)
self.vcdRegisterInterfaces(synthesisedUnit, None)
self.vcdRegisterRemainingSigna... | def beforeSim(self, simulator, synthesisedUnit):
"""
This method is called before first step of simulation.
"""
vcd = self.vcdWriter
vcd.date(datetime.now())
vcd.timescale(1)
self.vcdRegisterInterfaces(synthesisedUnit, None)
self.vcdRegisterRemainingSigna... | [
"This",
"method",
"is",
"called",
"before",
"first",
"step",
"of",
"simulation",
"."
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/vcdHdlSimConfig.py#L100-L111 | [
"def",
"beforeSim",
"(",
"self",
",",
"simulator",
",",
"synthesisedUnit",
")",
":",
"vcd",
"=",
"self",
".",
"vcdWriter",
"vcd",
".",
"date",
"(",
"datetime",
".",
"now",
"(",
")",
")",
"vcd",
".",
"timescale",
"(",
"1",
")",
"self",
".",
"vcdRegist... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | VcdHdlSimConfig.logChange | This method is called for every value change of any signal. | hwt/simulator/vcdHdlSimConfig.py | def logChange(self, nowTime, sig, nextVal):
"""
This method is called for every value change of any signal.
"""
try:
self.vcdWriter.logChange(nowTime, sig, nextVal)
except KeyError:
# not every signal has to be registered
pass | def logChange(self, nowTime, sig, nextVal):
"""
This method is called for every value change of any signal.
"""
try:
self.vcdWriter.logChange(nowTime, sig, nextVal)
except KeyError:
# not every signal has to be registered
pass | [
"This",
"method",
"is",
"called",
"for",
"every",
"value",
"change",
"of",
"any",
"signal",
"."
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/vcdHdlSimConfig.py#L113-L121 | [
"def",
"logChange",
"(",
"self",
",",
"nowTime",
",",
"sig",
",",
"nextVal",
")",
":",
"try",
":",
"self",
".",
"vcdWriter",
".",
"logChange",
"(",
"nowTime",
",",
"sig",
",",
"nextVal",
")",
"except",
"KeyError",
":",
"# not every signal has to be registere... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | SystemCSerializer_statements.HWProcess | Serialize HWProcess instance
:param scope: name scope to prevent name collisions | hwt/serializer/systemC/statements.py | def HWProcess(cls, proc, ctx):
"""
Serialize HWProcess instance
:param scope: name scope to prevent name collisions
"""
body = proc.statements
childCtx = ctx.withIndent()
statemets = [cls.asHdl(s, childCtx) for s in body]
proc.name = ctx.scope.checkedName... | def HWProcess(cls, proc, ctx):
"""
Serialize HWProcess instance
:param scope: name scope to prevent name collisions
"""
body = proc.statements
childCtx = ctx.withIndent()
statemets = [cls.asHdl(s, childCtx) for s in body]
proc.name = ctx.scope.checkedName... | [
"Serialize",
"HWProcess",
"instance"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/systemC/statements.py#L43-L58 | [
"def",
"HWProcess",
"(",
"cls",
",",
"proc",
",",
"ctx",
")",
":",
"body",
"=",
"proc",
".",
"statements",
"childCtx",
"=",
"ctx",
".",
"withIndent",
"(",
")",
"statemets",
"=",
"[",
"cls",
".",
"asHdl",
"(",
"s",
",",
"childCtx",
")",
"for",
"s",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | NameScope.setLevel | Trim or extend scope
lvl = 1 -> only one scope (global) | hwt/serializer/generic/nameScope.py | def setLevel(self, lvl):
"""
Trim or extend scope
lvl = 1 -> only one scope (global)
"""
while len(self) != lvl:
if len(self) > lvl:
self.pop()
else:
self.append(NameScopeItem(len(self))) | def setLevel(self, lvl):
"""
Trim or extend scope
lvl = 1 -> only one scope (global)
"""
while len(self) != lvl:
if len(self) > lvl:
self.pop()
else:
self.append(NameScopeItem(len(self))) | [
"Trim",
"or",
"extend",
"scope",
"lvl",
"=",
"1",
"-",
">",
"only",
"one",
"scope",
"(",
"global",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/generic/nameScope.py#L122-L131 | [
"def",
"setLevel",
"(",
"self",
",",
"lvl",
")",
":",
"while",
"len",
"(",
"self",
")",
"!=",
"lvl",
":",
"if",
"len",
"(",
"self",
")",
">",
"lvl",
":",
"self",
".",
"pop",
"(",
")",
"else",
":",
"self",
".",
"append",
"(",
"NameScopeItem",
"(... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | SliceVal._size | :return: how many bits is this slice selecting | hwt/hdl/types/sliceVal.py | def _size(self):
"""
:return: how many bits is this slice selecting
"""
assert isinstance(self, Value)
return int(self.val[0]) - int(self.val[1]) | def _size(self):
"""
:return: how many bits is this slice selecting
"""
assert isinstance(self, Value)
return int(self.val[0]) - int(self.val[1]) | [
":",
"return",
":",
"how",
"many",
"bits",
"is",
"this",
"slice",
"selecting"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/sliceVal.py#L19-L24 | [
"def",
"_size",
"(",
"self",
")",
":",
"assert",
"isinstance",
"(",
"self",
",",
"Value",
")",
"return",
"int",
"(",
"self",
".",
"val",
"[",
"0",
"]",
")",
"-",
"int",
"(",
"self",
".",
"val",
"[",
"1",
"]",
")"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | autoAddAgents | Walk all interfaces on unit and instantiate agent for every interface.
:return: all monitor/driver functions which should be added to simulation
as processes | hwt/simulator/agentConnector.py | def autoAddAgents(unit):
"""
Walk all interfaces on unit and instantiate agent for every interface.
:return: all monitor/driver functions which should be added to simulation
as processes
"""
proc = []
for intf in unit._interfaces:
if not intf._isExtern:
continue
... | def autoAddAgents(unit):
"""
Walk all interfaces on unit and instantiate agent for every interface.
:return: all monitor/driver functions which should be added to simulation
as processes
"""
proc = []
for intf in unit._interfaces:
if not intf._isExtern:
continue
... | [
"Walk",
"all",
"interfaces",
"on",
"unit",
"and",
"instantiate",
"agent",
"for",
"every",
"interface",
"."
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/agentConnector.py#L6-L33 | [
"def",
"autoAddAgents",
"(",
"unit",
")",
":",
"proc",
"=",
"[",
"]",
"for",
"intf",
"in",
"unit",
".",
"_interfaces",
":",
"if",
"not",
"intf",
".",
"_isExtern",
":",
"continue",
"intf",
".",
"_initSimAgent",
"(",
")",
"assert",
"intf",
".",
"_ag",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | valuesToInts | Iterable of values to ints (nonvalid = None) | hwt/simulator/agentConnector.py | def valuesToInts(values):
"""
Iterable of values to ints (nonvalid = None)
"""
res = []
append = res.append
for d in values:
if isinstance(d, int):
append(d)
else:
append(valToInt(d))
return res | def valuesToInts(values):
"""
Iterable of values to ints (nonvalid = None)
"""
res = []
append = res.append
for d in values:
if isinstance(d, int):
append(d)
else:
append(valToInt(d))
return res | [
"Iterable",
"of",
"values",
"to",
"ints",
"(",
"nonvalid",
"=",
"None",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/agentConnector.py#L36-L47 | [
"def",
"valuesToInts",
"(",
"values",
")",
":",
"res",
"=",
"[",
"]",
"append",
"=",
"res",
".",
"append",
"for",
"d",
"in",
"values",
":",
"if",
"isinstance",
"(",
"d",
",",
"int",
")",
":",
"append",
"(",
"d",
")",
"else",
":",
"append",
"(",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | InterfaceceImplDependentFns._getAssociatedRst | If interface has associated rst(_n) return it otherwise
try to find rst(_n) on parent recursively | hwt/synthesizer/interfaceLevel/interfaceUtils/implDependent.py | def _getAssociatedRst(self):
"""
If interface has associated rst(_n) return it otherwise
try to find rst(_n) on parent recursively
"""
a = self._associatedRst
if a is not None:
return a
p = self._parent
assert p is not None
if isinst... | def _getAssociatedRst(self):
"""
If interface has associated rst(_n) return it otherwise
try to find rst(_n) on parent recursively
"""
a = self._associatedRst
if a is not None:
return a
p = self._parent
assert p is not None
if isinst... | [
"If",
"interface",
"has",
"associated",
"rst",
"(",
"_n",
")",
"return",
"it",
"otherwise",
"try",
"to",
"find",
"rst",
"(",
"_n",
")",
"on",
"parent",
"recursively"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interfaceLevel/interfaceUtils/implDependent.py#L21-L37 | [
"def",
"_getAssociatedRst",
"(",
"self",
")",
":",
"a",
"=",
"self",
".",
"_associatedRst",
"if",
"a",
"is",
"not",
"None",
":",
"return",
"a",
"p",
"=",
"self",
".",
"_parent",
"assert",
"p",
"is",
"not",
"None",
"if",
"isinstance",
"(",
"p",
",",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | InterfaceceImplDependentFns._getAssociatedClk | If interface has associated clk return it otherwise
try to find clk on parent recursively | hwt/synthesizer/interfaceLevel/interfaceUtils/implDependent.py | def _getAssociatedClk(self):
"""
If interface has associated clk return it otherwise
try to find clk on parent recursively
"""
a = self._associatedClk
if a is not None:
return a
p = self._parent
assert p is not None
if isinstance(p, ... | def _getAssociatedClk(self):
"""
If interface has associated clk return it otherwise
try to find clk on parent recursively
"""
a = self._associatedClk
if a is not None:
return a
p = self._parent
assert p is not None
if isinstance(p, ... | [
"If",
"interface",
"has",
"associated",
"clk",
"return",
"it",
"otherwise",
"try",
"to",
"find",
"clk",
"on",
"parent",
"recursively"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interfaceLevel/interfaceUtils/implDependent.py#L39-L55 | [
"def",
"_getAssociatedClk",
"(",
"self",
")",
":",
"a",
"=",
"self",
".",
"_associatedClk",
"if",
"a",
"is",
"not",
"None",
":",
"return",
"a",
"p",
"=",
"self",
".",
"_parent",
"assert",
"p",
"is",
"not",
"None",
"if",
"isinstance",
"(",
"p",
",",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | SystemCSerializer.Architecture_var | :return: list of extra discovered processes | hwt/serializer/systemC/serializer.py | def Architecture_var(cls, v, serializerVars, extraTypes,
extraTypes_serialized, ctx, childCtx):
"""
:return: list of extra discovered processes
"""
v.name = ctx.scope.checkedName(v.name, v)
serializedVar = cls.SignalItem(v, childCtx, declaration=True)
... | def Architecture_var(cls, v, serializerVars, extraTypes,
extraTypes_serialized, ctx, childCtx):
"""
:return: list of extra discovered processes
"""
v.name = ctx.scope.checkedName(v.name, v)
serializedVar = cls.SignalItem(v, childCtx, declaration=True)
... | [
":",
"return",
":",
"list",
"of",
"extra",
"discovered",
"processes"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/systemC/serializer.py#L72-L79 | [
"def",
"Architecture_var",
"(",
"cls",
",",
"v",
",",
"serializerVars",
",",
"extraTypes",
",",
"extraTypes_serialized",
",",
"ctx",
",",
"childCtx",
")",
":",
"v",
".",
"name",
"=",
"ctx",
".",
"scope",
".",
"checkedName",
"(",
"v",
".",
"name",
",",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | distinctBy | uniq operation with key selector | hwt/pyUtils/arrayQuery.py | def distinctBy(iterable, fn):
"""
uniq operation with key selector
"""
s = set()
for i in iterable:
r = fn(i)
if r not in s:
s.add(r)
yield i | def distinctBy(iterable, fn):
"""
uniq operation with key selector
"""
s = set()
for i in iterable:
r = fn(i)
if r not in s:
s.add(r)
yield i | [
"uniq",
"operation",
"with",
"key",
"selector"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L20-L29 | [
"def",
"distinctBy",
"(",
"iterable",
",",
"fn",
")",
":",
"s",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"iterable",
":",
"r",
"=",
"fn",
"(",
"i",
")",
"if",
"r",
"not",
"in",
"s",
":",
"s",
".",
"add",
"(",
"r",
")",
"yield",
"i"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | single | Get value from iterable where fn(item) and check
if there is not fn(other item)
:raise DuplicitValueExc: when there are multiple items satisfying fn()
:raise NoValueExc: when no value satisfying fn(item) found | hwt/pyUtils/arrayQuery.py | def single(iterable, fn):
"""
Get value from iterable where fn(item) and check
if there is not fn(other item)
:raise DuplicitValueExc: when there are multiple items satisfying fn()
:raise NoValueExc: when no value satisfying fn(item) found
"""
found = False
ret = None
for i in iter... | def single(iterable, fn):
"""
Get value from iterable where fn(item) and check
if there is not fn(other item)
:raise DuplicitValueExc: when there are multiple items satisfying fn()
:raise NoValueExc: when no value satisfying fn(item) found
"""
found = False
ret = None
for i in iter... | [
"Get",
"value",
"from",
"iterable",
"where",
"fn",
"(",
"item",
")",
"and",
"check",
"if",
"there",
"is",
"not",
"fn",
"(",
"other",
"item",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L32-L53 | [
"def",
"single",
"(",
"iterable",
",",
"fn",
")",
":",
"found",
"=",
"False",
"ret",
"=",
"None",
"for",
"i",
"in",
"iterable",
":",
"if",
"fn",
"(",
"i",
")",
":",
"if",
"found",
":",
"raise",
"DuplicitValueExc",
"(",
"i",
")",
"found",
"=",
"Tr... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | take | :return: generator of first n items from iterrable | hwt/pyUtils/arrayQuery.py | def take(iterrable, howMay):
"""
:return: generator of first n items from iterrable
"""
assert howMay >= 0
if not howMay:
return
last = howMay - 1
for i, item in enumerate(iterrable):
yield item
if i == last:
return | def take(iterrable, howMay):
"""
:return: generator of first n items from iterrable
"""
assert howMay >= 0
if not howMay:
return
last = howMay - 1
for i, item in enumerate(iterrable):
yield item
if i == last:
return | [
":",
"return",
":",
"generator",
"of",
"first",
"n",
"items",
"from",
"iterrable"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L77-L90 | [
"def",
"take",
"(",
"iterrable",
",",
"howMay",
")",
":",
"assert",
"howMay",
">=",
"0",
"if",
"not",
"howMay",
":",
"return",
"last",
"=",
"howMay",
"-",
"1",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"iterrable",
")",
":",
"yield",
"item",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | iter_with_last | :return: generator of tuples (isLastFlag, item) | hwt/pyUtils/arrayQuery.py | def iter_with_last(iterable):
"""
:return: generator of tuples (isLastFlag, item)
"""
# Ensure it's an iterator and get the first field
iterable = iter(iterable)
prev = next(iterable)
for item in iterable:
# Lag by one item so I know I'm not at the end
yield False, prev
... | def iter_with_last(iterable):
"""
:return: generator of tuples (isLastFlag, item)
"""
# Ensure it's an iterator and get the first field
iterable = iter(iterable)
prev = next(iterable)
for item in iterable:
# Lag by one item so I know I'm not at the end
yield False, prev
... | [
":",
"return",
":",
"generator",
"of",
"tuples",
"(",
"isLastFlag",
"item",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L102-L114 | [
"def",
"iter_with_last",
"(",
"iterable",
")",
":",
"# Ensure it's an iterator and get the first field",
"iterable",
"=",
"iter",
"(",
"iterable",
")",
"prev",
"=",
"next",
"(",
"iterable",
")",
"for",
"item",
"in",
"iterable",
":",
"# Lag by one item so I know I'm no... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | groupedby | same like itertools.groupby
:note: This function does not needs initial sorting like itertools.groupby
:attention: Order of pairs is not deterministic. | hwt/pyUtils/arrayQuery.py | def groupedby(collection, fn):
"""
same like itertools.groupby
:note: This function does not needs initial sorting like itertools.groupby
:attention: Order of pairs is not deterministic.
"""
d = {}
for item in collection:
k = fn(item)
try:
arr = d[k]
exc... | def groupedby(collection, fn):
"""
same like itertools.groupby
:note: This function does not needs initial sorting like itertools.groupby
:attention: Order of pairs is not deterministic.
"""
d = {}
for item in collection:
k = fn(item)
try:
arr = d[k]
exc... | [
"same",
"like",
"itertools",
".",
"groupby"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L117-L135 | [
"def",
"groupedby",
"(",
"collection",
",",
"fn",
")",
":",
"d",
"=",
"{",
"}",
"for",
"item",
"in",
"collection",
":",
"k",
"=",
"fn",
"(",
"item",
")",
"try",
":",
"arr",
"=",
"d",
"[",
"k",
"]",
"except",
"KeyError",
":",
"arr",
"=",
"[",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | flatten | Flatten nested lists, tuples, generators and maps
:param level: maximum depth of flattening | hwt/pyUtils/arrayQuery.py | def flatten(iterables, level=inf):
"""
Flatten nested lists, tuples, generators and maps
:param level: maximum depth of flattening
"""
if level >= 0 and isinstance(iterables, (list, tuple, GeneratorType,
map, zip)):
level -= 1
for i in it... | def flatten(iterables, level=inf):
"""
Flatten nested lists, tuples, generators and maps
:param level: maximum depth of flattening
"""
if level >= 0 and isinstance(iterables, (list, tuple, GeneratorType,
map, zip)):
level -= 1
for i in it... | [
"Flatten",
"nested",
"lists",
"tuples",
"generators",
"and",
"maps"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L138-L150 | [
"def",
"flatten",
"(",
"iterables",
",",
"level",
"=",
"inf",
")",
":",
"if",
"level",
">=",
"0",
"and",
"isinstance",
"(",
"iterables",
",",
"(",
"list",
",",
"tuple",
",",
"GeneratorType",
",",
"map",
",",
"zip",
")",
")",
":",
"level",
"-=",
"1"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._cut_off_drivers_of | Doc on parent class :meth:`HdlStatement._cut_off_drivers_of` | hwt/hdl/ifContainter.py | def _cut_off_drivers_of(self, sig: RtlSignalBase):
"""
Doc on parent class :meth:`HdlStatement._cut_off_drivers_of`
"""
if len(self._outputs) == 1 and sig in self._outputs:
self.parentStm = None
return self
# try to cut off all statements which are driver... | def _cut_off_drivers_of(self, sig: RtlSignalBase):
"""
Doc on parent class :meth:`HdlStatement._cut_off_drivers_of`
"""
if len(self._outputs) == 1 and sig in self._outputs:
self.parentStm = None
return self
# try to cut off all statements which are driver... | [
"Doc",
"on",
"parent",
"class",
":",
"meth",
":",
"HdlStatement",
".",
"_cut_off_drivers_of"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L71-L154 | [
"def",
"_cut_off_drivers_of",
"(",
"self",
",",
"sig",
":",
"RtlSignalBase",
")",
":",
"if",
"len",
"(",
"self",
".",
"_outputs",
")",
"==",
"1",
"and",
"sig",
"in",
"self",
".",
"_outputs",
":",
"self",
".",
"parentStm",
"=",
"None",
"return",
"self",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._discover_enclosure | Doc on parent class :meth:`HdlStatement._discover_enclosure` | hwt/hdl/ifContainter.py | def _discover_enclosure(self):
"""
Doc on parent class :meth:`HdlStatement._discover_enclosure`
"""
outputs = self._outputs
self._ifTrue_enclosed_for = self._discover_enclosure_for_statements(
self.ifTrue, outputs)
elif_encls = self._elIfs_enclosed_for = []
... | def _discover_enclosure(self):
"""
Doc on parent class :meth:`HdlStatement._discover_enclosure`
"""
outputs = self._outputs
self._ifTrue_enclosed_for = self._discover_enclosure_for_statements(
self.ifTrue, outputs)
elif_encls = self._elIfs_enclosed_for = []
... | [
"Doc",
"on",
"parent",
"class",
":",
"meth",
":",
"HdlStatement",
".",
"_discover_enclosure"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L157-L186 | [
"def",
"_discover_enclosure",
"(",
"self",
")",
":",
"outputs",
"=",
"self",
".",
"_outputs",
"self",
".",
"_ifTrue_enclosed_for",
"=",
"self",
".",
"_discover_enclosure_for_statements",
"(",
"self",
".",
"ifTrue",
",",
"outputs",
")",
"elif_encls",
"=",
"self",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._discover_sensitivity | Doc on parent class :meth:`HdlStatement._discover_sensitivity` | hwt/hdl/ifContainter.py | def _discover_sensitivity(self, seen: set) -> None:
"""
Doc on parent class :meth:`HdlStatement._discover_sensitivity`
"""
assert self._sensitivity is None, self
ctx = self._sensitivity = SensitivityCtx()
self._discover_sensitivity_sig(self.cond, seen, ctx)
if ct... | def _discover_sensitivity(self, seen: set) -> None:
"""
Doc on parent class :meth:`HdlStatement._discover_sensitivity`
"""
assert self._sensitivity is None, self
ctx = self._sensitivity = SensitivityCtx()
self._discover_sensitivity_sig(self.cond, seen, ctx)
if ct... | [
"Doc",
"on",
"parent",
"class",
":",
"meth",
":",
"HdlStatement",
".",
"_discover_sensitivity"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L189-L227 | [
"def",
"_discover_sensitivity",
"(",
"self",
",",
"seen",
":",
"set",
")",
"->",
"None",
":",
"assert",
"self",
".",
"_sensitivity",
"is",
"None",
",",
"self",
"ctx",
"=",
"self",
".",
"_sensitivity",
"=",
"SensitivityCtx",
"(",
")",
"self",
".",
"_disco... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._iter_stms | Doc on parent class :meth:`HdlStatement._iter_stms` | hwt/hdl/ifContainter.py | def _iter_stms(self):
"""
Doc on parent class :meth:`HdlStatement._iter_stms`
"""
yield from self.ifTrue
for _, stms in self.elIfs:
yield from stms
if self.ifFalse is not None:
yield from self.ifFalse | def _iter_stms(self):
"""
Doc on parent class :meth:`HdlStatement._iter_stms`
"""
yield from self.ifTrue
for _, stms in self.elIfs:
yield from stms
if self.ifFalse is not None:
yield from self.ifFalse | [
"Doc",
"on",
"parent",
"class",
":",
"meth",
":",
"HdlStatement",
".",
"_iter_stms"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L250-L258 | [
"def",
"_iter_stms",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"ifTrue",
"for",
"_",
",",
"stms",
"in",
"self",
".",
"elIfs",
":",
"yield",
"from",
"stms",
"if",
"self",
".",
"ifFalse",
"is",
"not",
"None",
":",
"yield",
"from",
"self",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._try_reduce | Doc on parent class :meth:`HdlStatement._try_reduce` | hwt/hdl/ifContainter.py | def _try_reduce(self) -> Tuple[bool, List[HdlStatement]]:
"""
Doc on parent class :meth:`HdlStatement._try_reduce`
"""
# flag if IO of statement has changed
io_change = False
self.ifTrue, rank_decrease, _io_change = self._try_reduce_list(
self.ifTrue)
... | def _try_reduce(self) -> Tuple[bool, List[HdlStatement]]:
"""
Doc on parent class :meth:`HdlStatement._try_reduce`
"""
# flag if IO of statement has changed
io_change = False
self.ifTrue, rank_decrease, _io_change = self._try_reduce_list(
self.ifTrue)
... | [
"Doc",
"on",
"parent",
"class",
":",
"meth",
":",
"HdlStatement",
".",
"_try_reduce"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L261-L303 | [
"def",
"_try_reduce",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"List",
"[",
"HdlStatement",
"]",
"]",
":",
"# flag if IO of statement has changed",
"io_change",
"=",
"False",
"self",
".",
"ifTrue",
",",
"rank_decrease",
",",
"_io_change",
"=",
"self"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._merge_nested_if_from_else | Merge nested IfContarner form else branch to this IfContainer
as elif and else branches | hwt/hdl/ifContainter.py | def _merge_nested_if_from_else(self, ifStm: "IfContainer"):
"""
Merge nested IfContarner form else branch to this IfContainer
as elif and else branches
"""
self.elIfs.append((ifStm.cond, ifStm.ifTrue))
self.elIfs.extend(ifStm.elIfs)
self.ifFalse = ifStm.ifFalse | def _merge_nested_if_from_else(self, ifStm: "IfContainer"):
"""
Merge nested IfContarner form else branch to this IfContainer
as elif and else branches
"""
self.elIfs.append((ifStm.cond, ifStm.ifTrue))
self.elIfs.extend(ifStm.elIfs)
self.ifFalse = ifStm.ifFalse | [
"Merge",
"nested",
"IfContarner",
"form",
"else",
"branch",
"to",
"this",
"IfContainer",
"as",
"elif",
"and",
"else",
"branches"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L306-L314 | [
"def",
"_merge_nested_if_from_else",
"(",
"self",
",",
"ifStm",
":",
"\"IfContainer\"",
")",
":",
"self",
".",
"elIfs",
".",
"append",
"(",
"(",
"ifStm",
".",
"cond",
",",
"ifStm",
".",
"ifTrue",
")",
")",
"self",
".",
"elIfs",
".",
"extend",
"(",
"ifS... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer._merge_with_other_stm | :attention: statements has to be mergable (to check use _is_mergable method) | hwt/hdl/ifContainter.py | def _merge_with_other_stm(self, other: "IfContainer") -> None:
"""
:attention: statements has to be mergable (to check use _is_mergable method)
"""
merge = self._merge_statement_lists
self.ifTrue = merge(self.ifTrue, other.ifTrue)
new_elifs = []
for ((c, elifA), ... | def _merge_with_other_stm(self, other: "IfContainer") -> None:
"""
:attention: statements has to be mergable (to check use _is_mergable method)
"""
merge = self._merge_statement_lists
self.ifTrue = merge(self.ifTrue, other.ifTrue)
new_elifs = []
for ((c, elifA), ... | [
":",
"attention",
":",
"statements",
"has",
"to",
"be",
"mergable",
"(",
"to",
"check",
"use",
"_is_mergable",
"method",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L337-L355 | [
"def",
"_merge_with_other_stm",
"(",
"self",
",",
"other",
":",
"\"IfContainer\"",
")",
"->",
"None",
":",
"merge",
"=",
"self",
".",
"_merge_statement_lists",
"self",
".",
"ifTrue",
"=",
"merge",
"(",
"self",
".",
"ifTrue",
",",
"other",
".",
"ifTrue",
")... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IfContainer.isSame | :return: True if other has same meaning as this statement | hwt/hdl/ifContainter.py | def isSame(self, other: HdlStatement) -> bool:
"""
:return: True if other has same meaning as this statement
"""
if self is other:
return True
if self.rank != other.rank:
return False
if isinstance(other, IfContainer):
if self.cond is... | def isSame(self, other: HdlStatement) -> bool:
"""
:return: True if other has same meaning as this statement
"""
if self is other:
return True
if self.rank != other.rank:
return False
if isinstance(other, IfContainer):
if self.cond is... | [
":",
"return",
":",
"True",
"if",
"other",
"has",
"same",
"meaning",
"as",
"this",
"statement"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/ifContainter.py#L373-L399 | [
"def",
"isSame",
"(",
"self",
",",
"other",
":",
"HdlStatement",
")",
"->",
"bool",
":",
"if",
"self",
"is",
"other",
":",
"return",
"True",
"if",
"self",
".",
"rank",
"!=",
"other",
".",
"rank",
":",
"return",
"False",
"if",
"isinstance",
"(",
"othe... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | removeUnconnectedSignals | If signal is not driving anything remove it | hwt/synthesizer/rtlLevel/optimalizator.py | def removeUnconnectedSignals(netlist):
"""
If signal is not driving anything remove it
"""
toDelete = set()
toSearch = netlist.signals
while toSearch:
_toSearch = set()
for sig in toSearch:
if not sig.endpoints:
try:
if sig._inte... | def removeUnconnectedSignals(netlist):
"""
If signal is not driving anything remove it
"""
toDelete = set()
toSearch = netlist.signals
while toSearch:
_toSearch = set()
for sig in toSearch:
if not sig.endpoints:
try:
if sig._inte... | [
"If",
"signal",
"is",
"not",
"driving",
"anything",
"remove",
"it"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/optimalizator.py#L14-L63 | [
"def",
"removeUnconnectedSignals",
"(",
"netlist",
")",
":",
"toDelete",
"=",
"set",
"(",
")",
"toSearch",
"=",
"netlist",
".",
"signals",
"while",
"toSearch",
":",
"_toSearch",
"=",
"set",
"(",
")",
"for",
"sig",
"in",
"toSearch",
":",
"if",
"not",
"sig... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | checkIfIsTooSimple | check if process is just unconditional assignments
and it is useless to merge them | hwt/synthesizer/rtlLevel/optimalizator.py | def checkIfIsTooSimple(proc):
"""check if process is just unconditional assignments
and it is useless to merge them"""
try:
a, = proc.statements
if isinstance(a, Assignment):
return True
except ValueError:
pass
return False | def checkIfIsTooSimple(proc):
"""check if process is just unconditional assignments
and it is useless to merge them"""
try:
a, = proc.statements
if isinstance(a, Assignment):
return True
except ValueError:
pass
return False | [
"check",
"if",
"process",
"is",
"just",
"unconditional",
"assignments",
"and",
"it",
"is",
"useless",
"to",
"merge",
"them"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/optimalizator.py#L67-L76 | [
"def",
"checkIfIsTooSimple",
"(",
"proc",
")",
":",
"try",
":",
"a",
",",
"=",
"proc",
".",
"statements",
"if",
"isinstance",
"(",
"a",
",",
"Assignment",
")",
":",
"return",
"True",
"except",
"ValueError",
":",
"pass",
"return",
"False"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | tryToMerge | Try merge procB into procA
:raise IncompatibleStructure: if merge is not possible
:attention: procA is now result if merge has succeed
:return: procA which is now result of merge | hwt/synthesizer/rtlLevel/optimalizator.py | def tryToMerge(procA: HWProcess, procB: HWProcess):
"""
Try merge procB into procA
:raise IncompatibleStructure: if merge is not possible
:attention: procA is now result if merge has succeed
:return: procA which is now result of merge
"""
if (checkIfIsTooSimple(procA) or
checkIf... | def tryToMerge(procA: HWProcess, procB: HWProcess):
"""
Try merge procB into procA
:raise IncompatibleStructure: if merge is not possible
:attention: procA is now result if merge has succeed
:return: procA which is now result of merge
"""
if (checkIfIsTooSimple(procA) or
checkIf... | [
"Try",
"merge",
"procB",
"into",
"procA"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/optimalizator.py#L80-L102 | [
"def",
"tryToMerge",
"(",
"procA",
":",
"HWProcess",
",",
"procB",
":",
"HWProcess",
")",
":",
"if",
"(",
"checkIfIsTooSimple",
"(",
"procA",
")",
"or",
"checkIfIsTooSimple",
"(",
"procB",
")",
"or",
"areSetsIntersets",
"(",
"procA",
".",
"outputs",
",",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | reduceProcesses | Try to merge processes as much is possible
:param processes: list of processes instances | hwt/synthesizer/rtlLevel/optimalizator.py | def reduceProcesses(processes):
"""
Try to merge processes as much is possible
:param processes: list of processes instances
"""
# sort to make order of merging same deterministic
processes.sort(key=lambda x: (x.name, maxStmId(x)), reverse=True)
# now try to reduce processes with nearly sam... | def reduceProcesses(processes):
"""
Try to merge processes as much is possible
:param processes: list of processes instances
"""
# sort to make order of merging same deterministic
processes.sort(key=lambda x: (x.name, maxStmId(x)), reverse=True)
# now try to reduce processes with nearly sam... | [
"Try",
"to",
"merge",
"processes",
"as",
"much",
"is",
"possible"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/optimalizator.py#L106-L133 | [
"def",
"reduceProcesses",
"(",
"processes",
")",
":",
"# sort to make order of merging same deterministic",
"processes",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"name",
",",
"maxStmId",
"(",
"x",
")",
")",
",",
"reverse",
"=",
"True"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | BramPort_withoutClkAgent.onWriteReq | on writeReqRecieved in monitor mode | hwt/interfaces/agents/bramPort.py | def onWriteReq(self, sim, addr, data):
"""
on writeReqRecieved in monitor mode
"""
self.requests.append((WRITE, addr, data)) | def onWriteReq(self, sim, addr, data):
"""
on writeReqRecieved in monitor mode
"""
self.requests.append((WRITE, addr, data)) | [
"on",
"writeReqRecieved",
"in",
"monitor",
"mode"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/interfaces/agents/bramPort.py#L62-L66 | [
"def",
"onWriteReq",
"(",
"self",
",",
"sim",
",",
"addr",
",",
"data",
")",
":",
"self",
".",
"requests",
".",
"append",
"(",
"(",
"WRITE",
",",
"addr",
",",
"data",
")",
")"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | HwtSerializer.asHdl | Convert object to HDL string
:param obj: object to serialize
:param ctx: HwtSerializerCtx instance | hwt/serializer/hwt/serializer.py | def asHdl(cls, obj, ctx: HwtSerializerCtx):
"""
Convert object to HDL string
:param obj: object to serialize
:param ctx: HwtSerializerCtx instance
"""
if isinstance(obj, RtlSignalBase):
return cls.SignalItem(obj, ctx)
elif isinstance(obj, Value):
... | def asHdl(cls, obj, ctx: HwtSerializerCtx):
"""
Convert object to HDL string
:param obj: object to serialize
:param ctx: HwtSerializerCtx instance
"""
if isinstance(obj, RtlSignalBase):
return cls.SignalItem(obj, ctx)
elif isinstance(obj, Value):
... | [
"Convert",
"object",
"to",
"HDL",
"string"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/hwt/serializer.py#L57-L84 | [
"def",
"asHdl",
"(",
"cls",
",",
"obj",
",",
"ctx",
":",
"HwtSerializerCtx",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"RtlSignalBase",
")",
":",
"return",
"cls",
".",
"SignalItem",
"(",
"obj",
",",
"ctx",
")",
"elif",
"isinstance",
"(",
"obj",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | HwtSerializer.Entity | Entity is just forward declaration of Architecture, it is not used
in most HDL languages as there is no recursion in hierarchy | hwt/serializer/hwt/serializer.py | def Entity(cls, ent: Entity, ctx: HwtSerializerCtx):
"""
Entity is just forward declaration of Architecture, it is not used
in most HDL languages as there is no recursion in hierarchy
"""
cls.Entity_prepare(ent, ctx, serialize=False)
ent.name = ctx.scope.checkedName(ent.... | def Entity(cls, ent: Entity, ctx: HwtSerializerCtx):
"""
Entity is just forward declaration of Architecture, it is not used
in most HDL languages as there is no recursion in hierarchy
"""
cls.Entity_prepare(ent, ctx, serialize=False)
ent.name = ctx.scope.checkedName(ent.... | [
"Entity",
"is",
"just",
"forward",
"declaration",
"of",
"Architecture",
"it",
"is",
"not",
"used",
"in",
"most",
"HDL",
"languages",
"as",
"there",
"is",
"no",
"recursion",
"in",
"hierarchy"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/hwt/serializer.py#L95-L109 | [
"def",
"Entity",
"(",
"cls",
",",
"ent",
":",
"Entity",
",",
"ctx",
":",
"HwtSerializerCtx",
")",
":",
"cls",
".",
"Entity_prepare",
"(",
"ent",
",",
"ctx",
",",
"serialize",
"=",
"False",
")",
"ent",
".",
"name",
"=",
"ctx",
".",
"scope",
".",
"ch... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | toRtl | Convert unit to RTL using specified serializer
:param unitOrCls: unit instance or class, which should be converted
:param name: name override of top unit (if is None name is derived
form class name)
:param serializer: serializer which should be used for to RTL conversion
:param targetPlatform: ... | hwt/synthesizer/utils.py | def toRtl(unitOrCls: Unit, name: str=None,
serializer: GenericSerializer=VhdlSerializer,
targetPlatform=DummyPlatform(), saveTo: str=None):
"""
Convert unit to RTL using specified serializer
:param unitOrCls: unit instance or class, which should be converted
:param name: name overri... | def toRtl(unitOrCls: Unit, name: str=None,
serializer: GenericSerializer=VhdlSerializer,
targetPlatform=DummyPlatform(), saveTo: str=None):
"""
Convert unit to RTL using specified serializer
:param unitOrCls: unit instance or class, which should be converted
:param name: name overri... | [
"Convert",
"unit",
"to",
"RTL",
"using",
"specified",
"serializer"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/utils.py#L17-L134 | [
"def",
"toRtl",
"(",
"unitOrCls",
":",
"Unit",
",",
"name",
":",
"str",
"=",
"None",
",",
"serializer",
":",
"GenericSerializer",
"=",
"VhdlSerializer",
",",
"targetPlatform",
"=",
"DummyPlatform",
"(",
")",
",",
"saveTo",
":",
"str",
"=",
"None",
")",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | name_for_process_and_mark_outputs | Resolve name for process and mark outputs of statemens as not hidden | hwt/synthesizer/rtlLevel/netlist.py | def name_for_process_and_mark_outputs(statements: List[HdlStatement])\
-> str:
"""
Resolve name for process and mark outputs of statemens as not hidden
"""
out_names = []
for stm in statements:
for sig in stm._outputs:
if not sig.hasGenericName:
out_names.... | def name_for_process_and_mark_outputs(statements: List[HdlStatement])\
-> str:
"""
Resolve name for process and mark outputs of statemens as not hidden
"""
out_names = []
for stm in statements:
for sig in stm._outputs:
if not sig.hasGenericName:
out_names.... | [
"Resolve",
"name",
"for",
"process",
"and",
"mark",
"outputs",
"of",
"statemens",
"as",
"not",
"hidden"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L31-L45 | [
"def",
"name_for_process_and_mark_outputs",
"(",
"statements",
":",
"List",
"[",
"HdlStatement",
"]",
")",
"->",
"str",
":",
"out_names",
"=",
"[",
"]",
"for",
"stm",
"in",
"statements",
":",
"for",
"sig",
"in",
"stm",
".",
"_outputs",
":",
"if",
"not",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | cut_off_drivers_of | Cut off drivers from statements | hwt/synthesizer/rtlLevel/netlist.py | def cut_off_drivers_of(dstSignal, statements):
"""
Cut off drivers from statements
"""
separated = []
stm_filter = []
for stm in statements:
stm._clean_signal_meta()
d = stm._cut_off_drivers_of(dstSignal)
if d is not None:
separated.append(d)
f = d is... | def cut_off_drivers_of(dstSignal, statements):
"""
Cut off drivers from statements
"""
separated = []
stm_filter = []
for stm in statements:
stm._clean_signal_meta()
d = stm._cut_off_drivers_of(dstSignal)
if d is not None:
separated.append(d)
f = d is... | [
"Cut",
"off",
"drivers",
"from",
"statements"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L49-L64 | [
"def",
"cut_off_drivers_of",
"(",
"dstSignal",
",",
"statements",
")",
":",
"separated",
"=",
"[",
"]",
"stm_filter",
"=",
"[",
"]",
"for",
"stm",
"in",
"statements",
":",
"stm",
".",
"_clean_signal_meta",
"(",
")",
"d",
"=",
"stm",
".",
"_cut_off_drivers_... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | statements_to_HWProcesses | Pack statements into HWProcess instances,
* for each out signal resolve it's drivers and collect them
* split statements if there is and combinational loop
* merge statements if it is possible
* resolve sensitivitilists
* wrap into HWProcess instance
* for every IO of process generate name if si... | hwt/synthesizer/rtlLevel/netlist.py | def statements_to_HWProcesses(statements: List[HdlStatement])\
-> Generator[HWProcess, None, None]:
"""
Pack statements into HWProcess instances,
* for each out signal resolve it's drivers and collect them
* split statements if there is and combinational loop
* merge statements if it is poss... | def statements_to_HWProcesses(statements: List[HdlStatement])\
-> Generator[HWProcess, None, None]:
"""
Pack statements into HWProcess instances,
* for each out signal resolve it's drivers and collect them
* split statements if there is and combinational loop
* merge statements if it is poss... | [
"Pack",
"statements",
"into",
"HWProcess",
"instances",
"*",
"for",
"each",
"out",
"signal",
"resolve",
"it",
"s",
"drivers",
"and",
"collect",
"them",
"*",
"split",
"statements",
"if",
"there",
"is",
"and",
"combinational",
"loop",
"*",
"merge",
"statements",... | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L138-L161 | [
"def",
"statements_to_HWProcesses",
"(",
"statements",
":",
"List",
"[",
"HdlStatement",
"]",
")",
"->",
"Generator",
"[",
"HWProcess",
",",
"None",
",",
"None",
"]",
":",
"# create copy because this set will be reduced",
"statements",
"=",
"copy",
"(",
"statements"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | markVisibilityOfSignals | * check if all signals are driven by something
* mark signals with hidden = False if they are connecting statements
or if they are external interface | hwt/synthesizer/rtlLevel/netlist.py | def markVisibilityOfSignals(ctx, ctxName, signals, interfaceSignals):
"""
* check if all signals are driven by something
* mark signals with hidden = False if they are connecting statements
or if they are external interface
"""
for sig in signals:
driver_cnt = len(sig.drivers)
... | def markVisibilityOfSignals(ctx, ctxName, signals, interfaceSignals):
"""
* check if all signals are driven by something
* mark signals with hidden = False if they are connecting statements
or if they are external interface
"""
for sig in signals:
driver_cnt = len(sig.drivers)
... | [
"*",
"check",
"if",
"all",
"signals",
"are",
"driven",
"by",
"something",
"*",
"mark",
"signals",
"with",
"hidden",
"=",
"False",
"if",
"they",
"are",
"connecting",
"statements",
"or",
"if",
"they",
"are",
"external",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L175-L216 | [
"def",
"markVisibilityOfSignals",
"(",
"ctx",
",",
"ctxName",
",",
"signals",
",",
"interfaceSignals",
")",
":",
"for",
"sig",
"in",
"signals",
":",
"driver_cnt",
"=",
"len",
"(",
"sig",
".",
"drivers",
")",
"has_comb_driver",
"=",
"False",
"if",
"driver_cnt... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | RtlNetlist.sig | Create new signal in this context
:param clk: clk signal, if specified signal is synthesized
as SyncSignal
:param syncRst: synchronous reset signal | hwt/synthesizer/rtlLevel/netlist.py | def sig(self, name, dtype=BIT, clk=None, syncRst=None, defVal=None):
"""
Create new signal in this context
:param clk: clk signal, if specified signal is synthesized
as SyncSignal
:param syncRst: synchronous reset signal
"""
if isinstance(defVal, RtlSignal):
... | def sig(self, name, dtype=BIT, clk=None, syncRst=None, defVal=None):
"""
Create new signal in this context
:param clk: clk signal, if specified signal is synthesized
as SyncSignal
:param syncRst: synchronous reset signal
"""
if isinstance(defVal, RtlSignal):
... | [
"Create",
"new",
"signal",
"in",
"this",
"context"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L240-L284 | [
"def",
"sig",
"(",
"self",
",",
"name",
",",
"dtype",
"=",
"BIT",
",",
"clk",
"=",
"None",
",",
"syncRst",
"=",
"None",
",",
"defVal",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"defVal",
",",
"RtlSignal",
")",
":",
"assert",
"defVal",
".",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | RtlNetlist.synthesize | Build Entity and Architecture instance out of netlist representation | hwt/synthesizer/rtlLevel/netlist.py | def synthesize(self, name, interfaces, targetPlatform):
"""
Build Entity and Architecture instance out of netlist representation
"""
ent = Entity(name)
ent._name = name + "_inst" # instance name
# create generics
for _, v in self.params.items():
ent.... | def synthesize(self, name, interfaces, targetPlatform):
"""
Build Entity and Architecture instance out of netlist representation
"""
ent = Entity(name)
ent._name = name + "_inst" # instance name
# create generics
for _, v in self.params.items():
ent.... | [
"Build",
"Entity",
"and",
"Architecture",
"instance",
"out",
"of",
"netlist",
"representation"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L286-L335 | [
"def",
"synthesize",
"(",
"self",
",",
"name",
",",
"interfaces",
",",
"targetPlatform",
")",
":",
"ent",
"=",
"Entity",
"(",
"name",
")",
"ent",
".",
"_name",
"=",
"name",
"+",
"\"_inst\"",
"# instance name",
"# create generics",
"for",
"_",
",",
"v",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | toHVal | Convert python or hdl value/signal object to hdl value/signal object | hwt/hdl/types/typeCast.py | def toHVal(op: Any, suggestedType: Optional[HdlType]=None):
"""Convert python or hdl value/signal object to hdl value/signal object"""
if isinstance(op, Value) or isinstance(op, SignalItem):
return op
elif isinstance(op, InterfaceBase):
return op._sig
else:
if isinstance(op, int)... | def toHVal(op: Any, suggestedType: Optional[HdlType]=None):
"""Convert python or hdl value/signal object to hdl value/signal object"""
if isinstance(op, Value) or isinstance(op, SignalItem):
return op
elif isinstance(op, InterfaceBase):
return op._sig
else:
if isinstance(op, int)... | [
"Convert",
"python",
"or",
"hdl",
"value",
"/",
"signal",
"object",
"to",
"hdl",
"value",
"/",
"signal",
"object"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/typeCast.py#L16-L43 | [
"def",
"toHVal",
"(",
"op",
":",
"Any",
",",
"suggestedType",
":",
"Optional",
"[",
"HdlType",
"]",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"op",
",",
"Value",
")",
"or",
"isinstance",
"(",
"op",
",",
"SignalItem",
")",
":",
"return",
"op",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | GenericSerializer_Value.Value | :param dst: is signal connected with value
:param val: value object, can be instance of Signal or Value | hwt/serializer/generic/value.py | def Value(cls, val, ctx: SerializerCtx):
"""
:param dst: is signal connected with value
:param val: value object, can be instance of Signal or Value
"""
t = val._dtype
if isinstance(val, RtlSignalBase):
return cls.SignalItem(val, ctx)
c = cls.Value_t... | def Value(cls, val, ctx: SerializerCtx):
"""
:param dst: is signal connected with value
:param val: value object, can be instance of Signal or Value
"""
t = val._dtype
if isinstance(val, RtlSignalBase):
return cls.SignalItem(val, ctx)
c = cls.Value_t... | [
":",
"param",
"dst",
":",
"is",
"signal",
"connected",
"with",
"value",
":",
"param",
"val",
":",
"value",
"object",
"can",
"be",
"instance",
"of",
"Signal",
"or",
"Value"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/generic/value.py#L16-L47 | [
"def",
"Value",
"(",
"cls",
",",
"val",
",",
"ctx",
":",
"SerializerCtx",
")",
":",
"t",
"=",
"val",
".",
"_dtype",
"if",
"isinstance",
"(",
"val",
",",
"RtlSignalBase",
")",
":",
"return",
"cls",
".",
"SignalItem",
"(",
"val",
",",
"ctx",
")",
"c"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | getMaxStmIdForStm | Get maximum _instId from all assigments in statement | hwt/serializer/utils.py | def getMaxStmIdForStm(stm):
"""
Get maximum _instId from all assigments in statement
"""
maxId = 0
if isinstance(stm, Assignment):
return stm._instId
elif isinstance(stm, WaitStm):
return maxId
else:
for _stm in stm._iter_stms():
maxId = max(maxId, getMaxS... | def getMaxStmIdForStm(stm):
"""
Get maximum _instId from all assigments in statement
"""
maxId = 0
if isinstance(stm, Assignment):
return stm._instId
elif isinstance(stm, WaitStm):
return maxId
else:
for _stm in stm._iter_stms():
maxId = max(maxId, getMaxS... | [
"Get",
"maximum",
"_instId",
"from",
"all",
"assigments",
"in",
"statement"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/utils.py#L7-L19 | [
"def",
"getMaxStmIdForStm",
"(",
"stm",
")",
":",
"maxId",
"=",
"0",
"if",
"isinstance",
"(",
"stm",
",",
"Assignment",
")",
":",
"return",
"stm",
".",
"_instId",
"elif",
"isinstance",
"(",
"stm",
",",
"WaitStm",
")",
":",
"return",
"maxId",
"else",
":... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | maxStmId | get max statement id,
used for sorting of processes in architecture | hwt/serializer/utils.py | def maxStmId(proc):
"""
get max statement id,
used for sorting of processes in architecture
"""
maxId = 0
for stm in proc.statements:
maxId = max(maxId, getMaxStmIdForStm(stm))
return maxId | def maxStmId(proc):
"""
get max statement id,
used for sorting of processes in architecture
"""
maxId = 0
for stm in proc.statements:
maxId = max(maxId, getMaxStmIdForStm(stm))
return maxId | [
"get",
"max",
"statement",
"id",
"used",
"for",
"sorting",
"of",
"processes",
"in",
"architecture"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/utils.py#L23-L31 | [
"def",
"maxStmId",
"(",
"proc",
")",
":",
"maxId",
"=",
"0",
"for",
"stm",
"in",
"proc",
".",
"statements",
":",
"maxId",
"=",
"max",
"(",
"maxId",
",",
"getMaxStmIdForStm",
"(",
"stm",
")",
")",
"return",
"maxId"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | RdSyncedAgent.monitor | Collect data from interface | hwt/interfaces/agents/rdSynced.py | def monitor(self, sim):
"""Collect data from interface"""
if self.notReset(sim) and self._enabled:
self.wrRd(sim.write, 1)
yield sim.waitOnCombUpdate()
d = self.doRead(sim)
self.data.append(d)
else:
self.wrRd(sim.write, 0) | def monitor(self, sim):
"""Collect data from interface"""
if self.notReset(sim) and self._enabled:
self.wrRd(sim.write, 1)
yield sim.waitOnCombUpdate()
d = self.doRead(sim)
self.data.append(d)
else:
self.wrRd(sim.write, 0) | [
"Collect",
"data",
"from",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/interfaces/agents/rdSynced.py#L31-L41 | [
"def",
"monitor",
"(",
"self",
",",
"sim",
")",
":",
"if",
"self",
".",
"notReset",
"(",
"sim",
")",
"and",
"self",
".",
"_enabled",
":",
"self",
".",
"wrRd",
"(",
"sim",
".",
"write",
",",
"1",
")",
"yield",
"sim",
".",
"waitOnCombUpdate",
"(",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | RdSyncedAgent.doWrite | write data to interface | hwt/interfaces/agents/rdSynced.py | def doWrite(self, sim, data):
"""write data to interface"""
sim.write(data, self.intf.data) | def doWrite(self, sim, data):
"""write data to interface"""
sim.write(data, self.intf.data) | [
"write",
"data",
"to",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/interfaces/agents/rdSynced.py#L47-L49 | [
"def",
"doWrite",
"(",
"self",
",",
"sim",
",",
"data",
")",
":",
"sim",
".",
"write",
"(",
"data",
",",
"self",
".",
"intf",
".",
"data",
")"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | RdSyncedAgent.driver | Push data to interface | hwt/interfaces/agents/rdSynced.py | def driver(self, sim):
"""Push data to interface"""
r = sim.read
if self.actualData is NOP and self.data:
self.actualData = self.data.popleft()
do = self.actualData is not NOP
if do:
self.doWrite(sim, self.actualData)
else:
self.doWri... | def driver(self, sim):
"""Push data to interface"""
r = sim.read
if self.actualData is NOP and self.data:
self.actualData = self.data.popleft()
do = self.actualData is not NOP
if do:
self.doWrite(sim, self.actualData)
else:
self.doWri... | [
"Push",
"data",
"to",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/interfaces/agents/rdSynced.py#L51-L84 | [
"def",
"driver",
"(",
"self",
",",
"sim",
")",
":",
"r",
"=",
"sim",
".",
"read",
"if",
"self",
".",
"actualData",
"is",
"NOP",
"and",
"self",
".",
"data",
":",
"self",
".",
"actualData",
"=",
"self",
".",
"data",
".",
"popleft",
"(",
")",
"do",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | IntegerVal.fromPy | :param val: value of python type int or None
:param typeObj: instance of Integer
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid | hwt/hdl/types/integerVal.py | def fromPy(cls, val, typeObj, vldMask=None):
"""
:param val: value of python type int or None
:param typeObj: instance of Integer
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid
"""
asse... | def fromPy(cls, val, typeObj, vldMask=None):
"""
:param val: value of python type int or None
:param typeObj: instance of Integer
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid
"""
asse... | [
":",
"param",
"val",
":",
"value",
"of",
"python",
"type",
"int",
"or",
"None",
":",
"param",
"typeObj",
":",
"instance",
"of",
"Integer",
":",
"param",
"vldMask",
":",
"None",
"vldMask",
"is",
"resolved",
"from",
"val",
"if",
"is",
"0",
"value",
"is",... | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/integerVal.py#L50-L70 | [
"def",
"fromPy",
"(",
"cls",
",",
"val",
",",
"typeObj",
",",
"vldMask",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"typeObj",
",",
"Integer",
")",
"vld",
"=",
"int",
"(",
"val",
"is",
"not",
"None",
")",
"if",
"not",
"vld",
":",
"assert",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._m | Note that this interface will be master
:return: self | hwt/synthesizer/interface.py | def _m(self):
"""
Note that this interface will be master
:return: self
"""
assert not hasattr(self, "_interfaces") or not self._interfaces, \
"Too late to change direction of interface"
self._direction = DIRECTION.asIntfDirection(DIRECTION.opposite(self._mas... | def _m(self):
"""
Note that this interface will be master
:return: self
"""
assert not hasattr(self, "_interfaces") or not self._interfaces, \
"Too late to change direction of interface"
self._direction = DIRECTION.asIntfDirection(DIRECTION.opposite(self._mas... | [
"Note",
"that",
"this",
"interface",
"will",
"be",
"master"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L99-L109 | [
"def",
"_m",
"(",
"self",
")",
":",
"assert",
"not",
"hasattr",
"(",
"self",
",",
"\"_interfaces\"",
")",
"or",
"not",
"self",
".",
"_interfaces",
",",
"\"Too late to change direction of interface\"",
"self",
".",
"_direction",
"=",
"DIRECTION",
".",
"asIntfDire... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._loadDeclarations | load declaratoins from _declr method
This function is called first for parent and then for children | hwt/synthesizer/interface.py | def _loadDeclarations(self):
"""
load declaratoins from _declr method
This function is called first for parent and then for children
"""
if not hasattr(self, "_interfaces"):
self._interfaces = []
self._setAttrListener = self._declrCollector
self._declr... | def _loadDeclarations(self):
"""
load declaratoins from _declr method
This function is called first for parent and then for children
"""
if not hasattr(self, "_interfaces"):
self._interfaces = []
self._setAttrListener = self._declrCollector
self._declr... | [
"load",
"declaratoins",
"from",
"_declr",
"method",
"This",
"function",
"is",
"called",
"first",
"for",
"parent",
"and",
"then",
"for",
"children"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L118-L140 | [
"def",
"_loadDeclarations",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_interfaces\"",
")",
":",
"self",
".",
"_interfaces",
"=",
"[",
"]",
"self",
".",
"_setAttrListener",
"=",
"self",
".",
"_declrCollector",
"self",
".",
"_declr"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._clean | Remove all signals from this interface (used after unit is synthesized
and its parent is connecting its interface to this unit) | hwt/synthesizer/interface.py | def _clean(self, rmConnetions=True, lockNonExternal=True):
"""
Remove all signals from this interface (used after unit is synthesized
and its parent is connecting its interface to this unit)
"""
if self._interfaces:
for i in self._interfaces:
i._clean... | def _clean(self, rmConnetions=True, lockNonExternal=True):
"""
Remove all signals from this interface (used after unit is synthesized
and its parent is connecting its interface to this unit)
"""
if self._interfaces:
for i in self._interfaces:
i._clean... | [
"Remove",
"all",
"signals",
"from",
"this",
"interface",
"(",
"used",
"after",
"unit",
"is",
"synthesized",
"and",
"its",
"parent",
"is",
"connecting",
"its",
"interface",
"to",
"this",
"unit",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L143-L158 | [
"def",
"_clean",
"(",
"self",
",",
"rmConnetions",
"=",
"True",
",",
"lockNonExternal",
"=",
"True",
")",
":",
"if",
"self",
".",
"_interfaces",
":",
"for",
"i",
"in",
"self",
".",
"_interfaces",
":",
"i",
".",
"_clean",
"(",
"rmConnetions",
"=",
"rmCo... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._signalsForInterface | generate _sig for each interface which has no subinterface
if already has _sig return it instead
:param context: instance of RtlNetlist where signals should be created
:param prefix: name prefix for created signals
:param typeTransform: optional function (type) returns modified type
... | hwt/synthesizer/interface.py | def _signalsForInterface(self, context, prefix='', typeTransform=None):
"""
generate _sig for each interface which has no subinterface
if already has _sig return it instead
:param context: instance of RtlNetlist where signals should be created
:param prefix: name prefix for crea... | def _signalsForInterface(self, context, prefix='', typeTransform=None):
"""
generate _sig for each interface which has no subinterface
if already has _sig return it instead
:param context: instance of RtlNetlist where signals should be created
:param prefix: name prefix for crea... | [
"generate",
"_sig",
"for",
"each",
"interface",
"which",
"has",
"no",
"subinterface",
"if",
"already",
"has",
"_sig",
"return",
"it",
"instead"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L200-L232 | [
"def",
"_signalsForInterface",
"(",
"self",
",",
"context",
",",
"prefix",
"=",
"''",
",",
"typeTransform",
"=",
"None",
")",
":",
"sigs",
"=",
"[",
"]",
"if",
"self",
".",
"_interfaces",
":",
"for",
"intf",
"in",
"self",
".",
"_interfaces",
":",
"sigs... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._getPhysicalName | Get name in HDL | hwt/synthesizer/interface.py | def _getPhysicalName(self):
"""Get name in HDL """
if hasattr(self, "_boundedEntityPort"):
return self._boundedEntityPort.name
else:
return self._getFullName().replace('.', self._NAME_SEPARATOR) | def _getPhysicalName(self):
"""Get name in HDL """
if hasattr(self, "_boundedEntityPort"):
return self._boundedEntityPort.name
else:
return self._getFullName().replace('.', self._NAME_SEPARATOR) | [
"Get",
"name",
"in",
"HDL"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L234-L239 | [
"def",
"_getPhysicalName",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_boundedEntityPort\"",
")",
":",
"return",
"self",
".",
"_boundedEntityPort",
".",
"name",
"else",
":",
"return",
"self",
".",
"_getFullName",
"(",
")",
".",
"replace",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._replaceParam | Replace parameter on this interface (in configuration stage)
:ivar pName: actual name of param on me
:ivar newP: new Param instance by which should be old replaced | hwt/synthesizer/interface.py | def _replaceParam(self, p, newP):
"""
Replace parameter on this interface (in configuration stage)
:ivar pName: actual name of param on me
:ivar newP: new Param instance by which should be old replaced
"""
i = self._params.index(p)
pName = p._scopes[self][1]
... | def _replaceParam(self, p, newP):
"""
Replace parameter on this interface (in configuration stage)
:ivar pName: actual name of param on me
:ivar newP: new Param instance by which should be old replaced
"""
i = self._params.index(p)
pName = p._scopes[self][1]
... | [
"Replace",
"parameter",
"on",
"this",
"interface",
"(",
"in",
"configuration",
"stage",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L245-L258 | [
"def",
"_replaceParam",
"(",
"self",
",",
"p",
",",
"newP",
")",
":",
"i",
"=",
"self",
".",
"_params",
".",
"index",
"(",
"p",
")",
"pName",
"=",
"p",
".",
"_scopes",
"[",
"self",
"]",
"[",
"1",
"]",
"assert",
"i",
">",
"-",
"1",
"self",
"."... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._updateParamsFrom | :note: doc in :func:`~hwt.synthesizer.interfaceLevel.propDeclCollector._updateParamsFrom` | hwt/synthesizer/interface.py | def _updateParamsFrom(self, otherObj, updater=_default_param_updater,
exclude=None, prefix=""):
"""
:note: doc in :func:`~hwt.synthesizer.interfaceLevel.propDeclCollector._updateParamsFrom`
"""
PropDeclrCollector._updateParamsFrom(self, otherObj, updater, exclud... | def _updateParamsFrom(self, otherObj, updater=_default_param_updater,
exclude=None, prefix=""):
"""
:note: doc in :func:`~hwt.synthesizer.interfaceLevel.propDeclCollector._updateParamsFrom`
"""
PropDeclrCollector._updateParamsFrom(self, otherObj, updater, exclud... | [
":",
"note",
":",
"doc",
"in",
":",
"func",
":",
"~hwt",
".",
"synthesizer",
".",
"interfaceLevel",
".",
"propDeclCollector",
".",
"_updateParamsFrom"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L260-L265 | [
"def",
"_updateParamsFrom",
"(",
"self",
",",
"otherObj",
",",
"updater",
"=",
"_default_param_updater",
",",
"exclude",
"=",
"None",
",",
"prefix",
"=",
"\"\"",
")",
":",
"PropDeclrCollector",
".",
"_updateParamsFrom",
"(",
"self",
",",
"otherObj",
",",
"upda... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._bit_length | Sum of all width of interfaces in this interface | hwt/synthesizer/interface.py | def _bit_length(self):
"""Sum of all width of interfaces in this interface"""
try:
interfaces = self._interfaces
except AttributeError:
interfaces = None
if interfaces is None:
# not loaded interface
_intf = self._clone()
_intf... | def _bit_length(self):
"""Sum of all width of interfaces in this interface"""
try:
interfaces = self._interfaces
except AttributeError:
interfaces = None
if interfaces is None:
# not loaded interface
_intf = self._clone()
_intf... | [
"Sum",
"of",
"all",
"width",
"of",
"interfaces",
"in",
"this",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L267-L286 | [
"def",
"_bit_length",
"(",
"self",
")",
":",
"try",
":",
"interfaces",
"=",
"self",
".",
"_interfaces",
"except",
"AttributeError",
":",
"interfaces",
"=",
"None",
"if",
"interfaces",
"is",
"None",
":",
"# not loaded interface",
"_intf",
"=",
"self",
".",
"_... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | Interface._connectTo | connect to another interface interface (on rtl level)
works like self <= master in VHDL | hwt/synthesizer/interface.py | def _connectTo(self, master, exclude=None, fit=False):
"""
connect to another interface interface (on rtl level)
works like self <= master in VHDL
"""
return list(self._connectToIter(master, exclude, fit)) | def _connectTo(self, master, exclude=None, fit=False):
"""
connect to another interface interface (on rtl level)
works like self <= master in VHDL
"""
return list(self._connectToIter(master, exclude, fit)) | [
"connect",
"to",
"another",
"interface",
"interface",
"(",
"on",
"rtl",
"level",
")",
"works",
"like",
"self",
"<",
"=",
"master",
"in",
"VHDL"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/interface.py#L288-L293 | [
"def",
"_connectTo",
"(",
"self",
",",
"master",
",",
"exclude",
"=",
"None",
",",
"fit",
"=",
"False",
")",
":",
"return",
"list",
"(",
"self",
".",
"_connectToIter",
"(",
"master",
",",
"exclude",
",",
"fit",
")",
")"
] | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | sensitivityByOp | get sensitivity type for operator | hwt/hdl/operatorDefs.py | def sensitivityByOp(op):
"""
get sensitivity type for operator
"""
if op == AllOps.RISING_EDGE:
return SENSITIVITY.RISING
elif op == AllOps.FALLING_EDGE:
return SENSITIVITY.FALLING
else:
raise TypeError() | def sensitivityByOp(op):
"""
get sensitivity type for operator
"""
if op == AllOps.RISING_EDGE:
return SENSITIVITY.RISING
elif op == AllOps.FALLING_EDGE:
return SENSITIVITY.FALLING
else:
raise TypeError() | [
"get",
"sensitivity",
"type",
"for",
"operator"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/operatorDefs.py#L169-L178 | [
"def",
"sensitivityByOp",
"(",
"op",
")",
":",
"if",
"op",
"==",
"AllOps",
".",
"RISING_EDGE",
":",
"return",
"SENSITIVITY",
".",
"RISING",
"elif",
"op",
"==",
"AllOps",
".",
"FALLING_EDGE",
":",
"return",
"SENSITIVITY",
".",
"FALLING",
"else",
":",
"raise... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | OpDefinition.eval | Load all operands and process them by self._evalFn | hwt/hdl/operatorDefs.py | def eval(self, operator, simulator=None):
"""Load all operands and process them by self._evalFn"""
def getVal(v):
while not isinstance(v, Value):
v = v._val
return v
operands = list(map(getVal, operator.operands))
if isEventDependentOp(operator.... | def eval(self, operator, simulator=None):
"""Load all operands and process them by self._evalFn"""
def getVal(v):
while not isinstance(v, Value):
v = v._val
return v
operands = list(map(getVal, operator.operands))
if isEventDependentOp(operator.... | [
"Load",
"all",
"operands",
"and",
"process",
"them",
"by",
"self",
".",
"_evalFn"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/operatorDefs.py#L29-L44 | [
"def",
"eval",
"(",
"self",
",",
"operator",
",",
"simulator",
"=",
"None",
")",
":",
"def",
"getVal",
"(",
"v",
")",
":",
"while",
"not",
"isinstance",
"(",
"v",
",",
"Value",
")",
":",
"v",
"=",
"v",
".",
"_val",
"return",
"v",
"operands",
"=",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | convertBits | Cast signed-unsigned, to int or bool | hwt/hdl/types/bitsCast.py | def convertBits(self, sigOrVal, toType):
"""
Cast signed-unsigned, to int or bool
"""
if isinstance(sigOrVal, Value):
return convertBits__val(self, sigOrVal, toType)
elif isinstance(toType, HBool):
if self.bit_length() == 1:
v = 0 if sigOrVal._dtype.negated else 1
... | def convertBits(self, sigOrVal, toType):
"""
Cast signed-unsigned, to int or bool
"""
if isinstance(sigOrVal, Value):
return convertBits__val(self, sigOrVal, toType)
elif isinstance(toType, HBool):
if self.bit_length() == 1:
v = 0 if sigOrVal._dtype.negated else 1
... | [
"Cast",
"signed",
"-",
"unsigned",
"to",
"int",
"or",
"bool"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/bitsCast.py#L30-L46 | [
"def",
"convertBits",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
":",
"if",
"isinstance",
"(",
"sigOrVal",
",",
"Value",
")",
":",
"return",
"convertBits__val",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
"elif",
"isinstance",
"(",
"toType",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | reinterpret_bits_to_hstruct | Reinterpret signal of type Bits to signal of type HStruct | hwt/hdl/types/bitsCast.py | def reinterpret_bits_to_hstruct(sigOrVal, hStructT):
"""
Reinterpret signal of type Bits to signal of type HStruct
"""
container = hStructT.fromPy(None)
offset = 0
for f in hStructT.fields:
t = f.dtype
width = t.bit_length()
if f.name is not None:
s = sigOrVal... | def reinterpret_bits_to_hstruct(sigOrVal, hStructT):
"""
Reinterpret signal of type Bits to signal of type HStruct
"""
container = hStructT.fromPy(None)
offset = 0
for f in hStructT.fields:
t = f.dtype
width = t.bit_length()
if f.name is not None:
s = sigOrVal... | [
"Reinterpret",
"signal",
"of",
"type",
"Bits",
"to",
"signal",
"of",
"type",
"HStruct"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/bitsCast.py#L50-L66 | [
"def",
"reinterpret_bits_to_hstruct",
"(",
"sigOrVal",
",",
"hStructT",
")",
":",
"container",
"=",
"hStructT",
".",
"fromPy",
"(",
"None",
")",
"offset",
"=",
"0",
"for",
"f",
"in",
"hStructT",
".",
"fields",
":",
"t",
"=",
"f",
".",
"dtype",
"width",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | reinterpretBits | Cast object of same bit size between to other type
(f.e. bits to struct, union or array) | hwt/hdl/types/bitsCast.py | def reinterpretBits(self, sigOrVal, toType):
"""
Cast object of same bit size between to other type
(f.e. bits to struct, union or array)
"""
if isinstance(sigOrVal, Value):
return reinterpretBits__val(self, sigOrVal, toType)
elif isinstance(toType, Bits):
return fitTo_t(sigOrVal... | def reinterpretBits(self, sigOrVal, toType):
"""
Cast object of same bit size between to other type
(f.e. bits to struct, union or array)
"""
if isinstance(sigOrVal, Value):
return reinterpretBits__val(self, sigOrVal, toType)
elif isinstance(toType, Bits):
return fitTo_t(sigOrVal... | [
"Cast",
"object",
"of",
"same",
"bit",
"size",
"between",
"to",
"other",
"type",
"(",
"f",
".",
"e",
".",
"bits",
"to",
"struct",
"union",
"or",
"array",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/bitsCast.py#L96-L113 | [
"def",
"reinterpretBits",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
":",
"if",
"isinstance",
"(",
"sigOrVal",
",",
"Value",
")",
":",
"return",
"reinterpretBits__val",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
"elif",
"isinstance",
"(",
"to... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | iterSort | Sort items from iterators(generators) by alwas selecting item
with lowest value (min first)
:return: generator of tuples (origin index, item) where origin index
is index of iterator in "iterators" from where item commes from | hwt/hdl/frameTmplUtils.py | def iterSort(iterators, cmpFn):
"""
Sort items from iterators(generators) by alwas selecting item
with lowest value (min first)
:return: generator of tuples (origin index, item) where origin index
is index of iterator in "iterators" from where item commes from
"""
actual = []
_itera... | def iterSort(iterators, cmpFn):
"""
Sort items from iterators(generators) by alwas selecting item
with lowest value (min first)
:return: generator of tuples (origin index, item) where origin index
is index of iterator in "iterators" from where item commes from
"""
actual = []
_itera... | [
"Sort",
"items",
"from",
"iterators",
"(",
"generators",
")",
"by",
"alwas",
"selecting",
"item",
"with",
"lowest",
"value",
"(",
"min",
"first",
")"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L9-L70 | [
"def",
"iterSort",
"(",
"iterators",
",",
"cmpFn",
")",
":",
"actual",
"=",
"[",
"]",
"_iterators",
"=",
"[",
"]",
"for",
"i",
",",
"it",
"in",
"enumerate",
"(",
"iterators",
")",
":",
"try",
":",
"a",
"=",
"next",
"(",
"it",
")",
"_iterators",
"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | groupIntoChoices | :param splitsOnWord: list of lists of parts (fields splited on word
boundaries)
:return: generators of ChoicesOfFrameParts for each word
which are not crossing word boundaries | hwt/hdl/frameTmplUtils.py | def groupIntoChoices(splitsOnWord, wordWidth: int, origin: OneOfTransaction):
"""
:param splitsOnWord: list of lists of parts (fields splited on word
boundaries)
:return: generators of ChoicesOfFrameParts for each word
which are not crossing word boundaries
"""
def cmpWordIndex(a, b)... | def groupIntoChoices(splitsOnWord, wordWidth: int, origin: OneOfTransaction):
"""
:param splitsOnWord: list of lists of parts (fields splited on word
boundaries)
:return: generators of ChoicesOfFrameParts for each word
which are not crossing word boundaries
"""
def cmpWordIndex(a, b)... | [
":",
"param",
"splitsOnWord",
":",
"list",
"of",
"lists",
"of",
"parts",
"(",
"fields",
"splited",
"on",
"word",
"boundaries",
")",
":",
"return",
":",
"generators",
"of",
"ChoicesOfFrameParts",
"for",
"each",
"word",
"which",
"are",
"not",
"crossing",
"word... | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L168-L204 | [
"def",
"groupIntoChoices",
"(",
"splitsOnWord",
",",
"wordWidth",
":",
"int",
",",
"origin",
":",
"OneOfTransaction",
")",
":",
"def",
"cmpWordIndex",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
".",
"startOfPart",
"//",
"wordWidth",
"<",
"b",
".",
"sta... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | TransTmplWordIterator.fullWordCnt | Count of complete words between two addresses | hwt/hdl/frameTmplUtils.py | def fullWordCnt(self, start: int, end: int):
"""Count of complete words between two addresses
"""
assert end >= start, (start, end)
gap = max(0, (end - start) - (start % self.wordWidth))
return gap // self.wordWidth | def fullWordCnt(self, start: int, end: int):
"""Count of complete words between two addresses
"""
assert end >= start, (start, end)
gap = max(0, (end - start) - (start % self.wordWidth))
return gap // self.wordWidth | [
"Count",
"of",
"complete",
"words",
"between",
"two",
"addresses"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L215-L220 | [
"def",
"fullWordCnt",
"(",
"self",
",",
"start",
":",
"int",
",",
"end",
":",
"int",
")",
":",
"assert",
"end",
">=",
"start",
",",
"(",
"start",
",",
"end",
")",
"gap",
"=",
"max",
"(",
"0",
",",
"(",
"end",
"-",
"start",
")",
"-",
"(",
"sta... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | TransTmplWordIterator.groupByWordIndex | Group transaction parts splited on words to words
:param transaction: TransTmpl instance which parts
should be grupped into words
:return: generator of tuples (wordIndex, list of transaction parts
in this word) | hwt/hdl/frameTmplUtils.py | def groupByWordIndex(self, transaction: 'TransTmpl', offset: int):
"""
Group transaction parts splited on words to words
:param transaction: TransTmpl instance which parts
should be grupped into words
:return: generator of tuples (wordIndex, list of transaction parts
... | def groupByWordIndex(self, transaction: 'TransTmpl', offset: int):
"""
Group transaction parts splited on words to words
:param transaction: TransTmpl instance which parts
should be grupped into words
:return: generator of tuples (wordIndex, list of transaction parts
... | [
"Group",
"transaction",
"parts",
"splited",
"on",
"words",
"to",
"words"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L222-L247 | [
"def",
"groupByWordIndex",
"(",
"self",
",",
"transaction",
":",
"'TransTmpl'",
",",
"offset",
":",
"int",
")",
":",
"actualW",
"=",
"None",
"partsInWord",
"=",
"[",
"]",
"wordWidth",
"=",
"self",
".",
"wordWidth",
"for",
"item",
"in",
"self",
".",
"spli... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | TransTmplWordIterator.splitOnWords | :return: generator of TransPart instance | hwt/hdl/frameTmplUtils.py | def splitOnWords(self, transaction, addrOffset=0):
"""
:return: generator of TransPart instance
"""
wordWidth = self.wordWidth
end = addrOffset
for tmp in transaction.walkFlatten(offset=addrOffset):
if isinstance(tmp, OneOfTransaction):
split =... | def splitOnWords(self, transaction, addrOffset=0):
"""
:return: generator of TransPart instance
"""
wordWidth = self.wordWidth
end = addrOffset
for tmp in transaction.walkFlatten(offset=addrOffset):
if isinstance(tmp, OneOfTransaction):
split =... | [
":",
"return",
":",
"generator",
"of",
"TransPart",
"instance"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L250-L284 | [
"def",
"splitOnWords",
"(",
"self",
",",
"transaction",
",",
"addrOffset",
"=",
"0",
")",
":",
"wordWidth",
"=",
"self",
".",
"wordWidth",
"end",
"=",
"addrOffset",
"for",
"tmp",
"in",
"transaction",
".",
"walkFlatten",
"(",
"offset",
"=",
"addrOffset",
")... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | HBoolVal.fromPy | :param val: value of python type bool or None
:param typeObj: instance of HdlType
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid | hwt/hdl/types/boolVal.py | def fromPy(cls, val, typeObj, vldMask=None):
"""
:param val: value of python type bool or None
:param typeObj: instance of HdlType
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid
"""
vld... | def fromPy(cls, val, typeObj, vldMask=None):
"""
:param val: value of python type bool or None
:param typeObj: instance of HdlType
:param vldMask: None vldMask is resolved from val,
if is 0 value is invalidated
if is 1 value has to be valid
"""
vld... | [
":",
"param",
"val",
":",
"value",
"of",
"python",
"type",
"bool",
"or",
"None",
":",
"param",
"typeObj",
":",
"instance",
"of",
"HdlType",
":",
"param",
"vldMask",
":",
"None",
"vldMask",
"is",
"resolved",
"from",
"val",
"if",
"is",
"0",
"value",
"is"... | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/boolVal.py#L70-L89 | [
"def",
"fromPy",
"(",
"cls",
",",
"val",
",",
"typeObj",
",",
"vldMask",
"=",
"None",
")",
":",
"vld",
"=",
"int",
"(",
"val",
"is",
"not",
"None",
")",
"if",
"not",
"vld",
":",
"assert",
"vldMask",
"is",
"None",
"or",
"vldMask",
"==",
"0",
"val"... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | pprintInterface | Pretty print interface | hwt/simulator/utils.py | def pprintInterface(intf, prefix="", indent=0, file=sys.stdout):
"""
Pretty print interface
"""
try:
s = intf._sig
except AttributeError:
s = ""
if s is not "":
s = " " + repr(s)
file.write("".join([getIndent(indent), prefix, repr(intf._getFullName()),
... | def pprintInterface(intf, prefix="", indent=0, file=sys.stdout):
"""
Pretty print interface
"""
try:
s = intf._sig
except AttributeError:
s = ""
if s is not "":
s = " " + repr(s)
file.write("".join([getIndent(indent), prefix, repr(intf._getFullName()),
... | [
"Pretty",
"print",
"interface"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/utils.py#L14-L35 | [
"def",
"pprintInterface",
"(",
"intf",
",",
"prefix",
"=",
"\"\"",
",",
"indent",
"=",
"0",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"try",
":",
"s",
"=",
"intf",
".",
"_sig",
"except",
"AttributeError",
":",
"s",
"=",
"\"\"",
"if",
"s",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | FrameTmpl.framesFromTransTmpl | Convert transaction template into FrameTmpls
:param transaction: transaction template used which are FrameTmpls
created from
:param wordWidth: width of data signal in target interface
where frames will be used
:param maxFrameLen: maximum length of frame in bits,
... | hwt/hdl/frameTmpl.py | def framesFromTransTmpl(transaction: 'TransTmpl',
wordWidth: int,
maxFrameLen: Union[int, float]=inf,
maxPaddingWords: Union[int, float]=inf,
trimPaddingWordsOnStart: bool=False,
t... | def framesFromTransTmpl(transaction: 'TransTmpl',
wordWidth: int,
maxFrameLen: Union[int, float]=inf,
maxPaddingWords: Union[int, float]=inf,
trimPaddingWordsOnStart: bool=False,
t... | [
"Convert",
"transaction",
"template",
"into",
"FrameTmpls"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmpl.py#L67-L205 | [
"def",
"framesFromTransTmpl",
"(",
"transaction",
":",
"'TransTmpl'",
",",
"wordWidth",
":",
"int",
",",
"maxFrameLen",
":",
"Union",
"[",
"int",
",",
"float",
"]",
"=",
"inf",
",",
"maxPaddingWords",
":",
"Union",
"[",
"int",
",",
"float",
"]",
"=",
"in... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | FrameTmpl.walkWords | Walk enumerated words in this frame
:attention: not all indexes has to be present, only words
with items will be generated when not showPadding
:param showPadding: padding TransParts are also present
:return: generator of tuples (wordIndex, list of TransParts
in this wor... | hwt/hdl/frameTmpl.py | def walkWords(self, showPadding: bool=False):
"""
Walk enumerated words in this frame
:attention: not all indexes has to be present, only words
with items will be generated when not showPadding
:param showPadding: padding TransParts are also present
:return: generato... | def walkWords(self, showPadding: bool=False):
"""
Walk enumerated words in this frame
:attention: not all indexes has to be present, only words
with items will be generated when not showPadding
:param showPadding: padding TransParts are also present
:return: generato... | [
"Walk",
"enumerated",
"words",
"in",
"this",
"frame"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmpl.py#L220-L289 | [
"def",
"walkWords",
"(",
"self",
",",
"showPadding",
":",
"bool",
"=",
"False",
")",
":",
"wIndex",
"=",
"0",
"lastEnd",
"=",
"self",
".",
"startBitAddr",
"parts",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"parts",
":",
"end",
"=",
"p",
".",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | FrameTmpl.fieldToDataDict | Construct dictionary {StructField:value} for faster lookup of values
for fields | hwt/hdl/frameTmpl.py | def fieldToDataDict(dtype, data, res):
"""
Construct dictionary {StructField:value} for faster lookup of values
for fields
"""
# assert data is None or isinstance(data, dict)
for f in dtype.fields:
try:
fVal = data[f.name]
except Ke... | def fieldToDataDict(dtype, data, res):
"""
Construct dictionary {StructField:value} for faster lookup of values
for fields
"""
# assert data is None or isinstance(data, dict)
for f in dtype.fields:
try:
fVal = data[f.name]
except Ke... | [
"Construct",
"dictionary",
"{",
"StructField",
":",
"value",
"}",
"for",
"faster",
"lookup",
"of",
"values",
"for",
"fields"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmpl.py#L292-L316 | [
"def",
"fieldToDataDict",
"(",
"dtype",
",",
"data",
",",
"res",
")",
":",
"# assert data is None or isinstance(data, dict)",
"for",
"f",
"in",
"dtype",
".",
"fields",
":",
"try",
":",
"fVal",
"=",
"data",
"[",
"f",
".",
"name",
"]",
"except",
"KeyError",
... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
test | FrameTmpl.packData | Pack data into list of BitsVal of specified dataWidth
:param data: dict of values for struct fields {fieldName: value}
:return: list of BitsVal which are representing values of words | hwt/hdl/frameTmpl.py | def packData(self, data):
"""
Pack data into list of BitsVal of specified dataWidth
:param data: dict of values for struct fields {fieldName: value}
:return: list of BitsVal which are representing values of words
"""
typeOfWord = simBitsT(self.wordWidth, None)
f... | def packData(self, data):
"""
Pack data into list of BitsVal of specified dataWidth
:param data: dict of values for struct fields {fieldName: value}
:return: list of BitsVal which are representing values of words
"""
typeOfWord = simBitsT(self.wordWidth, None)
f... | [
"Pack",
"data",
"into",
"list",
"of",
"BitsVal",
"of",
"specified",
"dataWidth"
] | Nic30/hwt | python | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmpl.py#L318-L356 | [
"def",
"packData",
"(",
"self",
",",
"data",
")",
":",
"typeOfWord",
"=",
"simBitsT",
"(",
"self",
".",
"wordWidth",
",",
"None",
")",
"fieldToVal",
"=",
"self",
".",
"_fieldToTPart",
"if",
"fieldToVal",
"is",
"None",
":",
"fieldToVal",
"=",
"self",
".",... | 8cbb399e326da3b22c233b98188a9d08dec057e6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.