Assertions - Examples
Example for Assertions.
(a) Ethernet
(i) Example Immediate Assertion
module assert_immediate;
logic Rx_data_valid;
logic clk,reset;
always_ff @(posedge clk or posedge reset)
begin
if (Rx_data_valid)
begin
CHECK_RESET_WHEN_RX_DATA_VALID: assert (reset && Rx_data_valid) //checking assert condition
begin
$display(" Collect the bits from frame");
end
else
begin
$error("assert failed at time %0t",$time);
$display("the frame is truncated");
end
end
end
initial
begin
$monitor("Rx_data_valid = %0d clk = %d reset = %d",Rx_data_valid,clk,reset);
reset = 0;
Rx_data_valid = 0;
#6 Rx_data_valid = 1;
#8 Rx_data_valid = 0;
#7 reset = 1;
end
initial
begin
$display("Rx_data_valid = %0d clk = %d reset = %d",Rx_data_valid,clk,reset);
#50 $finish;
end
initial
begin
clk = 0;
forever
begin
#10;
clk = ~clk;
end
end
endmodule
Output in VCS
Rx_data_valid = 0 clk = x reset = 0
Rx_data_valid = 0 clk = 0 reset = 0
Rx_data_valid = 1 clk = 0 reset = 0
"assert_imm.sv", 9: assert_immeadiate.CHECK_RESET_WHEN_RX_DATA_VALID: started at 10s failed at 10s
Offending '(reset && Rx_data_valid)'
Error: "assert_imm.sv", 9: assert_immeadiate.CHECK_RESET_WHEN_RX_DATA_VALID: at time 10
assert failed at time 10
the frame is truncated
Rx_data_valid = 1 clk = 1 reset = 0
Rx_data_valid = 0 clk = 1 reset = 0
Rx_data_valid = 0 clk = 0 reset = 0
Rx_data_valid = 0 clk = 0 reset = 1
Rx_data_valid = 0 clk = 1 reset = 1
Rx_data_valid = 0 clk = 0 reset = 1
(ii) Example Sequential Assertion
module asser_seq;
int da,sa,en; // destination address , source address
int frame;
int reset;
logic clk;
always @(posedge clk or negedge reset)
begin
if(en)
begin
if(frame>64) || (frame<511))
begin
$display("Normal frame is transmitted without extension",frame);
end
else
$display("Normal frame transmitted with extention",frame);
end
end
property frame_transmit; //Transmit the frame using property
@(posedge clk)
en |-> frame;
endproperty
frame_transmit_assert: assert property (frame_transmit) //assert condition
else
$display("@ %0d assertion filed",$time);
initial
begin
en = 0;
reset = 0;
#15 en = 1;
#10 reset = 1;
#5 reset = 1;
#3 en = 1;
end
initial
begin
clk = 0;
forever
begin
#5 clk++;
end
end
initial
begin
$display(" %d %d %d %d ", en,reset,frame,clk,$time);
#100 $finish;
end
endmodule
Output in VCS
0 0 0 0 0
Normal frame is transmitted without extension 0
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 25s failed at 25s
Offending 'frame'
@ 25 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 35s failed at 35s
Offending 'frame'
@ 35 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 45s failed at 45s
Offending 'frame'
@ 45 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 55s failed at 55s
Offending 'frame'
@ 55 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 65s failed at 65s
Offending 'frame'
@ 65 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 75s failed at 75s
Offending 'frame'
@ 75 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 85s failed at 85s
Offending 'frame'
@ 85 assertion filed
Normal frame is transmitted without extension 0
"assert_seq.sv", 24: asser_seq.frame_transmit_assert: started at 95s failed at 95s
Offending 'frame'
@ 95 assertion filed
$finish at simulation time 100
(b) Sonet
(i) Example immediate assertion
module assert_on_FP();
bit clk;
bit frame_pulse;
reg [7:0]section_A1;
reg [7:0]section_A2;
bit [7:0]sonet_data_in;
bit A1A2_indicator;
initial
begin
clk = 0;
frame_pulse = 0;
sonet_data_in = 8'b0;
sonet_data_in = 8'b0;
#5 sonet_data_in = 'hf6;
#1 sonet_data_in = 'h28;
#1 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h56;
#4 A1A2_indicator= 1'b0;
#4 frame_pulse = 1'b0;
#1 sonet_data_in = 'h99;
#1 sonet_data_in = 'h88;
#5sonet_data_in = 'hf6;
#1 sonet_data_in = 'h28;
#1 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h56;
#4 A1A2_indicator= 1'b0;
#4 frame_pulse = 1'b0;
#1 sonet_data_in = 'h100;
#1 sonet_data_in = 'h28;
#5 sonet_data_in = 'hf6;
#1 sonet_data_in = 'h28;
#1 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h56;
#4 A1A2_indicator= 1'b0;
#4frame_pulse = 1'b0;
#1 sonet_data_in = 'h44;
#1 sonet_data_in = 'h33;
#100 $finish;
end
always #1 clk = ~clk;
// Assertion used in always block
always @ (posedge clk)
begin
if(A1A2_indicator==1'b1)
CHECK_IF_FRAME_PULSE_IS_HIGH : assert (frame_pulse== 1'b1)
begin
$display ( "Assert Passed at time %0t",$time);
end
else
begin
$error( "assert failed at time %0t", $time);
end
end
endmodule
Output in VCS
"immd_assert.sv", 50: assert_on_FP.CHECK_IF_FRAME_PULSE_IS_HIGH: started at 7s failed at 7s
Offending '(frame_pulse == 1'b1)'
Error: "immd_assert.sv", 50: assert_on_FP.CHECK_IF_FRAME_PULSE_IS_HIGH: at time 7
assert failed at time 7
Assert Passed at time 9
Assert Passed at time 11
Assert Passed at time 27
Assert Passed at time 29
Assert Passed at time 31
"immd_assert.sv", 50: assert_on_FP.CHECK_IF_FRAME_PULSE_IS_HIGH: started at 45s failed at 45s
Offending '(frame_pulse == 1'b1)'
Error: "immd_assert.sv", 50: assert_on_FP.CHECK_IF_FRAME_PULSE_IS_HIGH: at time 45
assert failed at time 45
Assert Passed at time 47
Assert Passed at time 49
(ii) Example Concurrent Assertion
module assert_on_FP();
bit clk;
bit frame_pulse;
reg [7:0]section_A1;
reg [7:0]section_A2;
bit [7:0]sonet_data_in;
bit A1A2_indicator;
initial
begin
clk = 0;
frame_pulse = 0;
sonet_data_in = 8'b0;
sonet_data_in = 8'b0;
#1 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h56;
#1 sonet_data_in = 'h28;
#1 sonet_data_in = 'h38;
#3 A1A2_indicator= 1'b0;
#4 frame_pulse = 1'b0;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#3 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#4 A1A2_indicator= 1'b0;
#4 frame_pulse = 1'b0;
#1 sonet_data_in = 'h100;
#1 sonet_data_in = 'h28;
#5 sonet_data_in = 'hf6;
#1 sonet_data_in = 'h28;
#1 A1A2_indicator= 1'b1;
#1 frame_pulse = 1'b1;
#1 sonet_data_in = 'h56;
#1 sonet_data_in = 'h86;
#1 sonet_data_in = 'h96;
#4 A1A2_indicator= 1'b0;
#4 frame_pulse = 1'b0;
#1 sonet_data_in = 'h00;
#1 sonet_data_in = 'h00;
#100 $finish;
end
always #1 clk = ~clk;
// Sequences with different operators
sequence A1A2indic_framepulse;
A1A2_indicator ##1 frame_pulse;
endsequence
sequence framepulse_sonet_data_in;
frame_pulse ##[2:5] sonet_data_in;
endsequence
//Property Layer
property seq_of_seq;
@(posedge clk)
A1A2indic_framepulse |-> framepulse_sonet_data_in;
endproperty
//Assertion Directive Layer
check_property: assert property(seq_of_seq);
endmodule
Output in VCS
"conc_assert.sv", 70: assert_on_FP.check_property: started at 21s failed at 33s
Offending 'sonet_data_in'
"conc_assert.sv", 70: assert_on_FP.check_property: started at 23s failed at 35s
Offending 'sonet_data_in'
"conc_assert.sv", 70: assert_on_FP.check_property: started at 51s failed at 63s
Offending 'sonet_data_in'
This blog contains all the information, latest technologies in VLSI and interview questions for freshers
Subscribe to:
Post Comments (Atom)
Popular Posts
-
http://www.mediafire.com/?n77dan3ovdwyoy3 http://www.mediafire.com/?8ncruxr37o1dbqb http://www.mediafire.com/?jqhvobf6j4gbp6e ...
-
Verilog code for an 8-bit shift-left register with a positive-edge clock, serial in and serial out. module shift (clk, si, so);...
-
Verilog code for a 4-bit unsigned up counter with asynchronous clear. module counter (clk, clr, q); input ...
-
seminar topics with ppts if u need any topics below mail me: bsnspkumar_484@yahoo.co.in Analysis of the Performance of DOA Algorithms in sma...
-
ECE Seminar topics These are the seminar topics based on Electronics and Communications. If u need abstracts of the below seminar topics u c...
-
// memory module `timescale 1ns/1ns module ram(wr_ad,rd_ad,wr_en,rd_en,clk,wr_dat,rd_dat); //parameter addr_width=4; //parameter depth=16; /...
-
Verilog code for single-port RAM in read-first mode. module raminfr (clk, en, we, addr, di, do); input clk; input ...
-
If inverted output of D flip-flop is connected to its input how the flip-flop behaves? Design a circuit to divide input frequency by 2...
-
http://www.mediafire.com/?h1bj9w1bx8kja69 http://www.mediafire.com/?yot1d4b0u344lmc http://www.mediafire.com/?hzqj1m6j91mg9td http://ww...
-
Synthesizeable constructs and VHDL templates VHDL is frequently used for two different goals: simulation of electronic designs and synthesis...
No comments:
Post a Comment