EmbDev.net

Forum: FPGA, VHDL & Verilog array of an entity


von amir (Guest)


Rate this post
useful
not useful
hi guys

I have register entity in my program.
the question is there will be 16 different registers in a very simple 
cpu. I should access each of these registers and according to read , 
write and select_register inputs, read or write on the selected 
register.

my problem is how to define an array of registers that let me read or 
write on them.

I mean something like this:

----type reg16 is array (0 to 15) of reg;----

thank you

von P. K. (pek)


Rate this post
useful
not useful
Try something like this:
1
entity GENREG is
2
  generic (
3
    WIDTH : integer := 8);           -- register width
4
  port (
5
    SysxC      : in  std_logic;
6
    -- Register input path
7
    ReqInxSO   : out std_logic;
8
    AckInxSI   : in  std_logic;
9
    InxDI      : in  unsigned(WIDTH-1 downto 0);
10
    -- Register output path
11
    ReqOutxSI  : in  std_logic;
12
    AckOutxSO  : out std_logic;
13
    OutxDO     : out unsigned(WIDTH-1 downto 0);
14
    -- Status
15
    RegBusyxSO : out std_logic;
16
    -- CSR interface
17
    SoftResxSI : in  std_logic := '0'
18
        );                                                   
19
end GENREG;

This is generic width inside the register. If you want a number of 
entities instantiated, try something like:
1
REG : for i in 0 to NR_REG-1 generate
2
  -- Instances
3
end generate REG;

: Edited by User
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
amir wrote:
> my problem is how to define an array of registers that let me read or
> write on them.
First define one of those 'reg' s. Maybe it's good to use a record for 
it.
Then  transfer this definition in a package and define the register set 
exactly the way you already did.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.