SOC课程实验
指令存储器IR设计
一、功能分析
1、传送指令编码到微控制器
clk_IR 上升沿有效,LD_IR1高电平有效,data->IR。
2、寄存器地址操作
Data[0]-> RS
Data[1]-> RD
3、生成PC的新地址
clk_IR 上升沿有效,LD_IR2高电平有效,data[3…0]->PC[11…8];
clk_IR 上升沿有效,LD_IR3高电平有效,data[7…0]->PC[7…0]。
4、生成RAM的读写地址
clk_IR 上升沿有效,LD_IR3高电平有效,data[7…0]->PC[7…0];
nARen低电平有效,PC[6…0]->AR[6…0]。
二、实验代码
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity module_IR is port(
clk_IR,nreset,LD_IR1,LD_IR2,LD_IR3,nARen:std_logic;
data:in std_logic_vector(7 downto 0);
IR:out std_logic_vector(7 downto 2);
PC:out std_logic_vector(11 downto 0);
AR:out std_logic_vector(6 downto 0);
RS,RD:out std_logic);
end entity module_IR;
architecture behavior of module_IR is
begin
process(nreset,clk_IR)
begin
if(nreset='1')then
IR<=(others=>'0');
PC<=(others=>'0');
AR<=(others=>'0');
RS<='0';
RD<='0';
else
if(clk_IR'event and clk_IR='1')then
if(LD_IR1='1')then
IR<=data(7 downto 2);
RS<=data(0);
RD<=data(1);
elsif(LD_IR2='1')then
PC(11 downto 8)<=data(3 downto 0);
elsif(LD_IR3='1')then
PC(7 downto 0)<=data(7 downto 0);
if(nARen='0') then
AR<=data(6 downto 0);
end if;
end if;
end if;
end if;
end process;
end architecture behavior;