EmbDev.net

Forum: FPGA, VHDL & Verilog changing outbit value


Author: david (Guest)
Posted on:

Rate this post
0 useful
not useful
hello,
I try to right a code that in every, say, clock change(not only a rise) 
it will change the out bit from 1 to 0 or from 0 to 1.

the architecture part is
architecture arc_wat of wat is
    signal a:std_logic:='1';
begin
  
  outb<=a;
  
  
  process(clk)
  begin
    a<=not(a);
  end process;

  
end arc_wat;

I tried to declare a in  the proccess and to move the outb<=a; to the 
process as well-still doesnt work-> in the simulation outb is 
undefined...

I tried to simplify a bigger problem, and yet i can't see why it is'nt 
working.

anyone see where is my error?

thank you!!!

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

Rate this post
0 useful
not useful
david wrote:
> I tried to declare a in  the proccess and to move the outb<=a; to the
> process as well-still doesnt work-> in the simulation outb is
> undefined...
So the problem is NOT in the posted code...

1. Usually a VHDL description begins with "library ieee;". Thats missing 
here.
2. What toolchain do you use?
3. What is your testbench?
4. What do you expect and what do you get instead?

> in the simulation outb is undefined...
What does clk look like? Is it toggling?

Author: david (Guest)
Posted on:
Attached files:
  • preview image for v.PNG
    v.PNG
    20 KB, 78 downloads

Rate this post
0 useful
not useful
the hole code is

library ieee;
use ieee.std_logic_1164.all;

entity wat is
  port(
      clk      :  in std_logic;
      outb    :  out std_logic
    );
end wat;

architecture arc_wat of wat is
    signal a:std_logic:='1';
begin

  outb<=a;


  process(clk)
  begin
    a<=not(a);
  end process;


end arc_wat;


the simulation is attached.

i expect to see outb shifting from 1<->0

Author: david (Guest)
Posted on:

Rate this post
0 useful
not useful
thank you for that fast replay!

Author: david (Guest)
Posted on:

Rate this post
0 useful
not useful
library ieee;
use ieee.std_logic_1164.all;

entity wat is
  port(
      clk      :  in std_logic;
      outb    :  out std_logic
    );
end wat;

architecture arc_wat of wat is
    signal a:std_logic:='1';
begin

  outb<=a;


  process(clk)
  begin
    a<=not(a);
  end process;


end arc_wat;

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

Rate this post
0 useful
not useful
For me its simulating (some kind of) "well" in the behavioural 
simualtion...

But you have a VERY big mistake in your code!
> process(clk)
>   begin
>     a<=not(a);
>   end process;
The sensitivity list is WRONG, because the process is NOT dependent on 
the clk. Its only dependent on any change of a.
You must get one thing very clear: the sensitivity list is ONLY for the 
simulator. It ist not used by the synthesizer, its simply ignored by 
the synthesizer!

And therefore the process MUST be this way:
> process(a)
>   begin
>     a<=not(a);
>   end process;
And then you can see: theres absolutely no clk involved in the 
description!


OK, lets go one step backwards...
david wrote:
> I try to right a code that in every, say, clock change(not only a rise)
> it will change the out bit from 1 to 0 or from 0 to 1.
Because VHDL is a hardware description language you must have a 
"picture" or a sketch or something in front of you (or in your mind) you 
can describe.
What piece of hardware can react on either clock edge? Is there a kind 
of "double clock flipflop" inside your FPGA/CPLD?
No? Then you cannot use a description of such a piece of hardware in 
your code.

So again one step back: what do you want to do?

: Edited by Moderator
Author: david (Guest)
Posted on:

Rate this post
0 useful
not useful
I pulled this code out as a test to some part of my project that does 
not function properly.

I just wanted to simulate this code properly to test another thing,(i 
could have added (if rising_edge(clk)) but it is not the real point for 
me.

the simulation you uploaded was recieved from running my code with no 
changes?

what at my computer/quartus2 options could have caused me to recieve the 
simulation i uploaded?

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

Rate this post
0 useful
not useful
david wrote:
> the simulation you uploaded was recieved from running my code with no
> changes?
Yes, indeed. The "test bench" is attached here. I used Xilinx ISE ISIM 
for simulation.

Keep in mind: I ran a pre synthesis behavioural simulation. Maybe a 
post synthesis timing simulation will get your result...

: Edited by Moderator
Author: david (Guest)
Posted on:

Rate this post
0 useful
not useful
thanks for the help! :)
you were right, the missing rising_edge caused the problem(no condition 
caused it to run non-stop)..

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.