A
Analog_Guy
Guest
Here's a two part question:
Q#1:
If a CONSTANT is defined of type INTEGER (i.e. CONSTANT counter_bits
: INTEGER := 1, does a range need to be specified? For synthesis, it
is generally good practice to constrain INTEGERs. However, I can see
that this makes sense for VARIABLES and SIGNALS, but does it also apply
to CONSTANTS?
Q#2:
Is it acceptable coding style to define a STD_LOGIC_VECTOR counter load
as an INTEGER CONSTANT (where conversion functions need to be called
when the counter is loaded), or can this lead to any synthesis issues?
CONSTANT counter_bits : INTEGER := 6;
CONSTANT counter_load : INTEGER := 59;
SIGNAL counter : STD_LOGIC_VECTOR(counter_bits - 1 DOWNTO 0);
strobe: PROCESS (reset_n, CLOCK)
BEGIN
IF (reset_n = '0') THEN
counter <= CONV_STD_LOGIC_VECTOR(counter_load, counter_bits);
ELSIF (CLOCK = '1' AND CLOCK'EVENT) THEN
IF (counter /= 0) THEN
counter <= counter - '1';
ELSE
counter <= CONV_STD_LOGIC_VECTOR(counter_load, counter_bits);
END IF;
END IF;
END PROCESS strobe;
Q#1:
If a CONSTANT is defined of type INTEGER (i.e. CONSTANT counter_bits
: INTEGER := 1, does a range need to be specified? For synthesis, it
is generally good practice to constrain INTEGERs. However, I can see
that this makes sense for VARIABLES and SIGNALS, but does it also apply
to CONSTANTS?
Q#2:
Is it acceptable coding style to define a STD_LOGIC_VECTOR counter load
as an INTEGER CONSTANT (where conversion functions need to be called
when the counter is loaded), or can this lead to any synthesis issues?
CONSTANT counter_bits : INTEGER := 6;
CONSTANT counter_load : INTEGER := 59;
SIGNAL counter : STD_LOGIC_VECTOR(counter_bits - 1 DOWNTO 0);
strobe: PROCESS (reset_n, CLOCK)
BEGIN
IF (reset_n = '0') THEN
counter <= CONV_STD_LOGIC_VECTOR(counter_load, counter_bits);
ELSIF (CLOCK = '1' AND CLOCK'EVENT) THEN
IF (counter /= 0) THEN
counter <= counter - '1';
ELSE
counter <= CONV_STD_LOGIC_VECTOR(counter_load, counter_bits);
END IF;
END IF;
END PROCESS strobe;