Stimulus and Response Stimulus and Response n n

  • Slides: 48
Download presentation
Stimulus and Response

Stimulus and Response

Stimulus and Response n n n Simple Stimulus Verifying the Output Self-Checking Testbenches Complex

Stimulus and Response n n n Simple Stimulus Verifying the Output Self-Checking Testbenches Complex Stimulus Complex Response Predicting the Output

Simple Stimulus n n n Generating Stimulus is the process of providing input signals

Simple Stimulus n n n Generating Stimulus is the process of providing input signals to the DUV Every input to the DUV is an output from a stimulus model Any deterministic waveform is easy to generate

Verilog Example 1 ‘timescale 1 ns/1 ns Module testbench; … Reg clk; Parameter cycle

Verilog Example 1 ‘timescale 1 ns/1 ns Module testbench; … Reg clk; Parameter cycle = 15; Always Begin #(cycle/2); clk=1’b 0; #(cycle/2); clk=1 b 1; End endmodule

Verilog Example 2 ‘timescale 1 ns/1 ns Module testbench; … Reg clk; Parameter cycle

Verilog Example 2 ‘timescale 1 ns/1 ns Module testbench; … Reg clk; Parameter cycle = 15; Always Begin #(cycle/2. 0); clk=1’b 0; #(cycle/2. 0); clk=1 b 1; End endmodule

Verilog Example 3 ‘timescale 1 ns/100 ps Module testbench; … Reg clk; Parameter cycle

Verilog Example 3 ‘timescale 1 ns/100 ps Module testbench; … Reg clk; Parameter cycle = 15; Always Begin #(cycle/2); clk=1’b 0; #(cycle/2); clk=1 b 1; End endmodule

Simple Stimulus (Cont) – Complex Waveforms n Complex waveforms n n Care must be

Simple Stimulus (Cont) – Complex Waveforms n Complex waveforms n n Care must be taken not to over constrain the waveform generation or limit it to a subset of its possible variations. Need to make sure that there are many instances of absolute min and max values n Controlled Randomization

Simple Stimulus (Cont) – Synchronized Waveforms n Stimulus for a DUV is never composed

Simple Stimulus (Cont) – Synchronized Waveforms n Stimulus for a DUV is never composed of 1 signal. You must synchronize all inputs to the DUV properly n In a synchronous design, most signals should be aligned with the clock

Sample of Synchronized Waveforms n Sample 5 -9 Always Begin #50 clk = 1’b

Sample of Synchronized Waveforms n Sample 5 -9 Always Begin #50 clk = 1’b 0; #50 clk = 1’b 1; End Initial Begin Rst = 1’b 0; #150 rst = 1’b 1; #200 rst = 1’b 0; End n Sample 5 -10 Always Begin #50 clk <= 1’b 0; #50 clk <= 1’b 1; End Initial Begin Rst = 1’b 0; #150 rst <= 1’b 1; #200 rst <= 1’b 0; End

Simple Stimulus (Cont) – Generating Waveforms n We talked about Delta Cycles – Can

Simple Stimulus (Cont) – Generating Waveforms n We talked about Delta Cycles – Can be equivalent to real delays. n If, due to delta cycle problems, you miss a value at one clock edge, then you will get that value on the next! n n Must have everything aligned! Generating Data Waveforms n If not done properly, could produce race conditions n n Can’t ensure that total number of delta cycles between clock and data is maintained, or at least in favor of the data signal. Interfaces specs never specify 0 -delay values, thus when generating synchronous data, always provide a real delay between active edge and transition on the data signal.

Simple Stimulus (Cont) – Encapsulating and Abstraction Waveform Generation n Encapsulating Waveform Generation n

Simple Stimulus (Cont) – Encapsulating and Abstraction Waveform Generation n Encapsulating Waveform Generation n Generation of waves may need to be repeated during simulation n n Place then generation in a subprogram and call that subprogram with the vector to be applied as the input to the subprogram Abstracting Waveform Generation n n Using synchronous test vectors (as above) is cumbersome and hard to interpret (maintainability) Easier if operations accomplished by the vectors were abstracted! n Try to apply worst possible combinations of inputs

Simple Stimulus (Cont)– Abstraction Waveform Generation Example n 2 -1 input sync reset D

Simple Stimulus (Cont)– Abstraction Waveform Generation Example n 2 -1 input sync reset D flip flop n n n Inputs: rst, d 0, d 1, sel, clk Output d_out Subprograms needed: n n n Reset Load input d 0 Load input d 1

Abstraction Waveform Generation Example (Cont) n Reset n Worst possible condition: n n D

Abstraction Waveform Generation Example (Cont) n Reset n Worst possible condition: n n D 0=1 D 1=1 Sel = randomly set Load d 0 n Worst possible condition: n D 1 is complement of d 0

Abstraction Waveform Generation Example (Cont) Task sync_reset; Begin rst<= 1’b 1; d 0 <=

Abstraction Waveform Generation Example (Cont) Task sync_reset; Begin rst<= 1’b 1; d 0 <= 1’b 1; d 1 <= 1’b 1; @(posedge clk); #(Thold); {rst, d 0, d 1, sel} <=4’bxxxx; #(cycle-Thold-Tsetup); End endtask Task load_d 0; input data; Begin rst <= 1’b 0; d 0 <= data; d 1 <= ~data; sel <= 1’b 0; @(posedge clk); #(Thold); {rst, d 0, d 1, sel} <=4’bxxxx; #(cycle-Thold-Tsetup); End endtask

Abstraction Waveform Generation Example (Cont) initial Begin sync_reset; load_d 0(1’b 1); sync_reset; load_d 1(1’b

Abstraction Waveform Generation Example (Cont) initial Begin sync_reset; load_d 0(1’b 1); sync_reset; load_d 1(1’b 1); load_d 0(1’b 0); load_d 1(1’b 1); sync_reset; …. . End

Verifying the Output n n Generating Stimulus is only about 30% of job, 70%

Verifying the Output n n Generating Stimulus is only about 30% of job, 70% is in verifying output Most obvious method is visually n n ASCII output Waveforms

Producing Simulation Results n n n Which signals are significant change with time In

Producing Simulation Results n n n Which signals are significant change with time In order to determine what is correct, must model this knowledge Producing the proper simulation results involves modeling the behavior of the signal sampling n n Sample at regular intervals (clk) Sample on interested signals (only when they change)

Minimizing Sampling n Minimizing the sampling improves the simulator performance n In VHDL only

Minimizing Sampling n Minimizing the sampling improves the simulator performance n In VHDL only put interesting signals on sensitivity list or use: ‘wait until <interesting condition>’ n In Verilog use n n n $monitor(“…”, <signal list>) $monitoroff $monitoron

Visual Inspection of Waveforms n Results are better (to understand) when plotted over time

Visual Inspection of Waveforms n Results are better (to understand) when plotted over time n n Advantage is that it plots the signal continuously overtime, not at specified points as in text view (the samples) Tool dependent on how to turn on Performance impact, want to minimize the total number of signals to view Mostly used for debug

Self-Checking Testbenches n Use self-checking – different techniques n Specify input and expected output

Self-Checking Testbenches n Use self-checking – different techniques n Specify input and expected output for each clock cycle n Problems n n Difficult to maintain Difficult to specify Difficult to debug Require perfectly synchronous interfaces

Self-Checking Testbenches (Cont) n Golden Vectors – Set of reference simulation results n DUV

Self-Checking Testbenches (Cont) n Golden Vectors – Set of reference simulation results n DUV vectors are captured and then compared against the golden set. n n If results are stored in ASCII format, use diff command Some tools allow for waveform comparisons Significant maintenance Separate clock domain references

Self-Checking Testbenches (Cont) n Run-Time Result Verification n Results compared in parallel with the

Self-Checking Testbenches (Cont) n Run-Time Result Verification n Results compared in parallel with the stimulus generation n Use a reference model n n The DUV and reference model are subjected to same stimulus Outputs of both, DUV and reference model, are constantly monitored and compared.

Self-Checking Testbenches (Cont) n Focus on operations instead of input and output vectors n

Self-Checking Testbenches (Cont) n Focus on operations instead of input and output vectors n n n Include the verification of the operations that were put into the subprograms. Instead of simply applying stimulus, include the checking, now just run the operations, individually or in sequence. Must verify that the operations are being performed.

Complex Stimulus n n n Talked about simple stimulus Complex stimulus includes feedback from

Complex Stimulus n n n Talked about simple stimulus Complex stimulus includes feedback from DUV to the stimulator Most desirable is a bus-functional model that is configurable.

Complex Stimulus (Cont) n Feedback between stimulus and design n Generator can wait for

Complex Stimulus (Cont) n Feedback between stimulus and design n Generator can wait for feedback before continuing Include timing and functional verification in the feedback monitoring Using feedback can cause deadlock during testing. n n DUV may not provide feedback and the model may not provide any more stimulus until there is feedback Eliminate the possibility of deadlock! n n I. e. a timeout (with error!) and test continues Testcase fails and stops immediately

Complex Stimulus (Cont) n Asynchronous interfaces n n Most vectors are inherently synchronous Many

Complex Stimulus (Cont) n Asynchronous interfaces n n Most vectors are inherently synchronous Many interfaces are specified in an asynchronous fashion (even though synchronous – FSM’s, flip-flop’s, etc) n n n If a clock is not specified in the specification, then it should not be part of the verification nor part of the stimulus Behavioral model do not need a clock Need to think of all failure modes

Complex Stimulus (Cont) – Example n CPU operations encapsulated using procedures n n Encapsulating

Complex Stimulus (Cont) – Example n CPU operations encapsulated using procedures n n Encapsulating complex stimulus is known as BFM’s (Bus Functional Models) If you had a specification for a 386 sx read cycle, then using vector stimulus would be inefficient – why?

Complex Stimulus (Cont) Example n Extend the CPU operations to include writes. Using test

Complex Stimulus (Cont) Example n Extend the CPU operations to include writes. Using test vectors, can’t do read -modify-write operations. n To do this, you’ll want to use the value returned on a read for a future write (after modifying it).

Complex Stimulus (Cont) n Configurable operations n n If you have interfaces that have

Complex Stimulus (Cont) n Configurable operations n n If you have interfaces that have certain signals that are configurable Don’t want to create nearly identical models – maintenance issues n n Simple configurable elements become complex when grouped. Solution - Create one model with configurable operations. Now you can use the model however you need to.

Complex Response n We identified that visual inspection is not the way to go.

Complex Response n We identified that visual inspection is not the way to go. And that was with simple responses, what about complex responses. n n Must automate this, one way to perform this is with BFM’s What is a complex response?

Complex Response – (Cont) n Example – UART transmit path n Waiting for output

Complex Response – (Cont) n Example – UART transmit path n Waiting for output before applying next input would prevent the ability to stress (or cause interesting conditions) n n Filling up the FIFO is one Stress the DUV under max conditions, must decouple generation from checking.

Complex Response – (Cont) n How do you deal with unknown or variable latency?

Complex Response – (Cont) n How do you deal with unknown or variable latency? n This latency is usually a by-product of the architecture or implementation. You may not care what it is. n If it is a by-product of the implementation and not a design requirement, why enforce one in verification?

Complex Response – (Cont) n How to verify output independently? n Put output checkers

Complex Response – (Cont) n How to verify output independently? n Put output checkers and stimulus generators in separate execution threads. n n n Processes in VHDL Always/initial and fork/join in Verilog Must synchronize to know when to start checking, etc.

Complex Response – (Cont) n Earlier we encapsulated input operations – can do the

Complex Response – (Cont) n Earlier we encapsulated input operations – can do the same for outputs n n For stimulus, the subprograms took the arguments as stimulus. For output operations, take the arguments as the expect results (results that the DUV should output) Implementation should be as configurable as the stimulus. Remember – consider all possible failure modes.

Complex Response – (Cont) n n This procedure ‘recv’ is very limited. Only can

Complex Response – (Cont) n n This procedure ‘recv’ is very limited. Only can be used in the current scope. n n n You pass in the expect and it compares the actual to this expect (predefined). What if output is to be ignored until a predetermined sequence of events? Or data? What if the output needs to be fed back to the stimulus model? What if…. ? Solution is to create a more generic output monitor.

Complex Response – (Cont) n Generic Output monitor: n Return the data that the

Complex Response – (Cont) n Generic Output monitor: n Return the data that the DUV output back to the caller! n n n The ‘higher authority’ now makes the call to what is correct and what is not. It is also controlling the stimulus model, therefore it knows more of the state of the environment and what is to be tested. The other things (protocols, etc) are still be verified. But do not arbitrarily constrain the input.

Complex Response – (Cont) n Monitoring multiple possible operations n You may have a

Complex Response – (Cont) n Monitoring multiple possible operations n You may have a situation where more than one type of output may be OK. (branch prediction, out of order processing, etc) n n Can’t predict unless you model the details of implementation. If you verify for a particular order, over constraining environment (starting directed tests).

Complex Response – (Cont) n How do you write an encapsulated output monitor for

Complex Response – (Cont) n How do you write an encapsulated output monitor for this? n 1 st write a monitor that identifies the next cycle. n n n Verifies the preamble to all operations on the output interface until it becomes unique It then returns any information collected thus far to the testbench. Testbench is left up to call the appropriate subprograms to complete the verification.

Complex Response – (Cont) n We defined a stimulator as one who has outputs.

Complex Response – (Cont) n We defined a stimulator as one who has outputs. If a monitor must provide output back to the DUV, is it not a stimulator? n n Stimulator (or generator) is a model that initiates a transaction Monitor is a model that may/many not respond to an operation initiated by the DUV.

Complex Response – (Cont) n Monitoring bi-di interfaces n Example: bridge chip n n

Complex Response – (Cont) n Monitoring bi-di interfaces n Example: bridge chip n n Cycles initiated on the on-chip bus are translated to PCI transactions (if addresses match) Allows master devices (on-chip) to transparently access slave devices on the PCI bus

Complex Response – (Cont) n What do you need to verify this? n n

Complex Response – (Cont) n What do you need to verify this? n n n On-chip bus cycle generator PCI bus cycle monitor Could you use a memory as the slave device instead of monitor? n Have the generator write to PCI space then read it back, and continue doing this in a random fashion?

Complex Response – (Cont) n Using the PCI monitor reduces the risk n n

Complex Response – (Cont) n Using the PCI monitor reduces the risk n n Have the monitor detect the PCI cycle and have it notify to the testbench along with the address being read or written. The testbench would decide if it is correct.

Complex Response – (Cont) n Let’s slice up the PCI cycle up into multiple

Complex Response – (Cont) n Let’s slice up the PCI cycle up into multiple monitors n n One to handle the preamble and type of cycle One to handle each data transfer n n Input/Output of monitor for data read/written Output to indicate whether to continue with more data xfers or terminate One to handle cycle termination Now that the cycle is broken up, we have the ability to provide the master and slave to throttle the transfer rate. It can assert irdy_n and trdy_n (these can be parameters for randomization).

Complex Response – (Cont) n n n By using the generic PCI bus monitor,

Complex Response – (Cont) n n n By using the generic PCI bus monitor, the testcase becomes shorter. The monitor provides access to all bus values. Also provides an easy mechanism to catch exceptions Also enable the use of few addresses to provide a sufficient test suite.

Predicting the Output n Unstated assumption with self-checking testbenches is that you have detailed

Predicting the Output n Unstated assumption with self-checking testbenches is that you have detailed knowledge of the output to be expected n This is the most crucial factor n Knowing exactly which output to expect and when determines the functional correctness.

Predicting the Output – (Cont) n Data formatters n n n Expect output =

Predicting the Output – (Cont) n Data formatters n n n Expect output = data input (reformatted) Simplest output prediction process May want to forward data to the monitor one value at a time. n n Due to pipelines and latency, this may constrain the generator (can’t change data until it is checked) Instead of one value at a time, use a FIFO structure May want to use a global array that both generator and monitor use. Another aspect (similar to global array) is to read in values from a file. This way can be more dynamic.

Predicting the Output – (Cont) n Packet Processors n n Portion of packet is

Predicting the Output – (Cont) n Packet Processors n n Portion of packet is transformed somehow Other portion is untouched n n Use untouched field to encode the expected transformation Simplifies testbench n n All controls for stimulus and expect generation are in one location. Include all necessary information in payload to determine correctness.

Predicting the Output – (Cont) n Complex Transformations n Expected output can only be

Predicting the Output – (Cont) n Complex Transformations n Expected output can only be determined by reproducing same transformation. n use alternative means (different algorithm) n Example was the DSP (using reals)