플립 플롭이 두 신호의 가장자리에서 트리거되었습니다
문제
두 개의 다른 신호의 가장자리에 반응하는 플립 플롭이 필요합니다. 이 같은:
if(rising_edge(sig1)) then
bit <= '0';
elsif(rising_edge(sig2)) then
bit <= '1';
end if;
그러한 플립 플롭이 존재합니까, 아니면 내가 사용할 수있는 다른 기술이 있습니까? Xilinx Virtex-5 FPGA에서 합성 할 수 있어야합니다. 감사
해결책
이 경우 일반적으로 내가하는 일은 제어 신호의 지연 버전을 유지하고 각 신호의 상승 가장자리에서 펄스 한 시계를 생성하는 것입니다. 그런 다음이 펄스를 사용하여 작은 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