Altera_Forum
Honored Contributor
13 years agoring oscillator as a clock
Hi,
I am having a problem using 2 ring oscillators as 2 different clocks to 2 8-bit counters. When I use them separately they are working. But when I combine the two circuits in one design the output of the two counters is (X). Please check the code and see the pic for more details.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use ieee.std_logic_arith.all ;
use ieee.std_logic_unsigned.all ;
entity ring_slow_fast is
port(counter1, counter2: out std_logic_vector(7 downto 0);
reset_n: in std_logic; -- active-low asynchronous reset
clk_fast, clk_slow: out std_logic -- synthesized clock
);
end entity;
architecture beh of ring_slow_fast is
signal node2: std_logic_vector(1 to 3); -- Internal nodes.
signal node1: std_logic_vector(1 to 5);
signal cnt1 :std_logic_vector(7 downto 0);
signal cnt2 :std_logic_vector(7 downto 0);
signal clk_slow_sig : std_logic;
signal clk_fast_sig : std_logic;
attribute keep1: boolean;
attribute keep2: boolean;
attribute keep1 of node1: signal is true;
attribute keep2 of node2: signal is true;
begin
node1(1) <= node1(5) nand reset_n;
node1(2) <= not node1(1);
node1(3) <= not node1(2);
node1(4) <= not node1(3);
node1(5) <= not node1(4);
clk_slow_sig <= not node1(1);
clk_slow<=clk_slow_sig;
counter1_process :process(clk_slow_sig)
begin
if(clk_slow_sig'event and clk_slow_sig='1')then
cnt1<=cnt1+1;
end if;
counter1<=cnt1;
end process;
node2(1) <= node2(3) nand reset_n;
node2(2) <= not node2(1);
node2(3) <= not node2(2);
clk_fast_sig <= not node2(1);
clk_fast<=clk_fast_sig;
counter2_process :process(clk_fast_sig)
begin
if(clk_fast_sig'event and clk_fast_sig='1')then
cnt2<=cnt2+1;
end if;
counter2<=cnt2;
end process;
end architecture;
https://www.alteraforum.com/forum/attachment.php?attachmentid=6795