Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20737 Discussions

get value from master_read_32

Altera_Forum
Honored Contributor II
6,332 Views

Hello evryone, 

 

I am trying to do a GUI interface with tcl to load the .sof that I generated into the FPGA with tcl. 

I want also in this tcl script read from a memory adress, get a value and put it into a label in the GUI interface. 

I am using master_read_32 command to do this: 

# set m_path [lindex [get_service_paths master] 0] 

 

# open_service master $m_path 

 

# master_read_32 $m_path 0x00000000 1 

 

to read the 32 bit value. 

 

My question is how can I save this value to put it into the label in the GUI interface!? 

 

I am waiting for some help please. 

Thanks a lot.
0 Kudos
23 Replies
Altera_Forum
Honored Contributor II
3,416 Views

Look at the Tcl client GUI example in this tutorial 

 

http://www.alterawiki.com/wiki/using_the_usb-blaster_as_an_sopc/qsys_avalon-mm_master_tutorial 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,416 Views

Hello Dave, 

 

that tutorial has nothing about how to save the master_read_32 <adress> to a variable to present that value saved into a label in GUI interface! 

Do you know how to do it? 

 

Kind regards,
0 Kudos
Altera_Forum
Honored Contributor II
3,416 Views

 

--- Quote Start ---  

 

that tutorial has nothing about how to save the master_read_32 <adress> to a variable to present that value saved into a label in GUI interface! 

Do you know how to do it? 

 

--- Quote End ---  

 

As I commented, the Tcl code for the client GUI has everything you need. 

 

The code for the GUI shows how to control the content of a label or hex entry box by mapping that entry to a text variable, eg., here's the code for the response for a read 

 

# A hex entry box with the default data set jtag(data) 0 entry $win.f1.e2 -textvariable jtag(data) -width 12 -justify right -relief sunken -validate key -validatecommand {validate_isxdigit %d %P}  

 

and for the corresponding read command 

 

# Pressing the read/write buttons will automatically connect # to the client if needed. The trace on jtag(socket) will # cause the connection status GUI elements to update # proc read_button {} { global jtag # The address and data entry boxes contain only digits, # so add the leading 0x to the address set data # and then strip the response 0x set jtag(data) }  

 

Every time read is called, it updates jtag(data), which in turn updates the GUI. 

 

Then if you look at jtag_read on the server in jtag_read_cmds.tcl, you will see  

 

# Read 32-bits puts "SERVER: jtag_read $addr" if {} { if {} { # JTAG connection lost? jtag_close error "Error: Check the JTAG interface\n -> '$result'" } } else { if {} { # JTAG connection lost? jtag_close error "Error: Check the JTAG interface\n -> '$result'" } } return $result  

 

which uses master_read_32 to implement the read procedure. 

 

You can lump all of this into a single Tcl procedure if you want. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Hello Dave, 

 

thanks for answering so quick. 

 

I have a question: I have one Qsys with a component that I did and JTAG to Avalon Master Brige into the Qsys, connected. I did some tests to read a value with the avalon_master and I use this in Qsys console: 

 

# set m_path [lindex [get_service_paths master] 0] 

 

# open_service master $m_path 

 

# master_read_32 $m_path 0x00000000 1 

 

# close_service master $m_path 

 

and with this I get the 32 bits value on the adress 0x00000000. 

 

When you write on your code JTAG it works with JTAG to Avalon Master Bridge or I need to change to other one in Qsys? 

 

King regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

 

When you write on your code JTAG it works with JTAG to Avalon Master Bridge or I need to change to other one in Qsys? 

 

--- Quote End ---  

 

You can answer this question yourself very easily by just looking at the tutorial ... which part of the block diagram on the main page of the tutorial is not clear? 

 

http://www.alterawiki.com/wiki/using_the_usb-blaster_as_an_sopc/qsys_avalon-mm_master_tutorial 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Hey Dave, 

 

Ok, I can use any of the 3 ways to get the value. I am just asking if I write down the code that u gave, that work for these 3? 

To run the script, I just need to build a GUI and do the Tcl procedure including the 3 codes that you gave me? 

 

Kind regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

 

Ok, I can use any of the 3 ways to get the value. I am just asking if I write down the code that u gave, that work for these 3? 

To run the script, I just need to build a GUI and do the Tcl procedure including the 3 codes that you gave me? 

 

--- Quote End ---  

 

Yes, if you build a Qsys system that contains a single JTAG-to-Avalon-MM master, then you should be able to use the Tcl scripts included with the tutorial directly. If it does not work, then look at the jtag_open command in the server Tcl code to see that the sequence works for your implementation (you can manually enter those commands in System Console to check). 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Thanks a lot for your help Dave. I will check those commands in System Console. 

When you say System Console , is the console that we open in Qsys tool menu right? 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

Thanks a lot for your help Dave. I will check those commands in System Console. 

When you say System Console , is the console that we open in Qsys tool menu right? 

 

--- Quote End ---  

 

Yes. You can also start it by opening a "NIOS II IDE Shell" (a cygwin console) and typing system-console. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Hello Dave, 

 

The tutorial works with any board or just that one that you put in your tutorial? 

I have a DE0-nano. 

 

Kind regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

I asked you because you have "Read the scripts for the slight di&#64256;erences in procedures (due to the slight di&#64256;erence in hardware available on these boards)." 

 

Kind Regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

 

The tutorial works with any board or just that one that you put in your tutorial? 

I have a DE0-nano. 

 

--- Quote End ---  

 

The tutorial can be made to work with any board, and has examples for the BeMicro, BeMicro-SDK, and DE2 boards. I didn't have a DE0-nano at the time (I do have one now). 

 

If you manually go through the tutorial, then you can create your own top-level design for the DE0-nano. If you get too confused, then I can send you the files. Try doing it yourself first as it will help you to learn the tools. 

 

Note that the software will work *regardless* of what you connect your JTAG-to-Avalon-MM master to. The client GUI simply issues read and write commands to the master component. They do not care what the master is connected to, as the client just reads and writes Avalon-MM addresses. 

 

The server also has a debug mode, where if you set the variable debug to 1 before sourcing the script, the reads and writes on the server are just to fake memory locations. Read the comments in jtag_server.tcl. 

 

The key advantage to having the source code for a tutorial is that you can "play" with the code. Don't be afraid to just try something - it might just work - and if it doesn't, you can then try to figure it out (Ok, be a "little" afraid when you are downloading to hardware, as you *must* have the pin assignments correct). Its only by "doing" that you really gain an understanding of what is going on. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Good afternoon Dave, 

 

sorry for disturbing you again, but this is really important for me. 

I am doing my final project in the university and I need just one this to finish. 

 

I need to read a 32 bits value from adress 0x00000000 and present it in a tcl GUI interface. 

I did a project with the follow Qsys and top and of course vhdl. 

I read from the adress with the Qsys system console before to test it and it was okay, I could read the 32 bits value from the adress 0x00000000. 

 

Qsys: http://img809.imageshack.us/img809/1674/58cn.png 

Top of the project: http://img690.imageshack.us/img690/9158/zml6.png 

 

My problem is how to read that value and put it that value into a tcl GUI interface. 

 

If you can help me I will appreciate it so much. I just need this to finish. 

 

Kind regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

 

sorry for disturbing you again, but this is really important for me. 

I am doing my final project in the university and I need just one this to finish. 

 

--- Quote End ---  

 

 

Ignore the fact that this has anything to do with Altera and learn the basics of Tcl/Tk. What you are asking can be found in any book on the subject. I posted examples in this thread: 

 

http://www.alteraforum.com/forum/showthread.php?t=27920 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Thanks Dave. 

 

Kind regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

Hello Dave, 

 

in the Client Application (Tcl GUI) I need to write which GUI I want to use with the jtag_cmds_sc.tcl right? 

Should I use the Server Application in the example that you gave? 

If yes, how can I use all (Client + Server) to run it in a simple way? 

 

Kind Regards
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

 

how can I use all (Client + Server) to run it in a simple way? 

 

--- Quote End ---  

 

I've already explained how to do that already. 

 

The server can be run in debug mode, where it reads and writes to an internal Tcl variable. 

 

The client can then be run and talk to the server. Reads and writes to addresses are "cached" in the server in a variable. Reads to a new address return zero, writes followed by reads to an address return the value written. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

There is any possibility just to do a simple GUI to read from a adress and present it? 

Because I am not understanding this with the client and server. 

Sorry for being such a novice in this. 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
3,417 Views

 

--- Quote Start ---  

There is any possibility just to do a simple GUI to read from a address and present it? 

--- Quote End ---  

 

Yes, of course there is. 

 

You can edit the client and remove all the code associated with the server.  

 

 

--- Quote Start ---  

 

Because I am not understanding this with the client and server. 

Sorry for being such a novice in this. 

 

--- Quote End ---  

 

I have already provided examples which show how to do everything you have asked. 

 

I have deliberately not "held your hand" and simply written the code for you, as that would achieve nothing (other than allowing you to skip the step of actually learning something). 

 

You need to post a question showing you have actually *tried* to write some Tcl code, and that you are *stuck*. 

 

Show that you have actually attempted to either do something yourself, or have a specific question about how some code works, and I'll help you. 

 

Did you even bother to open the tk_examples.zip file I linked to above? I'll give you the benefit of the doubt and tell you how you can run these examples; 

 

1. Download the examples, and extract them, eg., into c:/temp/tk_examples/ 

2. Start Quartus or ActiveState ActiveTcl 

3. If running Quartus, make the Tcl console visible via View->Utility Windows->Tcl Console 

4. In the Tcl console, change directory to the tk_examples folder and run (source) an example 

 

tcl> cd {C:\temp\tk_examples} 

tcl> source entrybox_ex.tcl 

 

and then play with the GUI. 

 

Then read the code, break it, debug it, and build your own GUI. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
3,213 Views

Hello Dave, 

 

Thank you so much for your help. It helped me a lot but now I am stuck in something that without this I can't finish. 

 

In this procedure: 

 

proc read_button {} { 

global jtag 

 

# The address and data entry boxes contain only digits, 

# so add the leading 0x to the address 

set data [jtag_read 0x$jtag(address)] 

 

# and then strip the response 0x 

set jtag(data) [format %X $data] 

 

I can't get the adress of the JTAG. I am using JTGA_to_Avalon_MM. Is because of this? 

The adress in Qsys is 0x00000000. 

 

Can you help me please? Because I am receiving this error: can't read "jtag(address)": no such element in array 

 

Kind regards
0 Kudos
Reply