23
John Aynsley, Doulos The Finer Points of UVM: Tasting Tips for the Connoisseur

UVM Sequences

  • Upload
    rax2411

  • View
    70

  • Download
    10

Embed Size (px)

DESCRIPTION

UVM Sequences

Citation preview

Page 1: UVM Sequences

John Aynsley, Doulos

The Finer Points of UVM:

Tasting Tips

for the Connoisseur

Page 2: UVM Sequences

The Finer Points of UVM

• Sequences and sequencers

• The arbitration queue

• Virtual sequences

• Request and response

• Multiple sequencer stacks

Page 3: UVM Sequences

The Big Picture

3

uvm_env

uvm_scoreboard Virtual sequencer

DUT

uvm_agentuvm_agent

uvm_agent

uvm_sequencer

uvm_driveruvm_monitor

uvm_test

uvm_test

Factory config db

uvm_agent

Register Layer

Page 4: UVM Sequences

Sequences and Sequencers

4

Sequencer

Driver

Sequence

Sequence

DUT

TLM export

TLM port

start_item(req);

finish_item(req);

seq_item_port.get(req);

Page 5: UVM Sequences

A Simple Sequence

5

class my_seq extends uvm_sequence #(my_tx); `uvm_object_utils(my_seq)

function new(string name = ""); super.new(name); endfunction: new

task body; repeat(4) begin req = my_tx::type_id::create("req"); start_item(req);

if (!req.randomize()) `uvm_error("", "failed to randomize")

finish_item(req); end endtaskendclass

Page 6: UVM Sequences

Nested Sequences

6

class top_seq extends uvm_sequence #(my_tx); ...

`uvm_declare_p_sequencer(my_seqr) ...

task body; repeat(3) begin my_seq seq; seq = my_seq::type_id::create("seq");

if (!seq.randomize()) `uvm_error("", "failed to randomize")

seq.start(p_sequencer, this); end endtask ... Parent

sequenceSequencer

Variable that points to sequencer

Page 7: UVM Sequences

Concurrent Sequences

7

task body; fork begin seq1 = my_seq::type_id::create("seq1"); if (!seq1.randomize()) `uvm_error("", "failed to randomize") seq1.start(p_sequencer, this); end begin seq2 = my_seq::type_id::create("seq2"); if (!seq2.randomize()) ... seq2.start(p_sequencer, this); end begin ... seq3.start(p_sequencer, this); end joinendtask

Transactions will be strictly interleaved

Page 8: UVM Sequences

The Finer Points of UVM

• Sequences and sequencers

• The arbitration queue

• Virtual sequences

• Request and response

• Multiple sequencer stacks

Page 9: UVM Sequences

Sequencer

The Arbitration Queue

9

Driver

priority

sequence

priority

sequence

priority

sequence

Arbitration queue

First in

start body start_item

seq_item_port.get(req);

Arbitration

start body start_item

fork

start body start_item

seq_item_port.get(req);

seq_item_port.get(req);

begin

finish_item

finish_item

finish_item

FIFO

join

end

Page 10: UVM Sequences

Setting the Arbritration Algorithm

10

task body; p_sequencer.set_arbitration( SEQ_ARB_STRICT_RANDOM); fork begin seq1 = my_seq::type_id::create("seq1"); if (!seq1.randomize()) `uvm_error("", "failed to randomize") seq1.start(p_sequencer, this, 1); end begin ... seq2.start(p_sequencer, this, 2); end begin ... seq3.start(p_sequencer, this, 3); end joinendtask Priority (default 100)

Page 11: UVM Sequences

Arbitration Algorithms

11

Arbitration mode Order in which requests granted

SEQ_ARB_FIFO FIFO order (default)

SEQ_ARB_RANDOM Random order

SEQ_ARB_STRICT_FIFO Highest priority first, then FIFO order

SEQ_ARB_STRICT_RANDOM Highest priority first, then random order

SEQ_ARB_WEIGHTED Weighted by priority

SEQ_ARB_USER User-defined

Page 12: UVM Sequences

User-Defined Arbitration Algorithm

12

class my_sequencer extends uvm_sequencer #(my_tx); ... function integer user_priority_arbitration( integer avail_sequences[$]); foreach (avail_sequences[i]) begin integer index = avail_sequences[i]; uvm_sequence_request req = arb_sequence_q[index]; int pri = req.item_priority; uvm_sequence_base seq = req.sequence_ptr; if (pri > max_pri) ... end return max_index; endfunction

endclass

Could access properties of the sequence object

Page 13: UVM Sequences

The Finer Points of UVM

• Sequences and sequencers

• The arbitration queue

• Virtual sequences

• Request and response

• Multiple sequencer stacks

Page 14: UVM Sequences

Sequencer

Driver

Sequencer

Driver

Virtual Sequences

14

Sequencer

Driver

priority

seq1

Sequencer

Virtual sequence vseq.start(seqr0, null, priority)

body

fork

seq1.start(seqr1, this)

body

start_item

...

seq2.start(seqr2, this, 50)

body

start_item

...

seqr1seqr2

seqr3

Blocks

Inherits priority

seqr0 Can be null

No transactions

Page 15: UVM Sequences

Sequencer Lock

15

Sequencer

Driver

Sequencer

Virtual sequence

seqr1

seqr0

No transactions

vseq.start(seqr0, null)

body

begin

this.lock(seqr1);

seq1.start(seqr1, this);

body

start_item

finish_item

this.unlock(seqr1);

...

priority

seqx

priority

seqy

priority

seq1

Important!

Page 16: UVM Sequences

Lock versus Grab

16

Sequencer

Driver

Virtual sequence

priority

seqx

priority

seqy

vseq1.start

body

begin

lock

seq1.start

unlock

Virtual sequence

vseq2.start

body

begin

lock

seq2.start

unlock

Virtual sequence

vseq3.start

body

begin

grab

seq3.start

ungrab

lock req

vseq2

grab req

vseq3

priority

seq3

Locks inserted here

Grabs inserted here

Head Tailpriority

seq1

priority

seq2

Page 17: UVM Sequences

The Finer Points of UVM

• Sequences and sequencers

• The arbitration queue

• Virtual sequences

• Request and response

• Multiple sequencer stacks

Page 18: UVM Sequences

Request and Response

18

Sequencer

Driver

Sequence

TLM export

TLM port

start_item(req);

finish_item(req);

get_response(rsp);

seq_item_port.get(req);

seq_item_port.put(rsp);

req rsp

DUTThe paper describes in detail how to code pipelined req/rsp and out-of-order responses

Page 19: UVM Sequences

Layered Sequencers

19

Sequencer

Driver

Sequencer

Sequence

Sequence

seq_item_port.get(req);

seq_item_port.put(rsp);

seqr_upper.get(req_up);

start_item(req_lo);

finish_item(req_lo);

get_response(rsp_lo);

seqr_upper.put(rsp_up);

start_item(req);

finish_item(req);

get_response(rsp);

req rsp

req rsp

Ptr to upper sequencer

Could be one:one or one:many or many:one or many:many

DUT

The paper shows more detail

req:rsp = 1:1

Page 20: UVM Sequences

The Finer Points of UVM

• Sequences and sequencers

• The arbitration queue

• Virtual sequences

• Request and response

• Multiple sequencer stacks

Page 21: UVM Sequences

Multiple Agents / Sequencer Stacks

21

Sequencer

Driver

Sequencer

Sequence

Sequence

Sequencer

Driver

Sequencer

Sequence

Sequence

Communicate or synchronize?

get(req)

Must not block!

Driven by the DUT interface timing

Analysis ports Callbacks Events Barriers

DUT

Page 22: UVM Sequences

Driver calls try_next_item

22

seq_item_port.try_next_item(req);

if (req == null)begin dut_vi.idle <= 1; ... @(posedge dut_vi.clock);endelsebegin seq_item_port.item_done();

dut_vi.idle <= 0; ... @(posedge dut_vi.clock); ... seq_item_port.put(rsp);

Wiggle pins for idle cycle

Must be called in same time step

Response can be pipelined

Page 23: UVM Sequences

The Finer Points of UVM

• The UVM sequence library

• Pipelined requests and responses

• The response handler

• UVM events and event pools

• The configuration database

Also in the paper