赞
踩
VHDL除法的过程中可以使用二进制的移位处理。
通过SLL实现五比特数的移动,另外常见的还有
SRL 逻辑右移 ---- 实现数据右移,左端补0;
SLA 算术左移 ---- 实现数据左移,同时复制最右端的位,填充在右端空出的位置;
SRA 算术右移 ---- 实现数据右移,同时复制最左端的位,填充在左端空出的位置;
ROL 循环逻辑左移 ---- 实现数据左移,从左端移出的位填充到右端空出的位置上;
ROR 循环逻辑右移 ----实现 数据右移,从右端移出的位填充到左端空出的位置上。
移位的类型必须为std_logic_vector j<= std_logic_vector(i sll 1);
或者如果为std_logic_vector类型,就在一个语句里面进行两次类型装换。P<=to_std_logic_vector( to_bit_vector(i) SLL 2 )
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test is
port (
i: in std_logic_vector (15 downto 0);
j: out std_logic_vector (15 downto 0)
signal p :std_logic_vector (15 downto 0) :
);
end entity test;
architecture a of test is begin
**j<= std_logic_vector(unsigned(i) sll 1);**
P<=to_std_logic_vector( to_bit_vector(i) SLL 2 )
end architecture a;
https://www.amobbs.com/thread-3732803-1-1.html
http://bbs.elecfans.com/jishu_927654_1_1.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。