- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 VHDL(以及一般的数字电路)还很陌生,我正在尝试使用 BCD 样式 block 实现两位数的计数器。该电路的外部有一些按钮,按下这些按钮时,会将感兴趣的数字加一(很像闹钟)。这是一个异步操作,会在某种形式的编辑模式下发生(外部强制)。我编写的代码在没有“elsifrising_edge(digitUp1)then”和“elsifrising_edge(digitUp1)then” block 的情况下工作正常,但包含它们时会失败。我真的不知道为什么它不起作用或如何修复它。不断出现错误,例如“无法在此时钟边缘实现分配的寄存器”、“无法推断 count2[3] 的寄存器,因为其行为取决于多个不同时钟的边缘”和“无法推断寄存器” count2[3]”位于 MinuteCounter.vhd(21),因为它在时钟边沿之外不保存其值”。任何帮助将不胜感激。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
-- ToDo: ENFORCE ON ALL COUNTERS (externally) LOGIC TO PAUSE AT MAX/MIN
entity MinuteCounter is
port( clockIn, digitUp1, digitUp2, reset, counting, countUp : in std_logic;
clockOut : out std_logic;
BCD1, BCD2 : out std_logic_vector(3 downto 0));
end MinuteCounter;
architecture structure of MinuteCounter is
signal count1, count2 : std_logic_vector(3 downto 0);
signal carryOut : std_logic;
begin
process( clockIn, digitUp1, digitUp2, countUp, reset, counting)
begin
-- Asynchronous reset
if reset = '1' then
count1 <= "0000";
count2 <= "0000";
-- What to run when there's an active edge of the clock
elsif rising_edge(clockIn) then
-- Code to run when timer is running
if counting = '1' then
-- What to do when counting up
if countUp = '1' then
if ((count1 = "1001") and (count2 = "0101")) then
count1 <= "0000";
count2 <= "0000";
if carryOut = '0' then
carryOut <= '1';
else
carryOut <= '0';
end if;
elsif count1 = "1001" then
count1 <= "0000";
count2 <= count2 + 1;
else
count1 <= count1 + 1;
end if;
-- What to do when counting down (This logic is hard to understand)
else
if ((count1 = "0000") and (count2 = "0000")) then
count1 <= "1001";
count2 <= "0101";
if carryOut = '0' then
carryOut <= '1';
else
carryOut <= '0';
end if;
elsif count1 = "0000" then
count1 <= "1001";
count2 <= count2 - 1;
else
count1 <= count1 - 1;
end if;
end if;
-- When counting is disabled, but there is an active edge (do nothing)
else
count1 <= count1;
count2 <= count2;
end if;
-- Code to run when entering values (will not be run if counting = '1') << Externally enforced
elsif rising_edge(digitUp1) then
if count1 = "1001" then
count1 <= "0000";
count1 <= count1 + 1;
else
count1 <= count1 + 1;
end if;
-- Code to run when entering values (will not be run if counting = '1') << Externally enforced
elsif rising_edge(digitUp2) then
if count2 = "0101" then
count2 <= "0000";
count2 <= count2 + 1;
else
count2 <= count2 + 1;
end if;
-- What to do when there is no active edge or other events (nothing)
else
count1 <= count1;
count2 <= count2;
end if;
end process;
-- Assign outputs
BCD1 <= count1;
BCD2 <= count2;
clockOut <= carryOut;
end structure;
最佳答案
问题标题中解释了“为什么它不起作用”:进程 block 内的多个上升沿检测。
VHDL是为了描述硬件而设计的,没有响应多个时钟信号的基本电路元件。所以你不能那样描述电路。
那么如何解决这个问题呢?
您将电路转换为任何单个进程仅具有一个时钟信号的电路(如果您正确使用,还可以选择一个异步复位信号)。这可以使用真实的寄存器和触发器来实现。
两种方法是:
在这些之间做出正确的决定需要对设计有一定的整体了解。
这里听起来好像所有三个时钟信号实际上都是按钮按下,而不是一个快速时钟。因此,您不能保证按下另一个按钮时会有时钟沿。
因此,这是前进的多种方法之一:制作一个时钟信号(在进程之外),它将覆盖所有三个输入事件。
my_clock <= clockIn or digitUp1 or digitUp2;
现在您可以使用此时钟重写该过程:
process(my_clock, reset) is
begin
if reset = '1' then
-- reset actions
elsif rising_edge(my_clock) then
-- what caused this event?
if digitUp1 = '1' then -- bump digit 1
elsif digitup2 = '1' then -- bump digit 2
else -- count normally
endif;
end if;
end process;
注释:
关于process - VHDL : Multiple rising_edge detections inside a process block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19879960/
同时使用 VHDL-2019 IEEE 规范部分。 5.2.3.1.一般 "However, an implementation shall allow the declaration of any
我正在设计通用移位算术运算符。除了以下面介绍的方式使用 32 位多路复用器(解码器)之外,还有更好的方法来实现它吗? ENTITY isra IS PORT ( clk: in std_lo
描述:我正在尝试编写一个具有 4 个输入和 3 个输出的 LUT(查找表)的 vhdl 模块。我希望我的 3 位输出是一个二进制数,等于输入中 1 的个数。 我的真值表: ABCD|XYZ 0000|
我想使用 vhdl 制作幂函数,其中幂是浮点数,数字是整数(将始终为“2”)。 2^ 一些浮点数。 我使用 ieee 库和(fixed_float_types.all、fixed_pkg.all 和
是否有可能有一个通用的包? 这意味着当我实例化实体时,我提供了一些泛型,包将依赖于它。 我有一个块,我想多次使用,每次使用不同的包(即不同的参数) 我必须使用包,因为我想使用数组数组,而我只能使用包来
使用 VHDL,我希望有一些寄存器在每个寄存器中存储 16 位。 所以我发现 VHDL 有一个内置数组,我想用它在 iy 中的每个元素中存储 16 位,所以我想知道 VHDL 是否将此数组映射到实际寄
在 vhdl 中我可以定义我自己的枚举类型并创建这种类型的信号: type tp is (red,green,blue,yellow); signal sg: tp := red; 但现在我想要一个
我是 VHDL 的新手。 有一行,如下所示: constant TIME_DELTA : time := 100 ns; 这是什么字time在行吗?是不是和integer一样的数据类型?当我在互联网上
A <= 3 * B; 上面语句中的3是一个整数或自然数。如果它是自然数,如果我在那里使用负数怎么办? VHDL 是否将其识别为整数? 最佳答案 整数文字属于匿名预定义类型universal_inte
我为以下 vhdl 代码编写了测试平台: library ieee; USE ieee.std_logic_1164.all; ---USE ieee.std_logic_unsigned.all;
我有使用 Verilog/SystemVerilog 的经验,但我是 VHDL 新手,我试图弄清楚何时应该使用组件实例化或实体实例化。我所说的组件实例化是指在实例化实体组件之前声明实体组件的传统方式。
我一直无法理解如何在 VHDL 中取消引用指针。 我想到的是一个 C 代码,如: int a; int* ptr_a; a = 42; ptr_a=&a; *ptr_a=451;/
我为以下 vhdl 代码编写了测试平台: library ieee; USE ieee.std_logic_1164.all; ---USE ieee.std_logic_unsigned.all;
我想知道VHDL中是否定义了整数溢出。我在 2002 年规范中找不到任何内容。 作为示例(注意,这可能无法编译,它只是一个通用示例...): entity foo is port ( clk
如何组合/捆绑语句以供进一步使用和更好地处理?例如,像这样的一些赋值会在以后的例程调用中多次使用。 ADDR_PC '0'); constant OP_NOP: std
我正在编写一个 IP 核,根据用户选择的通用参数,并非所有 OUT/IN 端口都是必需的。是否可以有可选端口?我知道类似的事情应该是可能的,因为当我使用 Xilinx IP-Cores 时,根据参数,
我有一个数组: type offsets_type is array (4 downto 0) of std_logic_vector (4 downto 0); signal av : of
type有什么区别和 subtype在 VHDL 中,我应该在哪里使用它们? 我的理解是subtype只是主要类型之一的缩小版本,例如 integer :subtype small_integer i
我试图更好地使用 VHDL protected 类型,所以我将以下测试放在一起(当然只是为了说明 - 我的实际用例要复杂得多): type prot_type1 is protected proc
首先,我想声明这是我参加的模拟考试。我知道答案是:cout = 4ns,S = 7ns。只是在寻找一点解释。提前致谢。 对于下面所示的全加器的 VHDL 实现,输出 cout 和 S 何时稳定在它们的
我是一名优秀的程序员,十分优秀!