实验背景:
移位指令:
RSR R1
RSL R1
这类指令的执行过程为:
由R1的编码通过RWBA1、RWBA0从通用寄存器组D口读出R1的内容,在S3~S0和M的控制下通过ALU,经移位逻辑循环右移或循环左移后送入总线BUS;再由/WE控制和R1的编码选择RWBA1、RWBA0,将BUS上的数据写入通用寄存器R1。
指令具体功能如下:
RSR 循环移位操作具体如下:
移位逻辑需要实现RSR、RSL操作,还需提供MOVA、MOVB、ADD、SUB、OR、NOT、OUT指令执行时,将数据传输至BUS总线的通路。
移位逻辑的输入输出引脚如下图所示:
VHDL语言
library ieee;
use ieee.std_logic_1164.all;
entity yiweiluoji is
port(fbus,flbus,frbus:in std_logic;
A:in std_logic_vector(7 downto 0);
W:out std_logic_vector(7 downto 0);
cf:out std_logic:='0');
end yiweiluoji;
architecture aaa of yiweiluoji is
begin
process (fbus,flbus,frbus)
begin
if(fbus='1' and flbus='0' and frbus='0') then--through shift
W<=A;
cf<='0';
elsif(fbus='1' and flbus='1' and frbus='0') then--left shift
W<=A(6 downto 0)&A(7) ;
cf<=A(7);
elsif(fbus='1' and frbus='1' and flbus='0') then--right shift
W<=A(0)&A(7 downto 1);
cf<=A(0);
else
W<="ZZZZZZZZ";
cf<='Z';
end if;
end process;
end aaa;
RTL视图