# Sbi\_read and fetch\_result return length

**URL:** <https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373>\
**Category:** Bitvis VIP SBI\
**Created:** [July 4, 2023, 4:14pm UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373 "2023-07-04T16:14:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoser519](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/hoser519/32/98_2.png) [@hoser519](https://forum.uvvm.org/u/hoser519)\
**Post date:** [July 4, 2023, 4:14pm UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/1 "2023-07-04T16:14:39Z")

</div>

Perhaps a naive question:  
I am trying to read the result from my SBI VVC with sbi\_read() using the following sequence:

sbi\_read(SBI\_VVCT, 1, x"00", “Reading back value from SBI”, C\_SCOPE);  
await\_completion(SBI\_VVCT, 1, 10 us, “Wait for SBI transaction to complete” );  
v\_cmd\_idx := get\_last\_received\_cmd\_idx(SBI\_VVCT,1);  
fetch\_result(SBI\_VVCT, 1, v\_cmd\_idx, v\_data, “Fetching read-result”);

I have set my SBI VVC with following parameters:

```
i1_sbi_vvc: entity bitvis_vip_sbi.sbi_vvc
generic map(
	GC_INSTANCE_IDX	=> 1,
	GC_ADDR_WIDTH	=> 8,
	GC_DATA_WIDTH	=> 32
)

```

However the compiler (modelsim) is coming with:

(vcom-1272) Length of formal “result” is 32; length of actual is 8.

I thought GC\_DATA\_WIDTH=32 would ensure everything was 32-bit, as far as I can tell from looking at uvvm code, “result” should be what I assigned for GC\_DATA\_WIDTH,

If I try and suppress this error, the simulation fails catastrophically, I should note that using sbi\_check() to do the read works perfectly, what gives?

---

<div class="post-metadata">

**Author:** ![UVVM\_Team](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/uvvm_team/32/102_2.png) [@UVVM\_Team](https://forum.uvvm.org/u/UVVM_Team)\
**Post date:** [July 10, 2023, 2:06pm UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/2 "2023-07-10T14:06:46Z")

</div>

Hi,  
Is it the fetch\_value() command that is failing?  
If so - are you sure v\_data is 32-bit?

Best regards  
The UVVM team

---

<div class="post-metadata">

**Author:** ![hoser519](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/hoser519/32/98_2.png) [@hoser519](https://forum.uvvm.org/u/hoser519)\
**Post date:** [July 10, 2023, 7:33pm UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/3 "2023-07-10T19:33:17Z")

</div>

It is the fetch\_result causing the compilation error. v\_data is of type t\_vvc\_result i.e.

```
 variable v_data : t_vvc_result;

```

According to the definitions in the vvc cmd package t\_vvc\_result is a std\_logic\_vector or length C\_VVC\_CMD\_DATA\_MAX\_LENGTH which is 32 by default, and will be defined to the size  
GC\_DATA\_WIDTH if specified, so I don’t know where the 8 is coming from. If I define v\_data as follows:

```
variable v_data : std_logic_vector(31 downto 0);

```

then it works and there is no error.

---

<div class="post-metadata">

**Author:** ![PeterLouisUller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/peterlouisuller/32/110_2.png) [@PeterLouisUller](https://forum.uvvm.org/u/PeterLouisUller)\
**Post date:** [July 12, 2023, 8:44am UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/4 "2023-07-12T08:44:28Z")

</div>

Hi,  
I will look in to this.  
Could you tell me what version of UVVM you are using?

Best regards,  
Peter

---

<div class="post-metadata">

**Author:** ![PeterLouisUller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/peterlouisuller/32/110_2.png) [@PeterLouisUller](https://forum.uvvm.org/u/PeterLouisUller)\
**Post date:** [July 12, 2023, 9:20am UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/5 "2023-07-12T09:20:11Z")

</div>

Are you using several different VVCs in your test environment?

As t\_vvc\_result is defined differently based on what vvc you are using you could try to hierarchically set the type of v\_result to the sbi subtype of t\_vvc\_result.

So instead of;

```auto
variable v_data : t_vvc_result;

```

try

```auto
variable v_data : bitvis_vip_sbi.vvc_cmd_pkg.t_vvc_result;

```

-Peter

---

<div class="post-metadata">

**Author:** ![hoser519](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/hoser519/32/98_2.png) [@hoser519](https://forum.uvvm.org/u/hoser519)\
**Post date:** [July 12, 2023, 8:29pm UTC](https://forum.uvvm.org/t/sbi-read-and-fetch-result-return-length/373/6 "2023-07-12T20:29:07Z")

</div>

Hi Peter,  
Yes I am using an SPI VVC in my testbench as well. So I tried your suggestion and it works, so it must be using t\_vvc\_result from the other VVC, I will keep that in mind. Thanks for the insight!  
mike
