VHDL LR移位器循环未更新
我这里有我的代码,但当我运行TB时,我遇到了一个问题,即当我离开左侧时,换档不起作用,并且时钟有另一个上升沿 这里的目标是制作一个左右并行移位寄存器。 寄存器必须在时钟的每个上升沿上更新。 当le高时,它加载信息,当left高时,它应该执行左循环移位。若右高,它应该做右循环移位 我做错了什么VHDL LR移位器循环未更新,vhdl,Vhdl,我这里有我的代码,但当我运行TB时,我遇到了一个问题,即当我离开左侧时,换档不起作用,并且时钟有另一个上升沿 这里的目标是制作一个左右并行移位寄存器。 寄存器必须在时钟的每个上升沿上更新。 当le高时,它加载信息,当left高时,它应该执行左循环移位。若右高,它应该做右循环移位 我做错了什么 --------------------------------------------------------- -- Description: -- An n-bit register (para
---------------------------------------------------------
-- Description:
-- An n-bit register (parallel in and out) with left and right shift
-- functionality (circular).
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity lr_shift_par_load is
generic(
C_REG_WIDTH : natural := 8
);
port(
reset : in STD_LOGIC;
clk : in STD_LOGIC;
left : in STD_LOGIC;
right : in STD_LOGIC;
le : in STD_LOGIC;
par_in : in STD_LOGIC_VECTOR(C_REG_WIDTH-1 downto 0);
par_out : out STD_LOGIC_VECTOR(C_REG_WIDTH-1 downto 0)
);
end lr_shift_par_load;
architecture Behavioral of lr_shift_par_load is
signal reg_i : std_logic_vector(C_REG_WIDTH-1 downto 0) := (others=>'0');
begin
-- TODO: Write a process that implements the correct behaviour for reg_i.
-- This should be a good refresher of your knowledge of last year.
process(clk,reset)
begin
if(reset = '1')then
reg_i <= (others=>'0');
end if;
if(rising_edge(clk)) then
if(le ='1') then
-- load
reg_i <= par_in;
elsif(le ='0' and left ='1')then
-- shift left
reg_i <= par_in(C_REG_WIDTH-2 downto 0) & par_in(C_REG_WIDTH-1);
elsif(le ='0' and left ='0'and right ='1')then
-- shift right
reg_i <= par_in(0) & par_in(C_REG_WIDTH-1 downto 1);
elsif(le ='0' and left ='0'and right ='0')then
--hold
reg_i <= par_in;
end if;
end if;
end process;
par_out <= reg_i;
end Behavioral;
---------------------------------------------------------
--说明:
--具有左右移位的n位寄存器(并行输入和输出)
--功能(循环)。
--
----------------------------------------------------------------------------------
图书馆IEEE;
使用IEEE.STD_LOGIC_1164.ALL;
--如果使用,请取消注释以下库声明
--具有有符号或无符号值的算术函数
使用IEEE.NUMERIC_STD.ALL;
--如果正在实例化,请取消对以下库声明的注释
--此代码中的任何Xilinx叶细胞。
--UNISIM图书馆;
--使用UNISIM.VComponents.all;
实体lr\U shift\U par\U负荷为
一般的(
C_REG_宽度:自然:=8
);
港口(
复位:在标准逻辑中;
clk:标准逻辑中;
左:在标准逻辑中;
右:在标准逻辑中;
le:标准逻辑;
par_in:标准逻辑向量(C_REG_WIDTH-1向下至0);
par_out:out标准逻辑向量(C_REG_WIDTH-1向下至0)
);
末端lr\u移位\u部件负载;
lr\U shift\U par\U负载的架构行为是
信号寄存器i:std_逻辑寄存器向量(C_寄存器宽度-1到0):=(其他=>'0');
开始
--TODO:编写一个实现reg_i正确行为的流程。
--这应该是你去年知识的一次很好的复习。
过程(时钟、复位)
开始
如果(重置='1'),则
注册号i“0”);
如果结束;
如果(上升沿(clk)),则
如果(le='1'),则
--装载
reg_i移位时,使用输入向量“par_in”。您可能希望使用移位寄存器本身:“reg_i”
而且你的情况也很复杂
if(le ='1') then
-- load
reg_i <= par_in;
elsif(le ='0' ... << Why are you testing for this?
If "le" was not zero it would never get here
but get handled in the first 'if'.
(le='0'和left='0'
是超级功能。重置和时钟有两个ifs。如果没有,时钟应该是ELS,否则时钟优先于重置,并且可能无法合成(或者您得到sim/模拟错误匹配)如果是“le”如果不是零,它将永远不会出现在这里
这个术语在合成中是固有的优先级,这是Tricky关于合并两个if语句的评论(if reset='1'然后…elsif rising_edge(clk)然后…
)建议支持合成原语映射。如果语句条件求值具有固有优先级,而冗余条件表达式则按照Oldfart提倡的手动方式在逻辑上减少,这可以减少模拟和合成执行时间。条件不必括在括号中,它们在语法上在V中是不同的高密度脂蛋白。
(le ='0' and left ='0'and right ='1') then