Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

tcl & in system sources and probes - int2bits

I'm trying to do something similar to the example in Quartus 9.0 Handbook, Volume 3 Chapter 17: Design Debugging Using In-System Sources and Probes - Example 17–1. Tcl Script Procedures for Reading and Writing to the...

I'm having problems related to the int2bits procedure

When I first tried to run it, I got invalid command name "int2bits", as if the proc is undefined

I found this at http://wiki.tcl.tk, so I added it:

proc int2bits {i} {

# returns a bitslist, e.g. int2bits 10 => {1 0 1 0}

set res ""

while {$i>0} {

set res [expr {$i%2}]$res

set i [expr {$i/2}]

}

if {$res==""} {set res 0}

split $res ""

}

Now the problem seems to be that int2bits returns something like 1 0 1 0, when it appears that the proper form needed in the write would be 1010

e.g. this form works

write_source_data -instance_index 0 -value [0010001000100010001000]

where this doesn't (it writes to the source, but something other than what I want)

write_source_data -instance_index 0 -value [0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0]

nor

write_source_data -instance_index 0 -value [int2bits 0x88888]

What is the proper form of the int2bits proc needed to make this work correctly? Or is there an alternative to int2bits to get the binary form needed?

2 Replies