24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

UM-364 14 - PSL Assertions<br />

Embedding assertions in your code<br />

Syntax<br />

Restrictions<br />

Example<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong><br />

One way of looking at assertions is as design documentation. In other words, anywhere you<br />

would normally write a comment to capture pre-conditions, constraints or other<br />

assumptions as well as to document the proper functionality of a module, process, or<br />

subprogram, use assertions to capture the information instead.<br />

PSL assertions are embedded using metacomments prefixed with 'psl'. For example:<br />

-- psl sequence s0 is {b0; b1; b2};<br />

The PSL statement can be multi-line. For example:<br />

-- psl sequence s0 is<br />

-- {b0; b1; b2};<br />

Note that the second line did not require a 'psl' prefix. Once in PSL context, the parser will<br />

remain there until a PSL statement is terminated with a semicolon (';').<br />

Embedded assertions have the following restriction as to where they can be embedded:<br />

Assertions can be embedded anywhere inside a Verilog module except initial blocks,<br />

always blocks, tasks, <strong>and</strong> functions. They cannot be embedded in UDPs.<br />

Assertions can be embedded only in declarative <strong>and</strong> statement regions of a VHDL entity<br />

or architecture body.<br />

In a statement region, assertions can app ear at places where concurrent statements may<br />

appear. If they appear in a sequential statement, <strong>ModelSim</strong> will generate an error.<br />

Assertions cannot be embedded in VHDL procedures <strong>and</strong> functions.<br />

library IEEE;<br />

use IEEE.std_logic_1164.all;<br />

use IEEE.numeric_std.all;<br />

use WORK.constants.all;<br />

entity dram_control is<br />

generic ( BUG : Boolean := TRUE );<br />

port ( clk : IN std_logic;<br />

reset_n : IN std_logic;<br />

as_n : IN std_logic;<br />

addr_in : IN std_logic_vector(AIN-1 downto 0);<br />

addr_out: OUT std_logic_vector(AOUT-1 downto 0);<br />

rw : IN std_logic; -- 1 to read; 0 to write<br />

we_n : OUT std_logic;<br />

ras_n : OUT std_logic;<br />

cas_n : OUT std_logic;<br />

ack : OUT std_logic );<br />

end entity dram_control;<br />

architecture RTL of dram_control is<br />

type memory_state is (IDLE, MEM_ACCESS, SWITCH, RAS_CAS, OP_ACK, REF1,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!