3 from __future__ 
import division
 
    4 from __future__ 
import print_function
 
    8 from contextlib 
import contextmanager
 
   12     old_target, sys.stdout = sys.stdout, new_target
 
   16         sys.stdout = old_target
 
   19     return "%s x" % random.choice([
'+', 
'+', 
'+', 
'-', 
'-', 
'|', 
'&', 
'^'])
 
   22     if random.randint(0, 4) == 0:
 
   27 for idx 
in range(100):
 
   29         if random.choice([
'bin', 
'uni']) == 
'bin':
 
   30             print(
'module uut_%05d(a, b, c, d, x, s, y);' % (idx))
 
   32                 random.choice([
'+', 
'-', 
'*', 
'/', 
'%']),
 
   33                 random.choice([
'<', 
'<=', 
'==', 
'!=', 
'===', 
'!==', 
'>=', 
'>' ]),
 
   34                 random.choice([
'<<', 
'>>', 
'<<<', 
'>>>']),
 
   35                 random.choice([
'|', 
'&', 
'^', 
'~^', 
'||', 
'&&']),
 
   37             print(
'  input%s [%d:0] a;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   38             print(
'  input%s [%d:0] b;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   39             print(
'  input%s [%d:0] c;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   40             print(
'  input%s [%d:0] d;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   41             print(
'  input%s [%d:0] x;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   43             print(
'  output [%d:0] y;' % random.randint(0, 8))
 
   44             print(
'  assign y = (s ? %s(%s %s %s) : %s(%s %s %s))%s;' %
 
   50             print(
'module uut_%05d(a, b, x, s, y);' % (idx))
 
   51             op = random.choice([
'~', 
'-', 
'!'])
 
   52             print(
'  input%s [%d:0] a;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   53             print(
'  input%s [%d:0] b;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   54             print(
'  input%s [%d:0] x;' % (random.choice([
'', 
' signed']), random.randint(0, 8)))
 
   56             print(
'  output [%d:0] y;' % random.randint(0, 8))
 
   57             print(
'  assign y = (s ? %s(%s%s) : %s(%s%s))%s;' %
 
   58                     (random.choice([
'', 
'$signed', 
'$unsigned']), op, 
maybe_plus_x(
'a'),
 
   59                      random.choice([
'', 
'$signed', 
'$unsigned']), op, 
maybe_plus_x(
'b'),
 
   63         print(
'read_verilog temp/uut_%05d.v' % idx)
 
   65         print(
'copy uut_%05d gold' % idx)
 
   66         print(
'rename uut_%05d gate' % idx)
 
   67         print(
'tee -a temp/all_share_log.txt log')
 
   68         print(
'tee -a temp/all_share_log.txt log #job# uut_%05d' % idx)
 
   69         print(
'tee -a temp/all_share_log.txt wreduce')
 
   70         print(
'tee -a temp/all_share_log.txt share -aggressive gate')
 
   71         print(
'miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp gold gate miter')
 
   72         print(
'sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter')