@@ -3,30 +3,37 @@ YS=../../yosys
33
44mkdir -p temp
55
6+ # non-POSIX sed -i inconsistency workaround
7+ remove_empty_lines () {
8+ local file=" $1 "
9+ sed ' /^$/d' " $file " > temp/tmp
10+ mv temp/tmp " $file "
11+ }
12+
613# write_rtlil and dump are equivalent
714$YS -p " read_verilog -sv everything.v; copy alu zzz; proc zzz; dump -o temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.write.il"
8- sed ' /^$/d ' -i.bak temp/roundtrip-text.dump.il
9- sed ' /^$/d ' -i.bak temp/roundtrip-text.write.il
15+ remove_empty_lines temp/roundtrip-text.dump.il
16+ remove_empty_lines temp/roundtrip-text.write.il
1017# Trim first line ("Generated by Yosys ...")
1118tail -n +2 temp/roundtrip-text.write.il > temp/roundtrip-text.write-nogen.il
1219diff temp/roundtrip-text.dump.il temp/roundtrip-text.write-nogen.il
1320diff temp/roundtrip-text.dump.il roundtrip-text.ref.il
1421
1522# Loading and writing it out again doesn't change the RTLIL
1623$YS -p " read_rtlil temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.reload.il"
17- sed ' /^$/d ' -i.bak temp/roundtrip-text.reload.il
24+ remove_empty_lines temp/roundtrip-text.reload.il
1825tail -n +2 temp/roundtrip-text.reload.il > temp/roundtrip-text.reload-nogen.il
1926diff temp/roundtrip-text.dump.il temp/roundtrip-text.reload-nogen.il
2027
2128# Hashing differences don't change the RTLIL
2229$YS --hash-seed=2345678 -p " read_rtlil temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.reload-hash.il"
23- sed ' /^$/d ' -i.bak temp/roundtrip-text.reload-hash.il
30+ remove_empty_lines temp/roundtrip-text.reload-hash.il
2431tail -n +2 temp/roundtrip-text.reload-hash.il > temp/roundtrip-text.reload-hash-nogen.il
2532diff temp/roundtrip-text.dump.il temp/roundtrip-text.reload-hash-nogen.il
2633
2734echo " Without ABC, we don't get any irreproducibility and can pin that"
2835echo " Has this test case started failing for you? Consider updating the reference"
2936$YS -p " read_verilog -sv everything.v; synth -relativeshare -noabc; write_rtlil temp/roundtrip-text.synth.il"
30- sed ' /^$/d ' -i.bak temp/roundtrip-text.synth.il
37+ remove_empty_lines temp/roundtrip-text.synth.il
3138tail -n +2 temp/roundtrip-text.synth.il > temp/roundtrip-text.synth-nogen.il
3239diff temp/roundtrip-text.synth-nogen.il roundtrip-text.synth.ref.il
0 commit comments