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.

constant value in VHDL

Status
Not open for further replies.

energy_baz

Junior Member level 1
Joined
Nov 24, 2010
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,413
hi,

Can I use this way to declare all my value for the constant because i need to use all these value in the same name.? Any idea how can I declare all these value in the same name..?
 
Last edited:

hi
Constant is a NON-varying value, if one name has different values it is a Variable) use array, if you dont want to change name. select_mod(1):=3, select_mod(2):=5 ...
 
I'm not sure how to use the variable....is this the correct way..?
 
Last edited:

In fact, an integer constant can take only one value. Array of integer is a common solution to select between values.

Code:
CONSTANT FREQ_SEL_MAX : integer := 13;
TYPE FREQ_PAR IS ARRAY (0 TO FREQ_SEL_MAX) OF INTEGER;	
CONSTANT SEL_PWM_DIV    : FREQ_PAR := (
      12000, 10000, 8000, 6000, 5000, 4000, 3000, 2500, 
      2000, 1500, 1250, 1000, 500, 200);

P.S.: You have to declare an array type to make it work.
 
A constant in any programming language is a value assigned to a specific name,
when you have an integer constant then it can only have one value.
You can use an array of integers if you want


Code VHDL - [expand]
1
2
3
4
5
6
7
8
TYPE SAMPE_main IS ARRAY (1 to 10) OF INTEGER;
CONSTANT SAMPLE : SAMPLE_main := (10,20,30,40,50,60,70,80,90,100);
 
--to use it
 
SAMPLE(0);
SAMPLE(1);
-- etc


Alex
 
I noticed a bad habit to edit your original posts, deleting the code examples that the other contributions are referring too. In my opinion, it's a serious disregard of the forum members effort to solve your problems - and a pretty strong hint to keep away from it in the future.
 

FvM : I have to delete all the codes immediately because it might cause me plagiarism for my project. That's the reason why I'd deleted all those codes. Sorry about that.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top