FPGA Center


It is an object whose value is determined once and can not be changed later. Constants can be declared directly or can be sub-elements of the other constants.

constant constant_name : type := value;

So that the code is more understandable and easily changeable, it is advised to use constants as much as possible.

EXAMPLE 1: (scalar type constants)

type DaysOfWeek is (Mon,Tue,Wen,Thu,Fri);
constant FirstDay: DaysOfWeek:= Mon;

constant LogicalGND : Bit := '0';
constant Temp,state: Integer := 16;
--Since Temp and State constants have the same value, they are defined in the same line.

constant CLK_Period : Time := 15 ns;  
constant MaxSimTime : Time := 200 * CLK_Period;
-- CLK_Period  constant is used in MaxSimTime constant.

  (complex type constants)

type Numeric Type is array (9 downto 0) of Integer range 0 to 9;
constant Code : Numeric Type := (2,6,4,8,0,0,1,3,0,5);
-- Since Code constant is a one dimensional array, a value is assigned to it with aggregate method.
constant Temp: Std_Logic_Vector(7 downto 0) := "00000000";
--DataBusReset sabiti Std_Logic_Vector tipinde oldu─čundan, de─čer atamas─▒ doprudan yap─▒lm─▒┼č.
Since DataBusReset constant is Std_Logic_Vector type , a value is assigned to it directly.


package Timing is
    constant Reset : Std_Logic; -- Reset constant is not assigned to a value.
end package Timing;

package body Timing is
    constant Reset: Std_Logic := '0';  -- The value of the Reset constant is specified here.
end package body Timing;







Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.