Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

How to access the Program Counter of Nios II

Altera_Forum
Honored Contributor II
1,027 Views

Hey everybody. I'm a fairly new user using this board, however I come here to search for topics that can help solve my problems. Lately I have been successful finding these troubleshooting topics except for one. 

 

I'm trying to access the Program Counter (PC) register of the Nios II Processor. Is there any available software function (C/C++ macro) that I'm able to access the program counter and store its value into a variable? 

 

If this is not possible, then what other possible solutions that allows me to retrieve the value of the PC? 

 

Thanks a lot
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
311 Views

Nios II provides the NEXTPC instruction that returns the PC of that instruction plus four.  

There doesn't appear to be a HAL macro available for using this 

instruction from C code. However, it is relatively easy to make one yourself. 

Just look at the examples in the HAL nios2.h file. It is located in your Nios II kit directory under components/altera_nios2/HAL/inc.
0 Kudos
Altera_Forum
Honored Contributor II
311 Views

 

--- Quote Start ---  

originally posted by james@May 30 2006, 10:13 AM 

nios ii provides the nextpc instruction that returns the pc of that instruction plus four.   

there doesn't appear to be a hal macro available for using this 

instruction from c code.  however, it is relatively easy to make one yourself. 

just look at the examples in the hal nios2.h file.  it is located in your nios ii kit directory under components/altera_nios2/hal/inc. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15686) 

--- quote end ---  

 

--- Quote End ---  

 

 

 

Thanks, I will certainly take a look at that
0 Kudos
Reply