EmbDev.net

Forum: FPGA, VHDL & Verilog Ring Oscilator in VHDL


von RO (Guest)


Rate this post
useful
not useful
Hi,
I am trying to implement a Ring Oscilator on FPGA. First, I want to 
simulate it to "see" a working code, then I will flash it on an FPGA 
board, therefore I don't want to use "wait for.." statements in code. 
The purpose is to make a physically unclonable function.
I am receiving simulation error during simulation:

ERROR: at 100 ns(10000): Iteration limit 10000 is reached. Possible zero 
delay oscillation detected where simulation can not advance in time 
because signals can not resolve to a stable value in File "....vhd" Line 
45. Please correct this code in order to advance past the current 
simulation time.

Can anoybody help me?
Maybe, is it because of optimization? How can I avoid optimization?

Thanks.
ISE WebPACK 14.7
Win 7 32-bit

source code:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
4
-- Uncomment the following library declaration if using
5
-- arithmetic functions with Signed or Unsigned values
6
--use IEEE.NUMERIC_STD.ALL;
7
8
-- Uncomment the following library declaration if instantiating
9
-- any Xilinx primitives in this code.
10
--library UNISIM;
11
--use UNISIM.VComponents.all;
12
13
entity ro_puf is
14
    Port ( clk_i : in  STD_LOGIC;
15
           rst_i : in  STD_LOGIC;
16
        clk_o : buffer  STD_LOGIC);
17
end ro_puf;
18
19
architecture Behavioral of ro_puf is
20
  signal chain :std_logic_vector(30 downto 0);
21
  attribute syn_keep: boolean;
22
  attribute syn_keep of chain: signal is true;
23
begin
24
  gen_chain:
25
  for i in 1 to 30 generate
26
    chain(i) <= not chain(i-1);
27
  end generate;
28
  chain(0) <= not chain(30) or not rst_i;
29
30
t_FF: process(rst_i, chain(0))
31
  begin
32
    if rst_i = '0' then
33
      clk_o <= '0';
34
    elsif rising_edge(chain(0)) then
35
      clk_o <= not clk_o;
36
    end if;
37
  end process t_FF;
38
39
end Behavioral;

Test bench:
1
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
 
4
-- Uncomment the following library declaration if using
5
-- arithmetic functions with Signed or Unsigned values
6
--USE ieee.numeric_std.ALL;
7
 
8
ENTITY ro_tb IS
9
END ro_tb;
10
 
11
ARCHITECTURE behavior OF ro_tb IS 
12
 
13
    -- Component Declaration for the Unit Under Test (UUT)
14
 
15
    COMPONENT ro_puf
16
    PORT(
17
         clk_i : IN  std_logic;
18
         rst_i : IN  std_logic;
19
         clk_o : BUFFER  std_logic
20
        );
21
    END COMPONENT;
22
    
23
24
   --Inputs
25
   signal clk_i : std_logic := '0';
26
   signal rst_i : std_logic := '0';
27
28
   --Outputs
29
   signal clk_o : std_logic;
30
31
   -- Clock period definitions
32
   constant clk_i_period : time := 10 ns;
33
 --  constant clk_o_period : time := 10 ns;
34
 
35
BEGIN
36
 
37
  -- Instantiate the Unit Under Test (UUT)
38
   uut: ro_puf PORT MAP (
39
          clk_i => clk_i,
40
          rst_i => rst_i,
41
          clk_o => clk_o
42
        );
43
44
   -- Clock process definitions
45
   clk_i_process :process
46
   begin
47
    clk_i <= '0';
48
    wait for clk_i_period/2;
49
    clk_i <= '1';
50
    wait for clk_i_period/2;
51
   end process;
52
 
53
--   clk_o_process :process
54
--   begin
55
--    clk_o <= '0';
56
--    wait for clk_o_period/2;
57
--    clk_o <= '1';
58
--    wait for clk_o_period/2;
59
--   end process;
60
-- 
61
62
   -- Stimulus process
63
   stim_proc: process
64
   begin    
65
      -- hold reset state for 100 ns.
66
      wait for 100 ns;  
67
    rst_i <= '1';
68
    wait for 50 ns;
69
    rst_i <= '0';
70
      wait for clk_i_period*100;
71
72
      -- insert stimulus here 
73
74
      wait;
75
   end process;
76
77
END;

von Lattice User (Guest)


Rate this post
useful
not useful
RO wrote:

> Maybe, is it because of optimization?

This is not the cause.

A ringoscillator is based on non zero delay of your inverters. The 
functional simulation however doesn't know about the delay, and 
therefore it gets caught in an infinite loop.

You need to run a post P&R simulation for to see it working.


> The purpose is to make a physically unclonable function.

I doubt you will achieve that, as the variation accross temperature and 
power supply are probably larger than the differences between individual 
FPGAs.

The jitter of such a ring oscillator is also often used as an TRNG.

von J. S. (engineer)


Rate this post
useful
not useful
You will need to implement a signal stucture, where an inverter acts as 
a delay and loop it back to the input. In order to make this work, an 
inverter chain will be required and it will have to be implemented in 
low level language in order to prevent the tool from removing logic.

You should only make use of waits in order to simulate physical delay 
with some 20...30ps between the inverters (LUTs) to get an impression of 
the function.

No clocking will be needed. Instead intelligent buffering is required to 
shape a useable clock from out of an oscillating ring:

http://www.96khz.org/oldpages/digitalnoisegenerator.htm

von J. S. (engineer)


Rate this post
useful
not useful
A, I just have seen, there was somebody posting the same time, ok.

Lattice User wrote:
> The jitter of such a ring oscillator is also often used as an TRNG.
Whereby it has to be mentioned, that the jitter is pretty low and 
moreovere these circuits appear to synchronize their behaviour on 
existent clocks in an FPGA because of power switching. Therefore I am 
continuosly changing the frequency in my solution to avoid the issue.

: Edited by User
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
RO wrote:
> Can anoybody help me?
> Maybe, is it because of optimization? How can I avoid optimization?
No its only because your code does not implement any delay which is 
necessary for a ring oscillator. Therefore the simulator calculates 
results but never is able to increase the time step. Try this:
1
  gen_chain:
2
  for i in 1 to 30 generate
3
    chain(i) <= not chain(i-1) after 200 ps;
4
  end generate;
5
  chain(0) <= not chain(30) or not rst_i  after 200 ps;

Have a look at this (try with google Translator, its German):
http://www.lothar-miller.de/s9y/archives/90-Ringoszillator.html
http://www.lothar-miller.de/s9y/archives/35-Ringoszillator-im-S3.html

: Edited by Moderator
von RO (Guest)


Rate this post
useful
not useful
Ok, thanks for  the answers.
I will try them.

von Dogbert (Guest)


Rate this post
useful
not useful
Lattice User wrote:
> I doubt you will achieve that, as the variation accross temperature and
> power supply are probably larger than the differences between individual
> FPGAs.

http://www.ee.usyd.edu.au/people/philip.leong/UserFiles/File/papers/id_tvlsi12.pdf

von FPGA-Freak (Guest)


Rate this post
useful
not useful
Chip Identification by analyzing ring oscillators? Not very secure, or?

von Duke Scarring (Guest)


Rate this post
useful
not useful
PUFs[1] on FPGA are just for academic intrest...

[1] https://en.wikipedia.org/wiki/Physical_unclonable_function

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.