yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
generate Namespace Reference

Functions

def redirect_stdout
 
def random_expr
 
def random_expression
 
def random_plus_x
 
def maybe_plus_x
 

Variables

 test_verific = False
 
tuple rst2 = random.choice([False, True])
 
list variables = ['a', 'b', 'c', 'x', 'y', 'z']
 
tuple state_bits = random.randint(5, 16)
 
list states = []
 
tuple n = random.randint(0, 2**state_bits-1)
 
list next_states = states[:]
 
tuple next_state = random.choice(next_states)
 
tuple op
 

Function Documentation

def generate.maybe_plus_x (   expr)

Definition at line 21 of file share/generate.py.

21 
22 def maybe_plus_x(expr):
23  if random.randint(0, 4) == 0:
24  return "(%s %s)" % (expr, random_plus_x())
25  else:
26  return expr
def random_plus_x
def maybe_plus_x

+ Here is the call graph for this function:

def generate.random_expr (   variables)

Definition at line 21 of file fsm/generate.py.

21 
22 def random_expr(variables):
23  c = random.choice(['bin', 'uni', 'var', 'const'])
24  if c == 'bin':
25  op = random.choice(['+', '-', '*', '<', '<=', '==', '!=', '>=', '>', '<<', '>>', '<<<', '>>>', '|', '&', '^', '~^', '||', '&&'])
26  return "(%s %s %s)" % (random_expr(variables), op, random_expr(variables))
27  if c == 'uni':
28  op = random.choice(['+', '-', '~', '|', '&', '^', '~^', '!', '$signed', '$unsigned'])
29  return "%s(%s)" % (op, random_expr(variables))
30  if c == 'var':
31  return random.choice(variables)
32  if c == 'const':
33  bits = random.randint(1, 32)
34  return "%d'd%s" % (bits, random.randint(0, 2**bits-1))
35  raise AssertionError
def random_expr
Definition: fsm/generate.py:21

+ Here is the call graph for this function:

def generate.random_expression (   depth = 3,
  maxparam = 0 
)

Definition at line 18 of file realmath/generate.py.

18 
19 def random_expression(depth = 3, maxparam = 0):
20  def recursion():
21  return random_expression(depth = depth-1, maxparam = maxparam)
22  if depth == 0:
23  if maxparam != 0 and random.randint(0, 1) != 0:
24  return 'p%02d' % random.randint(0, maxparam-1)
25  return random.choice([ '%e', '%f', '%g' ]) % random.uniform(-2, +2)
26  if random.randint(0, 4) == 0:
27  return recursion() + random.choice([ ' < ', ' <= ', ' == ', ' != ', ' >= ', ' > ' ]) + recursion() + ' ? ' + recursion() + ' : ' + recursion()
28  op_prefix = [ '+(', '-(' ]
29  op_infix = [ ' + ', ' - ', ' * ', ' / ' ]
30  op_func1 = [ '$ln', '$log10', '$exp', '$sqrt', '$floor', '$ceil', '$sin', '$cos', '$tan', '$asin', '$acos', '$atan', '$sinh', '$cosh', '$tanh', '$asinh', '$acosh', '$atanh' ]
31  op_func2 = [ '$pow', '$atan2', '$hypot' ]
32  op = random.choice(op_prefix + op_infix + op_func1 + op_func2)
33  if op in op_prefix:
34  return op + recursion() + ')'
35  if op in op_infix:
36  return '(' + recursion() + op + recursion() + ')'
37  if op in op_func1:
38  return op + '(' + recursion() + ')'
39  if op in op_func2:
40  return op + '(' + recursion() + ', ' + recursion() + ')'
41  raise
def random_expression

+ Here is the call graph for this function:

def generate.random_plus_x ( )

Definition at line 18 of file share/generate.py.

18 
19 def random_plus_x():
20  return "%s x" % random.choice(['+', '+', '+', '-', '-', '|', '&', '^'])
def random_plus_x

+ Here is the caller graph for this function:

def generate.redirect_stdout (   new_target)

Definition at line 14 of file fsm/generate.py.

14 
15 def redirect_stdout(new_target):
16  old_target, sys.stdout = sys.stdout, new_target
17  try:
18  yield new_target
19  finally:
20  sys.stdout = old_target
def redirect_stdout
Definition: fsm/generate.py:14

+ Here is the caller graph for this function:

Variable Documentation

tuple generate.n = random.randint(0, 2**state_bits-1)

Definition at line 59 of file fsm/generate.py.

tuple generate.next_state = random.choice(next_states)

Definition at line 76 of file fsm/generate.py.

list generate.next_states = states[:]

Definition at line 74 of file fsm/generate.py.

tuple generate.op
Initial value:
1 = random.choice([
2  random.choice(['+', '-', '*', '/', '%']),
3  random.choice(['<', '<=', '==', '!=', '===', '!==', '>=', '>' ]),
4  random.choice(['<<', '>>', '<<<', '>>>']),
5  random.choice(['|', '&', '^', '~^', '||', '&&']),
6  ])

Definition at line 31 of file share/generate.py.

tuple generate.rst2 = random.choice([False, True])

Definition at line 38 of file fsm/generate.py.

tuple generate.state_bits = random.randint(5, 16)

Definition at line 54 of file fsm/generate.py.

list generate.states = []

Definition at line 57 of file fsm/generate.py.

generate.test_verific = False

Definition at line 11 of file fsm/generate.py.

list generate.variables = ['a', 'b', 'c', 'x', 'y', 'z']

Definition at line 47 of file fsm/generate.py.