B
Brad Smallridge
Guest
Hi,
I always run into the issue of having counters
or adders where I don't want the resulting value
to exceed a certain threshold.
Here's an example but maybe not the best solution
in terms of synthesis:
signal count : std_logic_vector(7 downto 0);
signal addval : std_logic_vector(7 downto 0);
constant rollover : natural := 255;
begin
process(count,addval)
begin
if( count + addval > rollover ) then
count <= rollover;
else
count <= count+addval;
end if;
end process;
Rollover can sometimes be a signal. And usually I
will use clocked processes.
Does the above code infer two adders and a comparator?
So what would be the best solution in terms of
synthesis? I work with Xilinx ISE and Virtex V4s.
Brad Smallridge
AiVision
I always run into the issue of having counters
or adders where I don't want the resulting value
to exceed a certain threshold.
Here's an example but maybe not the best solution
in terms of synthesis:
signal count : std_logic_vector(7 downto 0);
signal addval : std_logic_vector(7 downto 0);
constant rollover : natural := 255;
begin
process(count,addval)
begin
if( count + addval > rollover ) then
count <= rollover;
else
count <= count+addval;
end if;
end process;
Rollover can sometimes be a signal. And usually I
will use clocked processes.
Does the above code infer two adders and a comparator?
So what would be the best solution in terms of
synthesis? I work with Xilinx ISE and Virtex V4s.
Brad Smallridge
AiVision