Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How to manipulate signals within certain time period in testbench in modelsim?

Status
Not open for further replies.

nervecell_23

Member level 1
Member level 1
Joined
Apr 26, 2013
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,565
For instance, I want to figure out how many times SignalA becomes active during 100ns and 200ns, instead of counting in the waveform, how to achieve it by HDL in the testbench?

I need to set up a counter first, then how to make it count only within a specified time period?

Thanks!
 

used this rising of falling edge of your signal as clock to increment your counter.

- - - Updated - - -

in verilog you could used variable $now to know when you could enable your counter.
 

Assuming your timescale is 1 ns in Verilog

Code:
integer counter;
initial begin
           count = 0;
           fork
            #100 begin : counter
                       forever @(posedge SignalA) count = count + 1;
                    end
            #200 disable counter;
          join
          $display("SignalA went high %0d times", count);
        end
This would be slightly easier in SystemVerilog which ModelSim does support
Code:
int counter;
initial begin
           count = 0;
           fork
            #100ns forever @(posedge SignalA) count++;
            #200ns;
          join_any
          disable fork;
          $display("SignalA went high %0d times", count);
        end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top