Hi,
Sorry I attached the wrong VHD file for the avalon interface. Here it is,
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_signed.all;
ENTITY reg16_avalon_interface IS
PORT ( clock, resetn : IN STD_LOGIC;
read, write, chipselect : IN STD_LOGIC;
writedata : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
byteenable : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
readdata : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
address: IN Std_Logic_Vector(3 downto 0);
Q_export : OUT STD_LOGIC_VECTOR(31 DOWNTO 0) );
END reg16_avalon_interface;
ARCHITECTURE Structure OF reg16_avalon_interface IS
type reg_type is array (16 downto 0) of std_logic_vector (31 downto 0);
SIGNAL local_byteenable : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL to_reg, from_reg : reg_type;
COMPONENT reg16
PORT ( clock, resetn : IN STD_LOGIC;
D : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
byteenable : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
Q : OUT STD_LOGIC_VECTOR(31 DOWNTO 0) );
END COMPONENT;
BEGIN
to_reg(to_integer(unsigned(address))) <= writedata;
WITH (chipselect AND write) SELECT
local_byteenable <= byteenable WHEN '1', "0000" WHEN OTHERS;
reg_instance: reg16 PORT MAP (clock, resetn, to_reg(to_integer(unsigned(address))), local_byteenable, from_reg(to_integer(unsigned(address))));
readdata <= from_reg(to_integer(unsigned(address)));
Q_export <= from_reg(to_integer(unsigned(address)));
END Structure;
I think I am going wrong with the way I am specifying the address signal. But I am not entirely sure how to implement this.
-Smruthi