1

您好我有这个简单的 VHDL 过程(从 MyHDL 代码生成):

DIGIPOT_CONTROLLER_CONNECTCLOCK: process (delayedClock) is
begin
    if to_boolean(clkEn) then
        if to_boolean(delayedClock) then
            scl_d <= '0';
        else
            scl_d <= 'Z';
        end if;
    else
        if to_boolean(sclIdleValue) then
            scl_d <= 'Z';
        else
            scl_d <= '0';
        end if;
    end if;
end process DIGIPOT_CONTROLLER_CONNECTCLOCK;

原始 MyHDL 代码:

@always(delayedClock)
def connectClock():
    if(clkEn):
        if(delayedClock):
            scl_d.next = False
        else:
            scl_d.next = None
    else:
        if(sclIdleValue):
            scl_d.next = None
        else:
            scl_d.next = False

在模拟中它工作得很好(ISIM 和 MyHDL 模拟器),但是当我尝试将它合成到 Spartan 6 中时,它会给出以下警告: clken 应该在进程的敏感列表中 sclidlevalue 应该在进程的敏感列表中

据我了解,它以某种方式推断出这个过程应该对 clkEn 和 sclIdleValue 信号敏感。但这当然不是我的本意。我希望它仅在延迟时钟更改其状态时更改输出,而不是在 clkEn 或 sclIdleValue 更改其各自状态时更改输出。

这是在 Spartan 6 架构中无法完成的事情吗?或者我应该以其他方式描述流程以实现我的预期行为?

4

1 回答 1

2

我终于弄清楚这是生成的 MyHDL 代码:

@always(delayedClock.posedge, reset.posedge)
def connectClock():
    if(reset == 1):
        delayedClock_int.next = True
    else:
        delayedClock_int.next = not delayedClock_int
        if(clkEn):
            if(delayedClock_int):
                scl_d.next = False
            else:
                scl_d.next = None
        else:
            if(sclIdleValue):
                scl_d.next = None
            else:
                scl_d.next = False

和(生成的)VHDL:

DIGIPOT_CONTROLLER_CONNECTCLOCK: process (delayedClock, reset) is
begin
    if (reset = '1') then
        delayedClock_int <= '1';
    elsif rising_edge(delayedClock) then
        delayedClock_int <= to_std_logic((not to_boolean(delayedClock_int)));
        if to_boolean(clkEn) then
            if to_boolean(delayedClock_int) then
                scl_d <= '0';
            else
                scl_d <= 'Z';
            end if;
        else
            if to_boolean(sclIdleValue) then
                scl_d <= 'Z';
            else
                scl_d <= '0';
            end if;
        end if;
    end if;
end process DIGIPOT_CONTROLLER_CONNECTCLOCK;

我必须将延迟时钟的频率设置为两倍(然后在我的 connectClock 过程中将其除以二),这样它会产生与原始过程相同的结果,并且可以在没有警告的情况下合成.. 逐步淘汰时钟的原因是 I2C 的 SCL波形如下图: 在此处输入图像描述

于 2013-04-04T15:25:56.333 回答