How to halt simulation process automatically in VHDL

Status
Not open for further replies.

gong.kidd

Junior Member level 2
Joined
Oct 24, 2006
Messages
20
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Activity points
1,379
how to halt a process

Hi guys, can anyone there is the VHDL statements which have the function like system task $stop in Verilog?

Thanks
 

Yes, I used it in my RTL, it works in NCsim, not in Modelsim
 

use assert statement with severity specified as "error" not "warning"
 

Hi
This works in modelsim, I have tried. may be its your severity level.
Code:
    if(now>100us) then
      assert FALSE
      report "End of Sim"
      severity Failure;
    end if;
Kr,
Avi
http://www.vlsiip.com
 

The input clock is in the stimulus file.
It`s:
"#10 pulse_in = ~pulse_in;"

I want every 10th pulse to show up at the output,
and I want the pulse at the output to be the same size as the pulse in the input.

I hope it`s clearer now.

Try below code

Code:
`timescale 1ns/100ps
 module top
(
   input  wire         pulse_in
  ,input  wire         reset_n       // active low reset
  ,output wire         pulse_out
);

  reg  [03:00] count, count_2;
  reg          out_pulse;

 // positive edge trigger counter
  always @ (posedge pulse_in or negedge reset_n)
    begin
      if (~reset_n)
        begin
          count <= {4{1'b0}};
        end
      else
        begin
          if (count == 4'h9)
            count <= {4{1'b0}};
          else
            count <= count + 1'b1;
        end
    end

  // negative edge trigger counter
  always @ (negedge pulse_in or negedge reset_n)
    begin
      if (~reset_n)
        begin
          count_2 <= {4{1'b0}};
        end
      else
        begin
          if (count_2 == 4'h9)
            count_2 <= {4{1'b0}};
          else
            count_2 <= count_2 + 1'b1;
        end
    end

  always @ (posedge pulse_in or negedge reset_n)
    begin
      if (~reset_n)
        begin
          out_pulse <= 1'b0;
        end
      else
        begin
          if (count == 4'h9)
            out_pulse <= 1'b1;
          else
            out_pulse <= 1'b0;
        end
    end

// assign pulse_out = out_pulse;
assign pulse_out = (((count == 4'h0) && (count_2 == 4'h0))? 1'b1 : 1'b0 );

endmodule

here is its testbench

Code:
`timescale 1ns/100ps

module top_tb();

  reg          clock, reset_n;
  wire         pulse_out;
  top top_instance
    (
      .pulse_in  ( clock     ), // input 
      .reset_n   ( reset_n   ), // input
      .pulse_out ( pulse_out )  // output
    );

  initial
    begin
      clock = 1'b0;
      reset_n = 1'b1;
    #15
      reset_n = 1'b0;
    #15
      reset_n = 1'b1;
    #1000
      $stop;
    end

  always 
    begin
      #5 clock = !clock;
    end
endmodule

Advantage is there will not any glitch on output. And code is synthesizable.

HTH
 

Attachments

  • wave.bmp
    1.1 MB · Views: 72

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…