FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
5946 Discussions

How can I write to Custom IP register from C code?

Altera_Forum
Honored Contributor II
1,121 Views

Hello all. I'm designing a custom IP that outputs simple number data in each cycle. 

 

The IP has both Avalon Slave Interface and Avalon Master Slave : 

The Master Interface is connected to On-Chip Memory's Avalon Slave Interface where I will store the output data in. 

The Slave Interface is connected to Nios2's Avalon Master Interface. 

 

 

Here, I want to write data into the custom IP, controlled on C code. I plan to use pointers like this : 

 

| volatile int * adr = (int *) (base address of custom IP); 

| adr = 0x00000001; 

 

I believe Nios2 Processor IP handles the Interface connections so that I can manage this on C code, right? 

 

 

I want to send the 32-bit data into the Custom IP, where it will store the data into it's register (reg). 

The data will be used to initiate the module - work as a 'start shotting numbers' register. 

 

What I just tried is doing it like : 

 

| // Avalon Slave // 

| output reg [31:0] s_rdata; 

|  

| input s_read; 

| input s_write; 

| input [3:0] s_addr; //slave address 

| input [31:0] s_wdata; //slave writedata 

|  

| reg [31:0] start; 

|  

|  

| always @(posedge clk) begin 

| start <= s_wdata; 

| end 

|  

| (later check 'if(start<=32'b1)' to initiate the module's function) 

 

However, for some reason the data wasn't written into 'start' register. 

 

 

 

So the question here is : How can I write to the IP's register, from C code? 

I need to make the work of the IP software-controlled. 

 

Thank you.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
98 Views

Hi, 

 

Refer below link 

ftp://ftp.altera.com/up/pub/altera_material/15.1/tutorials/making_qsys_components.pdf 

https://www.alteraforum.com/forum/showthread.php?t=50629 

 

Best Regards, 

Anand Raj Shankar 

(This message was posted on behalf of Intel Corporation)
Reply