Altera_Forum
Honored Contributor
11 years agobit shift and extract
Hi everyone!
i want to shift a number 24 bit to the right (cut off), and extract the remaining 8 bit. how to do it in vhdl? a = b >>24 & 0xff;
So far I tried to work with srl, shift_right(), '&' and 'and' operators - actually nothing worked out. Running everything within a procedure, I have the following declarations
(...)
variable temp: integer range 0 to 65535;
variable d3: integer range 0 to 15;
(...)
-- and currently apply it the following way
d3 := to_integer(shift_right(unsigned(temp), 24)) and "11111111";
first I left away any "and" construction: d3 := to_integer(shift_right(unsigned(temp), 24)); Errors I obtain:Error: VHDL Use Clause error at increment_display.vhd(61): more than one Use Clause imports a declaration of simple name "unsigned" -- none of the declarations are directly visible ...so I removed "unsigned()" Error: VHDL error at increment_display.vhd(61): can't determine type of object at or near identifier "shift_right" -- found 0 possible types ...so I removed to_integer(), actually everything was already devined as integer, no? Error: VHDL Qualified Expression error at increment_display.vhd(61): SHIFT_RIGHT type specified in Qualified Expression must match integer type that is implied for expression by context ...hum... Actually, I could not find much or any example snippets on shifting and extracting, is there a totally different way of doing this in VHDL?