我得到了这个微加法器 vhd 顶级文件,我得到了端口映射的 regs.vhd、ALUSuma.vhd 和 MemProgSuma.vhd(注册表、加法器和内存),它们都可以正常工作。我也得到了微加法器测试台,也在工作。
(我认为问题不在于它的工作方式,而在于我如何连接加法器的各个部分)
但是当涉及到测试台的模拟时,有些东西不起作用,大多数信号一直显示“U”,就好像它们没有被初始化一样……可能是映射不好,但我就是看不到是什么微加法器:
实体是这样的:
entity MicroSuma is
port (
Clk : in std_logic; -- clock
NRst : in std_logic; -- reset active with '0'
MemProgAddr : out std_logic_vector(31 downto 0); --
MemProgData : in std_logic_vector(31 downto 0) --
);
end MicroSuma;
建筑学:
architecture Practica of MicroSuma is
component Regs is
port (
Clk : in std_logic; -- clock
NRst : in std_logic; -- reset active with '0'
RtIn : in std_logic_vector(31 downto 0); -- input data
RtAddr : in std_logic_vector(4 downto 0); -- RT direction
RsAddr : in std_logic_vector(4 downto 0); -- RS1 direction
RsOut : out std_logic_vector(31 downto 0)); -- RS1 output
end component;
component ALUSuma is
port (
Op1 : in std_logic_vector(31 downto 0); -- first operand
Op2 : in std_logic_vector(31 downto 0); -- second operand
Res : out std_logic_vector(31 downto 0) -- Op1 + Op2
);
end component;
component MemProgSUMA is
port(
MemProgAddr : in std_logic_vector(31 downto 0); -- direction for the program's memory
MemProgData : out std_logic_vector(31 downto 0) -- oepration code
);
end component;
我的中间信号:
signal datoInmediato : std_logic_vector(15 downto 0);
signal rs : std_logic_vector(4 downto 0);
signal rt : std_logic_vector(4 downto 0);
-- alu-regs comunication
signal c : std_logic_vector(31 downto 0);
signal op1 : std_logic_vector(31 downto 0);
-- aux signals
signal op2 : std_logic_vector(31 downto 0);
signal instruccion : std_logic_vector(31 downto 0);
-- counter PC signal
signal contadorPC : std_logic_vector(31 downto 0);
-- Clock period
constant CLKPERIOD : time := 10 ns;
我做的端口映射是这样的:
begin
U1: Regs port map(
Clk => Clk,
NRst => NRst,
RtIn => c,
RtAddr => rt,
RsAddr => rs,
RsOut => op1
);
U2: ALUSuma port map(
Res => c,
Op1 => op1,
Op2 => op2
);
U3: MemProgSUMA port map(
MemProgAddr => contadorPC,
MemProgData => instruccion
);
我的程序的简单代码是:
-- PC Counter
process (Clk, NRst)
begin
if NRst = '0' then
contadorPC <= (others => '0');
elsif Clk = '1' and Clk'event then
contadorPC <= contadorPC + 4;
end if;
end process;
-- Sign extension
process(instruccion, datoInmediato)
begin
datoInmediato <= instruccion (15 downto 0);
op2(15 downto 0) <= datoInmediato;
op2(31 downto 16) <= (others => datoInmediato(15));
-- MemProgData - Regs comunication
rs <= instruccion(25 downto 21);
rt <= instruccion(20 downto 16);
end process;
end Practica;
仅此而已,这确实会有所帮助,因为我在尝试却没有看到自己做错了什么...