assert statement

A

Ashani Patel

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;
 
H

Hauke D

Hi,


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
 
F

frosty

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
 
T

Tricky

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.
 
K

KJ

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
 
M

Mike Treseler

Tricky said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top