Advertisement
mikepfrank

Ring Oscillator in VHDL

Apr 11th, 2011
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.57 KB | None | 0 0
  1.  
  2.     -- Resettable Ring Oscillator
  3.     -- by Michael Frank (FAMU/FSU), 4/11/2011
  4.     -- (released to public domain)
  5.  
  6.     -- NOTE: The precise clock frequency will vary depending on placement
  7.     -- and routing, manufacturing variation, temperature, etc., so cannot
  8.     -- be relied upon unless ALL of these factors are controlled.
  9.     -- I measured speeds of up to 666 MHz with this code on an Altera DE2
  10.     -- board (Cyclone II EP2C35F672C6N FPGA) without controlling placement.
  11.    
  12. library ieee;
  13.     use ieee.std_logic_1164.all;
  14.    
  15. entity ring_osc is
  16.     port (
  17.         reset_n: in std_logic;  -- active-low asynchronous reset
  18.         clk_out: out std_logic  -- synthesized clock
  19.     );
  20. end entity;
  21.  
  22. architecture structure of ring_osc is
  23.     signal node: std_logic_vector(1 to 3);      -- Internal nodes.
  24.  
  25.         -- The following is essential to prevent the circuit from
  26.         -- being simplified to a single NAND, which may not work,
  27.         -- since it can settle into a stable short-circuit state
  28.         -- with an output value between 0 and 1.  (Also, even if
  29.         -- it worked it would prob. be too fast to use the ring
  30.         -- osc. to drive any sequential logic).
  31.  
  32.     attribute keep: boolean;
  33.     attribute keep of node: signal is true;
  34. begin
  35.         -- Here is the ring oscillator itself.
  36.         -- Note that we have to specify the keep attribute for
  37.         -- all of these nodes to keep the NOTs from being optimized away.
  38.        
  39.     node(1) <= node(3) nand reset_n;
  40.     node(2) <= not node(1);
  41.     node(3) <= not node(2);
  42.    
  43.         -- We tap out of it with an inverter to keep the frequency
  44.         -- independent of the load.
  45.        
  46.     clk_out <= not node(1);
  47.    
  48. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement