Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee;
- use ieee.std_logic_1164.ALL;
- use ieee.numeric_std.ALL;
- -- Jednostka licznika od 0 do target
- entity PositiveCounter is
- generic (
- target: positive := 1000000
- );
- port (
- clk_in: IN STD_LOGIC;
- enabled: IN STD_LOGIC;
- Q: OUT STD_LOGIC;
- reset: IN STD_LOGIC
- );
- end entity;
- -- Implementacja licznika
- architecture PositiveCounterImpl of PositiveCounter is
- begin
- process (clk_in)
- variable clkCounter : integer range 0 to target;
- begin
- if (rising_edge(clk_in)) then
- if (reset = '1') then
- clkCounter := 0;
- elsif (enabled = '1' and clkCounter < target) then
- clkCounter := clkCounter + 1;
- end if;
- Q <= '1' when (clkCounter = target) else '0';
- end if;
- end process;
- end architecture;
Add Comment
Please, Sign In to add comment