开发者

Use of concatenation to shift in VHDL

开发者 https://www.devze.com 2023-04-11 11:58 出处:网络
Data_Int<=\'0\' & Data_Int(7 downto 1); --if shift then shift it right How is concatenation used to shift a position? I thought there is a shift right operator in VHDL. Can someone please exp
Data_Int<='0' & Data_Int(7 downto 1); --if shift then shift it right

How is concatenation used to shift a position? I thought there is a shift right operator in VHDL. Can someone please explain this to me?

Suppose

Data_Int : std_vector(10 downto 0);
-- and Data_Int 开发者_运维技巧has "1010010011" 

Thank you very much.


The shift operators (sll, srl, sla, sra, rol, and ror) are not provided in VHDL-87, so you'll see a lot of code explicitly shifting using concatenation and partial arrays. A more universal method of writing your above shift (which would work with various array sizes) would be:

Data_Shift <= '0' & Data_Int(data_Int'left downto Data_Int'right+1);

The concatenation provides a shift since you're dropping one bit (bit 0 in this case) and replacing it on the high-order side with something else (a logical zero here, although you could also shift in a logical 1, sign-extend, etc).

0

精彩评论

暂无评论...
验证码 换一张
取 消