1
votes

I am a beginner in vhdl with not much grasp on signal.

My understanding is you can assign signal value such as signal<='100' but you don't have to declare it. Is that correct?

Also, for sign extension ext_imme<=(31 downto 16=> imme(15)) & imme; why would this work for extending 16 bit to 32 bit by repeating imme(15) twice?

1
Your syntax isn't correct (some_signal <= "100"; signal is a reserved word), nor your assumption. A named signal is always declared, that name may be a prefix for an implicit signal name, slice name or indexed name. An object is a type and a value, designated by it's declared name. The expression on the right hand side of the signal assignment to ext_imme contains an aggregate assigning an array length 15 with each element having the value of imme(15) and concatenating that array with imme (presumably with a range 15 downto 0), producing an array value 32 long. Show declarations.user1155120

1 Answers

2
votes

1) You can not assign signal value such as signal<='100' without declaring it it. You are not correct.

VHDL doesn't like surprises. Everything always must be declared before you use it.

So, you must declare a signal (in the declarative region of the architecture, ie between architecture and begin):

architecture SOME_NAME of SOME_OTHER_NAME is
  -- declare signals (and other things) here, eg
  signal SOME_SIGNAL_NAME : std_logic;  -- or some other type
begin

You can also initialise signals when you declare them, but I would be very careful doing this if you intend to synthesise the code, eg:

  signal SOME_SIGNAL_NAME : std_logic := '0';  

2) This ext_imme<=(31 downto 16=> imme(15)) & imme is an example of an aggregate and a concatenation. An aggregate is a way of assigning to the elements of an array. A concatenation is a way of joining two arrays together to make a bigger array.

In your example, this is the aggregate: (31 downto 16=> imme(15)). Here you are making bits 31 down to 16 equal to bit 15 of imme. This gives you 16 bits all equal to bit 15 of imme.

The '&' operation is the concatenation operator. In your example, you are joining the 16 bits of the aggregate to the 16 bits of imme to make 32 bits in total.

Here some other examples of using aggregates: http://www.edaplayground.com/x/CQm.