Xilinx Vivadoで論理合成時に「else clause after check for clock not supported」のエラーが出る

例えば下記のようなVHDLを論理合成しようとするとelse clause after check for clock not supportedのエラーが出る。

 process(clk, enable)
 begin
 if clk'event and clk = '1' then
   -- 処理1;
 elsif enable = '1' then
   -- 処理2;
 end if;
end process;

原因

クロックを評価した後にelse文やelsif文を使うことはできないためエラーが出た。

対策

クロックを評価するif文の中で処理するようにする。

process(clk, enable)
begin
if clk'event and clk = '1' then
  if enable = '1' then
    -- 処理2;
  else
    -- 処理1;
  end if;
end if;
end process;

もしくは、下記のような非同期処理に変更する。

process(clk, enable)
begin
if enable = '1' then
  -- 処理2;
elsif clk'event and clk = '1' then
  -- 処理1;
end if;
end process;