SV
lbt_dvshare
这个作者很懒,什么都没留下…
展开
-
[SV]如何在class/module/interface共用同一个枚举变量
在UVM ENV中经常会用到枚举变量,往往会在多处使用同一个枚举变量,那怎么实现呢,上干货~~原创 2022-10-23 09:46:24 · 419 阅读 · 1 评论 -
[SV] cross bin 的一种用法
如果定义两个coverpoint a,b,如果cross a和b,假定a中有2个bin,b中有2个bin,cross之后一定只有4个bin吗?不一定。如果a中的bin没有将所有可能的值涵盖完,那么系统会分配默认的bin,那么交叉出来就不止4个bin。1.为什么要设置权重为0?先将需要交叉的两个coverpoint (addr和cmd )中添加“type_option.weight = 0; ”这段代码,表示覆盖率收集时不关心这两个coverpoint的bin。当addr和cmd中设置权重为0时,cr原创 2021-08-06 22:05:59 · 2225 阅读 · 1 评论 -
[SV] ignore_bins 用法
1. 和bins overlapcoverpoint p { bins exp[] = {[1:100]}; ignore_bins ign = {23,45,67};}2. 使用withcovergroup cover_me; x_cp : coverpoint x; y_cp : coverpoint y; x_y_cross: cross x_cp, y_cp { ignore_bins ignore_x_values_higher_than_...原创 2021-07-12 14:54:32 · 2429 阅读 · 0 评论 -
【SV】枚举类型
1.1. 用户自定义类型(typedef)局部typedef定义:只用于设计的特定部分时,typedef的定义可在module或interface中共享typedef定义:当在多个模型中使用时,typedef的定义可在包中进行,module,interface,program block可以通过导入packet子项来使用typedef定义例如:package chip_types; `ifdef TWO_STATE typedef bit dtype_t; //当宏定义TWO_STATE时原创 2020-12-20 15:43:48 · 6195 阅读 · 2 评论 -
[SV] 内嵌约束中local::的用法
在使用内嵌约束randomize()with {CONSTRAINT}时,约束体中的变量名的查找顺序默认是从被随机化对象开始查找,但如果调用randomize()函数局部域中也有同名变量,那就需要使用local::来显式声明该变量来源于外部函数,而非被随机化的对象(在约束中也可用this/super来索引这些变量)local::只表示“域”,并不指代某个句柄,所以也可以用local::this 表示调用randomize()函数的对象句柄。...原创 2020-07-11 10:15:06 · 4786 阅读 · 0 评论 -
[SV] module中如何把delay time作为参数
在testbench中我们经常需要加不同的delay来搭建direct pattern,可以通过plusargs来传递参数。如何实现呢?`timescale 1ns/1fsmodule top ; task automatic delay_fs(longint val); longint idx = 0; while(idx < val)begin #1fs; idx++ end endtask initial begin.原创 2020-06-17 13:30:42 · 985 阅读 · 0 评论 -
[SystemVerilog] cover group在module中的应用
cover group在class中的应用之前文章说过,cover group在class中的应用;在module中如何用呢?module dma_test_top(); covergroup idle_chk_cvg(logic i) @(posedge clk); idle_trans : coverpoint idle_vector[i] { bins idle = (1 => 0 => 1); } endgroup : idl原创 2020-05-29 22:20:28 · 1078 阅读 · 0 评论 -
【SV】$cast的用法
在systemVerilog中经常见到$cast,让我们了解一下。 含义 父类站的高,子类在底下。 从父类向子类的转换称为向下类型转换 (即 child_handle = father_handle,直接这样复制是不行的) 反之则称为向上类型转换(即 father_handle = handle_handle) ...原创 2020-03-28 09:54:26 · 12687 阅读 · 0 评论 -
[SV]动态数组特性
动态数组的特性:bit[7:0] d_array[];d_array = new[4];d_array ={0,1,2,3};d_array = new[10];//原来的四个元素被清空d_array = new[10](d_array);//原来的四个元素还存在function void funcs(); int pos[$] ; // ...原创 2019-11-24 14:53:57 · 2738 阅读 · 0 评论 -
[SV] local const protected
local:只允许类本身访问,需经过类本身的成员进行访问;protected:允许类本身和它的扩展类访问;const:分为两种:全局性、instance性的其中,全局性const:在声明时即赋值,之后不可修改;instace性const:只使用const进行声明,赋值发生在new()中...原创 2019-10-26 09:47:34 · 1693 阅读 · 0 评论 -
[SV]动态数组的大小
如何获取动态数组的大小呢?bit[7:0] b_array[];b_array = new[2];$size(b_array,1) 代表数组中元素的个数,此时为2b_array.size()代表数组中元素的个数$size(b_array,2) 代表数组元素的位宽,此时为8动态数组分配空间有以下两种方式bit[7:0] b_array[];b_array[0] = ...原创 2019-10-15 19:32:35 · 5031 阅读 · 0 评论 -
[SV]Constraint 遇到的问题
constraint con{ delay dist {0:/10};}上述写法可能导致constraint很难解,不要用上述写法。2. 对与求和的约束的写法(防止和溢出)bd_len_q.sum with(int'(item)) == 203. 数组元素不重复class A; rand bit [31:0] arr[]; constraint a...原创 2019-09-29 11:37:55 · 6122 阅读 · 0 评论 -
【SV】fork join_none的生命周期
遇到如下场景://seqfor(int ii=0;ii<10;ii++)begin fork automatic int jj=ii; `uvm_do_with(src_seq[jj],{id == jj;}) join_noneendwait(cfg.src_done == glb_cfg.src_en);#200ns;对于上述fork jo...原创 2019-09-19 14:35:33 · 771 阅读 · 0 评论 -
[SV]FSM
//gen vldforever begin @(my_if.tx_cb or negedge my_if.rst_n); if(!my_if.rst_n) my_if.tx_cb.rate_cnt <=0; else my_if.tx_cb.rate_cnt <= my_if.tx_cb.rate_cnt +1; my_if.tx_...原创 2019-08-01 16:58:03 · 161 阅读 · 0 评论 -
【SystemVerilog】define 編譯問題
在top_define.svh中定義了一種枚舉類型在top_define.svh中`ifndef TOP_DEFINE__SVH`define TOP_DEFINE__SVHtypedef enum bit[2:0] {TOP_HIB,TOP_BG,TOP_GS} FSM_STATE;typedef struct {bit[63:0] data; bit[7:0] ctrl} TR...原创 2019-05-22 19:11:03 · 556 阅读 · 0 评论 -
[SystemVerilog] signal bitwidth
常写a[MSB:LSB] 这里的MSB和LSB都要求是常数(或常数表达式)而如果写a[BASE -: WIDTH]或a[BASE +: WIDTH]则允许BASE改变(但WIDTH仍需为常数)Ex: data[ii +:1] 等价于data[ii+1:ii]...原创 2018-08-06 19:58:08 · 311 阅读 · 0 评论 -
【SystemVerilog】modport
A modport is like a sub-interface to an interface connection. Without modports, interface connections have universal access to all things defined in interface. Modports define a subset of signals for ...原创 2019-02-28 11:39:38 · 1925 阅读 · 0 评论 -
[SystemVerilog] read/write memory
最近看到AXI slave vip memory,记录下如何backdoor读写memory.define`MEM_MAX_DATA_WIDTH (64)define`MEM_MAX_ADDR_WIDTH (20)ps: define 记得加上括号。========================================================...原创 2019-03-02 11:41:36 · 2255 阅读 · 0 评论 -
【SystemVerilog】define的一种用法
今天有用到define的一种用法,在这share一下,直接上例子~~module top ; `define A_SRAM_RW(dst_cc_num,src_cc_num)\ if(strm_sel[``dst_cc_num``] == 1'b1)begin\ force top.my_dut.strm_in``dst_cc_num``_en = top...原创 2018-09-10 13:08:13 · 10952 阅读 · 0 评论 -
[SystemVerilog]Write log in file
在simulation时把指定内容写入特定文件中,方便debug~~integer log_file;log_file = $fopen($sformatf(“sram%0d_buffer.log”,cc_id),”a+”);$fwrite(log_file,”%0t”,$realtime);$fclose(log_file);...原创 2018-08-06 20:03:33 · 1650 阅读 · 0 评论 -
[SystemVerilog] interface array configuration
最近用到interface array,了解到可以用generate 来产生,而不需要一个一个来写,不多说,直接上code~~bit ck[`IF_NUM];generate for(genvar ii=0;ii&amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;`IF_NUM;ii++)begin:if_loop clk_if ck_vif(.clk(ck[ii])); initial begin ...原创 2018-08-06 19:17:50 · 2372 阅读 · 0 评论 -
[SystemVerilog] disable label and disable fork
The disable fork statement differs from disable in that disable fork considers the dynamic parent-child relationship of the processes, whereas disable uses the static, syntactical information of th...原创 2018-08-01 11:20:49 · 2600 阅读 · 6 评论 -
[SystemVerilog] fork join_none
SV中用的比较多的是fork…join_none,以及disable fork,wait fork; 其中,wait_fork会阻止当前线程,直到所有子线程完成; disable fork会kill disable fork 所在的当前线程以及所有子线程; The parent process continues to execute concurrently with all the...原创 2018-07-27 14:11:37 · 3802 阅读 · 0 评论 -
[SystemVerilog] clocking block
clocking blockcb input sample 采样受 #(input skew)控制,如果#nstep(n&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;0),采样的是前n个step的postpone区;如果#0,则是在本timestep的observed region进行采样。在active区会判断@(event),如果有@(edge)这样的事件,就会准备规划后面的cb内变量采样和驱动事件,这里只是一个触原创 2018-07-20 13:16:51 · 8045 阅读 · 0 评论 -
【systemverilog】 variable Scope and lifetime
Variables declared outside a module, program, interface, checker, task, or function are local to the compilation unit and have a static lifetime (exist for the whole simulation).Variables declared ...原创 2018-07-15 18:10:32 · 541 阅读 · 0 评论 -
【SystemVerilog】Fine-grain process control
A process is a built-in class that allows one process to access and control another process once it has started.Users can declare variables of type process and safely pass them through tasks or incor...原创 2018-07-06 16:17:08 · 477 阅读 · 0 评论 -
[systemverilog] cover group在class中的应用
Q:class cg ;int skew_val_vl[20]; covergroup skew_val_cg (int skew_val_vl);coverpoint skew_val_vl {bins skew_range_1 ={[124:0]};bins skew_range_2 ={[325:125]};bi...原创 2018-06-06 15:03:12 · 3849 阅读 · 5 评论 -
[systemverilog] dynamic array constraint
randintsome_dynamic_array[];randint unsignedSECOND_dynamic_array [];randlogic size_5_15; //decide the size of the array//constraint the value of the last element of arrayconstraint ...原创 2018-06-06 14:11:40 · 665 阅读 · 0 评论 -
【systemverilog】对小数的处理
在sv/verilog中,我们常用的是整数(int, longint),小数可以用(real),对小数的处理大致分为三种:1. 四舍五入2. 向上取整3. 向下取整这三种如何实现呢?1.四舍五入 如果除数和被除数均为整数,可以通过乘以1.0来实现 i.e. 164*8*1.0/28 =472. 向上取整 通过系统函数$ceil...原创 2018-07-10 09:58:50 · 25385 阅读 · 4 评论 -
【SystemVerilog】coverage options
今天複習到coverage的相關寫法,翻到LRM進行查閱,發現自己之前做過筆記,但時間已久就忘了,現在把他記錄一下方便自己查閱。coverage有兩大類option: 一類是針對每個covergroup instance的(即每個instance可以單獨指定),一類是針對covergroup type的(即每個covergroup指定);類似于class 中 靜態變量和local 變量,靜...原创 2019-01-12 12:01:43 · 3406 阅读 · 0 评论