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++

Interfacing Custom Component

Altera_Forum
Honored Contributor II
1,674 Views

Recently I built custom component of SDCARD. 

What I'm trying to make is an easy interfacing with the SDCARD module I built based on VHDL. 

I want to read or write from the SDCARD Mem only by using single write or read command. 

When I tried to convert my VHDL module to Custom Component, I have found out that the communication between my module and the AVALON is nothing like the waveforms at the datasheets and at the SOPC software (I'm working with Quartus 9.0). 

 

My problem is when I'm sending threw the NIOS IDE console simple "write" command, the AVALON sending 4 pulses of write on the "write" line instead of one. 

And that's not all, at the first pulse I receive threw the "writedata" line, the data I have inserted threw the console, and at the 4th pulse I receive threw the "address" line, the address I asked for (sometimes it's the wrong address). 

 

Another problem I have is when I'm inserting "read" command the AVALON sending me the address on the "writedata" line. 

 

This is very confusing, I don't think its have smth to do with my module, the only thing that I changed from other modules is that the system clk is 50M and the SD clk is 20M.  

 

I added few pictures of the data I receive on the signal tap, and the commands I send threw the console. And here's the index: 

 

PIC1-read mode, the AVALON sends the address to the "writedata" input. 

 

PIC2-while I'm sending threw the NIOS IDE write command, he generate 4 cycles of write, while at the first one he locking the data, and at the last he gives me the address, in this example,he give me the wrong address, i can upload exapmle with the right address at the 4th pulse. 

 

 

 

 

Data_in - writedata 

Data_out - readadata 

 

 

I can really use some help, 

thnx
0 Kudos
13 Replies
Altera_Forum
Honored Contributor II
531 Views

This seems to be the behavioral when accessing the slaves with pointers instead of the IORD_DIRECT respectively IOWR_DIRECT function.  

Have a look at the avalon interface specification. if a slave has less data bits than the master, the avalon switch fabric performs the full n bits access from the slave as the master has. therefore i highly recommend to use these IORD_DIRECT functions. 

in your case IOWR_8DIRECT( address , offset , data ) and IORD_8DIRECT( address, data ); 

if that does not help, could you please setup signaltap to monitor the avalon interface to your ip (chipselect, address, read, write, waitrequest, data )
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

First thnx for the fast replay 

 

I have tryed to use DIRECT commands but it had chang nothing. 

 

The SOPC give me some warning, he advice me to add "byteenable" to my custom although byteenable is affected by the writedata and readdata who have both only 1 byte. (as you can see at the picture) 

 

So I'm facing 2 choises: 

  • I'm adding byteebale with width of 1 bit, the cause is that the consol replay me that the width must be 2,4,6... 

  • I'm adding byteebale with width of 2 bit, and the colnsol replay that the byteenable must me one eight of readdata/writedata (8). :confused:
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

yes thats a know bug, i had discussed that with Alteras MySupport. 

If your datawidth is 8 then there is no need for the byteenable as this warning is a bug, so ignore it. but if your datawidth is more than 8 bit (16,32...) then you should add byteenable.
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

I changed the address width so it will be 2^n in my case 16 lines, and my data width is 8, so the width of the address and data between the NIOS and my custom will be the same. and still, even when I use DIRECT commanditstill doesn't work, do you have any other suggestion for me?

0 Kudos
Altera_Forum
Honored Contributor II
531 Views

I think you're heading down the wrong path here. Let's go back to basics.  

 

1 - Your VHDL component. It has a data width of 8 bits correct?. Please read section 3.6.1 of the following document: 

http://www.altera.com/literature/manual/mnl_avalon_spec.pdf 

My recommendation is that you make your component have a 32-bit data width regardless of the fact that you are only going to use 8 bits. 

 

2 - Why are you using the PIO macros for acessing your component? I recommend you use the IOWR and IORD macro directly. 

 

Start with these. If this doesn't fix your problem, let me know. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

I fixed the multiply pulses problem, but i still getting the address via the "writedata" signal during read operation. :

0 Kudos
Altera_Forum
Honored Contributor II
531 Views

you mean, during a nios read from your custom ip function the accessed address is displays via writedata and the avalon address lines as well ? 

 

as long as the avalon write signal is in inactive state, you can ignore the writedata signals. 

writedata is only valid if write is 1
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

Yes writedata is irrelevant during a read. Ignore it. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

that's the problem, I'm recieveing the address only via the "writedata" line.. :confused:

0 Kudos
Altera_Forum
Honored Contributor II
531 Views

then there must be something cluttered 

could you please post your tcl file that describes the connection between the avalon signals and your ip
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

 

--- Quote Start ---  

 

1 - Your VHDL component. It has a data width of 8 bits correct?. Please read section 3.6.1 of the following document: 

http://www.altera.com/literature/manual/mnl_avalon_spec.pdf 

My recommendation is that you make your component have a 32-bit data width regardless of the fact that you are only going to use 8 bits. 

 

Jake 

--- Quote End ---  

 

 

Sorry if I ask in the same thread, but it's the same thing. 

If I've to write a 16bit FIFO, if I define it as 16 bit wide always avalon master (Nios in my case) shall write it in couple each time it do a write. 

Better explained a Nios Write is 32 bit so from interconnection fabric is "mapped" into 2 16 bit wide write of 16 bit each. 

 

So if I need to write only 16 bit each time, I can define the fifo as 32 bit wide, then on the read side I connect only the 16 lower bit and then I'll have a 32 bit access on the Nios side will be mapped as 1 only write of all 32 bits of which I loose the 16 high, right? 

But in this case Quartus shall not instanciate the double of the memory right? 

 

In that case I can trick the avalon bus doing a sort of "avalon wrapper" in order to define the byte enable 4 byte enable all time in which all write are done with the 2 higher byte enable always disabled, whereas I shall define of course the Fifo only 16 bit wide as it is needed in reality. 

 

Or (sorry if I explain bad, but usually I do not do the software side of the Nios) a IOWR_16DIRECT( address , offset , data ) shall do a single write of only the 16 bit lower of the avalon data bus?
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

I have uploaded the tcl file and the VHDL files that attached to the design. 

 

I will be more that happy if someone will take a look at the component. 

 

 

and about "DarkWave" question i don't think i fully understand you'r problem, can you explain?
0 Kudos
Altera_Forum
Honored Contributor II
531 Views

Simply: 

On the avalon bus I've attached a NIOS cpu (that is 32 bit) and a 16 bit wide fifo. 

I need that the NIOS can write a defined number of word in the fifo, but the number can change in time and can be 0,1,2,3,4,.. etc.. 

Imagine that I'm in the case that the FIFO has to have only 1 message in the fifo. 

The problem is that if the NIOS do a "normal" write on the bus it writes 32 bit so it ends in having 2 msg in my fifo. 

The question is can the NIOS do a IODIREC16_WR on the fifo and so can I have in it only 1 msg in this case? 

Else I've to define the FIFO as 32 bit wide and on the read side consider valid only the lowest 16 bits. 

 

Thx
0 Kudos
Reply