id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
3,000
UCSBarchlab/PyRTL
pyrtl/helperfuncs.py
formatted_str_to_val
def formatted_str_to_val(data, format, enum_set=None): """ Return an unsigned integer representation of the data given format specified. :param data: a string holding the value to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable...
python
def formatted_str_to_val(data, format, enum_set=None): type = format[0] bitwidth = int(format[1:].split('/')[0]) bitmask = (1 << bitwidth)-1 if type == 's': rval = int(data) & bitmask elif type == 'x': rval = int(data, 16) elif type == 'b': rval = int(data, 2) elif ty...
[ "def", "formatted_str_to_val", "(", "data", ",", "format", ",", "enum_set", "=", "None", ")", ":", "type", "=", "format", "[", "0", "]", "bitwidth", "=", "int", "(", "format", "[", "1", ":", "]", ".", "split", "(", "'/'", ")", "[", "0", "]", ")",...
Return an unsigned integer representation of the data given format specified. :param data: a string holding the value to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable of enums which are used as part of the converstion process ...
[ "Return", "an", "unsigned", "integer", "representation", "of", "the", "data", "given", "format", "specified", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/helperfuncs.py#L226-L274
3,001
UCSBarchlab/PyRTL
pyrtl/helperfuncs.py
val_to_formatted_str
def val_to_formatted_str(val, format, enum_set=None): """ Return a string representation of the value given format specified. :param val: a string holding an unsigned integer to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable o...
python
def val_to_formatted_str(val, format, enum_set=None): type = format[0] bitwidth = int(format[1:].split('/')[0]) bitmask = (1 << bitwidth)-1 if type == 's': rval = str(val_to_signed_integer(val, bitwidth)) elif type == 'x': rval = hex(val)[2:] # cuts off '0x' at the start elif ty...
[ "def", "val_to_formatted_str", "(", "val", ",", "format", ",", "enum_set", "=", "None", ")", ":", "type", "=", "format", "[", "0", "]", "bitwidth", "=", "int", "(", "format", "[", "1", ":", "]", ".", "split", "(", "'/'", ")", "[", "0", "]", ")", ...
Return a string representation of the value given format specified. :param val: a string holding an unsigned integer to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable of enums which are used as part of the converstion process ...
[ "Return", "a", "string", "representation", "of", "the", "value", "given", "format", "specified", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/helperfuncs.py#L277-L323
3,002
UCSBarchlab/PyRTL
pyrtl/helperfuncs.py
_NetCount.shrank
def shrank(self, block=None, percent_diff=0, abs_diff=1): """ Returns whether a block has less nets than before :param Block block: block to check (if changed) :param Number percent_diff: percentage difference threshold :param int abs_diff: absolute difference threshold ...
python
def shrank(self, block=None, percent_diff=0, abs_diff=1): if block is None: block = self.block cur_nets = len(block.logic) net_goal = self.prev_nets * (1 - percent_diff) - abs_diff less_nets = (cur_nets <= net_goal) self.prev_nets = cur_nets return less_nets
[ "def", "shrank", "(", "self", ",", "block", "=", "None", ",", "percent_diff", "=", "0", ",", "abs_diff", "=", "1", ")", ":", "if", "block", "is", "None", ":", "block", "=", "self", ".", "block", "cur_nets", "=", "len", "(", "block", ".", "logic", ...
Returns whether a block has less nets than before :param Block block: block to check (if changed) :param Number percent_diff: percentage difference threshold :param int abs_diff: absolute difference threshold :return: boolean This function checks whether the change in the numbe...
[ "Returns", "whether", "a", "block", "has", "less", "nets", "than", "before" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/helperfuncs.py#L463-L482
3,003
UCSBarchlab/PyRTL
pyrtl/rtllib/adders.py
kogge_stone
def kogge_stone(a, b, cin=0): """ Creates a Kogge-Stone adder given two inputs :param WireVector a, b: The two WireVectors to add up (bitwidths don't need to match) :param cin: An optimal carry in WireVector or value :return: a Wirevector representing the output of the adder The Kogge-Stone ad...
python
def kogge_stone(a, b, cin=0): a, b = libutils.match_bitwidth(a, b) prop_orig = a ^ b prop_bits = [i for i in prop_orig] gen_bits = [i for i in a & b] prop_dist = 1 # creation of the carry calculation while prop_dist < len(a): for i in reversed(range(prop_dist, len(a))): ...
[ "def", "kogge_stone", "(", "a", ",", "b", ",", "cin", "=", "0", ")", ":", "a", ",", "b", "=", "libutils", ".", "match_bitwidth", "(", "a", ",", "b", ")", "prop_orig", "=", "a", "^", "b", "prop_bits", "=", "[", "i", "for", "i", "in", "prop_orig"...
Creates a Kogge-Stone adder given two inputs :param WireVector a, b: The two WireVectors to add up (bitwidths don't need to match) :param cin: An optimal carry in WireVector or value :return: a Wirevector representing the output of the adder The Kogge-Stone adder is a fast tree-based adder with O(log(...
[ "Creates", "a", "Kogge", "-", "Stone", "adder", "given", "two", "inputs" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/adders.py#L6-L37
3,004
UCSBarchlab/PyRTL
pyrtl/rtllib/adders.py
_cla_adder_unit
def _cla_adder_unit(a, b, cin): """ Carry generation and propogation signals will be calculated only using the inputs; their values don't rely on the sum. Every unit generates a cout signal which is used as cin for the next unit. """ gen = a & b prop = a ^ b assert(len(prop) == len(gen)...
python
def _cla_adder_unit(a, b, cin): gen = a & b prop = a ^ b assert(len(prop) == len(gen)) carry = [gen[0] | prop[0] & cin] sum_bit = prop[0] ^ cin cur_gen = gen[0] cur_prop = prop[0] for i in range(1, len(prop)): cur_gen = gen[i] | (prop[i] & cur_gen) cur_prop = cur_prop &...
[ "def", "_cla_adder_unit", "(", "a", ",", "b", ",", "cin", ")", ":", "gen", "=", "a", "&", "b", "prop", "=", "a", "^", "b", "assert", "(", "len", "(", "prop", ")", "==", "len", "(", "gen", ")", ")", "carry", "=", "[", "gen", "[", "0", "]", ...
Carry generation and propogation signals will be calculated only using the inputs; their values don't rely on the sum. Every unit generates a cout signal which is used as cin for the next unit.
[ "Carry", "generation", "and", "propogation", "signals", "will", "be", "calculated", "only", "using", "the", "inputs", ";", "their", "values", "don", "t", "rely", "on", "the", "sum", ".", "Every", "unit", "generates", "a", "cout", "signal", "which", "is", "...
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/adders.py#L116-L137
3,005
UCSBarchlab/PyRTL
pyrtl/rtllib/adders.py
fast_group_adder
def fast_group_adder(wires_to_add, reducer=wallace_reducer, final_adder=kogge_stone): """ A generalization of the carry save adder, this is designed to add many numbers together in a both area and time efficient manner. Uses a tree reducer to achieve this performance :param [WireVector] wires_to_a...
python
def fast_group_adder(wires_to_add, reducer=wallace_reducer, final_adder=kogge_stone): import math longest_wire_len = max(len(w) for w in wires_to_add) result_bitwidth = longest_wire_len + int(math.ceil(math.log(len(wires_to_add), 2))) bits = [[] for i in range(longest_wire_len)] for wire in wires_...
[ "def", "fast_group_adder", "(", "wires_to_add", ",", "reducer", "=", "wallace_reducer", ",", "final_adder", "=", "kogge_stone", ")", ":", "import", "math", "longest_wire_len", "=", "max", "(", "len", "(", "w", ")", "for", "w", "in", "wires_to_add", ")", "res...
A generalization of the carry save adder, this is designed to add many numbers together in a both area and time efficient manner. Uses a tree reducer to achieve this performance :param [WireVector] wires_to_add: an array of wirevectors to add :param reducer: the tree reducer to use :param final_ad...
[ "A", "generalization", "of", "the", "carry", "save", "adder", "this", "is", "designed", "to", "add", "many", "numbers", "together", "in", "a", "both", "area", "and", "time", "efficient", "manner", ".", "Uses", "a", "tree", "reducer", "to", "achieve", "this...
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/adders.py#L258-L282
3,006
UCSBarchlab/PyRTL
pyrtl/memory.py
MemBlock._build
def _build(self, addr, data, enable): """ Builds a write port. """ if self.max_write_ports is not None: self.write_ports += 1 if self.write_ports > self.max_write_ports: raise PyrtlError('maximum number of write ports (%d) exceeded' % ...
python
def _build(self, addr, data, enable): if self.max_write_ports is not None: self.write_ports += 1 if self.write_ports > self.max_write_ports: raise PyrtlError('maximum number of write ports (%d) exceeded' % self.max_write_ports) wri...
[ "def", "_build", "(", "self", ",", "addr", ",", "data", ",", "enable", ")", ":", "if", "self", ".", "max_write_ports", "is", "not", "None", ":", "self", ".", "write_ports", "+=", "1", "if", "self", ".", "write_ports", ">", "self", ".", "max_write_ports...
Builds a write port.
[ "Builds", "a", "write", "port", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/memory.py#L236-L249
3,007
UCSBarchlab/PyRTL
pyrtl/rtllib/aes.py
AES.encryption
def encryption(self, plaintext, key): """ Builds a single cycle AES Encryption circuit :param WireVector plaintext: text to encrypt :param WireVector key: AES key to use to encrypt :return: a WireVector containing the ciphertext """ if len(plaintext) != self._ke...
python
def encryption(self, plaintext, key): if len(plaintext) != self._key_len: raise pyrtl.PyrtlError("Ciphertext length is invalid") if len(key) != self._key_len: raise pyrtl.PyrtlError("key length is invalid") key_list = self._key_gen(key) t = self._add_round_key(pl...
[ "def", "encryption", "(", "self", ",", "plaintext", ",", "key", ")", ":", "if", "len", "(", "plaintext", ")", "!=", "self", ".", "_key_len", ":", "raise", "pyrtl", ".", "PyrtlError", "(", "\"Ciphertext length is invalid\"", ")", "if", "len", "(", "key", ...
Builds a single cycle AES Encryption circuit :param WireVector plaintext: text to encrypt :param WireVector key: AES key to use to encrypt :return: a WireVector containing the ciphertext
[ "Builds", "a", "single", "cycle", "AES", "Encryption", "circuit" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/aes.py#L53-L76
3,008
UCSBarchlab/PyRTL
pyrtl/rtllib/aes.py
AES.encrypt_state_m
def encrypt_state_m(self, plaintext_in, key_in, reset): """ Builds a multiple cycle AES Encryption state machine circuit :param reset: a one bit signal telling the state machine to reset and accept the current plaintext and key :return ready, cipher_text: ready is a one bit si...
python
def encrypt_state_m(self, plaintext_in, key_in, reset): if len(key_in) != len(plaintext_in): raise pyrtl.PyrtlError("AES key and plaintext should be the same length") plain_text, key = (pyrtl.Register(len(plaintext_in)) for i in range(2)) key_exp_in, add_round_in = (pyrtl.WireVector...
[ "def", "encrypt_state_m", "(", "self", ",", "plaintext_in", ",", "key_in", ",", "reset", ")", ":", "if", "len", "(", "key_in", ")", "!=", "len", "(", "plaintext_in", ")", ":", "raise", "pyrtl", ".", "PyrtlError", "(", "\"AES key and plaintext should be the sam...
Builds a multiple cycle AES Encryption state machine circuit :param reset: a one bit signal telling the state machine to reset and accept the current plaintext and key :return ready, cipher_text: ready is a one bit signal showing that the encryption result (cipher_text) has been cal...
[ "Builds", "a", "multiple", "cycle", "AES", "Encryption", "state", "machine", "circuit" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/aes.py#L78-L125
3,009
UCSBarchlab/PyRTL
pyrtl/rtllib/aes.py
AES.decryption
def decryption(self, ciphertext, key): """ Builds a single cycle AES Decryption circuit :param WireVector ciphertext: data to decrypt :param WireVector key: AES key to use to encrypt (AES is symmetric) :return: a WireVector containing the plaintext """ if len(cip...
python
def decryption(self, ciphertext, key): if len(ciphertext) != self._key_len: raise pyrtl.PyrtlError("Ciphertext length is invalid") if len(key) != self._key_len: raise pyrtl.PyrtlError("key length is invalid") key_list = self._key_gen(key) t = self._add_round_key(c...
[ "def", "decryption", "(", "self", ",", "ciphertext", ",", "key", ")", ":", "if", "len", "(", "ciphertext", ")", "!=", "self", ".", "_key_len", ":", "raise", "pyrtl", ".", "PyrtlError", "(", "\"Ciphertext length is invalid\"", ")", "if", "len", "(", "key", ...
Builds a single cycle AES Decryption circuit :param WireVector ciphertext: data to decrypt :param WireVector key: AES key to use to encrypt (AES is symmetric) :return: a WireVector containing the plaintext
[ "Builds", "a", "single", "cycle", "AES", "Decryption", "circuit" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/aes.py#L127-L149
3,010
UCSBarchlab/PyRTL
pyrtl/rtllib/aes.py
AES.decryption_statem
def decryption_statem(self, ciphertext_in, key_in, reset): """ Builds a multiple cycle AES Decryption state machine circuit :param reset: a one bit signal telling the state machine to reset and accept the current plaintext and key :return ready, plain_text: ready is a one bit ...
python
def decryption_statem(self, ciphertext_in, key_in, reset): if len(key_in) != len(ciphertext_in): raise pyrtl.PyrtlError("AES key and ciphertext should be the same length") cipher_text, key = (pyrtl.Register(len(ciphertext_in)) for i in range(2)) key_exp_in, add_round_in = (pyrtl.Wir...
[ "def", "decryption_statem", "(", "self", ",", "ciphertext_in", ",", "key_in", ",", "reset", ")", ":", "if", "len", "(", "key_in", ")", "!=", "len", "(", "ciphertext_in", ")", ":", "raise", "pyrtl", ".", "PyrtlError", "(", "\"AES key and ciphertext should be th...
Builds a multiple cycle AES Decryption state machine circuit :param reset: a one bit signal telling the state machine to reset and accept the current plaintext and key :return ready, plain_text: ready is a one bit signal showing that the decryption result (plain_text) has been calcu...
[ "Builds", "a", "multiple", "cycle", "AES", "Decryption", "state", "machine", "circuit" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/aes.py#L151-L205
3,011
UCSBarchlab/PyRTL
pyrtl/rtllib/aes.py
AES._g
def _g(self, word, key_expand_round): """ One-byte left circular rotation, substitution of each byte """ import numbers self._build_memories_if_not_exists() a = libutils.partition_wire(word, 8) sub = [self.sbox[a[index]] for index in (3, 0, 1, 2)] if isins...
python
def _g(self, word, key_expand_round): import numbers self._build_memories_if_not_exists() a = libutils.partition_wire(word, 8) sub = [self.sbox[a[index]] for index in (3, 0, 1, 2)] if isinstance(key_expand_round, numbers.Number): rcon_data = self._rcon_data[key_expand...
[ "def", "_g", "(", "self", ",", "word", ",", "key_expand_round", ")", ":", "import", "numbers", "self", ".", "_build_memories_if_not_exists", "(", ")", "a", "=", "libutils", ".", "partition_wire", "(", "word", ",", "8", ")", "sub", "=", "[", "self", ".", ...
One-byte left circular rotation, substitution of each byte
[ "One", "-", "byte", "left", "circular", "rotation", "substitution", "of", "each", "byte" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/aes.py#L223-L236
3,012
usrlocalben/pydux
pydux/extend.py
extend
def extend(*args): """shallow dictionary merge Args: a: dict to extend b: dict to apply to a Returns: new instance of the same type as _a_, with _a_ and _b_ merged. """ if not args: return {} first = args[0] rest = args[1:] out = type(first)(first) ...
python
def extend(*args): if not args: return {} first = args[0] rest = args[1:] out = type(first)(first) for each in rest: out.update(each) return out
[ "def", "extend", "(", "*", "args", ")", ":", "if", "not", "args", ":", "return", "{", "}", "first", "=", "args", "[", "0", "]", "rest", "=", "args", "[", "1", ":", "]", "out", "=", "type", "(", "first", ")", "(", "first", ")", "for", "each", ...
shallow dictionary merge Args: a: dict to extend b: dict to apply to a Returns: new instance of the same type as _a_, with _a_ and _b_ merged.
[ "shallow", "dictionary", "merge" ]
943ca1c75357b9289f55f17ff2d997a66a3313a4
https://github.com/usrlocalben/pydux/blob/943ca1c75357b9289f55f17ff2d997a66a3313a4/pydux/extend.py#L1-L19
3,013
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
_trivialgraph_default_namer
def _trivialgraph_default_namer(thing, is_edge=True): """ Returns a "good" string for thing in printed graphs. """ if is_edge: if thing.name is None or thing.name.startswith('tmp'): return '' else: return '/'.join([thing.name, str(len(thing))]) elif isinstance(thing, ...
python
def _trivialgraph_default_namer(thing, is_edge=True): if is_edge: if thing.name is None or thing.name.startswith('tmp'): return '' else: return '/'.join([thing.name, str(len(thing))]) elif isinstance(thing, Const): return str(thing.val) elif isinstance(thing, ...
[ "def", "_trivialgraph_default_namer", "(", "thing", ",", "is_edge", "=", "True", ")", ":", "if", "is_edge", ":", "if", "thing", ".", "name", "is", "None", "or", "thing", ".", "name", ".", "startswith", "(", "'tmp'", ")", ":", "return", "''", "else", ":...
Returns a "good" string for thing in printed graphs.
[ "Returns", "a", "good", "string", "for", "thing", "in", "printed", "graphs", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L362-L377
3,014
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
net_graph
def net_graph(block=None, split_state=False): """ Return a graph representation of the current block. Graph has the following form: { node1: { nodeA: edge1A, nodeB: edge1B}, node2: { nodeB: edge2B, nodeC: edge2C}, ... } aka: edge = graph[source][dest] Each node can...
python
def net_graph(block=None, split_state=False): # FIXME: make it not try to add unused wires (issue #204) block = working_block(block) from .wire import Register # self.sanity_check() graph = {} # add all of the nodes for net in block.logic: graph[net] = {} wire_src_dict, wire_ds...
[ "def", "net_graph", "(", "block", "=", "None", ",", "split_state", "=", "False", ")", ":", "# FIXME: make it not try to add unused wires (issue #204)", "block", "=", "working_block", "(", "block", ")", "from", ".", "wire", "import", "Register", "# self.sanity_check()"...
Return a graph representation of the current block. Graph has the following form: { node1: { nodeA: edge1A, nodeB: edge1B}, node2: { nodeB: edge2B, nodeC: edge2C}, ... } aka: edge = graph[source][dest] Each node can be either a logic net or a WireVector (e.g. an Input,...
[ "Return", "a", "graph", "representation", "of", "the", "current", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L380-L435
3,015
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
output_to_trivialgraph
def output_to_trivialgraph(file, namer=_trivialgraph_default_namer, block=None): """ Walk the block and output it in trivial graph format to the open file. """ graph = net_graph(block) node_index_map = {} # map node -> index # print the list of nodes for index, node in enumerate(graph): pr...
python
def output_to_trivialgraph(file, namer=_trivialgraph_default_namer, block=None): graph = net_graph(block) node_index_map = {} # map node -> index # print the list of nodes for index, node in enumerate(graph): print('%d %s' % (index, namer(node, is_edge=False)), file=file) node_index_ma...
[ "def", "output_to_trivialgraph", "(", "file", ",", "namer", "=", "_trivialgraph_default_namer", ",", "block", "=", "None", ")", ":", "graph", "=", "net_graph", "(", "block", ")", "node_index_map", "=", "{", "}", "# map node -> index", "# print the list of nodes", ...
Walk the block and output it in trivial graph format to the open file.
[ "Walk", "the", "block", "and", "output", "it", "in", "trivial", "graph", "format", "to", "the", "open", "file", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L438-L456
3,016
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
_graphviz_default_namer
def _graphviz_default_namer(thing, is_edge=True, is_to_splitmerge=False): """ Returns a "good" graphviz label for thing. """ if is_edge: if (thing.name is None or thing.name.startswith('tmp') or isinstance(thing, (Input, Output, Const, Register))): name = '' ...
python
def _graphviz_default_namer(thing, is_edge=True, is_to_splitmerge=False): if is_edge: if (thing.name is None or thing.name.startswith('tmp') or isinstance(thing, (Input, Output, Const, Register))): name = '' else: name = '/'.join([thing.name, s...
[ "def", "_graphviz_default_namer", "(", "thing", ",", "is_edge", "=", "True", ",", "is_to_splitmerge", "=", "False", ")", ":", "if", "is_edge", ":", "if", "(", "thing", ".", "name", "is", "None", "or", "thing", ".", "name", ".", "startswith", "(", "'tmp'"...
Returns a "good" graphviz label for thing.
[ "Returns", "a", "good", "graphviz", "label", "for", "thing", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L459-L502
3,017
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
output_to_graphviz
def output_to_graphviz(file, namer=_graphviz_default_namer, block=None): """ Walk the block and output it in graphviz format to the open file. """ print(block_to_graphviz_string(block, namer), file=file)
python
def output_to_graphviz(file, namer=_graphviz_default_namer, block=None): print(block_to_graphviz_string(block, namer), file=file)
[ "def", "output_to_graphviz", "(", "file", ",", "namer", "=", "_graphviz_default_namer", ",", "block", "=", "None", ")", ":", "print", "(", "block_to_graphviz_string", "(", "block", ",", "namer", ")", ",", "file", "=", "file", ")" ]
Walk the block and output it in graphviz format to the open file.
[ "Walk", "the", "block", "and", "output", "it", "in", "graphviz", "format", "to", "the", "open", "file", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L505-L507
3,018
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
block_to_svg
def block_to_svg(block=None): """ Return an SVG for the block. """ block = working_block(block) try: from graphviz import Source return Source(block_to_graphviz_string())._repr_svg_() except ImportError: raise PyrtlError('need graphviz installed (try "pip install graphviz")')
python
def block_to_svg(block=None): block = working_block(block) try: from graphviz import Source return Source(block_to_graphviz_string())._repr_svg_() except ImportError: raise PyrtlError('need graphviz installed (try "pip install graphviz")')
[ "def", "block_to_svg", "(", "block", "=", "None", ")", ":", "block", "=", "working_block", "(", "block", ")", "try", ":", "from", "graphviz", "import", "Source", "return", "Source", "(", "block_to_graphviz_string", "(", ")", ")", ".", "_repr_svg_", "(", ")...
Return an SVG for the block.
[ "Return", "an", "SVG", "for", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L544-L551
3,019
UCSBarchlab/PyRTL
pyrtl/inputoutput.py
trace_to_html
def trace_to_html(simtrace, trace_list=None, sortkey=None): """ Return a HTML block showing the trace. """ from .simulation import SimulationTrace, _trace_sort_key if not isinstance(simtrace, SimulationTrace): raise PyrtlError('first arguement must be of type SimulationTrace') trace = simtrace...
python
def trace_to_html(simtrace, trace_list=None, sortkey=None): from .simulation import SimulationTrace, _trace_sort_key if not isinstance(simtrace, SimulationTrace): raise PyrtlError('first arguement must be of type SimulationTrace') trace = simtrace.trace if sortkey is None: sortkey = _tr...
[ "def", "trace_to_html", "(", "simtrace", ",", "trace_list", "=", "None", ",", "sortkey", "=", "None", ")", ":", "from", ".", "simulation", "import", "SimulationTrace", ",", "_trace_sort_key", "if", "not", "isinstance", "(", "simtrace", ",", "SimulationTrace", ...
Return a HTML block showing the trace.
[ "Return", "a", "HTML", "block", "showing", "the", "trace", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/inputoutput.py#L554-L607
3,020
usrlocalben/pydux
pydux/create_store.py
create_store
def create_store(reducer, initial_state=None, enhancer=None): """ redux in a nutshell. observable has been omitted. Args: reducer: root reducer function for the state tree initial_state: optional initial state data enhancer: optional enhancer function for middleware etc. R...
python
def create_store(reducer, initial_state=None, enhancer=None): if enhancer is not None: if not hasattr(enhancer, '__call__'): raise TypeError('Expected the enhancer to be a function.') return enhancer(create_store)(reducer, initial_state) if not hasattr(reducer, '__call__'): ...
[ "def", "create_store", "(", "reducer", ",", "initial_state", "=", "None", ",", "enhancer", "=", "None", ")", ":", "if", "enhancer", "is", "not", "None", ":", "if", "not", "hasattr", "(", "enhancer", ",", "'__call__'", ")", ":", "raise", "TypeError", "(",...
redux in a nutshell. observable has been omitted. Args: reducer: root reducer function for the state tree initial_state: optional initial state data enhancer: optional enhancer function for middleware etc. Returns: a Pydux store
[ "redux", "in", "a", "nutshell", "." ]
943ca1c75357b9289f55f17ff2d997a66a3313a4
https://github.com/usrlocalben/pydux/blob/943ca1c75357b9289f55f17ff2d997a66a3313a4/pydux/create_store.py#L30-L124
3,021
UCSBarchlab/PyRTL
pyrtl/core.py
set_debug_mode
def set_debug_mode(debug=True): """ Set the global debug mode. """ global debug_mode global _setting_keep_wirevector_call_stack global _setting_slower_but_more_descriptive_tmps debug_mode = debug _setting_keep_wirevector_call_stack = debug _setting_slower_but_more_descriptive_tmps = debug
python
def set_debug_mode(debug=True): global debug_mode global _setting_keep_wirevector_call_stack global _setting_slower_but_more_descriptive_tmps debug_mode = debug _setting_keep_wirevector_call_stack = debug _setting_slower_but_more_descriptive_tmps = debug
[ "def", "set_debug_mode", "(", "debug", "=", "True", ")", ":", "global", "debug_mode", "global", "_setting_keep_wirevector_call_stack", "global", "_setting_slower_but_more_descriptive_tmps", "debug_mode", "=", "debug", "_setting_keep_wirevector_call_stack", "=", "debug", "_set...
Set the global debug mode.
[ "Set", "the", "global", "debug", "mode", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L699-L706
3,022
UCSBarchlab/PyRTL
pyrtl/core.py
Block.add_wirevector
def add_wirevector(self, wirevector): """ Add a wirevector object to the block.""" self.sanity_check_wirevector(wirevector) self.wirevector_set.add(wirevector) self.wirevector_by_name[wirevector.name] = wirevector
python
def add_wirevector(self, wirevector): self.sanity_check_wirevector(wirevector) self.wirevector_set.add(wirevector) self.wirevector_by_name[wirevector.name] = wirevector
[ "def", "add_wirevector", "(", "self", ",", "wirevector", ")", ":", "self", ".", "sanity_check_wirevector", "(", "wirevector", ")", "self", ".", "wirevector_set", ".", "add", "(", "wirevector", ")", "self", ".", "wirevector_by_name", "[", "wirevector", ".", "na...
Add a wirevector object to the block.
[ "Add", "a", "wirevector", "object", "to", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L224-L228
3,023
UCSBarchlab/PyRTL
pyrtl/core.py
Block.remove_wirevector
def remove_wirevector(self, wirevector): """ Remove a wirevector object to the block.""" self.wirevector_set.remove(wirevector) del self.wirevector_by_name[wirevector.name]
python
def remove_wirevector(self, wirevector): self.wirevector_set.remove(wirevector) del self.wirevector_by_name[wirevector.name]
[ "def", "remove_wirevector", "(", "self", ",", "wirevector", ")", ":", "self", ".", "wirevector_set", ".", "remove", "(", "wirevector", ")", "del", "self", ".", "wirevector_by_name", "[", "wirevector", ".", "name", "]" ]
Remove a wirevector object to the block.
[ "Remove", "a", "wirevector", "object", "to", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L230-L233
3,024
UCSBarchlab/PyRTL
pyrtl/core.py
Block.add_net
def add_net(self, net): """ Add a net to the logic of the block. The passed net, which must be of type LogicNet, is checked and then added to the block. No wires are added by this member, they must be added seperately with add_wirevector.""" self.sanity_check_net(net) ...
python
def add_net(self, net): self.sanity_check_net(net) self.logic.add(net)
[ "def", "add_net", "(", "self", ",", "net", ")", ":", "self", ".", "sanity_check_net", "(", "net", ")", "self", ".", "logic", ".", "add", "(", "net", ")" ]
Add a net to the logic of the block. The passed net, which must be of type LogicNet, is checked and then added to the block. No wires are added by this member, they must be added seperately with add_wirevector.
[ "Add", "a", "net", "to", "the", "logic", "of", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L235-L243
3,025
UCSBarchlab/PyRTL
pyrtl/core.py
Block.wirevector_subset
def wirevector_subset(self, cls=None, exclude=tuple()): """Return set of wirevectors, filtered by the type or tuple of types provided as cls. If no cls is specified, the full set of wirevectors associated with the Block are returned. If cls is a single type, or a tuple of types, only those wir...
python
def wirevector_subset(self, cls=None, exclude=tuple()): if cls is None: initial_set = self.wirevector_set else: initial_set = (x for x in self.wirevector_set if isinstance(x, cls)) if exclude == tuple(): return set(initial_set) else: return...
[ "def", "wirevector_subset", "(", "self", ",", "cls", "=", "None", ",", "exclude", "=", "tuple", "(", ")", ")", ":", "if", "cls", "is", "None", ":", "initial_set", "=", "self", ".", "wirevector_set", "else", ":", "initial_set", "=", "(", "x", "for", "...
Return set of wirevectors, filtered by the type or tuple of types provided as cls. If no cls is specified, the full set of wirevectors associated with the Block are returned. If cls is a single type, or a tuple of types, only those wirevectors of the matching types will be returned. This is h...
[ "Return", "set", "of", "wirevectors", "filtered", "by", "the", "type", "or", "tuple", "of", "types", "provided", "as", "cls", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L245-L259
3,026
UCSBarchlab/PyRTL
pyrtl/core.py
Block.get_wirevector_by_name
def get_wirevector_by_name(self, name, strict=False): """Return the wirevector matching name. By fallthrough, if a matching wirevector cannot be found the value None is returned. However, if the argument strict is set to True, then this will instead throw a PyrtlError when no match is ...
python
def get_wirevector_by_name(self, name, strict=False): if name in self.wirevector_by_name: return self.wirevector_by_name[name] elif strict: raise PyrtlError('error, block does not have a wirevector named %s' % name) else: return None
[ "def", "get_wirevector_by_name", "(", "self", ",", "name", ",", "strict", "=", "False", ")", ":", "if", "name", "in", "self", ".", "wirevector_by_name", ":", "return", "self", ".", "wirevector_by_name", "[", "name", "]", "elif", "strict", ":", "raise", "Py...
Return the wirevector matching name. By fallthrough, if a matching wirevector cannot be found the value None is returned. However, if the argument strict is set to True, then this will instead throw a PyrtlError when no match is found.
[ "Return", "the", "wirevector", "matching", "name", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L271-L282
3,027
UCSBarchlab/PyRTL
pyrtl/core.py
Block.net_connections
def net_connections(self, include_virtual_nodes=False): """ Returns a representation of the current block useful for creating a graph. :param include_virtual_nodes: if enabled, the wire itself will be used to signal an external source or sink (such as the source for an Input net). I...
python
def net_connections(self, include_virtual_nodes=False): src_list = {} dst_list = {} def add_wire_src(edge, node): if edge in src_list: raise PyrtlError('Wire "{}" has multiple drivers (check for multiple assignments ' 'with "<<=" or a...
[ "def", "net_connections", "(", "self", ",", "include_virtual_nodes", "=", "False", ")", ":", "src_list", "=", "{", "}", "dst_list", "=", "{", "}", "def", "add_wire_src", "(", "edge", ",", "node", ")", ":", "if", "edge", "in", "src_list", ":", "raise", ...
Returns a representation of the current block useful for creating a graph. :param include_virtual_nodes: if enabled, the wire itself will be used to signal an external source or sink (such as the source for an Input net). If disabled, these nodes will be excluded from the adjacency dictiona...
[ "Returns", "a", "representation", "of", "the", "current", "block", "useful", "for", "creating", "a", "graph", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L284-L332
3,028
UCSBarchlab/PyRTL
pyrtl/core.py
Block.sanity_check
def sanity_check(self): """ Check block and throw PyrtlError or PyrtlInternalError if there is an issue. Should not modify anything, only check data structures to make sure they have been built according to the assumptions stated in the Block comments.""" # TODO: check that the wirevec...
python
def sanity_check(self): # TODO: check that the wirevector_by_name is sane from .wire import Input, Const, Output from .helperfuncs import get_stack, get_stacks # check for valid LogicNets (and wires) for net in self.logic: self.sanity_check_net(net) for w in...
[ "def", "sanity_check", "(", "self", ")", ":", "# TODO: check that the wirevector_by_name is sane", "from", ".", "wire", "import", "Input", ",", "Const", ",", "Output", "from", ".", "helperfuncs", "import", "get_stack", ",", "get_stacks", "# check for valid LogicNets (an...
Check block and throw PyrtlError or PyrtlInternalError if there is an issue. Should not modify anything, only check data structures to make sure they have been built according to the assumptions stated in the Block comments.
[ "Check", "block", "and", "throw", "PyrtlError", "or", "PyrtlInternalError", "if", "there", "is", "an", "issue", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L373-L441
3,029
UCSBarchlab/PyRTL
pyrtl/core.py
Block.sanity_check_memory_sync
def sanity_check_memory_sync(self, wire_src_dict=None): """ Check that all memories are synchronous unless explicitly specified as async. While the semantics of 'm' memories reads is asynchronous, if you want your design to use a block ram (on an FPGA or otherwise) you want to make sure the ind...
python
def sanity_check_memory_sync(self, wire_src_dict=None): sync_mems = set(m for m in self.logic_subset('m') if not m.op_param[1].asynchronous) if not len(sync_mems): return # nothing to check here if wire_src_dict is None: wire_src_dict, wdd = self.net_connections() ...
[ "def", "sanity_check_memory_sync", "(", "self", ",", "wire_src_dict", "=", "None", ")", ":", "sync_mems", "=", "set", "(", "m", "for", "m", "in", "self", ".", "logic_subset", "(", "'m'", ")", "if", "not", "m", ".", "op_param", "[", "1", "]", ".", "as...
Check that all memories are synchronous unless explicitly specified as async. While the semantics of 'm' memories reads is asynchronous, if you want your design to use a block ram (on an FPGA or otherwise) you want to make sure the index is available at the beginning of the clock edge. This ch...
[ "Check", "that", "all", "memories", "are", "synchronous", "unless", "explicitly", "specified", "as", "async", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L443-L477
3,030
UCSBarchlab/PyRTL
pyrtl/core.py
Block.sanity_check_wirevector
def sanity_check_wirevector(self, w): """ Check that w is a valid wirevector type. """ from .wire import WireVector if not isinstance(w, WireVector): raise PyrtlError( 'error attempting to pass an input of type "%s" ' 'instead of WireVector' % type(w))
python
def sanity_check_wirevector(self, w): from .wire import WireVector if not isinstance(w, WireVector): raise PyrtlError( 'error attempting to pass an input of type "%s" ' 'instead of WireVector' % type(w))
[ "def", "sanity_check_wirevector", "(", "self", ",", "w", ")", ":", "from", ".", "wire", "import", "WireVector", "if", "not", "isinstance", "(", "w", ",", "WireVector", ")", ":", "raise", "PyrtlError", "(", "'error attempting to pass an input of type \"%s\" '", "'i...
Check that w is a valid wirevector type.
[ "Check", "that", "w", "is", "a", "valid", "wirevector", "type", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L479-L485
3,031
UCSBarchlab/PyRTL
pyrtl/core.py
_NameSanitizer.make_valid_string
def make_valid_string(self, string=''): """ Inputting a value for the first time """ if not self.is_valid_str(string): if string in self.val_map and not self.allow_dups: raise IndexError("Value {} has already been given to the sanitizer".format(string)) internal_n...
python
def make_valid_string(self, string=''): if not self.is_valid_str(string): if string in self.val_map and not self.allow_dups: raise IndexError("Value {} has already been given to the sanitizer".format(string)) internal_name = super(_NameSanitizer, self).make_valid_string()...
[ "def", "make_valid_string", "(", "self", ",", "string", "=", "''", ")", ":", "if", "not", "self", ".", "is_valid_str", "(", "string", ")", ":", "if", "string", "in", "self", ".", "val_map", "and", "not", "self", ".", "allow_dups", ":", "raise", "IndexE...
Inputting a value for the first time
[ "Inputting", "a", "value", "for", "the", "first", "time" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/core.py#L759-L770
3,032
UCSBarchlab/PyRTL
pyrtl/passes.py
optimize
def optimize(update_working_block=True, block=None, skip_sanity_check=False): """ Return an optimized version of a synthesized hardware block. :param Boolean update_working_block: Don't copy the block and optimize the new block :param Block block: the block to optimize (defaults to working block) ...
python
def optimize(update_working_block=True, block=None, skip_sanity_check=False): block = working_block(block) if not update_working_block: block = copy_block(block) with set_working_block(block, no_sanity_check=True): if (not skip_sanity_check) or debug_mode: block.sanity_check() ...
[ "def", "optimize", "(", "update_working_block", "=", "True", ",", "block", "=", "None", ",", "skip_sanity_check", "=", "False", ")", ":", "block", "=", "working_block", "(", "block", ")", "if", "not", "update_working_block", ":", "block", "=", "copy_block", ...
Return an optimized version of a synthesized hardware block. :param Boolean update_working_block: Don't copy the block and optimize the new block :param Block block: the block to optimize (defaults to working block) Note: optimize works on all hardware designs, both synthesized and non synthesized
[ "Return", "an", "optimized", "version", "of", "a", "synthesized", "hardware", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L28-L52
3,033
UCSBarchlab/PyRTL
pyrtl/passes.py
_remove_wire_nets
def _remove_wire_nets(block): """ Remove all wire nodes from the block. """ wire_src_dict = _ProducerList() wire_removal_set = set() # set of all wirevectors to be removed # one pass to build the map of value producers and # all of the nets and wires to be removed for net in block.logic: ...
python
def _remove_wire_nets(block): wire_src_dict = _ProducerList() wire_removal_set = set() # set of all wirevectors to be removed # one pass to build the map of value producers and # all of the nets and wires to be removed for net in block.logic: if net.op == 'w': wire_src_dict[net...
[ "def", "_remove_wire_nets", "(", "block", ")", ":", "wire_src_dict", "=", "_ProducerList", "(", ")", "wire_removal_set", "=", "set", "(", ")", "# set of all wirevectors to be removed", "# one pass to build the map of value producers and", "# all of the nets and wires to be remove...
Remove all wire nodes from the block.
[ "Remove", "all", "wire", "nodes", "from", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L74-L102
3,034
UCSBarchlab/PyRTL
pyrtl/passes.py
constant_propagation
def constant_propagation(block, silence_unexpected_net_warnings=False): """ Removes excess constants in the block. Note on resulting block: The output of the block can have wirevectors that are driven but not listened to. This is to be expected. These are to be removed by the _remove_unlistened_net...
python
def constant_propagation(block, silence_unexpected_net_warnings=False): net_count = _NetCount(block) while net_count.shrinking(): _constant_prop_pass(block, silence_unexpected_net_warnings)
[ "def", "constant_propagation", "(", "block", ",", "silence_unexpected_net_warnings", "=", "False", ")", ":", "net_count", "=", "_NetCount", "(", "block", ")", "while", "net_count", ".", "shrinking", "(", ")", ":", "_constant_prop_pass", "(", "block", ",", "silen...
Removes excess constants in the block. Note on resulting block: The output of the block can have wirevectors that are driven but not listened to. This is to be expected. These are to be removed by the _remove_unlistened_nets function
[ "Removes", "excess", "constants", "in", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L105-L115
3,035
UCSBarchlab/PyRTL
pyrtl/passes.py
common_subexp_elimination
def common_subexp_elimination(block=None, abs_thresh=1, percent_thresh=0): """ Common Subexpression Elimination for PyRTL blocks :param block: the block to run the subexpression elimination on :param abs_thresh: absolute threshold for stopping optimization :param percent_thresh: percent threshold f...
python
def common_subexp_elimination(block=None, abs_thresh=1, percent_thresh=0): block = working_block(block) net_count = _NetCount(block) while net_count.shrinking(block, percent_thresh, abs_thresh): net_table = _find_common_subexps(block) _replace_subexps(block, net_table)
[ "def", "common_subexp_elimination", "(", "block", "=", "None", ",", "abs_thresh", "=", "1", ",", "percent_thresh", "=", "0", ")", ":", "block", "=", "working_block", "(", "block", ")", "net_count", "=", "_NetCount", "(", "block", ")", "while", "net_count", ...
Common Subexpression Elimination for PyRTL blocks :param block: the block to run the subexpression elimination on :param abs_thresh: absolute threshold for stopping optimization :param percent_thresh: percent threshold for stopping optimization
[ "Common", "Subexpression", "Elimination", "for", "PyRTL", "blocks" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L218-L231
3,036
UCSBarchlab/PyRTL
pyrtl/passes.py
_remove_unlistened_nets
def _remove_unlistened_nets(block): """ Removes all nets that are not connected to an output wirevector """ listened_nets = set() listened_wires = set() prev_listened_net_count = 0 def add_to_listened(net): listened_nets.add(net) listened_wires.update(net.args) for a_net i...
python
def _remove_unlistened_nets(block): listened_nets = set() listened_wires = set() prev_listened_net_count = 0 def add_to_listened(net): listened_nets.add(net) listened_wires.update(net.args) for a_net in block.logic: if a_net.op == '@': add_to_listened(a_net) ...
[ "def", "_remove_unlistened_nets", "(", "block", ")", ":", "listened_nets", "=", "set", "(", ")", "listened_wires", "=", "set", "(", ")", "prev_listened_net_count", "=", "0", "def", "add_to_listened", "(", "net", ")", ":", "listened_nets", ".", "add", "(", "n...
Removes all nets that are not connected to an output wirevector
[ "Removes", "all", "nets", "that", "are", "not", "connected", "to", "an", "output", "wirevector" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L299-L325
3,037
UCSBarchlab/PyRTL
pyrtl/passes.py
_remove_unused_wires
def _remove_unused_wires(block, keep_inputs=True): """ Removes all unconnected wires from a block""" valid_wires = set() for logic_net in block.logic: valid_wires.update(logic_net.args, logic_net.dests) wire_removal_set = block.wirevector_set.difference(valid_wires) for removed_wire in wire...
python
def _remove_unused_wires(block, keep_inputs=True): valid_wires = set() for logic_net in block.logic: valid_wires.update(logic_net.args, logic_net.dests) wire_removal_set = block.wirevector_set.difference(valid_wires) for removed_wire in wire_removal_set: if isinstance(removed_wire, Inpu...
[ "def", "_remove_unused_wires", "(", "block", ",", "keep_inputs", "=", "True", ")", ":", "valid_wires", "=", "set", "(", ")", "for", "logic_net", "in", "block", ".", "logic", ":", "valid_wires", ".", "update", "(", "logic_net", ".", "args", ",", "logic_net"...
Removes all unconnected wires from a block
[ "Removes", "all", "unconnected", "wires", "from", "a", "block" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L328-L346
3,038
UCSBarchlab/PyRTL
pyrtl/passes.py
synthesize
def synthesize(update_working_block=True, block=None): """ Lower the design to just single-bit "and", "or", and "not" gates. :param update_working_block: Boolean specifying if working block update :param block: The block you want to synthesize :return: The newly synthesized block (of type PostSynthesis...
python
def synthesize(update_working_block=True, block=None): block_pre = working_block(block) block_pre.sanity_check() # before going further, make sure that pressynth is valid block_in = copy_block(block_pre, update_working_block=False) block_out = PostSynthBlock() # resulting block should only have on...
[ "def", "synthesize", "(", "update_working_block", "=", "True", ",", "block", "=", "None", ")", ":", "block_pre", "=", "working_block", "(", "block", ")", "block_pre", ".", "sanity_check", "(", ")", "# before going further, make sure that pressynth is valid", "block_in...
Lower the design to just single-bit "and", "or", and "not" gates. :param update_working_block: Boolean specifying if working block update :param block: The block you want to synthesize :return: The newly synthesized block (of type PostSynthesisBlock). Takes as input a block (default to working block) ...
[ "Lower", "the", "design", "to", "just", "single", "-", "bit", "and", "or", "and", "not", "gates", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L355-L438
3,039
UCSBarchlab/PyRTL
pyrtl/rtllib/barrel.py
barrel_shifter
def barrel_shifter(bits_to_shift, bit_in, direction, shift_dist, wrap_around=0): """ Create a barrel shifter that operates on data based on the wire width. :param bits_to_shift: the input wire :param bit_in: the 1-bit wire giving the value to shift in :param direction: a one bit WireVector representing...
python
def barrel_shifter(bits_to_shift, bit_in, direction, shift_dist, wrap_around=0): from pyrtl import concat, select # just for readability if wrap_around != 0: raise NotImplementedError # Implement with logN stages pyrtl.muxing between shifted and un-shifted values final_width = len(bits_to_shi...
[ "def", "barrel_shifter", "(", "bits_to_shift", ",", "bit_in", ",", "direction", ",", "shift_dist", ",", "wrap_around", "=", "0", ")", ":", "from", "pyrtl", "import", "concat", ",", "select", "# just for readability", "if", "wrap_around", "!=", "0", ":", "raise...
Create a barrel shifter that operates on data based on the wire width. :param bits_to_shift: the input wire :param bit_in: the 1-bit wire giving the value to shift in :param direction: a one bit WireVector representing shift direction (0 = shift down, 1 = shift up) :param shift_dist: WireVector...
[ "Create", "a", "barrel", "shifter", "that", "operates", "on", "data", "based", "on", "the", "wire", "width", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/barrel.py#L6-L44
3,040
usrlocalben/pydux
pydux/compose.py
compose
def compose(*funcs): """ chained function composition wrapper creates function f, where f(x) = arg0(arg1(arg2(...argN(x)))) if *funcs is empty, an identity function is returned. Args: *funcs: list of functions to chain Returns: a new function composed of chained calls to ...
python
def compose(*funcs): if not funcs: return lambda *args: args[0] if args else None if len(funcs) == 1: return funcs[0] last = funcs[-1] rest = funcs[0:-1] return lambda *args: reduce(lambda ax, func: func(ax), reversed(rest), last(*args))
[ "def", "compose", "(", "*", "funcs", ")", ":", "if", "not", "funcs", ":", "return", "lambda", "*", "args", ":", "args", "[", "0", "]", "if", "args", "else", "None", "if", "len", "(", "funcs", ")", "==", "1", ":", "return", "funcs", "[", "0", "]...
chained function composition wrapper creates function f, where f(x) = arg0(arg1(arg2(...argN(x)))) if *funcs is empty, an identity function is returned. Args: *funcs: list of functions to chain Returns: a new function composed of chained calls to *args
[ "chained", "function", "composition", "wrapper" ]
943ca1c75357b9289f55f17ff2d997a66a3313a4
https://github.com/usrlocalben/pydux/blob/943ca1c75357b9289f55f17ff2d997a66a3313a4/pydux/compose.py#L3-L26
3,041
UCSBarchlab/PyRTL
examples/introduction-to-hardware.py
software_fibonacci
def software_fibonacci(n): """ a normal old python function to return the Nth fibonacci number. """ a, b = 0, 1 for i in range(n): a, b = b, a + b return a
python
def software_fibonacci(n): a, b = 0, 1 for i in range(n): a, b = b, a + b return a
[ "def", "software_fibonacci", "(", "n", ")", ":", "a", ",", "b", "=", "0", ",", "1", "for", "i", "in", "range", "(", "n", ")", ":", "a", ",", "b", "=", "b", ",", "a", "+", "b", "return", "a" ]
a normal old python function to return the Nth fibonacci number.
[ "a", "normal", "old", "python", "function", "to", "return", "the", "Nth", "fibonacci", "number", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/examples/introduction-to-hardware.py#L12-L17
3,042
usrlocalben/pydux
pydux/apply_middleware.py
apply_middleware
def apply_middleware(*middlewares): """ creates an enhancer function composed of middleware Args: *middlewares: list of middleware functions to apply Returns: an enhancer for subsequent calls to create_store() """ def inner(create_store_): def create_wrapper(reducer, en...
python
def apply_middleware(*middlewares): def inner(create_store_): def create_wrapper(reducer, enhancer=None): store = create_store_(reducer, enhancer) dispatch = store['dispatch'] middleware_api = { 'get_state': store['get_state'], 'dispatch': ...
[ "def", "apply_middleware", "(", "*", "middlewares", ")", ":", "def", "inner", "(", "create_store_", ")", ":", "def", "create_wrapper", "(", "reducer", ",", "enhancer", "=", "None", ")", ":", "store", "=", "create_store_", "(", "reducer", ",", "enhancer", "...
creates an enhancer function composed of middleware Args: *middlewares: list of middleware functions to apply Returns: an enhancer for subsequent calls to create_store()
[ "creates", "an", "enhancer", "function", "composed", "of", "middleware" ]
943ca1c75357b9289f55f17ff2d997a66a3313a4
https://github.com/usrlocalben/pydux/blob/943ca1c75357b9289f55f17ff2d997a66a3313a4/pydux/apply_middleware.py#L5-L28
3,043
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
mux
def mux(index, *mux_ins, **kwargs): """ Multiplexer returning the value of the wire in . :param WireVector index: used as the select input to the multiplexer :param WireVector mux_ins: additional WireVector arguments selected when select>1 :param WireVector kwargs: additional WireVectors, keyword arg "...
python
def mux(index, *mux_ins, **kwargs): if kwargs: # only "default" is allowed as kwarg. if len(kwargs) != 1 or 'default' not in kwargs: try: result = select(index, **kwargs) import warnings warnings.warn("Predicates are being deprecated in Mux. " ...
[ "def", "mux", "(", "index", ",", "*", "mux_ins", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "# only \"default\" is allowed as kwarg.", "if", "len", "(", "kwargs", ")", "!=", "1", "or", "'default'", "not", "in", "kwargs", ":", "try", ":", "...
Multiplexer returning the value of the wire in . :param WireVector index: used as the select input to the multiplexer :param WireVector mux_ins: additional WireVector arguments selected when select>1 :param WireVector kwargs: additional WireVectors, keyword arg "default" If you are selecting between ...
[ "Multiplexer", "returning", "the", "value", "of", "the", "wire", "in", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L16-L82
3,044
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
select
def select(sel, truecase, falsecase): """ Multiplexer returning falsecase for select==0, otherwise truecase. :param WireVector sel: used as the select input to the multiplexer :param WireVector falsecase: the WireVector selected if select==0 :param WireVector truecase: the WireVector selected if select...
python
def select(sel, truecase, falsecase): sel, f, t = (as_wires(w) for w in (sel, falsecase, truecase)) f, t = match_bitwidth(f, t) outwire = WireVector(bitwidth=len(f)) net = LogicNet(op='x', op_param=None, args=(sel, f, t), dests=(outwire,)) working_block().add_net(net) # this includes sanity check ...
[ "def", "select", "(", "sel", ",", "truecase", ",", "falsecase", ")", ":", "sel", ",", "f", ",", "t", "=", "(", "as_wires", "(", "w", ")", "for", "w", "in", "(", "sel", ",", "falsecase", ",", "truecase", ")", ")", "f", ",", "t", "=", "match_bitw...
Multiplexer returning falsecase for select==0, otherwise truecase. :param WireVector sel: used as the select input to the multiplexer :param WireVector falsecase: the WireVector selected if select==0 :param WireVector truecase: the WireVector selected if select==1 The hardware this generates is exactl...
[ "Multiplexer", "returning", "falsecase", "for", "select", "==", "0", "otherwise", "truecase", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L85-L106
3,045
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
concat
def concat(*args): """ Concatenates multiple WireVectors into a single WireVector :param WireVector args: inputs to be concatenated :return: WireVector with length equal to the sum of the args' lengths You can provide multiple arguments and they will be combined with the right-most argument being ...
python
def concat(*args): if len(args) <= 0: raise PyrtlError('error, concat requires at least 1 argument') if len(args) == 1: return as_wires(args[0]) arg_wirevectors = tuple(as_wires(arg) for arg in args) final_width = sum(len(arg) for arg in arg_wirevectors) outwire = WireVector(bitwidt...
[ "def", "concat", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "<=", "0", ":", "raise", "PyrtlError", "(", "'error, concat requires at least 1 argument'", ")", "if", "len", "(", "args", ")", "==", "1", ":", "return", "as_wires", "(", "args",...
Concatenates multiple WireVectors into a single WireVector :param WireVector args: inputs to be concatenated :return: WireVector with length equal to the sum of the args' lengths You can provide multiple arguments and they will be combined with the right-most argument being the least significant bits ...
[ "Concatenates", "multiple", "WireVectors", "into", "a", "single", "WireVector" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L109-L139
3,046
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_add
def signed_add(a, b): """ Return wirevector for result of signed addition. :param a: a wirevector to serve as first input to addition :param b: a wirevector to serve as second input to addition Given a length n and length m wirevector the result of the signed addition is length max(n,m)+1. The in...
python
def signed_add(a, b): a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) result_len = len(a) + 1 ext_a = a.sign_extended(result_len) ext_b = b.sign_extended(result_len) # add and truncate to the correct length return (ext_a + ext_b)[0:result_len]
[ "def", "signed_add", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "match_bitwidth", "(", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", ",", "signed", "=", "True", ")", "result_len", "=", "len", "(", "a", ")", "+", "1", "ext_a"...
Return wirevector for result of signed addition. :param a: a wirevector to serve as first input to addition :param b: a wirevector to serve as second input to addition Given a length n and length m wirevector the result of the signed addition is length max(n,m)+1. The inputs are twos complement s...
[ "Return", "wirevector", "for", "result", "of", "signed", "addition", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L162-L176
3,047
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_lt
def signed_lt(a, b): """ Return a single bit result of signed less than comparison. """ a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = a - b return r[-1] ^ (~a[-1]) ^ (~b[-1])
python
def signed_lt(a, b): a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = a - b return r[-1] ^ (~a[-1]) ^ (~b[-1])
[ "def", "signed_lt", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "match_bitwidth", "(", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", ",", "signed", "=", "True", ")", "r", "=", "a", "-", "b", "return", "r", "[", "-", "1", ...
Return a single bit result of signed less than comparison.
[ "Return", "a", "single", "bit", "result", "of", "signed", "less", "than", "comparison", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L196-L200
3,048
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_le
def signed_le(a, b): """ Return a single bit result of signed less than or equal comparison. """ a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = a - b return (r[-1] ^ (~a[-1]) ^ (~b[-1])) | (a == b)
python
def signed_le(a, b): a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = a - b return (r[-1] ^ (~a[-1]) ^ (~b[-1])) | (a == b)
[ "def", "signed_le", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "match_bitwidth", "(", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", ",", "signed", "=", "True", ")", "r", "=", "a", "-", "b", "return", "(", "r", "[", "-", ...
Return a single bit result of signed less than or equal comparison.
[ "Return", "a", "single", "bit", "result", "of", "signed", "less", "than", "or", "equal", "comparison", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L203-L207
3,049
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_gt
def signed_gt(a, b): """ Return a single bit result of signed greater than comparison. """ a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = b - a return r[-1] ^ (~a[-1]) ^ (~b[-1])
python
def signed_gt(a, b): a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = b - a return r[-1] ^ (~a[-1]) ^ (~b[-1])
[ "def", "signed_gt", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "match_bitwidth", "(", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", ",", "signed", "=", "True", ")", "r", "=", "b", "-", "a", "return", "r", "[", "-", "1", ...
Return a single bit result of signed greater than comparison.
[ "Return", "a", "single", "bit", "result", "of", "signed", "greater", "than", "comparison", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L210-L214
3,050
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_ge
def signed_ge(a, b): """ Return a single bit result of signed greater than or equal comparison. """ a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = b - a return (r[-1] ^ (~a[-1]) ^ (~b[-1])) | (a == b)
python
def signed_ge(a, b): a, b = match_bitwidth(as_wires(a), as_wires(b), signed=True) r = b - a return (r[-1] ^ (~a[-1]) ^ (~b[-1])) | (a == b)
[ "def", "signed_ge", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "match_bitwidth", "(", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", ",", "signed", "=", "True", ")", "r", "=", "b", "-", "a", "return", "(", "r", "[", "-", ...
Return a single bit result of signed greater than or equal comparison.
[ "Return", "a", "single", "bit", "result", "of", "signed", "greater", "than", "or", "equal", "comparison", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L217-L221
3,051
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
shift_right_arithmetic
def shift_right_arithmetic(bits_to_shift, shift_amount): """ Shift right arithmetic operation. :param bits_to_shift: WireVector to shift right :param shift_amount: WireVector specifying amount to shift :return: WireVector of same length as bits_to_shift This function returns a new WireVector of le...
python
def shift_right_arithmetic(bits_to_shift, shift_amount): a, shamt = _check_shift_inputs(bits_to_shift, shift_amount) bit_in = bits_to_shift[-1] # shift in sign_bit dir = Const(0) # shift right return barrel.barrel_shifter(bits_to_shift, bit_in, dir, shift_amount)
[ "def", "shift_right_arithmetic", "(", "bits_to_shift", ",", "shift_amount", ")", ":", "a", ",", "shamt", "=", "_check_shift_inputs", "(", "bits_to_shift", ",", "shift_amount", ")", "bit_in", "=", "bits_to_shift", "[", "-", "1", "]", "# shift in sign_bit", "dir", ...
Shift right arithmetic operation. :param bits_to_shift: WireVector to shift right :param shift_amount: WireVector specifying amount to shift :return: WireVector of same length as bits_to_shift This function returns a new WireVector of length equal to the length of the input `bits_to_shift` but whe...
[ "Shift", "right", "arithmetic", "operation", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L250-L267
3,052
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
match_bitwidth
def match_bitwidth(*args, **opt): """ Matches the bitwidth of all of the input arguments with zero or sign extend :param args: WireVectors of which to match bitwidths :param opt: Optional keyword argument 'signed=True' (defaults to False) :return: tuple of args in order with extended bits Example ...
python
def match_bitwidth(*args, **opt): # TODO: when we drop 2.7 support, this code should be cleaned up with explicit # kwarg support for "signed" rather than the less than helpful "**opt" if len(opt) == 0: signed = False else: if len(opt) > 1 or 'signed' not in opt: raise PyrtlEr...
[ "def", "match_bitwidth", "(", "*", "args", ",", "*", "*", "opt", ")", ":", "# TODO: when we drop 2.7 support, this code should be cleaned up with explicit", "# kwarg support for \"signed\" rather than the less than helpful \"**opt\"", "if", "len", "(", "opt", ")", "==", "0", ...
Matches the bitwidth of all of the input arguments with zero or sign extend :param args: WireVectors of which to match bitwidths :param opt: Optional keyword argument 'signed=True' (defaults to False) :return: tuple of args in order with extended bits Example of matching the bitwidths of two WireVecto...
[ "Matches", "the", "bitwidth", "of", "all", "of", "the", "input", "arguments", "with", "zero", "or", "sign", "extend" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L308-L338
3,053
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
as_wires
def as_wires(val, bitwidth=None, truncating=True, block=None): """ Return wires from val which may be wires, integers, strings, or bools. :param val: a wirevector-like object or something that can be converted into a Const :param bitwidth: The bitwidth the resulting wire should be :param bool tru...
python
def as_wires(val, bitwidth=None, truncating=True, block=None): from .memory import _MemIndexed block = working_block(block) if isinstance(val, (int, six.string_types)): # note that this case captures bool as well (as bools are instances of ints) return Const(val, bitwidth=bitwidth, block=bl...
[ "def", "as_wires", "(", "val", ",", "bitwidth", "=", "None", ",", "truncating", "=", "True", ",", "block", "=", "None", ")", ":", "from", ".", "memory", "import", "_MemIndexed", "block", "=", "working_block", "(", "block", ")", "if", "isinstance", "(", ...
Return wires from val which may be wires, integers, strings, or bools. :param val: a wirevector-like object or something that can be converted into a Const :param bitwidth: The bitwidth the resulting wire should be :param bool truncating: determines whether bits will be dropped to achieve the de...
[ "Return", "wires", "from", "val", "which", "may", "be", "wires", "integers", "strings", "or", "bools", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L341-L388
3,054
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
bitfield_update
def bitfield_update(w, range_start, range_end, newvalue, truncating=False): """ Return wirevector w but with some of the bits overwritten by newvalue. :param w: a wirevector to use as the starting point for the update :param range_start: the start of the range of bits to be updated :param range_end: th...
python
def bitfield_update(w, range_start, range_end, newvalue, truncating=False): from .corecircuits import concat_list w = as_wires(w) idxs = list(range(len(w))) # we make a list of integers and slice those up to use as indexes idxs_lower = idxs[0:range_start] idxs_middle = idxs[range_start:range_end] ...
[ "def", "bitfield_update", "(", "w", ",", "range_start", ",", "range_end", ",", "newvalue", ",", "truncating", "=", "False", ")", ":", "from", ".", "corecircuits", "import", "concat_list", "w", "=", "as_wires", "(", "w", ")", "idxs", "=", "list", "(", "ra...
Return wirevector w but with some of the bits overwritten by newvalue. :param w: a wirevector to use as the starting point for the update :param range_start: the start of the range of bits to be updated :param range_end: the end of the range of bits to be updated :param newvalue: the value to be writte...
[ "Return", "wirevector", "w", "but", "with", "some", "of", "the", "bits", "overwritten", "by", "newvalue", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L391-L441
3,055
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
enum_mux
def enum_mux(cntrl, table, default=None, strict=True): """ Build a mux for the control signals specified by an enum. :param cntrl: is a wirevector and control for the mux. :param table: is a dictionary of the form mapping enum->wirevector. :param default: is a wirevector to use when the key is not pres...
python
def enum_mux(cntrl, table, default=None, strict=True): # check dictionary keys are of the right type keytypeset = set(type(x) for x in table.keys() if x is not otherwise) if len(keytypeset) != 1: raise PyrtlError('table mixes multiple types {} as keys'.format(keytypeset)) keytype = list(keytypes...
[ "def", "enum_mux", "(", "cntrl", ",", "table", ",", "default", "=", "None", ",", "strict", "=", "True", ")", ":", "# check dictionary keys are of the right type", "keytypeset", "=", "set", "(", "type", "(", "x", ")", "for", "x", "in", "table", ".", "keys",...
Build a mux for the control signals specified by an enum. :param cntrl: is a wirevector and control for the mux. :param table: is a dictionary of the form mapping enum->wirevector. :param default: is a wirevector to use when the key is not present. In addtion it is possible to use the key 'otherwis...
[ "Build", "a", "mux", "for", "the", "control", "signals", "specified", "by", "an", "enum", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L444-L495
3,056
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
rtl_any
def rtl_any(*vectorlist): """ Hardware equivalent of python native "any". :param WireVector vectorlist: all arguments are WireVectors of length 1 :return: WireVector of length 1 Returns a 1-bit WireVector which will hold a '1' if any of the inputs are '1' (i.e. it is a big ol' OR gate) """ ...
python
def rtl_any(*vectorlist): if len(vectorlist) <= 0: raise PyrtlError('rtl_any requires at least 1 argument') converted_vectorlist = [as_wires(v) for v in vectorlist] if any(len(v) != 1 for v in converted_vectorlist): raise PyrtlError('only length 1 WireVectors can be inputs to rtl_any') r...
[ "def", "rtl_any", "(", "*", "vectorlist", ")", ":", "if", "len", "(", "vectorlist", ")", "<=", "0", ":", "raise", "PyrtlError", "(", "'rtl_any requires at least 1 argument'", ")", "converted_vectorlist", "=", "[", "as_wires", "(", "v", ")", "for", "v", "in",...
Hardware equivalent of python native "any". :param WireVector vectorlist: all arguments are WireVectors of length 1 :return: WireVector of length 1 Returns a 1-bit WireVector which will hold a '1' if any of the inputs are '1' (i.e. it is a big ol' OR gate)
[ "Hardware", "equivalent", "of", "python", "native", "any", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L548-L562
3,057
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
rtl_all
def rtl_all(*vectorlist): """ Hardware equivalent of python native "all". :param WireVector vectorlist: all arguments are WireVectors of length 1 :return: WireVector of length 1 Returns a 1-bit WireVector which will hold a '1' only if all of the inputs are '1' (i.e. it is a big ol' AND gate) "...
python
def rtl_all(*vectorlist): if len(vectorlist) <= 0: raise PyrtlError('rtl_all requires at least 1 argument') converted_vectorlist = [as_wires(v) for v in vectorlist] if any(len(v) != 1 for v in converted_vectorlist): raise PyrtlError('only length 1 WireVectors can be inputs to rtl_all') r...
[ "def", "rtl_all", "(", "*", "vectorlist", ")", ":", "if", "len", "(", "vectorlist", ")", "<=", "0", ":", "raise", "PyrtlError", "(", "'rtl_all requires at least 1 argument'", ")", "converted_vectorlist", "=", "[", "as_wires", "(", "v", ")", "for", "v", "in",...
Hardware equivalent of python native "all". :param WireVector vectorlist: all arguments are WireVectors of length 1 :return: WireVector of length 1 Returns a 1-bit WireVector which will hold a '1' only if all of the inputs are '1' (i.e. it is a big ol' AND gate)
[ "Hardware", "equivalent", "of", "python", "native", "all", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L565-L579
3,058
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
_basic_mult
def _basic_mult(A, B): """ A stripped-down copy of the Wallace multiplier in rtllib """ if len(B) == 1: A, B = B, A # so that we can reuse the code below :) if len(A) == 1: return concat_list(list(A & b for b in B) + [Const(0)]) # keep WireVector len consistent result_bitwidth = len(A...
python
def _basic_mult(A, B): if len(B) == 1: A, B = B, A # so that we can reuse the code below :) if len(A) == 1: return concat_list(list(A & b for b in B) + [Const(0)]) # keep WireVector len consistent result_bitwidth = len(A) + len(B) bits = [[] for weight in range(result_bitwidth)] f...
[ "def", "_basic_mult", "(", "A", ",", "B", ")", ":", "if", "len", "(", "B", ")", "==", "1", ":", "A", ",", "B", "=", "B", ",", "A", "# so that we can reuse the code below :)", "if", "len", "(", "A", ")", "==", "1", ":", "return", "concat_list", "(",...
A stripped-down copy of the Wallace multiplier in rtllib
[ "A", "stripped", "-", "down", "copy", "of", "the", "Wallace", "multiplier", "in", "rtllib" ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L582-L613
3,059
UCSBarchlab/PyRTL
pyrtl/conditional.py
_push_condition
def _push_condition(predicate): """As we enter new conditions, this pushes them on the predicate stack.""" global _depth _check_under_condition() _depth += 1 if predicate is not otherwise and len(predicate) > 1: raise PyrtlError('all predicates for conditional assignments must wirevectors of...
python
def _push_condition(predicate): global _depth _check_under_condition() _depth += 1 if predicate is not otherwise and len(predicate) > 1: raise PyrtlError('all predicates for conditional assignments must wirevectors of len 1') _conditions_list_stack[-1].append(predicate) _conditions_list_...
[ "def", "_push_condition", "(", "predicate", ")", ":", "global", "_depth", "_check_under_condition", "(", ")", "_depth", "+=", "1", "if", "predicate", "is", "not", "otherwise", "and", "len", "(", "predicate", ")", ">", "1", ":", "raise", "PyrtlError", "(", ...
As we enter new conditions, this pushes them on the predicate stack.
[ "As", "we", "enter", "new", "conditions", "this", "pushes", "them", "on", "the", "predicate", "stack", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/conditional.py#L119-L127
3,060
UCSBarchlab/PyRTL
pyrtl/conditional.py
_build
def _build(lhs, rhs): """Stores the wire assignment details until finalize is called.""" _check_under_condition() final_predicate, pred_set = _current_select() _check_and_add_pred_set(lhs, pred_set) _predicate_map.setdefault(lhs, []).append((final_predicate, rhs))
python
def _build(lhs, rhs): _check_under_condition() final_predicate, pred_set = _current_select() _check_and_add_pred_set(lhs, pred_set) _predicate_map.setdefault(lhs, []).append((final_predicate, rhs))
[ "def", "_build", "(", "lhs", ",", "rhs", ")", ":", "_check_under_condition", "(", ")", "final_predicate", ",", "pred_set", "=", "_current_select", "(", ")", "_check_and_add_pred_set", "(", "lhs", ",", "pred_set", ")", "_predicate_map", ".", "setdefault", "(", ...
Stores the wire assignment details until finalize is called.
[ "Stores", "the", "wire", "assignment", "details", "until", "finalize", "is", "called", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/conditional.py#L138-L143
3,061
UCSBarchlab/PyRTL
pyrtl/conditional.py
_pred_sets_are_in_conflict
def _pred_sets_are_in_conflict(pred_set_a, pred_set_b): """ Find conflict in sets, return conflict if found, else None. """ # pred_sets conflict if we cannot find one shared predicate that is "negated" in one # and "non-negated" in the other for pred_a, bool_a in pred_set_a: for pred_b, bool_b i...
python
def _pred_sets_are_in_conflict(pred_set_a, pred_set_b): # pred_sets conflict if we cannot find one shared predicate that is "negated" in one # and "non-negated" in the other for pred_a, bool_a in pred_set_a: for pred_b, bool_b in pred_set_b: if pred_a is pred_b and bool_a != bool_b: ...
[ "def", "_pred_sets_are_in_conflict", "(", "pred_set_a", ",", "pred_set_b", ")", ":", "# pred_sets conflict if we cannot find one shared predicate that is \"negated\" in one", "# and \"non-negated\" in the other", "for", "pred_a", ",", "bool_a", "in", "pred_set_a", ":", "for", "pr...
Find conflict in sets, return conflict if found, else None.
[ "Find", "conflict", "in", "sets", "return", "conflict", "if", "found", "else", "None", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/conditional.py#L171-L179
3,062
UCSBarchlab/PyRTL
pyrtl/conditional.py
_finalize
def _finalize(): """Build the required muxes and call back to WireVector to finalize the wirevector build.""" from .memory import MemBlock from pyrtl.corecircuits import select for lhs in _predicate_map: # handle memory write ports if isinstance(lhs, MemBlock): p, (addr, data...
python
def _finalize(): from .memory import MemBlock from pyrtl.corecircuits import select for lhs in _predicate_map: # handle memory write ports if isinstance(lhs, MemBlock): p, (addr, data, enable) = _predicate_map[lhs][0] combined_enable = select(p, truecase=enable, false...
[ "def", "_finalize", "(", ")", ":", "from", ".", "memory", "import", "MemBlock", "from", "pyrtl", ".", "corecircuits", "import", "select", "for", "lhs", "in", "_predicate_map", ":", "# handle memory write ports", "if", "isinstance", "(", "lhs", ",", "MemBlock", ...
Build the required muxes and call back to WireVector to finalize the wirevector build.
[ "Build", "the", "required", "muxes", "and", "call", "back", "to", "WireVector", "to", "finalize", "the", "wirevector", "build", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/conditional.py#L182-L212
3,063
UCSBarchlab/PyRTL
pyrtl/conditional.py
_current_select
def _current_select(): """ Function to calculate the current "predicate" in the current context. Returns a tuple of information: (predicate, pred_set). The value pred_set is a set([ (predicate, bool), ... ]) as described in the _reset_conditional_state """ # helper to create the conjuction of ...
python
def _current_select(): # helper to create the conjuction of predicates def and_with_possible_none(a, b): assert(a is not None or b is not None) if a is None: return b if b is None: return a return a & b def between_otherwise_and_current(predlist): ...
[ "def", "_current_select", "(", ")", ":", "# helper to create the conjuction of predicates", "def", "and_with_possible_none", "(", "a", ",", "b", ")", ":", "assert", "(", "a", "is", "not", "None", "or", "b", "is", "not", "None", ")", "if", "a", "is", "None", ...
Function to calculate the current "predicate" in the current context. Returns a tuple of information: (predicate, pred_set). The value pred_set is a set([ (predicate, bool), ... ]) as described in the _reset_conditional_state
[ "Function", "to", "calculate", "the", "current", "predicate", "in", "the", "current", "context", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/conditional.py#L215-L262
3,064
UCSBarchlab/PyRTL
pyrtl/analysis/estimate.py
area_estimation
def area_estimation(tech_in_nm=130, block=None): """ Estimates the total area of the block. :param tech_in_nm: the size of the circuit technology to be estimated (for example, 65 is 65nm and 250 is 0.25um) :return: tuple of estimated areas (logic, mem) in terms of mm^2 The estimations are base...
python
def area_estimation(tech_in_nm=130, block=None): def mem_area_estimate(tech_in_nm, bits, ports, is_rom): # http://www.cs.ucsb.edu/~sherwood/pubs/ICCD-srammodel.pdf # ROM is assumed to be 1/10th of area of SRAM tech_in_um = tech_in_nm / 1000.0 area_estimate = 0.001 * tech_in_um**2.07 ...
[ "def", "area_estimation", "(", "tech_in_nm", "=", "130", ",", "block", "=", "None", ")", ":", "def", "mem_area_estimate", "(", "tech_in_nm", ",", "bits", ",", "ports", ",", "is_rom", ")", ":", "# http://www.cs.ucsb.edu/~sherwood/pubs/ICCD-srammodel.pdf", "# ROM is a...
Estimates the total area of the block. :param tech_in_nm: the size of the circuit technology to be estimated (for example, 65 is 65nm and 250 is 0.25um) :return: tuple of estimated areas (logic, mem) in terms of mm^2 The estimations are based off of 130nm stdcell designs for the logic, and cus...
[ "Estimates", "the", "total", "area", "of", "the", "block", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L29-L116
3,065
UCSBarchlab/PyRTL
pyrtl/analysis/estimate.py
_bits_ports_and_isrom_from_memory
def _bits_ports_and_isrom_from_memory(mem): """ Helper to extract mem bits and ports for estimation. """ is_rom = False bits = 2**mem.addrwidth * mem.bitwidth read_ports = len(mem.readport_nets) try: write_ports = len(mem.writeport_nets) except AttributeError: # dealing with ROMs ...
python
def _bits_ports_and_isrom_from_memory(mem): is_rom = False bits = 2**mem.addrwidth * mem.bitwidth read_ports = len(mem.readport_nets) try: write_ports = len(mem.writeport_nets) except AttributeError: # dealing with ROMs if not isinstance(mem, RomBlock): raise PyrtlIntern...
[ "def", "_bits_ports_and_isrom_from_memory", "(", "mem", ")", ":", "is_rom", "=", "False", "bits", "=", "2", "**", "mem", ".", "addrwidth", "*", "mem", ".", "bitwidth", "read_ports", "=", "len", "(", "mem", ".", "readport_nets", ")", "try", ":", "write_port...
Helper to extract mem bits and ports for estimation.
[ "Helper", "to", "extract", "mem", "bits", "and", "ports", "for", "estimation", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L119-L133
3,066
UCSBarchlab/PyRTL
pyrtl/analysis/estimate.py
yosys_area_delay
def yosys_area_delay(library, abc_cmd=None, block=None): """ Synthesize with Yosys and return estimate of area and delay. :param library: stdcell library file to target in liberty format :param abc_cmd: string of commands for yosys to pass to abc for synthesis :param block: pyrtl block to analyze :...
python
def yosys_area_delay(library, abc_cmd=None, block=None): if abc_cmd is None: abc_cmd = 'strash;scorr;ifraig;retime;dch,-f;map;print_stats;' else: # first, replace whitespace with commas as per yosys requirements re.sub(r"\s+", ',', abc_cmd) # then append with "print_stats" to gen...
[ "def", "yosys_area_delay", "(", "library", ",", "abc_cmd", "=", "None", ",", "block", "=", "None", ")", ":", "if", "abc_cmd", "is", "None", ":", "abc_cmd", "=", "'strash;scorr;ifraig;retime;dch,-f;map;print_stats;'", "else", ":", "# first, replace whitespace with comm...
Synthesize with Yosys and return estimate of area and delay. :param library: stdcell library file to target in liberty format :param abc_cmd: string of commands for yosys to pass to abc for synthesis :param block: pyrtl block to analyze :return: a tuple of numbers: area, delay The area and delay a...
[ "Synthesize", "with", "Yosys", "and", "return", "estimate", "of", "area", "and", "delay", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L329-L389
3,067
UCSBarchlab/PyRTL
pyrtl/analysis/estimate.py
TimingAnalysis.max_freq
def max_freq(self, tech_in_nm=130, ffoverhead=None): """ Estimates the max frequency of a block in MHz. :param tech_in_nm: the size of the circuit technology to be estimated (for example, 65 is 65nm and 250 is 0.25um) :param ffoverhead: setup and ff propagation delay in picoseconds ...
python
def max_freq(self, tech_in_nm=130, ffoverhead=None): cp_length = self.max_length() scale_factor = 130.0 / tech_in_nm if ffoverhead is None: clock_period_in_ps = scale_factor * (cp_length + 189 + 194) else: clock_period_in_ps = (scale_factor * cp_length) + ffoverhe...
[ "def", "max_freq", "(", "self", ",", "tech_in_nm", "=", "130", ",", "ffoverhead", "=", "None", ")", ":", "cp_length", "=", "self", ".", "max_length", "(", ")", "scale_factor", "=", "130.0", "/", "tech_in_nm", "if", "ffoverhead", "is", "None", ":", "clock...
Estimates the max frequency of a block in MHz. :param tech_in_nm: the size of the circuit technology to be estimated (for example, 65 is 65nm and 250 is 0.25um) :param ffoverhead: setup and ff propagation delay in picoseconds :return: a number representing an estimate of the max fre...
[ "Estimates", "the", "max", "frequency", "of", "a", "block", "in", "MHz", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L234-L254
3,068
UCSBarchlab/PyRTL
pyrtl/analysis/estimate.py
TimingAnalysis.critical_path
def critical_path(self, print_cp=True, cp_limit=100): """ Takes a timing map and returns the critical paths of the system. :param print_cp: Whether to print the critical path to the terminal after calculation :return: a list containing tuples with the 'first' wire as the ...
python
def critical_path(self, print_cp=True, cp_limit=100): critical_paths = [] # storage of all completed critical paths wire_src_map, dst_map = self.block.net_connections() def critical_path_pass(old_critical_path, first_wire): if isinstance(first_wire, (Input, Const, Register)): ...
[ "def", "critical_path", "(", "self", ",", "print_cp", "=", "True", ",", "cp_limit", "=", "100", ")", ":", "critical_paths", "=", "[", "]", "# storage of all completed critical paths", "wire_src_map", ",", "dst_map", "=", "self", ".", "block", ".", "net_connectio...
Takes a timing map and returns the critical paths of the system. :param print_cp: Whether to print the critical path to the terminal after calculation :return: a list containing tuples with the 'first' wire as the first value and the critical paths (which themselves are lists ...
[ "Takes", "a", "timing", "map", "and", "returns", "the", "critical", "paths", "of", "the", "system", "." ]
0988e5c9c10ededd5e1f58d5306603f9edf4b3e2
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/analysis/estimate.py#L267-L306
3,069
v1k45/python-qBittorrent
qbittorrent/client.py
Client._post
def _post(self, endpoint, data, **kwargs): """ Method to perform POST request on the API. :param endpoint: Endpoint of the API. :param data: POST DATA for the request. :param kwargs: Other keyword arguments for requests. :return: Response of the POST request. ""...
python
def _post(self, endpoint, data, **kwargs): return self._request(endpoint, 'post', data, **kwargs)
[ "def", "_post", "(", "self", ",", "endpoint", ",", "data", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_request", "(", "endpoint", ",", "'post'", ",", "data", ",", "*", "*", "kwargs", ")" ]
Method to perform POST request on the API. :param endpoint: Endpoint of the API. :param data: POST DATA for the request. :param kwargs: Other keyword arguments for requests. :return: Response of the POST request.
[ "Method", "to", "perform", "POST", "request", "on", "the", "API", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L46-L56
3,070
v1k45/python-qBittorrent
qbittorrent/client.py
Client._request
def _request(self, endpoint, method, data=None, **kwargs): """ Method to hanle both GET and POST requests. :param endpoint: Endpoint of the API. :param method: Method of HTTP request. :param data: POST DATA for the request. :param kwargs: Other keyword arguments. ...
python
def _request(self, endpoint, method, data=None, **kwargs): final_url = self.url + endpoint if not self._is_authenticated: raise LoginRequired rq = self.session if method == 'get': request = rq.get(final_url, **kwargs) else: request = rq.post(...
[ "def", "_request", "(", "self", ",", "endpoint", ",", "method", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "final_url", "=", "self", ".", "url", "+", "endpoint", "if", "not", "self", ".", "_is_authenticated", ":", "raise", "LoginRequi...
Method to hanle both GET and POST requests. :param endpoint: Endpoint of the API. :param method: Method of HTTP request. :param data: POST DATA for the request. :param kwargs: Other keyword arguments. :return: Response for the request.
[ "Method", "to", "hanle", "both", "GET", "and", "POST", "requests", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L58-L91
3,071
v1k45/python-qBittorrent
qbittorrent/client.py
Client.login
def login(self, username='admin', password='admin'): """ Method to authenticate the qBittorrent Client. Declares a class attribute named ``session`` which stores the authenticated session if the login is correct. Else, shows the login error. :param username: Username. ...
python
def login(self, username='admin', password='admin'): self.session = requests.Session() login = self.session.post(self.url+'login', data={'username': username, 'password': password}) if login.text == 'Ok.': self...
[ "def", "login", "(", "self", ",", "username", "=", "'admin'", ",", "password", "=", "'admin'", ")", ":", "self", ".", "session", "=", "requests", ".", "Session", "(", ")", "login", "=", "self", ".", "session", ".", "post", "(", "self", ".", "url", ...
Method to authenticate the qBittorrent Client. Declares a class attribute named ``session`` which stores the authenticated session if the login is correct. Else, shows the login error. :param username: Username. :param password: Password. :return: Response to login req...
[ "Method", "to", "authenticate", "the", "qBittorrent", "Client", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L93-L113
3,072
v1k45/python-qBittorrent
qbittorrent/client.py
Client.torrents
def torrents(self, **filters): """ Returns a list of torrents matching the supplied filters. :param filter: Current status of the torrents. :param category: Fetch all torrents with the supplied label. :param sort: Sort torrents by. :param reverse: Enable reverse sorting....
python
def torrents(self, **filters): params = {} for name, value in filters.items(): # make sure that old 'status' argument still works name = 'filter' if name == 'status' else name params[name] = value return self._get('query/torrents', params=params)
[ "def", "torrents", "(", "self", ",", "*", "*", "filters", ")", ":", "params", "=", "{", "}", "for", "name", ",", "value", "in", "filters", ".", "items", "(", ")", ":", "# make sure that old 'status' argument still works", "name", "=", "'filter'", "if", "na...
Returns a list of torrents matching the supplied filters. :param filter: Current status of the torrents. :param category: Fetch all torrents with the supplied label. :param sort: Sort torrents by. :param reverse: Enable reverse sorting. :param limit: Limit the number of torrents...
[ "Returns", "a", "list", "of", "torrents", "matching", "the", "supplied", "filters", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L150-L169
3,073
v1k45/python-qBittorrent
qbittorrent/client.py
Client.preferences
def preferences(self): """ Get the current qBittorrent preferences. Can also be used to assign individual preferences. For setting multiple preferences at once, see ``set_preferences`` method. Note: Even if this is a ``property``, to fetch the current preferences...
python
def preferences(self): prefs = self._get('query/preferences') class Proxy(Client): """ Proxy class to to allow assignment of individual preferences. this class overrides some methods to ease things. Because of this, settings can be assigned like:: ...
[ "def", "preferences", "(", "self", ")", ":", "prefs", "=", "self", ".", "_get", "(", "'query/preferences'", ")", "class", "Proxy", "(", "Client", ")", ":", "\"\"\"\n Proxy class to to allow assignment of individual preferences.\n this class overrides som...
Get the current qBittorrent preferences. Can also be used to assign individual preferences. For setting multiple preferences at once, see ``set_preferences`` method. Note: Even if this is a ``property``, to fetch the current preferences dict, you are required to call it ...
[ "Get", "the", "current", "qBittorrent", "preferences", ".", "Can", "also", "be", "used", "to", "assign", "individual", "preferences", ".", "For", "setting", "multiple", "preferences", "at", "once", "see", "set_preferences", "method", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L211-L268
3,074
v1k45/python-qBittorrent
qbittorrent/client.py
Client.download_from_link
def download_from_link(self, link, **kwargs): """ Download torrent using a link. :param link: URL Link or list of. :param savepath: Path to download the torrent. :param category: Label or Category of the torrent(s). :return: Empty JSON data. """ # old:ne...
python
def download_from_link(self, link, **kwargs): # old:new format old_arg_map = {'save_path': 'savepath'} # , 'label': 'category'} # convert old option names to new option names options = kwargs.copy() for old_arg, new_arg in old_arg_map.items(): if options.get(old_arg...
[ "def", "download_from_link", "(", "self", ",", "link", ",", "*", "*", "kwargs", ")", ":", "# old:new format", "old_arg_map", "=", "{", "'save_path'", ":", "'savepath'", "}", "# , 'label': 'category'}", "# convert old option names to new option names", "options", "=", ...
Download torrent using a link. :param link: URL Link or list of. :param savepath: Path to download the torrent. :param category: Label or Category of the torrent(s). :return: Empty JSON data.
[ "Download", "torrent", "using", "a", "link", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L279-L307
3,075
v1k45/python-qBittorrent
qbittorrent/client.py
Client.download_from_file
def download_from_file(self, file_buffer, **kwargs): """ Download torrent using a file. :param file_buffer: Single file() buffer or list of. :param save_path: Path to download the torrent. :param label: Label of the torrent(s). :return: Empty JSON data. """ ...
python
def download_from_file(self, file_buffer, **kwargs): if isinstance(file_buffer, list): torrent_files = {} for i, f in enumerate(file_buffer): torrent_files.update({'torrents%s' % i: f}) else: torrent_files = {'torrents': file_buffer} data = kw...
[ "def", "download_from_file", "(", "self", ",", "file_buffer", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "file_buffer", ",", "list", ")", ":", "torrent_files", "=", "{", "}", "for", "i", ",", "f", "in", "enumerate", "(", "file_buffer", ...
Download torrent using a file. :param file_buffer: Single file() buffer or list of. :param save_path: Path to download the torrent. :param label: Label of the torrent(s). :return: Empty JSON data.
[ "Download", "torrent", "using", "a", "file", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L309-L330
3,076
v1k45/python-qBittorrent
qbittorrent/client.py
Client.add_trackers
def add_trackers(self, infohash, trackers): """ Add trackers to a torrent. :param infohash: INFO HASH of torrent. :param trackers: Trackers. """ data = {'hash': infohash.lower(), 'urls': trackers} return self._post('command/addTrackers', data=data...
python
def add_trackers(self, infohash, trackers): data = {'hash': infohash.lower(), 'urls': trackers} return self._post('command/addTrackers', data=data)
[ "def", "add_trackers", "(", "self", ",", "infohash", ",", "trackers", ")", ":", "data", "=", "{", "'hash'", ":", "infohash", ".", "lower", "(", ")", ",", "'urls'", ":", "trackers", "}", "return", "self", ".", "_post", "(", "'command/addTrackers'", ",", ...
Add trackers to a torrent. :param infohash: INFO HASH of torrent. :param trackers: Trackers.
[ "Add", "trackers", "to", "a", "torrent", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L332-L341
3,077
v1k45/python-qBittorrent
qbittorrent/client.py
Client._process_infohash_list
def _process_infohash_list(infohash_list): """ Method to convert the infohash_list to qBittorrent API friendly values. :param infohash_list: List of infohash. """ if isinstance(infohash_list, list): data = {'hashes': '|'.join([h.lower() for h in infohash_list])} ...
python
def _process_infohash_list(infohash_list): if isinstance(infohash_list, list): data = {'hashes': '|'.join([h.lower() for h in infohash_list])} else: data = {'hashes': infohash_list.lower()} return data
[ "def", "_process_infohash_list", "(", "infohash_list", ")", ":", "if", "isinstance", "(", "infohash_list", ",", "list", ")", ":", "data", "=", "{", "'hashes'", ":", "'|'", ".", "join", "(", "[", "h", ".", "lower", "(", ")", "for", "h", "in", "infohash_...
Method to convert the infohash_list to qBittorrent API friendly values. :param infohash_list: List of infohash.
[ "Method", "to", "convert", "the", "infohash_list", "to", "qBittorrent", "API", "friendly", "values", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L344-L354
3,078
v1k45/python-qBittorrent
qbittorrent/client.py
Client.pause_multiple
def pause_multiple(self, infohash_list): """ Pause multiple torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/pauseAll', data=data)
python
def pause_multiple(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/pauseAll', data=data)
[ "def", "pause_multiple", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/pauseAll'", ",", "data", "=", "data", ")" ]
Pause multiple torrents. :param infohash_list: Single or list() of infohashes.
[ "Pause", "multiple", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L370-L377
3,079
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_category
def set_category(self, infohash_list, category): """ Set the category on multiple torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) data['category'] = category return self._post('command/setCateg...
python
def set_category(self, infohash_list, category): data = self._process_infohash_list(infohash_list) data['category'] = category return self._post('command/setCategory', data=data)
[ "def", "set_category", "(", "self", ",", "infohash_list", ",", "category", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "data", "[", "'category'", "]", "=", "category", "return", "self", ".", "_post", "(", "'comman...
Set the category on multiple torrents. :param infohash_list: Single or list() of infohashes.
[ "Set", "the", "category", "on", "multiple", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L390-L398
3,080
v1k45/python-qBittorrent
qbittorrent/client.py
Client.resume_multiple
def resume_multiple(self, infohash_list): """ Resume multiple paused torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/resumeAll', data=data)
python
def resume_multiple(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/resumeAll', data=data)
[ "def", "resume_multiple", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/resumeAll'", ",", "data", "=", "data", ")" ]
Resume multiple paused torrents. :param infohash_list: Single or list() of infohashes.
[ "Resume", "multiple", "paused", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L414-L421
3,081
v1k45/python-qBittorrent
qbittorrent/client.py
Client.delete
def delete(self, infohash_list): """ Delete torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/delete', data=data)
python
def delete(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/delete', data=data)
[ "def", "delete", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/delete'", ",", "data", "=", "data", ")" ]
Delete torrents. :param infohash_list: Single or list() of infohashes.
[ "Delete", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L423-L430
3,082
v1k45/python-qBittorrent
qbittorrent/client.py
Client.delete_permanently
def delete_permanently(self, infohash_list): """ Permanently delete torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/deletePerm', data=data)
python
def delete_permanently(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/deletePerm', data=data)
[ "def", "delete_permanently", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/deletePerm'", ",", "data", "=", "data", ")" ]
Permanently delete torrents. :param infohash_list: Single or list() of infohashes.
[ "Permanently", "delete", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L432-L439
3,083
v1k45/python-qBittorrent
qbittorrent/client.py
Client.recheck
def recheck(self, infohash_list): """ Recheck torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/recheck', data=data)
python
def recheck(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/recheck', data=data)
[ "def", "recheck", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/recheck'", ",", "data", "=", "data", ")" ]
Recheck torrents. :param infohash_list: Single or list() of infohashes.
[ "Recheck", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L441-L448
3,084
v1k45/python-qBittorrent
qbittorrent/client.py
Client.increase_priority
def increase_priority(self, infohash_list): """ Increase priority of torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/increasePrio', data=data)
python
def increase_priority(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/increasePrio', data=data)
[ "def", "increase_priority", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/increasePrio'", ",", "data", "=", "data", ")" ]
Increase priority of torrents. :param infohash_list: Single or list() of infohashes.
[ "Increase", "priority", "of", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L450-L457
3,085
v1k45/python-qBittorrent
qbittorrent/client.py
Client.decrease_priority
def decrease_priority(self, infohash_list): """ Decrease priority of torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/decreasePrio', data=data)
python
def decrease_priority(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/decreasePrio', data=data)
[ "def", "decrease_priority", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/decreasePrio'", ",", "data", "=", "data", ")" ]
Decrease priority of torrents. :param infohash_list: Single or list() of infohashes.
[ "Decrease", "priority", "of", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L459-L466
3,086
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_max_priority
def set_max_priority(self, infohash_list): """ Set torrents to maximum priority level. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/topPrio', data=data)
python
def set_max_priority(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/topPrio', data=data)
[ "def", "set_max_priority", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/topPrio'", ",", "data", "=", "data", ")" ]
Set torrents to maximum priority level. :param infohash_list: Single or list() of infohashes.
[ "Set", "torrents", "to", "maximum", "priority", "level", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L468-L475
3,087
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_min_priority
def set_min_priority(self, infohash_list): """ Set torrents to minimum priority level. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/bottomPrio', data=data)
python
def set_min_priority(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/bottomPrio', data=data)
[ "def", "set_min_priority", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/bottomPrio'", ",", "data", "=", "data", ")" ]
Set torrents to minimum priority level. :param infohash_list: Single or list() of infohashes.
[ "Set", "torrents", "to", "minimum", "priority", "level", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L477-L484
3,088
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_file_priority
def set_file_priority(self, infohash, file_id, priority): """ Set file of a torrent to a supplied priority level. :param infohash: INFO HASH of torrent. :param file_id: ID of the file to set priority. :param priority: Priority level of the file. """ if priority n...
python
def set_file_priority(self, infohash, file_id, priority): if priority not in [0, 1, 2, 7]: raise ValueError("Invalid priority, refer WEB-UI docs for info.") elif not isinstance(file_id, int): raise TypeError("File ID must be an int") data = {'hash': infohash.lower(), ...
[ "def", "set_file_priority", "(", "self", ",", "infohash", ",", "file_id", ",", "priority", ")", ":", "if", "priority", "not", "in", "[", "0", ",", "1", ",", "2", ",", "7", "]", ":", "raise", "ValueError", "(", "\"Invalid priority, refer WEB-UI docs for info....
Set file of a torrent to a supplied priority level. :param infohash: INFO HASH of torrent. :param file_id: ID of the file to set priority. :param priority: Priority level of the file.
[ "Set", "file", "of", "a", "torrent", "to", "a", "supplied", "priority", "level", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L486-L503
3,089
v1k45/python-qBittorrent
qbittorrent/client.py
Client.get_torrent_download_limit
def get_torrent_download_limit(self, infohash_list): """ Get download speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/getTorrentsDlLimit', data=da...
python
def get_torrent_download_limit(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/getTorrentsDlLimit', data=data)
[ "def", "get_torrent_download_limit", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/getTorrentsDlLimit'", ",", "data", "=", "data", ")" ]
Get download speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes.
[ "Get", "download", "speed", "limit", "of", "the", "supplied", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L542-L549
3,090
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_torrent_download_limit
def set_torrent_download_limit(self, infohash_list, limit): """ Set download speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. :param limit: Speed limit in bytes. """ data = self._process_infohash_list(infohash_list) data...
python
def set_torrent_download_limit(self, infohash_list, limit): data = self._process_infohash_list(infohash_list) data.update({'limit': limit}) return self._post('command/setTorrentsDlLimit', data=data)
[ "def", "set_torrent_download_limit", "(", "self", ",", "infohash_list", ",", "limit", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "data", ".", "update", "(", "{", "'limit'", ":", "limit", "}", ")", "return", "self...
Set download speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. :param limit: Speed limit in bytes.
[ "Set", "download", "speed", "limit", "of", "the", "supplied", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L551-L560
3,091
v1k45/python-qBittorrent
qbittorrent/client.py
Client.get_torrent_upload_limit
def get_torrent_upload_limit(self, infohash_list): """ Get upoload speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/getTorrentsUpLimit', data=data)
python
def get_torrent_upload_limit(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/getTorrentsUpLimit', data=data)
[ "def", "get_torrent_upload_limit", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/getTorrentsUpLimit'", ",", "data", "=", "data", ")" ]
Get upoload speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes.
[ "Get", "upoload", "speed", "limit", "of", "the", "supplied", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L562-L569
3,092
v1k45/python-qBittorrent
qbittorrent/client.py
Client.set_torrent_upload_limit
def set_torrent_upload_limit(self, infohash_list, limit): """ Set upload speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. :param limit: Speed limit in bytes. """ data = self._process_infohash_list(infohash_list) data.upd...
python
def set_torrent_upload_limit(self, infohash_list, limit): data = self._process_infohash_list(infohash_list) data.update({'limit': limit}) return self._post('command/setTorrentsUpLimit', data=data)
[ "def", "set_torrent_upload_limit", "(", "self", ",", "infohash_list", ",", "limit", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "data", ".", "update", "(", "{", "'limit'", ":", "limit", "}", ")", "return", "self",...
Set upload speed limit of the supplied torrents. :param infohash_list: Single or list() of infohashes. :param limit: Speed limit in bytes.
[ "Set", "upload", "speed", "limit", "of", "the", "supplied", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L571-L580
3,093
v1k45/python-qBittorrent
qbittorrent/client.py
Client.toggle_sequential_download
def toggle_sequential_download(self, infohash_list): """ Toggle sequential download in supplied torrents. :param infohash_list: Single or list() of infohashes. """ data = self._process_infohash_list(infohash_list) return self._post('command/toggleSequentialDownload', dat...
python
def toggle_sequential_download(self, infohash_list): data = self._process_infohash_list(infohash_list) return self._post('command/toggleSequentialDownload', data=data)
[ "def", "toggle_sequential_download", "(", "self", ",", "infohash_list", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "return", "self", ".", "_post", "(", "'command/toggleSequentialDownload'", ",", "data", "=", "data", ")...
Toggle sequential download in supplied torrents. :param infohash_list: Single or list() of infohashes.
[ "Toggle", "sequential", "download", "in", "supplied", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L609-L616
3,094
v1k45/python-qBittorrent
qbittorrent/client.py
Client.force_start
def force_start(self, infohash_list, value=True): """ Force start selected torrents. :param infohash_list: Single or list() of infohashes. :param value: Force start value (bool) """ data = self._process_infohash_list(infohash_list) data.update({'value': json.dump...
python
def force_start(self, infohash_list, value=True): data = self._process_infohash_list(infohash_list) data.update({'value': json.dumps(value)}) return self._post('command/setForceStart', data=data)
[ "def", "force_start", "(", "self", ",", "infohash_list", ",", "value", "=", "True", ")", ":", "data", "=", "self", ".", "_process_infohash_list", "(", "infohash_list", ")", "data", ".", "update", "(", "{", "'value'", ":", "json", ".", "dumps", "(", "valu...
Force start selected torrents. :param infohash_list: Single or list() of infohashes. :param value: Force start value (bool)
[ "Force", "start", "selected", "torrents", "." ]
04f9482a022dcc78c56b0b9acb9ca455f855ae24
https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L627-L636
3,095
nirum/tableprint
tableprint/utils.py
humantime
def humantime(time): """Converts a time in seconds to a reasonable human readable time Parameters ---------- t : float The number of seconds Returns ------- time : string The human readable formatted value of the given time """ try: time = float(time) ex...
python
def humantime(time): try: time = float(time) except (ValueError, TypeError): raise ValueError("Input must be numeric") # weeks if time >= 7 * 60 * 60 * 24: weeks = math.floor(time / (7 * 60 * 60 * 24)) timestr = "{:g} weeks, ".format(weeks) + humantime(time % (7 * 60 * 6...
[ "def", "humantime", "(", "time", ")", ":", "try", ":", "time", "=", "float", "(", "time", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "raise", "ValueError", "(", "\"Input must be numeric\"", ")", "# weeks", "if", "time", ">=", "7", "*",...
Converts a time in seconds to a reasonable human readable time Parameters ---------- t : float The number of seconds Returns ------- time : string The human readable formatted value of the given time
[ "Converts", "a", "time", "in", "seconds", "to", "a", "reasonable", "human", "readable", "time" ]
50ab4b96706fce8ee035a4d48cb456e3271eab3d
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/utils.py#L13-L67
3,096
nirum/tableprint
tableprint/utils.py
ansi_len
def ansi_len(string): """Extra length due to any ANSI sequences in the string.""" return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string))
python
def ansi_len(string): return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string))
[ "def", "ansi_len", "(", "string", ")", ":", "return", "len", "(", "string", ")", "-", "wcswidth", "(", "re", ".", "compile", "(", "r'\\x1b[^m]*m'", ")", ".", "sub", "(", "''", ",", "string", ")", ")" ]
Extra length due to any ANSI sequences in the string.
[ "Extra", "length", "due", "to", "any", "ANSI", "sequences", "in", "the", "string", "." ]
50ab4b96706fce8ee035a4d48cb456e3271eab3d
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/utils.py#L70-L72
3,097
nirum/tableprint
tableprint/utils.py
format_line
def format_line(data, linestyle): """Formats a list of elements using the given line style""" return linestyle.begin + linestyle.sep.join(data) + linestyle.end
python
def format_line(data, linestyle): return linestyle.begin + linestyle.sep.join(data) + linestyle.end
[ "def", "format_line", "(", "data", ",", "linestyle", ")", ":", "return", "linestyle", ".", "begin", "+", "linestyle", ".", "sep", ".", "join", "(", "data", ")", "+", "linestyle", ".", "end" ]
Formats a list of elements using the given line style
[ "Formats", "a", "list", "of", "elements", "using", "the", "given", "line", "style" ]
50ab4b96706fce8ee035a4d48cb456e3271eab3d
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/utils.py#L75-L77
3,098
nirum/tableprint
tableprint/utils.py
parse_width
def parse_width(width, n): """Parses an int or array of widths Parameters ---------- width : int or array_like n : int """ if isinstance(width, int): widths = [width] * n else: assert len(width) == n, "Widths and data do not match" widths = width return wid...
python
def parse_width(width, n): if isinstance(width, int): widths = [width] * n else: assert len(width) == n, "Widths and data do not match" widths = width return widths
[ "def", "parse_width", "(", "width", ",", "n", ")", ":", "if", "isinstance", "(", "width", ",", "int", ")", ":", "widths", "=", "[", "width", "]", "*", "n", "else", ":", "assert", "len", "(", "width", ")", "==", "n", ",", "\"Widths and data do not mat...
Parses an int or array of widths Parameters ---------- width : int or array_like n : int
[ "Parses", "an", "int", "or", "array", "of", "widths" ]
50ab4b96706fce8ee035a4d48cb456e3271eab3d
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/utils.py#L80-L95
3,099
nirum/tableprint
tableprint/printer.py
table
def table(data, headers=None, format_spec=FMT, width=WIDTH, align=ALIGN, style=STYLE, out=sys.stdout): """Print a table with the given data Parameters ---------- data : array_like An (m x n) array containing the data to print (m rows of n columns) headers : list, optional A list of...
python
def table(data, headers=None, format_spec=FMT, width=WIDTH, align=ALIGN, style=STYLE, out=sys.stdout): # Number of columns in the table. ncols = len(data[0]) if headers is None else len(headers) tablestyle = STYLES[style] widths = parse_width(width, ncols) # Initialize with a hr or the header t...
[ "def", "table", "(", "data", ",", "headers", "=", "None", ",", "format_spec", "=", "FMT", ",", "width", "=", "WIDTH", ",", "align", "=", "ALIGN", ",", "style", "=", "STYLE", ",", "out", "=", "sys", ".", "stdout", ")", ":", "# Number of columns in the t...
Print a table with the given data Parameters ---------- data : array_like An (m x n) array containing the data to print (m rows of n columns) headers : list, optional A list of n strings consisting of the header of each of the n columns (Default: None) format_spec : string, option...
[ "Print", "a", "table", "with", "the", "given", "data" ]
50ab4b96706fce8ee035a4d48cb456e3271eab3d
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/printer.py#L79-L123