I'm new to VHDL programming. I want to have frequency divider of an input clock signal by 2 consecutive integer x, y each of them last for 2 cycles. Actually I wrote it only for x. How can have clock cycle last for two periods? below is my code,thanks for your reply.

library ieee;
use ieee.std_logic_1164.all;

entity clk_divider is
            port(   clk_in:in std_logic;
                    clk_out:out std_logic);
end entity;

architecture beh of clk_divider is
                        variable tmp:std_logic:='0';
                        variable count1:integer:=0;
                        --variable count2:integer:=0;

                            if (rising_edge(clk_in)) then
                                    if(count1=x-1) then
                                        tmp:=not tmp;
                                    end if;
                            end if; 
                        end process;
end architecture;  

Generally, clocks should be modified only through use of PLL/DCM, thus not made through use of ordinary logic. The reason is that clock handling in and FPGA/ASIC requires separate routing and constraining, in for the tools to work correctly.

Instead of generating a derived clock, you can use the original clock, but then make an enable signal so for example a calculation does only update the result when the enable signal is asserted.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.