0

in UVM e Reference document is written:

You can call read_reg_field or write_reg_field for registers whose fields
are defined as single_field_access (see “vr_ad_port_unit Syntax and Examples”).
...
For example:
write_reg_fields tx_mode_reg {.resv = 4; .dest = 2};

But there is no example for using read_reg_field... Could you please explain how should it be used?

(I've tried the next code, but it gives compilation error: some_var = read_reg_field my_reg_file.my_reg {.my_reg_field} ) Thank you for your help.

Halona
  • 1,475
  • 1
  • 15
  • 26
  • I'm not sure what version of the UVM e reference you're quoting, but something seems off. You mention `write_reg_field`, but then the example shows `write_reg_fields`, which is a different macro. – Tudor Timi Oct 28 '14 at 16:42
  • 1
    Hi, you're right - it seems to me like a typo in the reference. The reference I'm using:Product Version 13.2 UVM World Version 1.1 January 2014 – Halona Oct 28 '14 at 16:46
  • So, as far as I know there isn't any `read_reg` fields macro. There's also none defined in `vr_ad_macro.e`. – Tudor Timi Oct 28 '14 at 16:48

2 Answers2

1

As far as I know there is no read_reg_fieds macro. If you want to do a read to a register and then save the value of a certain field, do this:

read_reg my_reg;
value = my_reg.my_reg_field;

Normally, when you read register, you read them completely. Reading only individual fields makes sense if your bus protocol allows narrow transfers (i.e. your data width is 32 bits, but you can do 16 bit transfers on it). I haven't seen such a thing implemented in vr_ad (could be there and I just don't know of it), but UVM RAL (the SystemVerilog register package) supports it.

Long story short, if you just care about getting your data from your DUT, using read_reg is enough.

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53
1

When the Design Under Test is implemented in verilog or vhdl - you can read the register as a whole, you cannot "read just some of its fields".

A register is at a specific address, reading this register -> read from this address.

The quote of the spec about fields access is when the DUT is a SystemC model.

Connecting to SC models is done using ports. If the model defines a port for each field - you can read a field.

user3467290
  • 706
  • 3
  • 4
  • I don't entirely agree with this. Let's say that you have 32 bit wide registers. This means the addresses of the registers are multiples of 4. If you had a register at offset 0 composed of four 1 byte fields, then you could very well just read offset 1 to get `field1` (provided the underlying bus protocol allows this). – Tudor Timi Oct 29 '14 at 13:36