【问题标题】:Why does this attempt of creating a synchronous reset in VHDL "not hold its value under NOT(clock-edge) condition"为什么这种在 VHDL 中创建同步复位的尝试“在 NOT(时钟沿)条件下不能保持其值”
【发布时间】:2020-04-05 14:15:18
【问题描述】:

美好的一天, 我写了以下实体:

library ieee; 
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all; 


entity ADCinterface is    
generic (
    adc_id : std_logic_vector(1 downto 0):="00";            -- Holds the ID of the ADC its assigned to; for data reference
    word_size : natural := 32;                              -- Size of the transmission word in bit (overeall)
    crc_length : natural :=8                                -- Size/Length of the crc
);
port(   
    --internal Ports
    clkin:      in   std_logic;                             -- Module main Clock
    n_reset:    in   std_logic;                             -- Module reset
    adc_clkin:  in   std_logic;                             -- ADC sample clock input
    spi_clkin:  in   std_logic;                             -- SPI master clock input
    ack_buffer: in   std_logic;                             -- Signals that the buffer has been copied and can be overwritten
    paket_ID:   out  std_logic_vector(5 downto 0);          -- write the paket ID, a consecutive number 
    spi_data:   out  std_logic_vector(word_size-1 downto 0);-- Holds the data received from the adc
    data_buffer:out  std_logic_vector(word_size-1 downto 0);-- holds the data for the paket manager
    word_valid: out  std_logic;                             -- Signals data available to the internal paket manager

    --External ports 
    data_in:    in   std_logic;                             -- SPI data input
    ndrdy:      in   std_logic;                             -- Frame Sync pin (alias nDRDY) input from the ADC
    data_out:   out  std_logic;                             -- SPI data output
    start_adc:  out  std_logic;                             -- Enables the ADC
    adc_clk:    out  std_logic;                             -- ADC sampling clk out
    spi_clkout: out  std_logic                              -- SPI master clock out     
); 
end ADCinterface;

architecture ADCinterface_arch of ADCinterface is

    signal receive_word         : bit := '0';       --enables the receive process
    signal adc_data_ready       : std_logic := '0';     --holds the captured falling edge on ndrdy

begin
    adc_data_ready <= ndrdy;

    ADCinterface : process (clkin)

    begin

    if (rising_edge(clkin) and n_reset='0') then
        receive_word        <= '0';             --stop any active transmission

    elsif (rising_edge(clkin) and adc_data_ready='1') then
        receive_word <= '1';    --start / enable the data transmission
    end if;

    end process ADCinterface;
end ADCinterface_arch; 

无法合成错误:

错误 - 第 (65) 行: 声明是不可综合的,因为它不保持其价值 NOT(时钟沿)条件。 VHDL-1242

第 65 行对应于最后一个“end if;”声明。

当我现在改变时

if (rising_edge(clkin) and n_reset='0') then

if (n_reset='0') then

它没有错误地完成合成。我使用 Lattice Diamond V 3.11.2.446 和 LSE 进行合成。

我看不出这种变化如何改变你,有人可以帮我理解这里发生了什么吗?在这两种情况下,我希望生成的逻辑能够在非时钟边缘条件下保持其值......

提前致谢

【问题讨论】:

  • 将复位置于同步复位的时钟条件内。

标签: vhdl


【解决方案1】:

问题是你用了两次rising_edge,合成工具不知道怎么办,因为不能合成

if (rising_edge(clkin) and n_reset='0') then
    receive_word        <= '0';             --stop any active transmission

elsif (rising_edge(clkin) and adc_data_ready='1') then
    receive_word <= '1';    --start / enable the data transmission
end if;

尝试改变:

if (rising_edge(clkin))
    if (n_reset='0') then
        receive_word        <= '0';             --stop any active transmission
    elsif (adc_data_ready='1') then
        receive_word <= '1';    --start / enable the data transmission
    end if;
end if;

【讨论】:

    【解决方案2】:

    综合工具会寻找特定的代码模式来找出要推断出什么样的逻辑。因此,即使两者之间没有明显(逻辑)差异

    if rising_edge(clk) and n_reset = '0' then
    

    if rising_edge(clk) then
        if n_reset = '0' then
    

    您的综合工具可能只能识别后者。 您的手册中应该有一个部分(可能名为“推荐的 HDL 编码风格”或类似的部分)解释了推断所需实现所需的 VHDL 语法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-09
      相关资源
      最近更新 更多