请教一段程序,看不懂功能,不长

library IEEE ;
use IEEE.STD_LOGIC_1164.ALL ;
use IEEE.STD_LOGIC_UNSIGNED.ALL ;
use IEEE.STD_LOGIC_ARITH.ALL ;
library UNISIM ;
use UNISIM.VCOMPONENTS.ALL ;

entity PULSE_GEN is
    generic (
        P_TYPE      : integer                       := 0
        ) ;
    port (
        XRST        : in    std_logic               ; -- Reset Input ( Asynchronous )
        CLK_I       : in    std_logic               ; -- Clock at input side
        CLK_O       : in    std_logic               ; -- Clock at output side
        PULSE_I     : in    std_logic               ; -- Pulse input
        PULSE_O     : out   std_logic                 -- Pulse output
        ) ;
end PULSE_GEN ;
architecture RTL of PULSE_GEN is
-- control signal
    signal  R_PULSE_I   : std_logic                     ;
    signal  R_PULSE_O   : std_logic_vector(2 downto 0)  ;
begin
    generatepulse: if ( P_TYPE = 0 ) generate
        process ( CLK_I, XRST ) begin
            if( XRST = '0' ) then
                R_PULSE_I       <=  '0' ;
            elsif ( CLK_I'Event and CLK_I = '1' ) then
                if ( PULSE_I = '1' ) then
                    R_PULSE_I   <= not R_PULSE_I ;
                end if ;
            end if ;
        end process ;
        -- Output pulse sync. and generate                  ( CLK_O domain )
        process ( CLK_O, XRST ) begin
            if(  XRST = '0' ) then
                R_PULSE_O   <= ( others => '0' ) ;
            elsif ( CLK_O'Event and CLK_O = '1' ) then
                R_PULSE_O   <= R_PULSE_O(1 downto 0) & R_PULSE_I ;
            end if ;
        end process ;
        PULSE_O <=  '1' when ( R_PULSE_O(2) /= R_PULSE_O(1) ) else '0' ;   -- 0 -> 1
    end generate ;
end RTL ;

看不懂PULSE_O
我也来说两句 查看全部回复

最新回复

  • sxf530006 (2008-7-11 23:21:47)

    帅哥,是分频器吧
  • fwang (2008-7-11 23:41:09)

    高频窄脉冲信号的跨时钟域转换和整形电路。
    设计还是很巧妙的,电路正常工作的要求是clk_o >> clk_i (周期).同时plus_in频率不能高于clk_o

    [ 本帖最后由 fwang 于 2008-7-11 23:44 编辑 ]
  • yachong001 (2008-7-17 16:04:39)

    QUOTE:

    原帖由 fwang 于 2008-7-11 23:41 发表
    高频窄脉冲信号的跨时钟域转换和整形电路。
    设计还是很巧妙的,电路正常工作的要求是clk_o >> clk_i (周期).同时plus_in频率不能高于clk_o
    能否详细的解说下?我都看傻了。就是这个功能的
  • yachong001 (2008-7-17 18:09:57)

    modelsim仿真结果:


    無題.JPG

  • tangxiangwei (2008-7-17 18:34:00)

    学习了,谢谢。
  • yachong001 (2008-7-18 09:11:40)

    我还是想不明白......
  • yachong001 (2008-7-21 17:46:16)

    还是想不明白......
  • fwang (2008-7-21 19:00:41)

    it is very easy. if you draw the timing diagram by hand, you will find the first process is to extend the plus to a long signal, and the second process is to latch the long signal. then the very short puls can transfer to a wide plus signal in the slow clock domain.
    I can not input chinese, if you still have questions, pls send me message.