-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathformal_check.tcl
More file actions
105 lines (98 loc) · 3.23 KB
/
Copy pathformal_check.tcl
File metadata and controls
105 lines (98 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
proc lec_check_enabled { } {
return [expr {
[env_var_equals LEC_CHECK 1]
&& [info exists ::env(KEPLER_FORMAL_EXE)]
&& [file executable $::env(KEPLER_FORMAL_EXE)]
}]
}
proc write_lec_verilog { filename } {
set remove_cells [find_physical_only_masters]
if { [env_var_exists_and_non_empty REMOVE_CELLS_FOR_LEC] } {
lappend remove_cells {*}$::env(REMOVE_CELLS_FOR_LEC)
}
set out_file $::env(RESULTS_DIR)/$filename
write_verilog -remove_cells $remove_cells $out_file
# Add auxiliary Verilog files (e.g., blackbox stubs) for LEC
if { [env_var_exists_and_non_empty LEC_AUX_VERILOG_FILES] } {
set out [open $out_file a]
foreach aux_file $::env(LEC_AUX_VERILOG_FILES) {
if { ![file exists $aux_file] } {
close $out
error "LEC auxiliary Verilog file not found: $aux_file"
}
puts $out "\n// ORFS auxiliary Verilog for Kepler LEC: $aux_file"
set in [open $aux_file r]
fcopy $in $out
close $in
puts $out ""
}
close $out
}
}
proc write_lec_script { step file1 file2 } {
set outfile [open "$::env(OBJECTS_DIR)/${step}_lec_test.yml" w]
puts $outfile "format: verilog"
puts $outfile "input_paths:"
puts $outfile " - $::env(RESULTS_DIR)/${file1}"
puts $outfile " - $::env(RESULTS_DIR)/${file2}"
puts $outfile "liberty_files:"
foreach libFile $::env(LIB_FILES) {
puts $outfile " - $libFile"
}
puts $outfile "log_file: $::env(LOG_DIR)/${step}_lec_check.log"
close $outfile
}
proc write_sec_script { step file1 file2 } {
set outfile [open "$::env(OBJECTS_DIR)/${step}_sec_test.yml" w]
puts $outfile "format: verilog"
puts $outfile "verification: sec"
puts $outfile "sec_engine: pdr"
puts $outfile "input_paths:"
puts $outfile " - $::env(RESULTS_DIR)/${file1}"
puts $outfile " - $::env(RESULTS_DIR)/${file2}"
puts $outfile "liberty_files:"
foreach libFile $::env(LIB_FILES) {
puts $outfile " - $libFile"
}
puts $outfile "log_file: $::env(LOG_DIR)/${step}_sec_check.log"
close $outfile
}
proc formal_check_label { step } {
if { [string equal $step 4_rsz] } {
return "Repair timing output"
}
return "Global output"
}
proc run_lec_test { step file1 file2 } {
write_lec_script $step $file1 $file2
# tclint-disable-next-line command-args
eval exec $::env(KEPLER_FORMAL_EXE) --config $::env(OBJECTS_DIR)/${step}_lec_test.yml
try {
set count [exec grep -c "Found difference" $::env(LOG_DIR)/${step}_lec_check.log]
} trap CHILDSTATUS {results options} {
# This block executes if grep returns a non-zero exit code
set count 0
}
set label [formal_check_label $step]
if { $count > 0 } {
error "$label failed lec test"
} else {
puts "$label passed lec test"
}
}
proc run_sec_test { step file1 file2 } {
write_sec_script $step $file1 $file2
# tclint-disable-next-line command-args
eval exec $::env(KEPLER_FORMAL_EXE) --config $::env(OBJECTS_DIR)/${step}_sec_test.yml
try {
set count [exec grep -c "SEC found a counterexample" $::env(LOG_DIR)/${step}_sec_check.log]
} trap CHILDSTATUS {results options} {
# This block executes if grep returns a non-zero exit code
set count 0
}
if { $count > 0 } {
error "Global output failed sec test"
} else {
puts "Global output passed sec test"
}
}