diff --git a/tcl/twopass.tcl b/tcl/twopass.tcl index f7a68bc55c5..e7a0be58806 100644 --- a/tcl/twopass.tcl +++ b/tcl/twopass.tcl @@ -463,7 +463,8 @@ proc ::tp::hal_to_tcl {ifile ofile} { # I couldn't find any usage examples. set ::TP(conflictwords) {list gets} - # in a .tcl file, use "hal list" and "hal gets" instead + # 1) list: in the created .tcl file, use "hal list" + # 2) gets: is not epected in a conventional (so err exit) if [catch {set fdin [open $ifile r] set fdout [open $ofile w] @@ -505,16 +506,27 @@ proc ::tp::hal_to_tcl {ifile ofile} { break } + set conflict_tag "_LIST_TAG_" if {[string first # $line] == 0} continue foreach suspect $::TP(conflictwords) { - if { ([string first "$suspect " $line] == 0) - || ([string first " $suspect " $line] >= 0) - } { - puts "hal_to_tcl:NOTE: in file $ifile, line $lno: \"$suspect\"\ - conflicts with haltcl usage,\nprepended with 'hal' for compatibility" - puts "$lno:<$theline>" - # prepend hal command to convert conflictword: - set line "# hal_to_tcl prepended hal:\nhal $line" + if { [string first "$suspect" [string trim $line]] == 0 } { + # use stderr to make runtests expected cleaner + switch $suspect { + list { + puts stderr "hal_to_tcl:NOTE: \"$suspect\> in file $ifile\ + conflicts with haltcl usage" + puts stderr "near line $lno:<$line>" + puts stderr "prepended with 'hal' for compatibility" + # tag to fix in converted file (after line extends etc) + set line "$conflict_tag $line" + } + default { + # no other conflict words are expected in a conventional halfile + puts stderr "hal_to_tcl:Unexpected <$suspect>: in file $ifile" + puts stderr "$lno:<$line>" + exit 1 + } + } } } set idx 0 @@ -561,6 +573,11 @@ proc ::tp::hal_to_tcl {ifile ofile} { set comment ";[string range $line $cidx end]" set line "$notcomment$comment" } + if {[string first $conflict_tag $line] == 0} { + # remove tag, use puts to output result of list command + # like: puts [hal list ...] + set line "puts \[hal [string range $line [string len $conflict_tag] end] \]" + } puts $fdout $line if {[string trim "$theline"] != [string trim "$line"]} { verbose "converted hal line for tcl from $ifile:" diff --git a/tests/twopass-personality/b.hal b/tests/twopass-personality/b.hal index 5d5da26b5e8..9a9ea249f57 100644 --- a/tests/twopass-personality/b.hal +++ b/tests/twopass-personality/b.hal @@ -1,2 +1,5 @@ loadrt logic names=gateC personality=0x503 -loadusr -w halcmd list pin +list pin +list param +list funct +list sig diff --git a/tests/twopass-personality/expected b/tests/twopass-personality/expected index 2deb12ecb6a..f685d13dbb9 100644 --- a/tests/twopass-personality/expected +++ b/tests/twopass-personality/expected @@ -1,8 +1,11 @@ twopass:invoked with <> options twopass:found ./a.hal twopass:found ./b.hal -hal_to_tcl:NOTE: in file ./b.hal, line 2: "list" conflicts with haltcl usage, -prepended with 'hal' for compatibility -2: + + + gateA.and gateA.in-00 gateA.in-01 gateA.in-02 gateA.in-03 gateA.time gateB.in-00 gateB.in-01 gateB.or gateB.time gateC.and gateC.in-00 gateC.in-01 gateC.in-02 gateC.time gateC.xor +gateA.tmax gateA.tmax-increased gateB.tmax gateB.tmax-increased gateC.tmax gateC.tmax-increased +gateA gateB gateC + diff --git a/tests/twopass/b.hal b/tests/twopass/b.hal index 6110c1535a2..ee50483c53b 100644 --- a/tests/twopass/b.hal +++ b/tests/twopass/b.hal @@ -1,3 +1,6 @@ loadrt and2 names=andZ net p andZ.in0 -show pin +list pin +list param +list funct +list sig diff --git a/tests/twopass/expected b/tests/twopass/expected index e9d4b8c5d6e..c410b9e45db 100644 --- a/tests/twopass/expected +++ b/tests/twopass/expected @@ -1,18 +1,11 @@ twopass:invoked with <> options twopass:found ./a.hal twopass:found ./b.hal -Component Pins: -Owner Type Dir Value Name - 4 bit IN FALSE andX.in0 <== p - 4 bit IN FALSE andX.in1 <== p - 4 bit OUT FALSE andX.out - 4 s32 OUT 0 andX.time - 4 bit IN FALSE andY.in0 - 4 bit IN FALSE andY.in1 - 4 bit OUT FALSE andY.out ==> p - 4 s32 OUT 0 andY.time - 4 bit IN FALSE andZ.in0 <== p - 4 bit IN FALSE andZ.in1 - 4 bit OUT FALSE andZ.out - 4 s32 OUT 0 andZ.time + + + +andX.in0 andX.in1 andX.out andX.time andY.in0 andY.in1 andY.out andY.time andZ.in0 andZ.in1 andZ.out andZ.time +andX.tmax andX.tmax-increased andY.tmax andY.tmax-increased andZ.tmax andZ.tmax-increased +andX andY andZ +p