Re: When do I always put a "else NULL" statement in my VHDL code?

Discussion in 'VHDL' started by Jim Lewis, Sep 15, 2003.

  1. Jim Lewis

    Jim Lewis Guest

    Walala,
    The "else null ;" does nothing for synthesis or simulation.
    It does document that fact that you deliberately left this
    branch open.

    It does imply "else count <= count ;". Note, don't do this
    as it causes simulations to run slower (it schedules signal count
    to get the value from the expression count).

    For your loop code,
    p0: PROCESS(rst, clk)
    BEGIN
    if rst = '1' then
    for I in 0 to 7 loop
    for J in 0 to 7 loop
    XX(I)(J)<=0;
    end loop;
    end loop;
    elsif (clk'event and clk = '1') then
    ....

    You can replace the loop with:
    if rst = '1' then
    XX <= (others => (others => 0) ) ;


    Cheers,
    Jim Lewis
    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Jim Lewis
    Director of Training mailto:
    SynthWorks Design Inc. http://www.SynthWorks.com
    1-503-590-4787

    Expert VHDL Training for Hardware Design and Verification
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



    walala wrote:

    > Dear all,
    >
    > I feel confused by "else null" statement:
    >
    > if rst = '1' then
    > count <= 0;
    > elsif clk'event and clk = '1' then
    > if(INPUTEND = '1') then
    > ...
    > end if;
    > end if;
    >
    > I learned from books that I should exhaust all branches of "if"
    > statement, so I write in the following way:
    >
    > if rst = '1' then
    > count <= 0;
    > elsif clk'event and clk = '1' then
    > if (INPUTEND = '1') then
    > ...
    > else
    > null;
    > end if;
    > else
    > null;
    > end if;
    >
    >
    > But I also saw on the Internet sometimes people don't write code in my
    > cubersome way...
    >
    > Can anybody clarify a little for me? When I need to write this "else
    > null", and when I don't need it?
    >
    > Thanks a lot,
    >
    > -Walala
    Jim Lewis, Sep 15, 2003
    #1
    1. Advertising

  2. Jim Lewis

    walala Guest

    Dear Jim,

    Good code! Thank you very much for pointing out that me for me! I did not
    know I can do in such a simpler way before... Let me have a try any rate!

    -Walala
    >
    > You can replace the loop with:
    > if rst = '1' then
    > XX <= (others => (others => 0) ) ;
    >
    >
    > Cheers,
    > Jim Lewis
    > --
    walala, Sep 16, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelvin
    Replies:
    1
    Views:
    3,151
    Kelvin
    Sep 13, 2003
  2. walala
    Replies:
    2
    Views:
    665
    Ken Smith
    Oct 11, 2003
  3. Mike Treseler
    Replies:
    0
    Views:
    533
    Mike Treseler
    Sep 12, 2003
  4. Deryck
    Replies:
    4
    Views:
    513
    derek giroulle
    Jun 22, 2004
  5. afd
    Replies:
    1
    Views:
    8,301
    Colin Paul Gloster
    Mar 23, 2007
Loading...

Share This Page