简体   繁体   中英

Specman UVM: What is the difference between write_reg { .field == 2;}; and write_reg_fields?

I'm working with vr_ad package for e. My question is: What is the difference between 2 following macros for modifying registers (suppose foo register consists of 2 fields: field1 and field2 ):

1)

write_reg foo {.field1 == 1;};

2)

write_reg_fields foo {.field1 = 1};

I really appreciate any help

There is a very important difference between these forms.

In the first, the register value will be generated, using all defined constraints, + the constraint you wrote in this action (field1 == 1). The new generated value will be written to the DUT.

In the second code, what you state is that you want to modify only one field of the register - field1. What will happen is that vr_ad will get the current value of the register from the e model (the shadow model), change field1 - and will write the new value the the register in the DUT. None of the other register's fields will be changed. Also - there is no check that the value you assign to field1 complies with the constraints defined on this register.

Lets use it like an example:

foo = 0xA8;
field1 = 0x8;
field2 = 0xA;
  1. will write a totally new value in foo and in RTL, and that value(using your example above where field1 == 1) will be 0x01;

  2. will change only that filed you constrained and value of foo in this case will be 0xA1;

But except that I wanted to say that in fist example you could also get the same result by doing following:

var tem_read_val: uint(bits: 8);
read_reg foo TO tem_read_val;
tem_read_val[3:0] = field1;
write_reg foo read_reg;

=> foo is 0xA1;

From the beginning I was not aware of write reg filds, so I had to use something like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM