# How to read data back in the sequencer from VVC component

**URL:** <https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99>\
**Category:** VVC Framework\
**Tags:** uvvm, question\
**Created:** [September 25, 2020, 6:33am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99 "2020-09-25T06:33:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 25, 2020, 6:33am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/1 "2020-09-25T06:33:10Z")

</div>

Hi,  
I was trying to implement a simple UVVM environment for my DUT where I am able to drive the data from the sequencer to the VVC component successfully,

But when i am trying to read the data back from the VVC component to the sequencer i am facing some issue in doing that

I don’t have any compilation issues when i am doing that

can someone help me where am i doing the mistake?

Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 25, 2020, 7:27am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/2 "2020-09-25T07:27:45Z")

</div>

Hi Riyaz,

What kind of issue are you having and which VVC are you using?

Best regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 25, 2020, 7:42am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/3 "2020-09-25T07:42:32Z")

</div>

Hi Erick,

i am not able to read the data back to sequencer maybe a connection issue or maybe I might have missed some thing not sure

I actually tried to attach the snapshots, don’t know why I cant do that it is not accepting it

Best Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 25, 2020, 7:54am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/4 "2020-09-25T07:54:58Z")

</div>

Here is an example of how to do a read operation in the SBI VVC (taken from the VVC Quick Reference):

> variable v\_cmd\_idx : natural; – Command index for the last read  
> variable v\_data : work.vvc\_cmd\_pkg.t\_vvc\_result; – Result from read.  
> (…)  
> sbi\_read(SBI\_VVCT, 1, C\_ADDR\_UART\_BAUDRATE, “Read from Peripheral 1”);  
> v\_cmd\_idx := get\_last\_received\_cmd\_idx(SBI\_VVCT, 1);  
> await\_completion(SBI\_VVCT,1, v\_cmd\_idx, 1 us, “Wait for read to finish”);  
> fetch\_result(SBI\_VVCT,1, v\_cmd\_idx, v\_data, “Fetching result from read operation”);

Remember that when you do a read or receive operation in a VVC you need to wait until the command has completed (await\_completion) and you need to fetch the data from the VVC.

Best Regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 25, 2020, 8:05am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/5 "2020-09-25T08:05:45Z")

</div>

Is there any possibility that I can contact you to explain my issue and some inputs for that

I feel like I need some more info regarding this

It will be helpful if you do this 🙂

Best Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 25, 2020, 8:13am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/6 "2020-09-25T08:13:20Z")

</div>

You could try copying the part of the testbench code that you are using to read the data from the VVC so I can understand better what the issue is. Otherwise, you can send an email to support@bitvis.no explaining your issue if you prefer.

Best regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 25, 2020, 8:21am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/7 "2020-09-25T08:21:46Z")

</div>

p\_main: process  
– variable v\_ready : std\_logic ;  
– variable v\_done : std\_logic;  
variable v\_result : std\_logic\_vector(15 downto 0);  
begin  
wait for 50 ns;  
alu\_write(ALU\_INTF\_VVCT,1,“00000011”,“00000010”,“001”,‘1’,“ALU\_INTF\_WRITE”, C\_SCOPE);  
alu\_read(ALU\_INTF\_VVCT,1,v\_result,“input data result”, C\_SCOPE);  
await\_completion(ALU\_INTF\_VVCT,1,100 ns, “wait till finish”);  
wait for 100 ns;  
alu\_write(ALU\_INTF\_VVCT,1,“00000111”,“00000101”,“010”,‘1’,“ALU\_INTF\_WRITE”, C\_SCOPE);  
alu\_read(ALU\_INTF\_VVCT,1,v\_result,“input data result”, C\_SCOPE);  
await\_completion(ALU\_INTF\_VVCT,1,100 ns, “wait till finish”);  
wait for 100 ns;  
alu\_write(ALU\_INTF\_VVCT,1,“00000111”,“00000101”,“011”,‘1’,“ALU\_INTF\_WRITE”, C\_SCOPE);  
alu\_read(ALU\_INTF\_VVCT,1,v\_result,“input data result”, C\_SCOPE);  
await\_completion(ALU\_INTF\_VVCT,1,100 ns, “wait till finish”);  
wait for 100 ns;  
alu\_write(ALU\_INTF\_VVCT,1,“00001010”,“00000010”,“100”,‘1’,“ALU\_INTF\_WRITE”, C\_SCOPE);  
alu\_read(ALU\_INTF\_VVCT,1,v\_result,“input data result”, C\_SCOPE);  
await\_completion(ALU\_INTF\_VVCT,1,100 ns, “wait till finish”);

this is what I was trying to do in my test sequencer

procedure alu\_intf\_read(  
variable data\_value : out std\_logic\_vector;  
constant msg : in string;  
signal clk : in std\_logic;  
signal alu\_intf\_if : inout t\_alu\_intf\_if;  
constant scope : in string := C\_SCOPE;  
constant msg\_id\_panel : in t\_msg\_id\_panel := shared\_msg\_id\_panel;  
constant config : in t\_alu\_intf\_bfm\_config := C\_ALU\_INTF\_BFM\_CONFIG\_DEFAULT  
) is

```
begin

-- wait until alu_intf_if.done = '1';
data_value := alu_intf_if.rslt;

end procedure;

```

this is in bfm package  
procedure alu\_read(  
signal VVCT : inout t\_vvc\_target\_record;  
constant vvc\_instance\_idx : in integer;  
variable data\_out : out std\_logic\_vector;  
constant msg : in string;  
constant scope : in string := C\_VVC\_CMD\_SCOPE\_DEFAULT  
) is  
constant proc\_name : string := “alu\_read”;  
constant proc\_call : string := proc\_name & “(” & to\_string(VVCT, vvc\_instance\_idx) – First part common for all  
& ", " & to\_string(data\_out) & “)”;  
variable v\_msg\_id\_panel : t\_msg\_id\_panel := shared\_msg\_id\_panel;  
begin  
– Create command by setting common global ‘VVCT’ signal record and dedicated VVC ‘shared\_vvc\_cmd’ record  
– locking semaphore in set\_general\_target\_and\_command\_fields to gain exclusive right to VVCT and shared\_vvc\_cmd  
– semaphore gets unlocked in await\_cmd\_from\_sequencer of the targeted VVC  
set\_general\_target\_and\_command\_fields(VVCT, vvc\_instance\_idx, proc\_call, msg, QUEUED, ALU\_INTF\_READ);  
shared\_vvc\_cmd.operation := ALU\_INTF\_READ;  
data\_out := shared\_vvc\_cmd.rslt;  
– data\_out := shared\_vvc\_response.result;

```
-- shared_vvc_cmd.parent_msg_id_panel := parent_msg_id_panel;
-- if parent_msg_id_panel /= C_UNUSED_MSG_ID_PANEL then
  -- v_msg_id_panel := parent_msg_id_panel;
-- end if;
send_command_to_vvc(VVCT, std.env.resolution_limit, scope, v_msg_id_panel);

```

end procedure;

this is in the methods package

```
      when ALU_INTF_READ =>
     -- Call the corresponding procedure in the BFM package.
        alu_intf_read(data_value => v_result,
                      msg => format_msg(v_cmd),
                      clk => clk,
                      alu_intf_if => alu_intf_vvc_if,
                      scope => C_SCOPE,
                      msg_id_panel => v_msg_id_panel,
                      config => vvc_config.bfm_config);

```

this is an instantiation of bfm i had done in my VVC

Best Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 25, 2020, 9:29am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/8 "2020-09-25T09:29:10Z")

</div>

I think the problem is in the **alu\_read()** procedure in the methods\_pkg.  
You are assigning the **shared\_vvc\_cmd.rslt** to **data\_out**. However at this moment the BFM procedure **alu\_intf\_read()** hasn’t been executed, as this only happens after the **send\_command\_to\_vvc()**. Also **shared\_vvc\_cmd** is reset at the beginning of the procedure with set\_general\_target\_and\_command\_fields(), therefore this shared variable will never have the read data and is only meant to be used to transmit data **towards** the VVC.

The correct way of doing this would be to use the fetch procedure which should be in your VVC if you used the vvc\_generator.py script.

This is the standard way of reading data from a VVC since the procedure calls are non-time consuming (from the test sequencer) so any read data has to be stored in a queue inside the VVC. This is the code in the VVC that does that:

> work.td\_vvc\_entity\_support\_pkg.store\_result(result\_queue =\> result\_queue,  
> cmd\_idx =\> v\_cmd.cmd\_idx,  
> result =\> v\_result);

So from your test sequencer you can use the following commands:

> alu\_write(ALU\_INTF\_VVCT,1,“00000011”,“00000010”,“001”,‘1’,“ALU\_INTF\_WRITE”, C\_SCOPE);  
> alu\_read(ALU\_INTF\_VVCT,1,“input data result”, C\_SCOPE);  
> v\_cmd\_idx := get\_last\_received\_cmd\_idx(ALU\_INTF\_VVCT, 1);  
> await\_completion(ALU\_INTF\_VVCT,1,100 ns, “wait till finish”); – this waits for all VVC cmds to finish  
> fetch\_result(ALU\_INTF\_VVCT,1, v\_cmd\_idx, v\_result, “Fetching result from read operation”);

You could of course make an overload procedure if you want to avoid repeating some of the commands.  
I hope this helps.

Best Regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 25, 2020, 12:11pm UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/9 "2020-09-25T12:11:59Z")

</div>

It is working now when I added those lines into my test sequencer

I have one more question here if you have some signals which will come out as output to tell the status how can I read it like how you are reading the result

because  
work.td\_vvc\_entity\_support\_pkg.store\_result(result\_queue =\> result\_queue,  
cmd\_idx =\> v\_cmd.cmd\_idx,  
result =\> v\_result);  
this store result will store only one result

can you explain this doubt also?

Best Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 25, 2020, 5:21pm UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/10 "2020-09-25T17:21:17Z")

</div>

If you want to read more than one signal, i.e. status signals, from your **alu\_intf\_read()** procedure, then you can just add the output signals to the procedure and change the **t\_vvc\_result** subtype in **vvc\_cmd\_pkg.vhd** to use a record type with those signals, so that you can store the signals in the result\_queue.

Best Regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Riyazria](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Riyazria](https://forum.uvvm.org/u/Riyazria)\
**Post date:** [September 28, 2020, 9:46am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/11 "2020-09-28T09:46:26Z")

</div>

Hi Erick,

when i drive one set of data my output will take 60 ns of time to come out and after that a ready signal will generate which indicate that the next set of data can be driven

when I do the same thing of setting the delay to 80 ns my TB is not working it is throwing an error

this is first set of stimuli

```auto
alu_write(ALU_INTF_VVCT,1,"00000011","00000010","001",'1',"ALU_INTF_WRITE", C_SCOPE);
alu_read(ALU_INTF_VVCT,1,"input data result", C_SCOPE);
v_cmd_idx := get_last_received_cmd_idx(ALU_INTF_VVCT, 1);
await_completion(ALU_INTF_VVCT,1,80 ns); -- this waits for all VVC cmds to finish
fetch_result(ALU_INTF_VVCT,1, v_cmd_idx, v_result, "Fetching result from read operation");
wait for 80 ns;

```

this is second set of stimuli

```auto
alu_write(ALU_INTF_VVCT,1,"00000111","00000101","010",'1',"ALU_INTF_WRITE", C_SCOPE);
alu_read(ALU_INTF_VVCT,1,"input data result", C_SCOPE);
v_cmd_idx := get_last_received_cmd_idx(ALU_INTF_VVCT, 1);
await_completion(ALU_INTF_VVCT,1,80 ns);
fetch_result(ALU_INTF_VVCT,1, v_cmd_idx, v_result, "Fetching result from read operation");
wait for 80 ns;

```

error is like time out for uvvm cmd : await\_completion(ALU\_INTF\_VVCT,1,80 ns); while waiting for acknowledge from VVC

can you tell what is the reason for this error

Best Regards,  
Riyaz

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [September 29, 2020, 6:14am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/12 "2020-09-29T06:14:01Z")

</div>

Hi Riyaz,

The error **await\_completion(ALU\_INTF\_VVCT,1,80 ns); while waiting for acknowledge from VVC** means that the VVC is still busy executing a command, so probably the DUT is hasn’t finished doing what it’s supposed to. Try extending the timeout in await\_completion().

Best Regards,  
Erick

---

<div class="post-metadata">

**Author:** ![Erick](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Erick](https://forum.uvvm.org/u/Erick)\
**Post date:** [October 1, 2020, 5:59am UTC](https://forum.uvvm.org/t/how-to-read-data-back-in-the-sequencer-from-vvc-component/99/13 "2020-10-01T05:59:25Z")

</div>

Split this topic on October 1, 2020, 5:59am UTC

A post was split to a new topic: [Randomization seed](https://forum.uvvm.org/t/randomization-seed/106)
