Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

tcl & in system sources and probes - int2bits

Altera_Forum
Honored Contributor II
1,575 Views

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?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
752 Views

See http://tmml.sourceforge.net/doc/tcl/expr.html. As you can see expr adds a space to produce a list as a result. Check http://tcl.projectforum.com/young/251 for tips about handling strings and the difference with lists in TCL.

0 Kudos
Altera_Forum
Honored Contributor II
752 Views

OK, so this works: 

write_source_data -instance_index 0 -value [regsub -all " " [int2bits 0x88888] ""] 

 

So does modifying int2bits to do the regsub after the split. 

 

I still think the example in the Quartus manual is confusing at best, and probably wrong. 

 

Thanks for the help. :)
0 Kudos
Reply