-1

Can someone explain to me what is the meaning of this statement in VHDL:

aIn : in STD_LOGIC;
signal oSyncStages : std_logic_vector(STAGES-1 downto 0);
oSyncStages <= oSyncStages(oSyncStages'high-1 downto 0) & aIn;

Based on the response on this post, Vector ( X ) when x is a number, it indicate the index in the vector, but if it is a range like here "downto", what's the meaning?

winny
  • 13,064
  • 6
  • 46
  • 63

1 Answers1

1

"what is the meaning of this statement in VHDL" You show three statements but I imagine you mean the third one, the assignment statement:

aIn                : in STD_LOGIC;
signal oSyncStages : std_logic_vector(STAGES-1 downto 0);

oSyncStages  <=  oSyncStages(oSyncStages'high-1 downto 0) & aIn;

In a clocked process, the assignment will implement a shift register.

For a vector type like std_logic_vector, attribute high returns the highest bit number.

So if std_logic_vector oSyncStages was an 8-bit vector numbered (7 downto 0) then this is actually:

oSyncStages  <=  oSyncStages( 6 downto  0) & aIn;

Using attributes to discover the characteristics of signals and types allows flexible designs to be written that work with, for instance, different widths of signals.

That is shown here, as oSyncStages itself has its width specified by STAGES. You don't show the source of STAGES but it must be from a constant or generic.

All of this explanation can be found in VHDL reference information on the internet, and in more detail. That will cover basics, such as 'what are vector types'. Research further for yourself rather than asking low-level questions here, there's mountains out there already written that will help you learn and faster.

TonyM
  • 21,742
  • 4
  • 39
  • 62
  • Maybe I wasn't clear. Based on my understanding => since we cannot use "AND" operator between a vector and a single bit, I thought that we index a single bit in the vector oSyncStages (which one ??LSB ?? MSB??) and we assign the result of the operation to a single bit in oSyncStages (again which one ?? LSB ?? MSB). My confusion comes from the "AND" operation between a range "downto" with a single bit – sharuhkhan Mar 03 '22 at 10:18
  • 2
    My bad, this is a concate operator not logical and, thanks for the hint "shift register". newbie mistake :). Thank you. – sharuhkhan Mar 03 '22 at 10:26