module basic-uvm session6 sequences and tests
TRANSCRIPT
![Page 1: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/1.jpg)
[email protected] www.verificationacademy.com
UVM Basics Sequences and Tests
John Aynsley CTO, Doulos
![Page 2: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/2.jpg)
Layered Sequential Stimulus
Transaction = command to driver
Constrained random sequence of transactions
Nested, layered or virtual sequences
Sequence of transactions
Sequence of sequences
![Page 3: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/3.jpg)
Sequence of Transactions class read_modify_write extends uvm_sequence #(my_transaction); `uvm_object_utils(read_modify_write) function new (string name = ""); super.new(name); endfunction: new task body; my_transaction tx; int a; int d; tx = my_transaction::type_id::create("tx"); start_item(tx);
Sequence has no parent
![Page 4: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/4.jpg)
Sequence of Transactions class read_modify_write extends uvm_sequence #(my_transaction); `uvm_object_utils(read_modify_write) function new (string name = ""); super.new(name); endfunction: new task body; my_transaction tx; int a; int d; tx = my_transaction::type_id::create("tx"); start_item(tx); assert( tx.randomize() ); tx.cmd = 0; finish_item(tx);
Read with random addr and data
![Page 5: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/5.jpg)
Sequence of Transactions
... a = tx.addr; d = tx.data; ++d;
Modify
![Page 6: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/6.jpg)
Sequence of Transactions
... a = tx.addr; d = tx.data; ++d; tx = my_transaction::type_id::create("tx"); start_item(tx); tx.cmd = 1; tx.addr = a; tx.data = d; finish_item(tx); endtask: body endclass: read_modify_write
Write with same random addr and data
![Page 7: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/7.jpg)
Sequence of Sequences
class seq_of_commands extends uvm_sequence #(my_transaction); `uvm_object_utils(seq_of_commands) rand int n;
"Knob" – fully random, fully determined, or partially constrained
![Page 8: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/8.jpg)
Sequence of Sequences
class seq_of_commands extends uvm_sequence #(my_transaction); `uvm_object_utils(seq_of_commands) rand int n; constraint how_many { n inside {[2:4]}; }
![Page 9: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/9.jpg)
Sequence of Sequences
class seq_of_commands extends uvm_sequence #(my_transaction); `uvm_object_utils(seq_of_commands) rand int n; constraint how_many { n inside {[2:4]}; } ... task body; repeat(n) begin end endtask: body
![Page 10: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/10.jpg)
Sequence of Sequences
class seq_of_commands extends uvm_sequence #(my_transaction); `uvm_object_utils(seq_of_commands) rand int n; constraint how_many { n inside {[2:4]}; } ... task body; repeat(n) begin read_modify_write seq; seq = read_modify_write::type_id::create("seq"); start_item(seq); finish_item(seq); end endtask: body
![Page 11: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/11.jpg)
End-of-Test
task body; uvm_test_done.raise_objection(this); repeat(n) begin read_modify_write seq; seq = read_modify_write::type_id::create("seq"); start_item(seq); finish_item(seq); end uvm_test_done.drop_objection(this); endtask: body
![Page 12: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/12.jpg)
A Set of Sequences
package my_sequences; import uvm_pkg::*; class read_modify_write extends uvm_sequence #(my_transaction); ... class seq_of_commands extends uvm_sequence #(my_transaction); ... endpackage
![Page 13: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/13.jpg)
Starting a Sequence
class test1 extends uvm_test; `uvm_component_utils(test1) my_env my_env_h; ... task run_phase(uvm_phase phase); read_modify_write seq; seq = read_modify_write::type_id::create("seq");
![Page 14: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/14.jpg)
Starting a Sequence
class test1 extends uvm_test; `uvm_component_utils(test1) my_env my_env_h; ... task run_phase(uvm_phase phase); read_modify_write seq; seq = read_modify_write::type_id::create("seq"); seq.start( ...
![Page 15: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/15.jpg)
Starting a Sequence
class test1 extends uvm_test; `uvm_component_utils(test1) my_env my_env_h; ... task run_phase(uvm_phase phase); read_modify_write seq; seq = read_modify_write::type_id::create("seq"); seq.start( my_env_h.my_agent_h.my_sequencer_h );
A deterministic sequence
![Page 16: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/16.jpg)
Starting a Sequence
class test2 extends uvm_test; `uvm_component_utils(test2) my_env my_env_h; ... task run_phase(uvm_phase phase); seq_of_commands seq; seq = seq_of_commands::type_id::create("seq");
![Page 17: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/17.jpg)
Randomizing a Sequence
class test2 extends uvm_test; `uvm_component_utils(test2) my_env my_env_h; ... task run_phase(uvm_phase phase); seq_of_commands seq; seq = seq_of_commands::type_id::create("seq"); assert( seq.randomize() ); seq.start( my_env_h.my_agent_h.my_sequencer_h );
![Page 18: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/18.jpg)
Constraining a Sequence
class test3 extends uvm_test; `uvm_component_utils(test3) my_env my_env_h; ... task run_phase(uvm_phase phase); seq_of_commands seq; seq = seq_of_commands::type_id::create("seq"); seq.how_many.constraint_mode(0); assert( seq.randomize() with { seq.n > 10 && seq.n < 20; } ); seq.start( my_env_h.my_agent_h.my_sequencer_h );
![Page 19: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/19.jpg)
Selecting a Test
module top; ... initial begin: blk ... run_test("test3"); end endmodule: top
![Page 20: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/20.jpg)
Selecting a Test
module top; ... initial begin: blk ... run_test(); end endmodule: top
vsim +UVM_TESTNAME=test3 Command line:
![Page 21: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/21.jpg)
Summary
Tests define differences
![Page 22: Module Basic-uvm Session6 Sequences and Tests](https://reader034.vdocuments.site/reader034/viewer/2022042521/54f986274a79599d368b4775/html5/thumbnails/22.jpg)
[email protected] www.verificationacademy.com
UVM Basics Sequences and Tests
John Aynsley CTO, Doulos