UVM: Sending a Transaction - IKSciting
1917
post-template-default,single,single-post,postid-1917,single-format-standard,bridge-core-2.8.7,qodef-qi--no-touch,qi-addons-for-elementor-1.7.1,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,qode-content-sidebar-responsive,qode-theme-ver-27.1,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.6.0,vc_responsive,elementor-default,elementor-kit-838

Sending a Transaction

Sequence가 sequencer를 통해 sequence item, 즉, transaction을 driver로 전달할 때 start_itemfinish_item과 같은 method를 사용한다. 조금 더 상세한 driver와 sequencer 간의 communication 방식은 Driver Sequencer Handshake Mechanism 페이지를 참고하자.

class my_sequence extends uvm_sequence#(my_transaction);

  // ...

  virtual task body();
    req = my_transaction::type_id::create("req");
    start_item(req);
    if (!req.randomize()) begin
      `uvm_fatal(get_type_name(), "randomization fail");
    end
    finish_item(req);
  endtask: body
endclass: my_sequence

UVM은 사용자의 편의를 위하여 `uvm_do`uvm_do_with 또는 `uvm_create`uvm_send`uvm_rand_send`uvm_rand_send_with와 같은 macro를 제공한다. 아래 code에서 보여주는 `uvm_do를 이용한 방식은 위 code의 start_itemfinish_item을 이용한 방식과 동일한 동작을 수행하는 것으로 생각할 수 있다. 물론 엄밀히 말하면 내부 동작 상에 차이가 존재하며, 이는 사용자의 편의를 위해 제공된다고 하지만, 대부분의 경우 이러한 macro를 사용하는 것은 권장하지 않는다. 따라서 macro 사용에 대한 자세한 설명은 생략한다.

class my_sequence extends uvm_sequence#(my_transaction);

  // ...

  virtual task body();
    `uvm_do(req)
  endtask: body
endclass: my_sequence

가장 기본이 되는 `uvm_do는 `uvm_createrandomize`uvm_send로 이루어진다고 볼 수 있으며, 이는 start_itemrandomizefinish_item으로 모두 표현이 가능하다.

// not recommended
`uvm_do(req)
// not recommended
`uvm_create(req)
if (!req.randomize()) begin
  `uvm_fatal(get_type_name(), "randomization fail");
end
`uvm_send(req)
// recommended
req = my_transaction::type_id::create("req");
start_item(req);
if (!req.randomize()) begin
  `uvm_fatal(get_type_name(), "randomization fail");
end
finish_item(req);

Macro를 사용하면 여러 줄의 code를 한 줄로 간단하게 표현할 수 있음에도 macro 사용을 권장하지 않는 이유는 다음과 같다.

  • Macro에 의해 UVM이 어떻게 동작하는지 정확하게 이해하지 못하는 경우 의도하지 않은 동작을 기술할 위험이 있다.
  • Simulation hang 등 문제가 발생하였을 경우 debugging이 힘들다.
  • Constraint solver call 등으로 인한 불필요한 performance overhead가 발생한다.
  • Randomization 여부 등을 명시적으로 표현하는 것이 readability 측면에서 유리하다.
  • Macro에 의해 정해진 동작만 수행할 수 있으므로 flexibility가 낮다.

참고로 macro는 sequence 내에서 sub-sequence를 start 할 때 사용되기도 한다. 물론 이 경우에도 위와 동일한 이유로 macro 사용은 권장되지 않는다.

// not recommended
`uvm_do(seq)
// recommended
seq = my_sequence::type_id::create("seq");
if (!seq.randomize()) begin
  `uvm_fatal(get_type_name(), "randomization fail");
end
seq.start(seqr);

References

1 Comment

Post A Comment