اطلاعیه

Collapse
No announcement yet.

شمارش تعداد پالس در یک ثانیه

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    شمارش تعداد پالس در یک ثانیه

    سلام. من تو بخشی از برنامه ام، باید ببینم تعداد پالس های یک کلاک تو یک ثانیه چقدره. کسی میتونه کمکم کنه؟ پیشاپیش ممنون
    خودم برنامه ای که نوشتم اینجوریه که با استفاده از کلاک داخلی برد fpga که دارم و 20MHz ( 50 ns )هست شمارنده ای 20 میلیون بار میشمره (یعنی یک ثانیه) و در حین شمردن تا 20 میلیون شمارنده ی دیگه ای تعداد پالس های کلاک مد نظر رو بشماره و به محض اینکه شمارنده 1 ، 20 میلیون شمرد، تعداد شمارنده ی 2 در سیگنالی ریخته بشه. این برنامه تو شبیه سازی با isim نتیجه ی درست میده و روی برد جواب نمیده.
    زبان vhdl و برد spartan3 و نرم افزار ise .

    [code=vhdl]
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.STD_LOGIC_unSIGNED.ALL;
    use ieee.numeric_std.all;


    entity rez is
    port (
    CLK_20M : in STD_LOGIC;

    );
    end rez;

    architecture Behavioral of rez is

    signal a: std_logic_vector(25 downto 0);
    signal clk_312khz :STD_LOGIC;-- 3.2 us
    signal cnt_1: integer range 0 to 19999999 :=0 ;
    signal cnt_2: integer range 0 to 67108863 :=0 ;
    signal cnt_3: integer range 0 to 67108863 :=0 ;
    signal enable : STD_LOGIC;

    begin

    clk_divider2:process (CLK_20M)
    variable counter: std_logic_vector(8 downto 0) ; -- divider: 2^9
    begin
    if rising_edge(CLK_20M) then
    counter:=counter + 1;
    end if;
    clk_312khz <= counter(5);

    end process; --clk_divider1
    one:process(CLK_20M)
    begin

    if rising_edge(CLK_20M) then
    cnt_1 <= cnt_1 + 1 ;
    if (cnt_1 < 20000000) then
    enable <= '1';
    if (cnt_1 = 19999999) then
    enable <= '0';
    end if;
    end if;
    end if;

    end process;
    two:process(clk_312khz)
    begin
    if (enable = '1&#039 then
    if rising_edge(clk_312khz) then
    cnt_2 <= cnt_2 + 1;
    end if;
    end if;

    end process;

    three:process(enable)
    begin
    if (enable = '0&#039 then
    cnt_3 <= cnt_2;
    a <= std_logic_vector(to_signed(cnt_2,a'length));

    end if;
    end process;


    end Behavioral;

    [/code]
لطفا صبر کنید...
X