assert statement

Discussion in 'VHDL' started by Ashani Patel, Jul 1, 2008.

  1. Ashani Patel

    Ashani Patel Guest

    can anyone tell me what's wrong with this assert statements.

    hereis my code:

    ----------------------------------------------------------------------------------
    -- Company:
    -- Engineer:
    --
    -- Create Date: 17:54:42 05/12/2008
    -- Design Name:
    -- Module Name: fifoashani - Behavioral
    -- Project Name:
    -- Target Devices:
    -- Tool versions:
    -- Description:
    --
    -- Dependencies:
    --
    -- Revision:
    -- Revision 0.01 - File Created
    -- Additional Comments:
    --
    ----------------------------------------------------------------------------------
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.STD_LOGIC_ARITH.ALL;
    use IEEE.STD_LOGIC_UNSIGNED.ALL;

    ---- Uncomment the following library declaration if instantiating
    ---- any Xilinx primitives in this code.
    --library UNISIM;
    --use UNISIM.VComponents.all;

    entity fifo is
    port( wren : in std_logic;
    rden: in std_logic;
    reset : in std_logic;
    clk : in std_logic;
    data : in std_logic_vector(3 downto 0);
    stackfull: out std_logic;
    stackempty: out std_logic;
    dop: out std_logic_vector(3 downto 0));
    end fifo;

    architecture Behavioral of fifo is

    type stack is array(0 to 7) of std_logic_vector(3 downto 0);
    signal int_reg : std_logic_vector(3 downto 0);
    signal int_stack : stack;
    signal countup: integer :=0;
    signal countdn: integer :=0;
    signal stackempty_var: std_logic :='0';
    signal stackfull_var : std_logic :='0';



    begin

    process(clk)


    begin


    if(clk'event and clk='1') then

    if (reset = '1') then
    stackfull_var <= '0';
    stackempty_var <= '0';
    countup <= 0;
    countdn <= 0;
    int_reg <= "0000";


    elsif(wren = '1') then
    assert not (countup>7)
    report " stackfull"
    severity NOTE ;

    -- if(countup>7) then
    -- stackfull_var <='1';

    int_stack(countup)<= data;
    countup <= countup + 1;


    elsif(rden = '1') then
    assert (countdn >7)
    report "stack empty"
    severity NOTE ;
    -- if(countdn > 7) then
    -- stackempty_var <= '1';

    int_reg <= int_stack(countdn);
    countdn <= countdn + 1;
    end if;

    end if;

    end process;

    dop <= int_reg;
    stackfull <= stackfull_var;
    stackempty <= stackempty_var;

    end Behavioral;
    Ashani Patel, Jul 1, 2008
    #1
    1. Advertising

  2. Ashani Patel

    Hauke D Guest

    Hi,


    On Jul 1, 9:39 am, Ashani Patel <> wrote:
    > can anyone tell me what's wrong with this assert statements.
    >
    > hereis my code:
    > <snip>


    It would be much more helpful to know what problem you're having. Are
    you getting error messages, and if so, what are they? Is your code not
    behaving as expected, and if so, what is the expected behavior and
    what behavior are you getting?

    Regards,
    -- Hauke D
    Hauke D, Jul 1, 2008
    #2
    1. Advertising

  3. Ashani Patel

    frosty Guest

    If I'm not completely wrong you are using the assert statement in a
    false manner. A assert-statement checks the condition and if the
    condition is not fullfilled it sets the report.
    Your conditions for full(empty) are not met until countup(countdn)
    reaches the value 7. So, for the first 7 values the note is printed.

    regards,
    Matthias
    frosty, Jul 1, 2008
    #3
  4. Ashani Patel

    Tricky Guest

    On 1 Jul, 11:19, frosty <> wrote:
    > If I'm not completely wrong you are using the assert statement in a
    > false manner. A assert-statement checks the condition and if the
    > condition is not fullfilled it sets the report.
    > Your conditions for full(empty) are not met until countup(countdn)
    > reaches the value 7. So, for the first 7 values the note is printed.
    >
    > regards,
    >  Matthias


    Personally, I find code a lot more readable if asserts are completly
    ignored and this is used instead:

    if problem then report "there is a problem" severity WARNING;

    The assert does mean when your are reading that a test is being
    performed, and tells the synthesiser to ignore it, but the report
    should do that for you anyway.
    Tricky, Jul 2, 2008
    #4
  5. Ashani Patel

    KJ Guest

    On Jul 2, 10:48 am, Tricky <> wrote:

    > Personally, I find code a lot more readable if asserts are completly
    > ignored and this is used instead:
    >
    > if problem then report "there is a problem" severity WARNING;
    >


    Dang that "end if;" anyway...
    Dang, can't use that as a concurrent statement either...

    But your point is a good one, getting over the learning curve hump
    that the assert condition is asserting something to be true, but the
    message you display is what you display when the condition fails can
    be frustrating...until you get over that hump.

    KJ
    KJ, Jul 2, 2008
    #5
  6. Tricky wrote:

    > Personally, I find code a lot more readable if asserts are completly
    > ignored and this is used instead:
    >
    > if problem then report "there is a problem" severity WARNING;



    The problem I have with asserts is not with the polarity,
    but with debugging.

    I wrote a function that defaults as a print to stdio
    with optional parameters for comments, expected value, and mode.
    On the first cut, I just print. Later I add an expected value
    and print differences and error messages for failures.
    Passes can be quiet or verbose.

    -- Mike Treseler
    Mike Treseler, Jul 3, 2008
    #6
    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. dwerdna
    Replies:
    5
    Views:
    5,321
    Ajeetha
    Mar 31, 2005
  2. Robert Brewer
    Replies:
    1
    Views:
    480
    bsmith
    Nov 7, 2004
  3. Thomas Guettler

    assert 0, "foo" vs. assert(0, "foo")

    Thomas Guettler, Feb 23, 2005, in forum: Python
    Replies:
    3
    Views:
    2,498
    Carl Banks
    Feb 23, 2005
  4. Alex Vinokur

    assert(x) and '#define ASSERT(x) assert(x)'

    Alex Vinokur, Nov 25, 2004, in forum: C Programming
    Replies:
    5
    Views:
    893
    Keith Thompson
    Nov 25, 2004
  5. ImpalerCore

    To assert or not to assert...

    ImpalerCore, Apr 27, 2010, in forum: C Programming
    Replies:
    79
    Views:
    1,632
    Richard Bos
    May 17, 2010
Loading...

Share This Page