vhdl - 需要有关 VHDL 中变量声明的帮助
问题描述
我正在为我的学位学习 VHDL,我被要求修复此代码中的错误,但经过多次尝试,我无法让它运行。编译器返回“Mem_Addr 已使用但未声明”,突出显示我在下面提到的行。我无法正确声明 Mem_Addr。
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
LIBRARY altera_mf;
USE altera_mf.altera_mf_components.ALL;
ENTITY Ifetch IS
PORT( SIGNAL Instruction : OUT STD_LOGIC_VECTOR( 31 DOWNTO 0 );
SIGNAL PC_plus_4_out : OUT STD_LOGIC_VECTOR( 7 DOWNTO 0 );
SIGNAL Add_result : IN STD_LOGIC_VECTOR( 7 DOWNTO 0 );
SIGNAL Branch : IN STD_LOGIC;
SIGNAL Zero : IN STD_LOGIC;
SIGNAL PC_out : OUT STD_LOGIC_VECTOR( 9 DOWNTO 0 );
SIGNAL clock, reset : IN STD_LOGIC);
END Ifetch;
ARCHITECTURE behavior OF Ifetch IS
SIGNAL PC, PC_plus_4 : STD_LOGIC_VECTOR( 9 DOWNTO 0 );
SIGNAL next_PC : STD_LOGIC_VECTOR( 7 DOWNTO 0 );
BEGIN
--ROM for Instruction Memory
data_memory: altsyncram
GENERIC MAP (
operation_mode => "ROM",
width_a => 32,
widthad_a => 8,
lpm_type => "altsyncram",
outdata_reg_a => "UNREGISTERED",
-- Reads in mif file for initial data memory values
init_file => "program.mif",
intended_device_family => "Cyclone")
-- Fetch next instruction from memory using PC
PORT MAP (
clock0 => clock,
-- ERROR HERE
address_a => Mem_Addr,
--
q_a => Instruction
);
-- Instructions always start on a word address - not byte
PC(1 DOWNTO 0) <= "00";
-- copy output signals - allows read inside module
PC_out <= PC;
PC_plus_4_out <= PC_plus_4;
-- send word address to inst. memory address register
Mem_Addr <= Next_PC;
-- Adder to increment PC by 4
PC_plus_4( 9 DOWNTO 2 ) <= PC( 9 DOWNTO 2 ) + 1;
PC_plus_4( 1 DOWNTO 0 ) <= "00";
-- Mux to select Branch Address or PC + 4
Next_PC <= X"00" WHEN Reset = '1' ELSE
Add_result WHEN ( ( Branch = '1' ) AND ( Zero = '1' ) )
ELSE PC_plus_4( 9 DOWNTO 2 );
-- Store PC in register and load next PC on clock edge
PROCESS
BEGIN
WAIT UNTIL ( clock'EVENT ) AND ( clock = '1' );
IF reset = '1' THEN
PC <= "0000000000" ;
ELSE
PC( 9 DOWNTO 2 ) <= Next_PC;
END IF;
END PROCESS;
END behavior;
解决方案
您正在将 ram 的地址端口连接到一个名为 mem_addr 的信号 - 只有该信号不存在,因为您没有声明它。
在其他信号旁边你需要这样的东西:
signal Mem_Addr : std_logic_vector(7 downto 0);
推荐阅读
- code-climate - codeclimate 验证配置错误
- mysql - 这个 MySQL 语法有什么问题?
- usb - STM32 F407 Discovery 操纵杆 Thrustmaster T-Flight Hotas X
- sql-server - SELECT 每秒 IIS 方法调用的平均计数
- wordpress - 显示包含新帖子的类别列表
- node.js - 如何在服务器上为多个 nodejs 应用程序设置 nginx(使用带有命名空间的 socket.io)
- asp.net - 使用正则表达式获取 html 单选按钮值
- azure-devops - 在 VSTS 中通过 CD 部署时,.NET Core Webjob 不发布
- css - 找不到 Typo3 文件
- css - 如何在引导程序中垂直切换侧边栏上的面板标题