mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	Some changes to yosys-smtbmc cmd line options, add --final-only
This commit is contained in:
		
							parent
							
								
									23afeadb5e
								
							
						
					
					
						commit
						f56dba8e20
					
				
					 1 changed files with 49 additions and 33 deletions
				
			
		| 
						 | 
					@ -32,6 +32,7 @@ outconstr = None
 | 
				
			||||||
gentrace = False
 | 
					gentrace = False
 | 
				
			||||||
tempind = False
 | 
					tempind = False
 | 
				
			||||||
assume_skipped = None
 | 
					assume_skipped = None
 | 
				
			||||||
 | 
					final_only = False
 | 
				
			||||||
topmod = None
 | 
					topmod = None
 | 
				
			||||||
so = smtopts()
 | 
					so = smtopts()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,14 +41,10 @@ def usage():
 | 
				
			||||||
    print("""
 | 
					    print("""
 | 
				
			||||||
yosys-smtbmc [options] <yosys_smt2_output>
 | 
					yosys-smtbmc [options] <yosys_smt2_output>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -t <num_steps>, -t <skip_steps>:<num_steps>
 | 
					    -t <num_steps>
 | 
				
			||||||
        default: skip_steps=0, num_steps=20
 | 
					    -t <skip_steps>:<num_steps>
 | 
				
			||||||
 | 
					    -t <skip_steps>:<step_size>:<num_steps>
 | 
				
			||||||
    -u <start_step>
 | 
					        default: skip_steps=0, step_size=1, num_steps=20
 | 
				
			||||||
        assume asserts in skipped steps in BMC
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    -S <step_size>
 | 
					 | 
				
			||||||
        prove <step_size> time steps at once
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -g
 | 
					    -g
 | 
				
			||||||
        generate an arbitrary trace that satisfies
 | 
					        generate an arbitrary trace that satisfies
 | 
				
			||||||
| 
						 | 
					@ -62,6 +59,14 @@ yosys-smtbmc [options] <yosys_smt2_output>
 | 
				
			||||||
    --smtc <constr_filename>
 | 
					    --smtc <constr_filename>
 | 
				
			||||||
        read constraints file
 | 
					        read constraints file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    --final-only
 | 
				
			||||||
 | 
					        only check final constraints, assume base case
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    --assume-skipped <start_step>
 | 
				
			||||||
 | 
					        assume asserts in skipped steps in BMC.
 | 
				
			||||||
 | 
					        no assumptions are created for skipped steps
 | 
				
			||||||
 | 
					        before <start_step>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    --dump-vcd <vcd_filename>
 | 
					    --dump-vcd <vcd_filename>
 | 
				
			||||||
        write trace to this VCD file
 | 
					        write trace to this VCD file
 | 
				
			||||||
        (hint: use 'write_smt2 -wires' for maximum
 | 
					        (hint: use 'write_smt2 -wires' for maximum
 | 
				
			||||||
| 
						 | 
					@ -77,22 +82,29 @@ yosys-smtbmc [options] <yosys_smt2_output>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    opts, args = getopt.getopt(sys.argv[1:], so.shortopts + "t:u:S:igm:", so.longopts + ["smtc=", "dump-vcd=", "dump-vlogtb=", "dump-smtc="])
 | 
					    opts, args = getopt.getopt(sys.argv[1:], so.shortopts + "t:igm:", so.longopts +
 | 
				
			||||||
 | 
					            ["final-only", "assume-skipped=", "smtc=", "dump-vcd=", "dump-vlogtb=", "dump-smtc="])
 | 
				
			||||||
except:
 | 
					except:
 | 
				
			||||||
    usage()
 | 
					    usage()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for o, a in opts:
 | 
					for o, a in opts:
 | 
				
			||||||
    if o == "-t":
 | 
					    if o == "-t":
 | 
				
			||||||
        match = re.match(r"(\d+):(.*)", a)
 | 
					        a = a.split(":")
 | 
				
			||||||
        if match:
 | 
					        if len(a) == 1:
 | 
				
			||||||
            skip_steps = int(match.group(1))
 | 
					            num_steps = int(a[1])
 | 
				
			||||||
            num_steps = int(match.group(2))
 | 
					        elif len(a) == 2:
 | 
				
			||||||
 | 
					            skip_steps = int(a[0])
 | 
				
			||||||
 | 
					            num_steps = int(a[1])
 | 
				
			||||||
 | 
					        elif len(a) == 3:
 | 
				
			||||||
 | 
					            skip_steps = int(a[0])
 | 
				
			||||||
 | 
					            step_size = int(a[1])
 | 
				
			||||||
 | 
					            num_steps = int(a[2])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            num_steps = int(a)
 | 
					            assert 0
 | 
				
			||||||
    elif o == "-u":
 | 
					    elif o == "--assume-skipped":
 | 
				
			||||||
        assume_skipped = int(a)
 | 
					        assume_skipped = int(a)
 | 
				
			||||||
    elif o == "-S":
 | 
					    elif o == "--final-only":
 | 
				
			||||||
        step_size = int(a)
 | 
					        final_only = True
 | 
				
			||||||
    elif o == "--smtc":
 | 
					    elif o == "--smtc":
 | 
				
			||||||
        inconstr.append(a)
 | 
					        inconstr.append(a)
 | 
				
			||||||
    elif o == "--dump-vcd":
 | 
					    elif o == "--dump-vcd":
 | 
				
			||||||
| 
						 | 
					@ -532,6 +544,7 @@ else: # not tempind
 | 
				
			||||||
                last_check_step = step+i
 | 
					                last_check_step = step+i
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if not gentrace:
 | 
					        if not gentrace:
 | 
				
			||||||
 | 
					            if not final_only:
 | 
				
			||||||
                if last_check_step == step:
 | 
					                if last_check_step == step:
 | 
				
			||||||
                    print("%s Checking asserts in step %d.." % (smt.timestamp(), step))
 | 
					                    print("%s Checking asserts in step %d.." % (smt.timestamp(), step))
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
| 
						 | 
					@ -550,6 +563,10 @@ else: # not tempind
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                smt.write("(pop 1)")
 | 
					                smt.write("(pop 1)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for i in range(step, last_check_step+1):
 | 
				
			||||||
 | 
					                smt.write("(assert (%s_a s%d))" % (topmod, i))
 | 
				
			||||||
 | 
					                smt.write("(assert %s)" % get_constr_expr(constr_asserts, i))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if constr_final_start is not None:
 | 
					            if constr_final_start is not None:
 | 
				
			||||||
                for i in range(step, last_check_step+1):
 | 
					                for i in range(step, last_check_step+1):
 | 
				
			||||||
                    if i < constr_final_start:
 | 
					                    if i < constr_final_start:
 | 
				
			||||||
| 
						 | 
					@ -572,12 +589,11 @@ else: # not tempind
 | 
				
			||||||
                if not retstatus:
 | 
					                if not retstatus:
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if constr_final_start is None:
 | 
					        else: # gentrace
 | 
				
			||||||
            for i in range(step, last_check_step+1):
 | 
					            for i in range(step, last_check_step+1):
 | 
				
			||||||
                smt.write("(assert (%s_a s%d))" % (topmod, i))
 | 
					                smt.write("(assert (%s_a s%d))" % (topmod, i))
 | 
				
			||||||
                smt.write("(assert %s)" % get_constr_expr(constr_asserts, i))
 | 
					                smt.write("(assert %s)" % get_constr_expr(constr_asserts, i))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if gentrace:
 | 
					 | 
				
			||||||
            print("%s Solving for step %d.." % (smt.timestamp(), step))
 | 
					            print("%s Solving for step %d.." % (smt.timestamp(), step))
 | 
				
			||||||
            if smt.check_sat() != "sat":
 | 
					            if smt.check_sat() != "sat":
 | 
				
			||||||
                print("%s No solution found!" % smt.timestamp())
 | 
					                print("%s No solution found!" % smt.timestamp())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue