如何从VHDL中的实体变量创建子信号/子变量?
我目前正在用VHDL实现一个MIPS处理器。系统组件(将ALU、寄存器文件、控制单元等粘在一起)具有以下实体描述:如何从VHDL中的实体变量创建子信号/子变量?,vhdl,Vhdl,我目前正在用VHDL实现一个MIPS处理器。系统组件(将ALU、寄存器文件、控制单元等粘在一起)具有以下实体描述: entity system is port ( reset : in std_logic; sys_clk : in std_logic; instruction : in std_logic_vector(15 downto 0); sy
entity system is
port (
reset : in std_logic;
sys_clk : in std_logic;
instruction : in std_logic_vector(15 downto 0);
sys_mem_dump : in std_logic := '0'
);
end system;
在这个系统的架构部分,我试图创建指令变量的“子变量”,对应于使用的操作码和寄存器
architecture Behavioral of system is
instruction_opcode : std_logic_vector(3 downto 0) := instruction(15 downto 12);
instruction_rd : std_logic_vector(3 downto 0) := instruction(11 downto 8); -- destination register
instruction_rs : std_logic_vector(3 downto 0) := instruction(7 downto 4); -- source register
instruction_rt : std_logic_vector(3 downto 0) := instruction(3 downto 0); -- target register
-- a bunch of signals
begin
-- a bunch of port maps
end Behavioral
我尝试了
信号
、变量
、共享变量
和常量
,但当我将其中一个变量映射到寄存器文件时,这些都会导致寄存器文件的地址未初始化。我还尝试将这些变量放入系统实体端口,但这也不起作用。我也不想将系统实体端口中的指令
变量拆分为这四个变量。同意paebles的观点:您似乎缺乏基本的VHDL知识,应该在书中查找
您至少应该知道这种方法:
architecture Behavioral of system is
signal instruction_opcode : std_logic_vector(3 downto 0);
begin
instruction_opcode <= instruction(15 downto 12);
end architecture;
同意paebles的观点:您似乎缺乏基本的VHDL知识,应该在书中查找 您至少应该知道这种方法:
architecture Behavioral of system is
signal instruction_opcode : std_logic_vector(3 downto 0);
begin
instruction_opcode <= instruction(15 downto 12);
end architecture;
一条反映你评论的共同线索
@Paepbels难道用VHDL就不可能做到这一点吗?我看过synario手册和其他一些网站,没有一个数据对象类型与这个用例匹配 你使用的参考资料不充分 除了JH Bonarius的回答中描述的中间信号和对象别名外,还有一种方法使用声明为子类型的索引范围:
library ieee;
use ieee.std_logic_1164.all;
entity field is
port (
fourbitfield: in std_logic_vector (3 downto 0)
);
end entity;
architecture foo of field is
begin
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity system is
port (
reset: in std_logic;
sys_clk: in std_logic;
instruction: in std_logic_vector(15 downto 0);
sys_mem_dump: in std_logic := '0'
);
end entity system;
architecture foo of system is
subtype opcode is integer range 15 downto 12;
subtype rd is integer range 11 downto 8;
subtype rs is integer range 7 downto 4;
subtype rt is integer range 3 downto 0;
begin
U1:
entity work.field port map (instruction(opcode));
U2:
entity work.field port map (instruction(rd));
U3:
entity work.field port map (instruction(rs));
U4:
entity work.field port map (instruction(rt));
end architecture;
U1:
entity work.field port map (fourbitfield => instruction(15 downto 12));
这将分析、阐述和模拟(在证明没有边界错误的情况下,实际上什么都不做)
实体是一个独立的设计单元,自然允许抽象(在细化组件实例化期间,端口名称与端口映射中的实际信号相关联)。所有其他形式的名称或使用中间对象都是为了可读性而设计的抽象形式,并且由样式决定
在上述指令(操作码)
中,切片名称(IEEE Std 1076-2008 8.5切片名称)以整数子类型的形式提供离散范围。同样,您可以使用离散范围(例如15到12)的切片名称作为关联列表中的实际值,而无需声明子类型:
library ieee;
use ieee.std_logic_1164.all;
entity field is
port (
fourbitfield: in std_logic_vector (3 downto 0)
);
end entity;
architecture foo of field is
begin
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity system is
port (
reset: in std_logic;
sys_clk: in std_logic;
instruction: in std_logic_vector(15 downto 0);
sys_mem_dump: in std_logic := '0'
);
end entity system;
architecture foo of system is
subtype opcode is integer range 15 downto 12;
subtype rd is integer range 11 downto 8;
subtype rs is integer range 7 downto 4;
subtype rt is integer range 3 downto 0;
begin
U1:
entity work.field port map (instruction(opcode));
U2:
entity work.field port map (instruction(rd));
U3:
entity work.field port map (instruction(rs));
U4:
entity work.field port map (instruction(rt));
end architecture;
U1:
entity work.field port map (fourbitfield => instruction(15 downto 12));
在这里显示的正式端口和实际信号之间使用命名关联可以排除进一步抽象的需要。口述抽象会影响VHDL标准不要求的风格
您对子信号或变量的想法与VHDL中的片名一致,就像使用中间信号一样容易。别名只是命名实体(包括对象切片)的其他名称
如果您使用任何其他抽象方法,则可能会根据预期读者的复杂程度而定
如果有人彻底搜索Stackoverflow上的标记,您会找到这三种方法的示例。聪明的读者可以编辑你的问题,使之与VHDL语法一致,并将其作为副本提交。反映你的评论的公共线程
@Paepbels难道用VHDL就不可能做到这一点吗?我看过synario手册和其他一些网站,没有一个数据对象类型与这个用例匹配 你使用的参考资料不充分 除了JH Bonarius的回答中描述的中间信号和对象别名外,还有一种方法使用声明为子类型的索引范围:
library ieee;
use ieee.std_logic_1164.all;
entity field is
port (
fourbitfield: in std_logic_vector (3 downto 0)
);
end entity;
architecture foo of field is
begin
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity system is
port (
reset: in std_logic;
sys_clk: in std_logic;
instruction: in std_logic_vector(15 downto 0);
sys_mem_dump: in std_logic := '0'
);
end entity system;
architecture foo of system is
subtype opcode is integer range 15 downto 12;
subtype rd is integer range 11 downto 8;
subtype rs is integer range 7 downto 4;
subtype rt is integer range 3 downto 0;
begin
U1:
entity work.field port map (instruction(opcode));
U2:
entity work.field port map (instruction(rd));
U3:
entity work.field port map (instruction(rs));
U4:
entity work.field port map (instruction(rt));
end architecture;
U1:
entity work.field port map (fourbitfield => instruction(15 downto 12));
这将分析、阐述和模拟(在证明没有边界错误的情况下,实际上什么都不做)
实体是一个独立的设计单元,自然允许抽象(在细化组件实例化期间,端口名称与端口映射中的实际信号相关联)。所有其他形式的名称或使用中间对象都是为了可读性而设计的抽象形式,并且由样式决定
在上述指令(操作码)
中,切片名称(IEEE Std 1076-2008 8.5切片名称)以整数子类型的形式提供离散范围。同样,您可以使用离散范围(例如15到12)的切片名称作为关联列表中的实际值,而无需声明子类型:
library ieee;
use ieee.std_logic_1164.all;
entity field is
port (
fourbitfield: in std_logic_vector (3 downto 0)
);
end entity;
architecture foo of field is
begin
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity system is
port (
reset: in std_logic;
sys_clk: in std_logic;
instruction: in std_logic_vector(15 downto 0);
sys_mem_dump: in std_logic := '0'
);
end entity system;
architecture foo of system is
subtype opcode is integer range 15 downto 12;
subtype rd is integer range 11 downto 8;
subtype rs is integer range 7 downto 4;
subtype rt is integer range 3 downto 0;
begin
U1:
entity work.field port map (instruction(opcode));
U2:
entity work.field port map (instruction(rd));
U3:
entity work.field port map (instruction(rs));
U4:
entity work.field port map (instruction(rt));
end architecture;
U1:
entity work.field port map (fourbitfield => instruction(15 downto 12));
在这里显示的正式端口和实际信号之间使用命名关联可以排除进一步抽象的需要。口述抽象会影响VHDL标准不要求的风格
您对子信号或变量的想法与VHDL中的片名一致,就像使用中间信号一样容易。别名只是命名实体(包括对象切片)的其他名称
如果您使用任何其他抽象方法,则可能会根据预期读者的复杂程度而定
如果有人彻底搜索Stackoverflow上的标记,您会找到这三种方法的示例。聪明的读者可以编辑您的问题,使其与VHDL语法一致,并将其作为副本提交。请阅读您的教授的课程材料、书籍或任何其他有关VHDL的资源,因为缺少基础知识。@Paebbels用VHDL做这件事难道不可能吗?我看过synario手册和其他一些网站,没有一个数据对象类型与此用例匹配。请阅读您的教授的课程材料、书籍或任何其他有关VHDL的资源,因为缺少基础知识。@Paebbels用VHDL做这件事难道根本不可能吗?我看过synario手册和其他一些网站,没有一个数据对象类型与此用例匹配。我的书中几乎没有VHDL,我们希望上学期学习VHDL,这一点都没有。谢谢你回答这个问题。在我的书中几乎没有VHDL,我们被期望上学期学习VHDL,这一点都没有发生。谢谢你回答我的问题