VHDL——使逻辑可综合

VHDL - making the logic synthesizable

我正在设计一个相对简单的内存仲裁器,有两种状态。

ModelSim 中的仿真运行良好,证明我的仲裁器按要求运行。但是我被告知我编写的代码不可综合。我在下面包含了相关过程的代码。

启用信号根据请求变高,将启用信号设置为低表示已为端口提供服务。要求是如果有两个同时请求,端口2应该连接。然而,如果端口 1 由于先前的请求已经连接,端口 2 应该等待直到端口 1 被服务。

我的问题是:

  1. 我编写的代码有什么问题(以及为什么)?
  2. 要使此代码可综合,您的方法是什么(不寻求最终解决方案,但希望得到有用的提示)

由于格式化代码部分的问题 post 我也将代码作为图像包含在内。

transition: process (clk)
begin
        if rising_edge(clk) then

           if reset = '1' then    
              state <=  port1;
           else
               if (state = port1) and (req_p2.enable='1') and 
                  (req_p1.enable='0' or rising_edge(req_p1.enable)) then
                  state <= port2;

               elsif(state = port2) and (req_p2.enable='0') then
                  state <= port1;
               end if;
           end if;

        end if;
end process;

这行你的代码不可合成:

rising_edge(req_p1.enable)

为了使其可综合,您需要用一些检测上升沿的实际逻辑替换 rising_edge 函数 - 同步上升沿检测器。类似的东西应该可以工作(我不知道你的要求):

sync_rising_edge: process (clk)
begin
  if rising_edge(clk) then
     if reset = '1' then    
        req_p1_enable_d <=  '0';
     else
        req_p1_enable_d <= req_p1.enable;
     end if;
  end if;
end process;

transition: process (clk)
begin
        if rising_edge(clk) then

           if reset = '1' then    
              state <=  port1;
           else
               if (state = port1) and (req_p2.enable='1') and 
                  (req_p1.enable='0' or (req_p1_enable_d = '0' and req_p1.enable = '1')) then
                  state <= port2;

               elsif(state = port2) and (req_p2.enable='0') then
                  state <= port1;
               end if;
           end if;

        end if;
end process;

如果在 时钟进程 中以常规方式使用 rising_edge 函数,则它是可综合的。参见 my answer here