Ring oscillator timing simulation

OP (Company: U1) #3389295
Rate this post
useful
not useful
Hi, I am trying to simulate a ring oscillator in Modelsim using the 
delay (.sdo) file generated by Quartus to get the relationship between 
frequency and # of gates. For some reason whenever I simulate this I get 
the exact same frequency, 1.6 GHz, regardless if my oscillator has 1 
gate or 1000. My simulation is basically just:

assign B = ~A;
assign C = ~B;
assign A = ~C;

and then expanded in a generate loop for more gates.

An I doing something wrong with the sdo file? I first compile in 
Modelsim, then select Simulate, add the sdo file, then start.

Thanks
OP (Company: U1) #3389673
Rate this post
useful
not useful
I thought that the delay the simulator used (generated by Quartus) would 
be the same as if I manually added a delay assignment, only I don't know 
what delay to use in real time. So nothing should be analog in the 
simulation. All I really want to know is the delay across a single gate, 
which should accumulate for larger loops, but I'm not confident in my 
simulation due to the weird results.
OP (Company: U1) #3389731
Rate this post
useful
not useful
Of course all circuit behavior is analog behavior, calling it digital is 
an approximation. Given enough gates the output of the oscillator should 
be approximately digital. If I just attach a constant delay to each 
assignment then the oscillator works perfectly in simulation, only I 
have to guess what the gate delay is. I was hoping the synthesized delay 
file would have a more accurate delay.
Moderator (Company: Titel) #3389771
Rate this post
useful
not useful
Chris C1111 wrote:
> Hi, I am trying to simulate a ring oscillator in Modelsim using the
> delay (.sdo) file generated by Quartus to get the relationship between
> frequency and # of gates. For some reason whenever I simulate this I get
> the exact same frequency, 1.6 GHz, regardless if my oscillator has 1
> gate or 1000.
Beside the fact that the frequency will be much differtent in real life:
whats the initial value for all the gates? How do you assign it?
Moderator (Company: Titel) #3390352
Rate this post
useful
not useful
Chris C1111 wrote:
> For the example in my first post if I set A = 1, then B and C are
> automatically initialized to 0 and 1 since during initialization there
> is no combinational loop.
And after that all "even" signals will be 1 and all "odd" signals will 
be 0. And thenn, what will happen if they circle araound? Will there 
(for any single signal) be a difference between the short "10101" 
sequence and the long "10101010101010101010101010101010101010101" 
cycling around? No, in both cases each single signal will toggle at 
maximum speed...

So try it with passing through the signal and only toggle its polarity 
on one bit:
assign B = ~A;
assign C = B;
assign A = C;
But then you will have to tell the synthesizer that it has to "keep" all 
of the signals. In VHDL for Xilinx you could do it this way:
http://www.lothar-miller.de/s9y/categories/29-Ringoszillator
(try the google translator, its German)
Guest #3390881
Rate this post
useful
not useful
You don't need to specify the intermediate signals as output.
As Lothar told you already, you have to tell Quartus to don't optimize 
these signals.

Take a look at the attributes keep, noprune and preserve.

Can't remember right now which one did the trick.

I adopted Lothars code to run on a de0nano using Quartus II 12.0.
OP (Company: U1) #3390926
Rate this post
useful
not useful
Thanks for pointing that out! Somehow I completely missed Lothar's last 
post. What you said makes perfect sense, I can't believe I missed that. 
Why does wikipedia state the output frequency is 1/(2*N×inverter delay)?

http://en.wikipedia.org/wiki/Ring_oscillator
(the figure caption)

Edit: I don't think what you said is correct. Immediately after 
initialization, everything is stable except for the first inverter, so 
the last inverter won't toggle until every inverter before it has. At 
that point every inverter is stable again except for the first one.
Moderator (Company: Titel) #3391429
Rate this post
useful
not useful
Chris C1111 wrote:
> Edit: I don't think what you said is correct.
Hmmm...

You and wikipedia are right. I did a short test with symbolic delay:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3

4
entity RingO is
5
    Port ( reset : in  STD_LOGIC; 
6
           fout  : out STD_LOGIC);
7
end RingO;
8

9
architecture Behavioral of RingO is
10
  signal ring    : std_logic_vector(2 downto 0); -- ungerade Bitanzahl
11
--  signal ring    : std_logic_vector(20 downto 0); -- ungerade Bitanzahl
12
  attribute KEEP : string; 
13
  attribute KEEP of ring : signal is "true"; 
14
begin
15
  assert ring'length mod 2 = 1 report "Length of ring must be an odd number!" severity failure;
16

17
  process (ring,reset) begin
18
     for i in ring'range loop
19
       if i = ring'left then
20
         if reset='1' then
21
           ring(i) <= '1';
22
         else
23
           ring(i) <= not ring(0) after 1ns;
24
         end if;
25
       else
26
         ring(i)   <= not ring(i+1) after 1ns;
27
       end if;
28
     end loop;
29
  end process;
30

31
  fout <= ring(0);
32

33
end Behavioral;
I will check this on hardware later...  ;-)
Attached files:
#7117443
Rate this post
useful
not useful
Chris C. wrote:
> I get about 250MHz with 21 gates on
> hardware, I'm too scared to go much faster than that.

I used ring oscillators with up to 1.2GHz with a chain length which 
makes sure, that all inverters fully saturate before the signal is 
looped back to them. According to the switching time and routing, it is 
possible to tune the model's delays appropriately.

http://www.96khz.org/htm/noisegenerator2.htm

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now