2 つの信号のエッジでトリガーされるフリップフロップ
質問
2 つの異なる信号のエッジに反応するフリップフロップが必要です。このようなもの:
if(rising_edge(sig1)) then
bit <= '0';
elsif(rising_edge(sig2)) then
bit <= '1';
end if;
そのようなフリップフロップは存在しますか、それとも使用できる他のテクニックはありますか?これを Xilinx Virtex-5 FPGA で合成できるようにする必要があります。ありがとう
解決
この場合、私が通常行うことは、両方の制御信号の遅延バージョンを保持し、各信号の立ち上がりエッジで 1 クロック幅のパルスを生成することです。次に、これらのパルスを使用して小さな FSM を駆動し、「ビット」信号を生成します。以下に VHDL の一部を示します。
-- -*-vhdl-*-
-- Finding edges of control signals and using the
-- edges to control the state of an output variable
--
library ieee;
use ieee.std_logic_1164.all;
entity stackoverflow_edges is
port ( clk : in std_ulogic;
rst : in std_ulogic;
sig1 : in std_ulogic;
sig2 : in std_ulogic;
bito : out std_ulogic );
end entity stackoverflow_edges;
architecture rtl of stackoverflow_edges is
signal sig1_d1 , sig2_d1 : std_ulogic;
signal sig1_rise, sig2_rise : std_ulogic;
begin
-- Flops to store a delayed version of the control signals
-- If the contorl signals are not synchronous with clk,
-- consider using a bank of 2 delays and using those outputs
-- to generate the edge flags
delay_regs: process ( clk ) is
begin
if rising_edge(clk) then
if rst = '1' then
sig1_d1 <= '0';
sig2_d1 <= '0';
else
sig1_d1 <= sig1;
sig2_d1 <= sig2;
end if;
end if;
end process delay_regs;
-- Edge flags
edge_flags: process (sig1, sig1_d1, sig2, sig2_d1) is
begin
sig1_rise <= sig1 and not sig1_d1;
sig2_rise <= sig2 and not sig2_d1;
end process edge_flags;
-- Output control bit
output_ctrl: process (clk) is
begin
if rst = '1' then
bito <= '0';
elsif sig1_rise = '1' then
bito <= '1';
elsif sig2_rise = '1' then
bito <= '0';
end if;
end process output_ctrl;
end rtl;
私は Verilog の方がずっと快適なので、この VHDL を再確認してください (コメントは歓迎です)。
波形 http://img33.imageshack.us/img33/893/stackoverflowvhdlq.png
このコードは、クロックがすべての制御信号パルスを捕捉できるほど高速であることを前提としています。制御信号がクロックと同期していない場合は、 さらに遠く 遅延制御信号の遅延バージョン (例: sig_d2
) 次に、からフラグを作成します sig_d1
そして sig_d2
.
所属していません StackOverflow