Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

incrementing unsigned array

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
I have a custom type that's defined as follows:
Code:
type unconstrained_array is array ( natural range <> ) of unsigned ;

signal x is declared as follows:
signal x : unconstrained_array ;

I want to write a loop that assignes to x an array of incrementing unsigned numbers as follows:

"0000"
"0001"
"0010"
.
.
.
"1111"

However, becuse x is an unconstrained array, I want the code to be generic and except any width and depth of x.
This is what I wrote so far:

Code:
for index in x ' range 
loop
x ( index ) <= to_unsigned ( index , ( x ' length ) ) ;
end loop ;

What do you think? Anything I should fix?
 

First of all, x cannot be declared like this:
signal x : unconstrained_array ;

It needs to have it's two dimensions defined at declaration:
something like this:

signal x : unconstrained_array(7 downto 0)(7 downto 0);

When you have got over this hurdle, the for loop you have should work this this minor modification:

x ( index ) <= to_unsigned ( index , ( x(index)'length ) ) ;
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
This is what I wrote:

Code:
running_address : process ( all ) is 
begin
  for index in x ' range
  [COLOR="#FF0000"]loop[/COLOR] 
    x ( index ) <= to_unsigned ( index , ( x ( index ) ' length ) ) ; 
  end loop ;	
end process running_address ;

However, this code causes modelsim to freeze.
Pressing the break key releases the freeze after a long delay with a note that points to the line marked in red)
Rewriting the code in a non generic way, doesn't cause a problem.

Any ideas?
 

because you put process(all) this process will be re-run when ANY signal changes. This will probably slow modelsim to a crawl.

This isnt really a process - you dont have anything that would cause a change in X. Everything is constant, so why is it in a process?
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
so why is it in a process?
I used a process because of the "for" loop.

What alternative do you suggest?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top