EmbDev.net

Forum: FPGA, VHDL & Verilog changing outbit value


von david (Guest)


Rate this post
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
1
architecture arc_wat of wat is
2
    signal a:std_logic:='1';
3
begin
4
  
5
  outb<=a;
6
  
7
  
8
  process(clk)
9
  begin
10
    a<=not(a);
11
  end process;
12
13
  
14
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
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
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?

von david (Guest)


Attached files:

Rate this post
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

von david (Guest)


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

von david (Guest)


Rate this post
useful
not useful
1
library ieee;
2
use ieee.std_logic_1164.all;
3
4
entity wat is
5
  port(
6
      clk      :  in std_logic;
7
      outb    :  out std_logic
8
    );
9
end wat;
10
11
architecture arc_wat of wat is
12
    signal a:std_logic:='1';
13
begin
14
15
  outb<=a;
16
17
18
  process(clk)
19
  begin
20
    a<=not(a);
21
  end process;
22
23
24
end arc_wat;

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

Rate this post
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
von david (Guest)


Rate this post
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?

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

Rate this post
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
von david (Guest)


Rate this post
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)..

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.