snippet `
\`ifndef ${1:`toupper(vim_snippets#Filename('$1_SV', 'UNTITLED_SV'))`}
\`define $1
${0}
\`endif /* end of include guard: $1 */
snippet always always @ ..
always @(${1:posedge clk}) begin
${2}
end
snippet always always_comb ..
always_comb begin
${1}
end
snippet always_comb always_comb ..
always_comb begin
${1}
end
snippet always always_ff ..
always_ff @(${1:posedge clk or negedge reset_n})
${2}
end
snippet always_ff always_ff ..
always_ff @(${1:posedge clk or negedge reset_n})
${2}
end
snippet always always_latch ..
always_latch
${1}
end
snippet always_latch always_latch ..
always_latch
${1}
end
snippet case case() ..
case(${1:expression})
${2:value1}: begin
${3}
end
// other case branches
default: begin
end
endcase
snippet case casex() ..
casex(${1:expression})
${2:value1}: begin
${3}
end
// other case branches
default: begin
end
endcase
snippet casex casex() ..
casex(${1:expression})
${2:value1}: begin
${3}
end
// other case branches
default: begin
end
endcase
snippet case casez() ..
casez(${1:expression})
${2:value1}: begin
${3}
end
// other case branches
default: begin
end
endcase
snippet casez casez() ..
casez(${1:expression})
${2:value1}: begin
${3}
end
// other case branches
default: begin
end
endcase
snippet class class .. endclass
//class ${1:class_name} ;
//
class $1 ;
function new(string name = "$1");
${2}
endfunction: new
endclass: $1
snippet clocking clocking .. { .. }
clocking ${1:name_cb} @(posedge ${2:clock});
default input #${3:setup_time} output #${4:hold_time};
${5}
// output declarations
// input declarations
endclocking: $1
snippet do do .. while()
do begin
${2}
end while($1);
snippet enum enum .. { .. }
typedef enum {${2}
} ${1:name_e};
snippet final final ..
final begin
${1}
end
snippet for for() ..
for(${1:int i = 0}; ${2:i < n}; ${3:i++}) begin
${4}
end
snippet generate generate..for() ..
for(${1:genvar i = 0}; ${2:i < n}; ${3:i = i + 1}) begin
${4}
end
endgenerate
snippet foreach foreach(x[i]) ..
foreach(${1:x}[i]) begin
${2}
end
snippet forever forever ..
forever begin
${1}
end
snippet fork fork .. join
fork
begin
${1}
end
begin
end
join
snippet fork fork .. join_any
fork
begin
${1}
end
begin
end
join_any
snippet fork fork .. join_none
fork
begin
${1}
end
begin
end
join_none
snippet function function .. endfunction
function ${1:void} ${2:function_name} ($3);
${4}
endfunction: $2
snippet cover covergroup .. endgroup
covergroup ${1:function_name}_grp;
\`include($1_coverage)
endgroup: $1
snippet cg covergroup .. endgroup
//covergroup: ${1:function_name}_grp;
\`include($1_coverage)
endgroup: $1
snippet cp coverpoint
//coverpoint: ${1:function}_cov
// signal_a = {intf_fcov.sin_a,intf_fcov.sin_b}
$1_cov:coverpoint (${3:signal_a or register_a or field_a})\
iff(${4:intf_fcov.sinc})\
{\
bins bin0 {5'b00000};)\
}
snippet cp_a coverpoint_array
\`define ${1:FUNCTION1}_COV(idx)\
//coverpoint_array: ${2:function1}= tolower("$1")
// signal_a = {intf_fcov.sin_a[idx],intf_fcov.sin_b[idx]}
$2\`\`idx:coverpoint (${3:signal_a[idx] or register_a[idx] or field_a})\
iff($3)\
{\
bins bin0 {5'b00000};)\
bins bin1 {5'b00001};)\
}
\`$1_COV(0)
\`$1_COV(1)
snippet group_grp group_covergroup
covergroup ${1:function_name}_grp;
\`include($1_coverage)
endcovergroup:$1
snippet if if() ..
if(${1:condition}) begin
${2}
end
snippet ife if() .. else
if(${1:condition}) begin
${2}
end
else begin
${3}
end
snippet initial initial ..
initial begin
${1}
end
snippet interface interface .. { .. }
// vmm rule 4-4 -- interfaces shall be packaged into the same files as the
// transactors that use them
interface ${1:name_if} (// input wire clk,
// input wire reset
);
timeunit 1ns;
timeprecision 100ps;
${2}
parameter hold_time = 2; // timeunit is 1ns
parameter setup_time = 2; // change timing values as per requirement
// Clocking Blocks
// just type clocking and tab to invoke snippet
// Modports
// just type modport and tab to invoke snippet
// debug
// debug intf
endinterface: $1
snippet modport modport .. { .. }
modport ${1:name_mp}
(${2}
// clocking clocking_cb,
// input input_name,
// output output_port,
// ....
);
snippet module module .. endmodule
module ${1:module_name} (/*port details*/);
${2}
endmodule: $1
snippet once `ifndef XXX; `define XXX; `endif
\`ifndef ${1:`toupper('_'.substitute(expand('%:t'), '\.', '_', '').'_')`}
\`define $1
${2}
\`endif // Guard
snippet package package .. endpackage
// package: ${1:package_name}
//
package $1;
${2}
endpackage: $1
snippet parameter parameter ..
parameter ${1:param_name} = ${2:param_value};
${3}
snippet program program .. { .. }
program automatic ${1:name};
// declarations
${2}
initial begin
end
endprogram: $1
snippet randcase randcase .. endcase
randcase;
${1:weight1}:
${3}
${2:weight2}:
endcase
snippet repeat repeat(N) ..
repeat(${1:N}) begin
${2}
end
snippet struct struct ... { ... }
typedef struct {
${2}
} ${1:name_s};
snippet task task .. endtask
task ${1:task_name} ($3);
${2}
endtask: $1
snippet union union ... { ... }
typedef union {
${2}
} ${1:name_u};
snippet while while() ..
while (${1:condition}) begin
${2}
end
snippet create type_id::create( .. )
type_id::create("${1:`expand('%:t:r')`}", this);
snippet uvm_error uvm_error
\`uvm_error(${1:get_full_name(),"message"})
snippet uvm_fatal uvm_fatal
\`uvm_fatal(${1:get_full_name(),"message"})
snippet uvm_info uvm_info
\`uvm_info(${1:get_full_name(),"message"},UVM_NONE)
snippet uvm_macro uvm_object_utils
\`uvm_object_utils(${1:`expand('%:t:r')`})
snippet uvm_macro uvm_component_param_utils
\`uvm_component_param_utils($1)
snippet uvm_macro uvm_component_utils
\`uvm_component_utils($1)
snippet extern build_phase
extern virtual function void build_phase(uvm_phase phase);
snippet extern connect_phase
extern virtual function void connect_phase(uvm_phase phase);
snippet extern end_phase
extern virtual function void end_of_elaboration_phase(uvm_phase phase);
snippet extern start_phase
extern virtual function void start_of_simulation_phase(uvm_phase phase);
snippet extern run_phase
extern virtual task run_phase(uvm_phase phase);
snippet extern pre_reset_phase
extern virtual task pre_reset_phase(uvm_phase phase);
snippet extern reset_phase
extern virtual task reset_phase(uvm_phase phase);
snippet extern post_reset_phase
extern virtual task post_reset_phase(uvm_phase phase);
snippet extern pre_configure_phase
extern virtual task pre_configure_phase(uvm_phase phase);
snippet extern configure_phase
extern virtual task configure_phase(uvm_phase phase);
snippet extern post_configure_phase
extern virtual task post_configure_phase(uvm_phase phase);
snippet extern pre_main_phase
extern virtual task pre_main_phase(uvm_phase phase);
snippet extern main_phase
extern virtual task main_phase(uvm_phase phase);
snippet extern post_main_phase
extern virtual task post_main_phase(uvm_phase phase);
snippet extern pre_shutdown_phase
extern virtual task pre_shutdown_phase(uvm_phase phase);
snippet extern shutdown_phase
extern virtual task shutdown_phase(uvm_phase phase);
snippet extern post_shutdown_phase
extern virtual task post_shutdown_phase(uvm_phase phase);
snippet extern extract_phase
extern virtual function void extract_phase(uvm_phase phase);
snippet extern check_phase
extern virtual function void check_phase(uvm_phase phase);
snippet extern report_phase
extern virtual function void report_phase(uvm_phase phase);
snippet extern final_phase
extern virtual function void final_phase(uvm_phase phase);
snippet phase build_phase
function void ${1:`expand('%:t:r')`}${2:::}build_phase(uvm_phase phase);
/* note: Do not call super.build_phase() from any class that is extended from an UVM base class! */
/* For more information see UVM Cookbook v1800.2 p.503 */
$3//super.build_phase(phase);
$0
endfunction: build_phase
snippet phase run_phase
task ${1:`expand('%:t:r')`}${2:::}run_phase(uvm_phase phase);
phase.raise_objection(this);
\`uvm_info(${3:get_full_name()},"${4:run_phase} started, objection raised.", ${5:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($3, "$4 finished, objection dropped ", $5)
endtask: run_phase
snippet phase pre_reset_phase
task ${1:`expand('%:t:r')`}${2:::}pre_reset_phase(uvm_phase phase);
$0
endtask: pre_reset_phase
snippet phase reset_phase
task ${1:`expand('%:t:r')`}${2:::}reset_phase(uvm_phase phase);
phase.raise_objection(this);
\`uvm_info(${3:get_full_name()},"${4:reset_phase} started, objection raised.", ${5:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($3, "$4 finished, objection dropped ", $5)
endtask: reset_phase
snippet phase post_reset_phase
task ${1:`expand('%:t:r')`}${2:::}post_reset_phase(uvm_phase phase);
$0
endtask: post_reset_phase
snippet phase pre_configure_phase
task ${1:`expand('%:t:r')`}${2:::}pre_configure_phase(uvm_phase phase);
$0
endtask: pre_configure_phase
snippet phase configure_phase
task ${1:`expand('%:t:r')`}${2:::}configure_phase(uvm_phase phase);
phase.raise_objection(this);
\`uvm_info(${3:get_full_name()},"${4:configure_phase} started, objection raised.", ${5:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($3, "$4 finished, objection dropped ", $5)
endtask: configure_phase
snippet phase post_configure_phase
task ${1:`expand('%:t:r')`}${2:::}post_configure_phase(uvm_phase phase);
$0
endtask: post_configure_phase
snippet phase pre_main_phase
task ${1:`expand('%:t:r')`}${2:::}pre_main_phase(uvm_phase phase);
$0
endtask: pre_main_phase
snippet phase main_phase
task ${1:`expand('%:t:r')`}${2:::}main_phase(uvm_phase phase);
phase.raise_objection(this);
\`uvm_info(${3:get_full_name()},"${4:main_phase} started, objection raised.", ${5:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($3, "$4 finished, objection dropped ", $5)
endtask: main_phase
snippet phase post_main_phase
task ${1:`expand('%:t:r')`}${2:::}post_main_phase(uvm_phase phase);
$0
endtask: post_main_phase
snippet phase pre_shutdown_phase
task ${1:`expand('%:t:r')`}${2:::}pre_shutdown_phase(uvm_phase phase);
$0
endtask: pre_shutdown_phase
snippet phase shutdown_phase
task ${1:`expand('%:t:r')`}${2:::}shutdown_phase(uvm_phase phase);
phase.raise_objection(this);
\`uvm_info(${3:get_full_name()},"${4:shutdown_phase} started, objection raised.", ${5:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($3, "$4 finished, objection dropped ", $5)
endtask: shutdown_phase
snippet phase post_shutdown_phase
task ${1:`expand('%:t:r')`}${2:::}post_shutdown_phase(uvm_phase phase);
$0
endtask: post_shutdown_phase
snippet phase extract_phase
function void ${1:`expand('%:t:r')`}${2:::}extract_phase(uvm_phase phase);
super.extract_phase(phase);
$0
endfunction: extract_phase
snippet phase check_phase
function void ${1:`expand('%:t:r')`}${2:::}check_phase(uvm_phase phase);
super.check_phase(phase);
$0
endfunction: check_phase
snippet phase report_phase
function void ${1:`expand('%:t:r')`}${2:::}report_phase(uvm_phase phase);
super.report_phase(phase);
$0
endfunction: report_phase
snippet phase final_phase
function void ${1:`expand('%:t:r')`}${2:::}final_phase(uvm_phase phase);
super.final_phase(phase);
$0
endfunction: final_phase
snippet uvm_objection
phase.raise_objection(this);
\`uvm_info(${1:get_full_name()},"${2:main_phase} started, objection raised.", ${3:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($1, "$2 finished, objection dropped ", $3)
snippet objection
phase.raise_objection(this);
\`uvm_info(${1:get_full_name()},"${2:main_phase} started, objection raised.", ${3:UVM_NONE})
$0
phase.drop_objection(this);
uvm_info($1, "$2 finished, objection dropped ", $3)
snippet force
for(int i = 0;i < ${1:n};i++)begin
uvm_hdl_force($sformatf("${2:abs path}",i),${3:value});
end
snippet release
for(int i = 0;i < ${1:n};i++)begin
uvm_hdl_release($sformatf("${2:abs path}",i));
end
snippet sequence
// Class: $1
//
class ${1:`expand('%:t:r')`} extends ${2:uvm_sequence};
\`uvm_object_utils($1);
// Group: Variables
// Group: Constraints
// Group: Functions
// Constructor: new
function new(string name = "$1");
super.new(name);
endfunction: new
// Task: pre_start
// This task is a user-definable callback that is called before the optional
// execution of <pre_body>.
// extern virtual task pre_start();
// Task: pre_body
// This task is a user-definable callback that is called before the execution
// of <body> ~only~ when the sequence is started with <start>.
// If <start> is called with ~call_pre_post~ set to 0, ~pre_body~ is not called.
// extern virtual task pre_body();
// Task: pre_do
// This task is a user-definable callback task that is called ~on the parent
// sequence~, if any. The sequence has issued a wait_for_grant() call and after
// the sequencer has selected this sequence, and before the item is randomized.
//
// Although pre_do is a task, consuming simulation cycles may result in unexpected
// behavior on the driver.
// extern virtual task pre_do(bit is_item);
// Function: mid_do
// This function is a user-definable callback function that is called after the
// sequence item has been randomized, and just before the item is sent to the
// driver.
// extern virtual function void mid_do(uvm_sequence_item this_item);
// Task: body
// This is the user-defined task where the main sequence code resides.
extern virtual task body();
// Function: post_do
// This function is a user-definable callback function that is called after the
// driver has indicated that it has completed the item, using either this
// item_done or put methods.
// extern virtual function void post_do(uvm_sequence_item this_item);
// Task: post_body
// This task is a user-definable callback task that is called after the execution
// of <body> ~only~ when the sequence is started with <start>.
// If <start> is called with ~call_pre_post~ set to 0, ~post_body~ is not called.
// extern virtual task post_body();
// Task: post_start
// This task is a user-definable callback that is called after the optional
// execution of <post_body>.
// extern virtual task post_start();
$0
endclass: $1
snippet uvm_sequence_with_parameters
// Class: $1
//
class ${1:`expand('%:t:r')`} #(${2:parameters}) extends ${3:uvm_sequence};
typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t;
\`uvm_object_param_utils(this_type_t);
// Group: Variables
// Group: Constraints
// Group: Functions
// Constructor: new
function new(string name = "$1");
super.new(name);
endfunction: new
// Task: pre_start
// This task is a user-definable callback that is called before the optional
// execution of <pre_body>.
// extern virtual task pre_start();
// Task: pre_body
// This task is a user-definable callback that is called before the execution
// of <body> ~only~ when the sequence is started with <start>.
// If <start> is called with ~call_pre_post~ set to 0, ~pre_body~ is not called.
// extern virtual task pre_body();
// Task: pre_do
// This task is a user-definable callback task that is called ~on the parent
// sequence~, if any. The sequence has issued a wait_for_grant() call and after
// the sequencer has selected this sequence, and before the item is randomized.
//
// Although pre_do is a task, consuming simulation cycles may result in unexpected
// behavior on the driver.
// extern virtual task pre_do(bit is_item);
// Function: mid_do
// This function is a user-definable callback function that is called after the
// sequence item has been randomized, and just before the item is sent to the
// driver.
// extern virtual function void mid_do(uvm_sequence_item this_item);
// Task: body
// This is the user-defined task where the main sequence code resides.
extern virtual task body();
// Function: post_do
// This function is a user-definable callback function that is called after the
// driver has indicated that it has completed the item, using either this
// item_done or put methods.
// extern virtual function void post_do(uvm_sequence_item this_item);
// Task: post_body
// This task is a user-definable callback task that is called after the execution
// of <body> ~only~ when the sequence is started with <start>.
// If <start> is called with ~call_pre_post~ set to 0, ~post_body~ is not called.
// extern virtual task post_body();
// Task: post_start
// This task is a user-definable callback that is called after the optional
// execution of <post_body>.
// extern virtual task post_start();
$0
endclass: $1
snippet uvm_sequence_functions
// task ${1:my_class::}pre_start();
// endtask: pre_start
// task pre_body();
// endtask: pre_body
// task pre_do(bit is_item);
// endtask: pre_do
// function void mid_do(uvm_sequence_item this_item);
// endfunction: mid_do
task $1body();
$0
endtask: body
// function void post_do(uvm_sequence_item this_item);
// endfunction: post_do
// task post_body();
// endtask: post_body
// task post_start();
// endtask: post_start
snippet uvm_sequence_item
// Class: $1
//
class ${1:`expand('%:t:r')`} extends ${2:uvm_sequence_item};
typedef $1 this_type_t;
\`uvm_object_utils($1);
// Group: Variables
// Group: Constraints
// Group: Functions
// Constructor: new
function new(string name = "$1");
super.new(name);
endfunction: new
// Function: do_copy
// extern function void do_copy(uvm_object rhs);
// Function: do_compare
// extern function bit do_compare(uvm_object rhs, uvm_comparer comparer);
// Function: convert2string
// extern function string convert2string();
// Function: do_print
// extern function void do_print(uvm_printer printer);
// Function: do_record
// extern function void do_record(uvm_recorder recorder);
// Function: do_pack
// extern function void do_pack();
// Function: do_unpack
// extern function void do_unpack();
$0
endclass: $1
/*----------------------------------------------------------------------------*/
/* Constraints */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Functions */
/*----------------------------------------------------------------------------*/
snippet uvm_sequence_item_with_parameters
// Class: $1
//
class ${1:`expand('%:t:r')`} #(${2:parameters}) extends ${3:uvm_sequence_item};
typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t;
\`uvm_object_param_utils(this_type_t);
// Group: Variables
// Group: Constraints
// Group: Functions
// Constructor: new
function new(string name = "$1");
super.new(name);
endfunction: new
// Function: do_copy
// extern function void do_copy(uvm_object rhs);
// Function: do_compare
// extern function bit do_compare(uvm_object rhs, uvm_comparer comparer);
// Function: convert2string
// extern function string convert2string();
// Function: do_print
// extern function void do_print(uvm_printer printer);
// Function: do_record
// extern function void do_record(uvm_recorder recorder);
// Function: do_pack
// extern function void do_pack();
// Function: do_unpack
// extern function void do_unpack();
$0
endclass: $1
/*----------------------------------------------------------------------------*/
/* Constraints */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Functions */
/*----------------------------------------------------------------------------*/
snippet uvm_sequence_item_do_copy
function void ${1:`expand('%:t:r')`}${2:::}do_copy(uvm_object rhs);
this_type_t rhs_;
if (!\$cast(rhs_, rhs)) begin
\`uvm_error({this.get_name(), ".do_copy()"}, "Cast failed!");
return;
end
// \`uvm_info({this.get_name(), ".do_copy()"}, "Cast succeded.", UVM_HIGH);
/* chain the copy with parent classes */
super.do_copy(rhs);
/* list of local properties to be copied */
// <this.property_name = rhs_.property_name>;
endfunction: do_copy$0
snippet uvm_sequence_item_do_compare
function bit ${1:`expand('%:t:r')`}${2:::}do_compare(uvm_object rhs, uvm_comparer comparer);
this_type_t rhs_;
if (!\$cast(rhs_, rhs)) begin
\`uvm_error({this.get_name(), ".do_compare()"}, "Cast failed!");
return;
end
// \`uvm_info({this.get_name(), ".do_compare()"}, "Cast succeded.", UVM_HIGH);
/* chain the compare with parent classes */
do_compare = super.do_compare(rhs, comparer);
/* list of local properties to be compared: */
do_compare &= (
// <this.property_name == rhs_.property_name> &&
// <this.property_name == rhs_.property_name>
);
endfunction: do_compare$0
snippet uvm_sequence_item_convert2string
function string ${1:`expand('%:t:r')`}${2:::}convert2string();
string s;
/* chain the convert2string with parent classes */
s = super.convert2string();
/* list of local properties to be printed: */
// guide 0---4---8--12--16--20--24--28--32--36--40--44--48--
// s = {s, \$sformatf("property_label : 0x%0h\n", property_name)};
// s = {s, \$sformatf("property_label : %0d\n", property_name)};
return s;
endfunction: convert2string$0
snippet uvm_sequence_item_do_print
function void ${1:`expand('%:t:r')`}${2:::}do_print(uvm_printer printer)
/* chain the print with parent classes */
super.do_print(printer);
/* list of local properties to be printed: */
// printer.print_string("property_label", property_name);
// printer.print_field_int("property_label", property_name, \$bits(property_name), UVM_HEX);
endfunction: do_print$0
snippet uvm_sequence_item_do_record
function void ${1:`expand('%:t:r')`}${2:::}do_record(uvm_recorder recorder);
/* chain the record with parent classes */
super.do_record(recorder);
/* list of local properties to be recorded: */
/* note: use uvm_record_int, uvm_record_string, uvm_record_time, uvm_record_real for known basic types. */
// \`uvm_record_string("property_label", property_name);
// \`uvm_record_int("property_label", property_name, \$bits(property_name), UVM_HEX);
endfunction: do_record$0
snippet uvm_sequence_item_do_pack
function void ${1:`expand('%:t:r')`}${2:::}do_pack(uvm_packer packer);
/* chain the pack with parent classes */
super.do_pack(packer);
/* list of local properties to be packed: */
// note: look up the appropriate macro(s) for your properties!
// \`uvm_pack_int(property_name);
// \`uvm_pack_queue(property_name);
// \`uvm_pack_string(property_name);
endfunction: do_pack$0
snippet uvm_sequence_item_do_unpack
function void ${1:`expand('%:t:r')`}${2:::}do_unpack(uvm_packer packer);
/* chain the unpack with parent classes */
super.do_unpack(packer);
/* list of local properties to be unpacked: */
// note: look up the appropriate macro(s) for your properties!
// \`uvm_unpack_int(property_name);
// \`uvm_unpack_queue(property_name);
// \`uvm_unpack_string(property_name);
endfunction: do_unpack$0