gpt4 book ai didi

simulation - VHDL定时器同步/异步加载速度问题

转载 作者:行者123 更新时间:2023-12-02 21:49:45 24 4
gpt4 key购买 nike

我正在尝试在 Spartan 6 上编写类似总线的 i2c 代码。我有很多状态,我使用以下计数器进行计时。

  -- Timer --
TimesUp <= true when TmrCnt = 0 else
false when TmrCnt /= 0 else
false;
tmrProc: process(ClkxC, SetTmr, TmrInit)
begin
if (rising_edge(ClkxC)) then
if (SetTmr = '1') then
TmrCnt <= TmrInit;
elsif (TmrCnt > 0) then
TmrCnt <= TmrCnt - 1;
end if;
end if;
end process;

问题是我的状态机在同一个时钟上计时,并且在某些短持续时间的状态下它只是爆炸,就好像计时器没有及时设置一样。

所以我尝试了这个:

  -- Timer --
TimesUp <= true when TmrCnt = 0 else
false when TmrCnt /= 0 else
false;
tmrProc: process(ClkxC, SetTmr, TmrInit)
begin
if (SetTmr = '1') then
TmrCnt <= TmrInit;
elsif (rising_edge(ClkxC)) then
if (TmrCnt > 0) then
TmrCnt <= TmrCnt - 1;
end if;
end if;
end process;

现在它模拟得很好,但是当我尝试实现时,我收到一条错误消息:

   This design contains one or more registers/latches that are directly
incompatible with the Spartan6 architecture. The two primary causes of this is
either a register or latch described with both an asynchronous set and
asynchronous reset, or a register or latch described with an asynchronous
set or reset which however has an initialization value of the opposite
polarity (i.e. asynchronous reset with an initialization value of 1).

我真的不知道如何在不破坏斯巴达 6 规则的情况下使计时器加载得足够快。

最佳答案

该警告已在 Xilinx WP309 Targeting and Retargeting Guide for Spartan-6 FPGAs 中明确描述。 [P9-11]。

To reduce cost of the overall architecture, slices in Spartan-6 FPGAs do not have a REV 
pin. As a result, flip-flops no longer implement both a set signal and a reset signal. In
addition, a register with a set or reset signal can only have an initialization value of
the same polarity. For example, a flip-flop with an asynchronous reset can only have an
initialization value of 0.

也就是说,使用 Xilinx Spartan-6 FPGA 时不推荐使用以下类型的寄存器/锁存器:

      ______|______  
| Set |
| |
---| D Q |--- -- 1. a register/latch with both ASYNCHRONOUS
| _ | set and reset signals
---|>Clk Q |o-- -- NOT RECOMMENDED
| |
| Reset |
|___________|
|



-- 2. a register/latch described with an ASYNCHRONOUS set/reset which
however has an initialization value of the opposite polarity

-- The default value of reg is 0 which is the left
-- bound value of the integer type definition.
signal reg: integer range 0 to 7; <-----
|
process (clk, reset) |___ opposite
begin | NOT RECOMMENDED
if (reset = '0') then |
reg <= 7; <-----
elsif ( rising_edge(clk) ) then
reg <= val;
end if;
end process;

Xilinx 推荐的解决方案:

 1. Remove either the set or reset from all registers and latches
if not needed for required functionality
2. Modify the code in order to produce a synchronous set and/or
reset (both is preferred)
3. Ensure all registers have the same initialization value as the
described asynchronous set or reset polarity
4. Use the -async_to_sync option to transform the asynchronous
set/reset to synchronous operation
(timing simulation highly recommended when using this option)

在您的设计中,您可以将 TmrCnt 初始化为 TmrInit 或向上计数 TmrCnt

关于simulation - VHDL定时器同步/异步加载速度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18881793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com