FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6343 Discussions

How to use Avalon Bus by Eclipse?

Gyud0
Beginner
783 Views

Hey,

I would like to know how to write and read data by a C code that runs by Eclipse and uses the Avalon Bus .

I designed the entity below that contains the Avalon Bus ports,clock,reset and the outputs to my inner design (out1,out2,out3) and output to NIOS (out4).

The whole design by Qsys include: NIOS2, my design,JTAG UART,On chip memory and System ID.

The addresses range for my design by Qsys is 0x401020-0x40102F, hence 16 bytes of addresses,thus 4 addresses of 32bit each.

 

I wrote a C code that out2 will get the value 3 , bit it doesn't work. in Eclipse Debug mode I see the value 0 at the whole addresses space, but I got the value 0x01241000" at address 0x40103C (outta from address space of my design).

 

Thank you very much !

 

 

My Avalon Bus entity :

 

library ieee;

use ieee.std_logic_1164.all;

library ieee.std_logic_arith.all;

entity avalon_entity is

port(

clk,rst_n: in std_logic;

avs_read,avs_write: in std_logic;--FROM NIOS

avs_readdata: out std_logic_vector(31 downto 0); --to NIOS

avs_writedata: in std_logic_vector(31 downto 0); --FROM NIOS

avs_address: in std_logic_vector(1 downto 0);--FROM NIOS

out1,out2,out3,out4:out std_logic_vector(31 downto 0)

);

end entity avalon_entity;

architecture behave of avalon_entity is

 

signal reg1,reg2,reg3,reg4: std_logic_vector(31 downto 0);

 

begin

 

out1<=reg1;

out2<=reg2;

out3<=reg3;

out4<=reg4;

 

process(clk,rst_n)

begin

if rst_n='0' then

reg1<=(others=>'0');

reg2<=(others=>'0');

reg3<=(others=>'0');

reg4<=(others=>'0');

elsif rising_edge(clk) then

if avs_write='1' then

case conv_integer(avs_address) is

when 0=> reg1<=avs_writedata;

when 1=> reg2<=avs_writedata;

when 2=> reg3<=avs_writedata;

when others=> NULL;

end case;

 

end if;

if avs_read='1' then

case conv_integer(avs_address) is

when 0=> reg4<=avs_readdata;

when others=> NULL;

end case;

end if;

 

end if;

end process;

 

end behave;

The C code:

 

#include<stdio.h>

int main()

{

IOWR(0x401020,0x04,0x03);

printf("0x401024=%u\n",0x0);

}

 

The output is :

0x401024=8650772.

This is a garbage value.

0 Kudos
1 Reply
Gyud0
Beginner
316 Views

I made it. Thank you anyway =)

0 Kudos
Reply