实验背景:
寄存器是CPU内的重要组成部分,模型机的通用寄存器组包含3个8位寄存器A、B、C,实现对此3个寄存器的读写操作。其接口及功能如下:
VHDL语言
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity tongyongjicunqi is
port(clk,WE:in std_logic;
RA,WA:in std_logic_vector (1 downto 0);
i:in std_logic_vector(7 downto 0);
S,D:out std_logic_vector(7 downto 0);
AAA,BBB,CCC:out std_logic_vector(7 downto 0));
end tongyongjicunqi;
architecture aaa of tongyongjicunqi is
signal a:std_logic_vector(7 downto 0):="00000000";
signal b:std_logic_vector(7 downto 0):="00000000";
signal c:std_logic_vector(7 downto 0):="00000000";
begin
process (clk, WE, RA, WA)
begin
--if(WE='0' and falling_edge (clk)) then
if (WE='0' and (clk'event and clk='0')) then
if(WA="00") then a<=i;
elsif(WA="01") then b<=i;
elsif(WA="10") then c<=i;
end if;
end if;
if(RA="00") then S<=a;
elsif(RA="01") then S<=b;
elsif(RA="10") then S<=c;
end if;
if(WA="00") then D<=a;
elsif(WA="01") then D<=b;
elsif (WA="10") then D<=c;
end if;
AAA<=a;
BBB<=b;
CCC<=c;
end process;
end aaa;
RTL视图