EmbDev.net

Forum: FPGA, VHDL & Verilog Ring Oscillator with Feedback


Author: Katta Satish (Company: SelfTaught) (kattasatish)
Posted on:

Rate this post
0 useful
not useful
Hello

I am implementing Ring Oscillator with feedback using
nand and also with not gate in VHDL,and not getting expected
output, need some inputs. Code as follows:-
Nand gate:
entity osc2 is
    Port ( a : inout  STD_LOGIC;
           b : inout  STD_LOGIC);
end osc2;

architecture Behavioral of osc2 is
signal x1, x2, x3, x4, x5 : STD_LOGIC;

component nandGate is
    Port ( inp1 : in  STD_LOGIC;
           inp2 : in  STD_LOGIC;
           out1 : out  STD_LOGIC);
end component;

begin
-- a <= b;

l0 : nandGate port map (inp1 => a, inp2 => a, out1 => x1);
l1 : nandGate port map (inp1 => x1, inp2 => x1, out1 => x2);
l2 : nandGate port map (inp1 => x2, inp2 => x2, out1 => b);

end Behavioral;


Not Gate:
entity osc is
    Port ( inp : inout  STD_LOGIC;
          oup : inout  STD_LOGIC);
end osc;

architecture Behavioral of osc is
signal x1, x2, x3, x4  : STD_LOGIC;

component andgate is
    Port ( inp1 : in  STD_LOGIC;
           inp2 : in  STD_LOGIC;
           out1 : out  STD_LOGIC);
end component;

component inverter1 is
    Port ( a : in  STD_LOGIC;
           b : out  STD_LOGIC);
end component;

begin
 -- x4 <= oup;

l0: andgate port map ( inp1 => inp, inp2 => oup, out1 => x1 );
l1: inverter1 port map ( a => x1, b => x2 );
l2: inverter1 port map ( a => x2, b => x3);
l3: inverter1 port map ( a => x3, b => oup );

end Behavioral;

i am not getting any input. How to give feedback (ie output to input) so
ring oscillator will be toggle. thanks

: Edited by Moderator
Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
1 useful
not useful
entity osc is
    Port ( inp : inout  STD_LOGIC;
          oup : inout  STD_LOGIC);
end osc;
If i were your teacher, you would get the worst grade just for this port 
definition! Why the heck is an input connected to an inout port? And why 
an output even so? Summary: laziness ist not good for good grades!

Katta Satish wrote:
> and not getting expected output
What do you get instead? And how do you see the erroneuos result?

> How to give feedback (ie output to input)
You use a signal to connect them together. And you do that already with 
the x1..x3 signals. Just finisch up the job by using the x4 signal:
entity osc is
    Port ( inp : in  STD_LOGIC;
           oup : out  STD_LOGIC);
end osc;

architecture Behavioral of osc is
signal x1, x2, x3, x4  : STD_LOGIC;

component andgate is
    Port ( inp1 : in  STD_LOGIC;
           inp2 : in  STD_LOGIC;
           out1 : out  STD_LOGIC);
end component;

component inverter1 is
    Port ( a : in  STD_LOGIC;
           b : out  STD_LOGIC);
end component;

begin
 oup <= x4;

l0: andgate port map ( inp1 => inp, inp2 => x4, out1 => x1 );
l1: inverter1 port map ( a => x1, b => x2 );
l2: inverter1 port map ( a => x2, b => x3 );
l3: inverter1 port map ( a => x3, b => x4 );

end Behavioral;

Why do you instantiate each lousy gate manually? An AND gate you can 
write down this way:
result <= a and b;
And a NOT gate is simply this:
result <= not a;
So finally your description looks like that:
entity osc is
    Port ( inp : in  STD_LOGIC;
           oup : out STD_LOGIC);
end osc;

architecture Behavioral of osc is
  signal x1, x2, x3, x4  : STD_LOGIC;
begin
  oup <= o;
  x1  <= inp and x4;
  x2  <= not x1;
  x3  <= not x2;
  x4  <= not x3;
end Behavioral;
Looks much more easy to read, doesn't it?

Katta Satish wrote:
> so ring oscillator will be toggle.
Have a look at my implementations, they run fairly well...
http://www.lothar-miller.de/s9y/categories/29-Ringoszillator
(Google translator will help out, its German)

One more hint: pls use the VHDL tags further on:
[vhdl]
vhdl code here
[/vhdl]

: Edited by Moderator
Author: Katta Satish (Company: SelfTaught) (kattasatish)
Posted on:

Rate this post
0 useful
not useful
Dear Miller,

Thanks for correcting me.
In my test bench, when i gave as below commenting clk signals , for 
single
value there is no toggle for 2 inverter gate.

 wait for 10 ns;
      reset <= '0';
 wait; -- i want without commenting this, else input is toggling the same
           so ouput toggles.


But a ring osc with any feedback should toggle with any input.
I am trying to check delay in Ring Osc when odd inverters.

: Edited by Moderator
Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Katta Satish wrote:
> In my test bench
What simulation do you perform? A behavioural simulation or a post P&R 
(timing) simulation?
You cannot simulate this design without timing information. A simple 
behavioural simulation will give rubbish or an error due to the 
combinational loop...

One more hint: don't insert a "testbench" nor a "bench" inside the tag
[vhdl testbench]
---
[/vhdl bench]
Simply use it as i posted it previously and as its stated a few lines 
above the edit box...

: Edited by Moderator
Author: Katta Satish (Company: SelfTaught) (kattasatish)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Sir,

Thanks.
I am using Xilinx ISE 12.4. and use ISE simulator.
Attached jpg file of PlaceRoute and Simulate Behavioral Model as per 
previous test bench input.

No Toggling of Ring Osc.
Is do file generates for ISE Simulator?
Refering to Youtube-Video "How to do a Timing Simulation using Modelsim and Xilinx ISE" the author uses 
do
file for model sim.

Regards

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
As I said: you cannot do a behavioral simulation on a combinatorial 
loop. Didn't you read what I wrote?

What's the code for the waveform above? And what about the other 
internal signals values?

Author: Katta Satish (Company: SelfTaught) (kattasatish)
Posted on:

Rate this post
0 useful
not useful
Sir,

Thanks for your time.
1) Q: you cannot do a behavioral simulation on a combinatorial
loop ?
A : As in my first post i wrote without loops.where i tried to
give feedback.

2)Q: What's the code for the waveform above? --
A: Synthesis code 
:http://www.lothar-miller.de/s9y/categories/29-Ringoszillator.

3) Q : what about the other internal signals values?
   A : Gave ring <= "011" in the testbench.
   Errors:"F:/FPGAP/ringosc/osc3_tb.vhd" Line 84: <ring> is not 
declared.
   ERROR:HDLCompiler:854 - "F:/FPGAP/ringosc/osc3_tb.vhd" Line 38: Unit
   <behavior> ignored due to previous errors.
   VHDL file F:/FPGAP/ringosc/osc3_tb.vhd ignored due to errors

3) Do i need to give values to signals also?
   Gave values to rst only. such as ring <= "011" in the testbench.
   NEVER read giving values to signal.

Regards

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Katta Satish wrote:
> 2)Q: What's the code for the waveform above? --
> A: Synthesis code
> :http://www.lothar-miller.de/s9y/categories/29-Ringoszillator.
Did you have a little look at the waveform pictures there and at yours? 
My ring oscillator is reset when reset='1'. So in your waveform the ring 
oscillator is always in reset!

> 3) Q : what about the other internal signals values?
>    A : Gave ring <= "011" in the testbench.
Of course thats not possible, because in the VHDL module named 
"testbench" the signal "ring" is unknown. But you can look inside the 
component under test with the simulator. Just open the corresponding 
node of the component tree and add the desired signal to the wavefrom.

Author: Henk (Guest)
Posted on:

Rate this post
0 useful
not useful
Could you give my une impression, in how it was possible to simultate 
these VHDL physique correctely?  Normallely it is not possible to 
simulate phyisquel signals and wirings. For other reason it was of 
interrest when you use these ciruits in gerneal? Where is the use of an 
oscillation without a realation?

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.