Looking for something others

B

Brad Smallridge

Guest
Hi folks,

How does one write this code cleanly?

if( segment_pointer_count="111111111" ) then
segment_pointer_count <= "000000001"; -- skip zero
else
segment_pointer_count <= segment_pointer_count+1;
end if;


That is, with something that is length independent.

Thanks,

Brad Smallridge
b r a d @ a i v i s i o n . c o m
 
Hello

Brad Smallridge wrote:
Hi folks,

How does one write this code cleanly?

if( segment_pointer_count="111111111" ) then
segment_pointer_count <= "000000001"; -- skip zero
else
segment_pointer_count <= segment_pointer_count+1;
end if;

That is, with something that is length independent.
You can write this:

if segment_pointer_count = (segment_pointer_count'range => '1') then
segment_pointer_count <= (0 => '1', others => '0');
else
....

Nicolas
 
if( segment_pointer_count= X"FF" ) then
segment_pointer_count <= X"01"; -- skip zero
else
segment_pointer_count <= segment_pointer_count+1;
end if;
 

Welcome to EDABoard.com

Sponsor

Back
Top