Use of a bit from a packed array as a ref to task

Hello,
I have a task that receives a logic as a ref, e.g. :
task MyTask(ref logic ref_input)
I send this task signals from an interface. If the signal is a single bit it works OK, but I cannot use a one bit slice from a packed array as input. i.e. :
interface myInterface
logic myBit;
logic [7:0] myByte;

MyTask(myBit); //works OK
MyTask(MyByte[0]); //causes elaboration error vsim-8465
MyTask(MyByte[0:0]); //also causes elaboration error vsim-8465

My Question is :
How to convert the input MyByte[0] to appropriate expression(without defining another signal and assigning myByte[0] to it) ?
Thanks

In reply to shaygueta:

SystemVerilog does not allow a select of a packed array to be passed by reference. Do you really need pass by reference, or will input or output work for you?

Hi,
Yes, I need to pass it by ref, because the task waits for the signal to change value

In reply to shaygueta:

Can you pass then entire byte by ref to the task, then select the bit inside the task? You can add an extra argument that indicates which bit to select.

In reply to dave_59:

Hi,
No,because what I want is a general task. Sometimes the signal I will send is a single bit, and in other cases it will be a single bit from an array(that can be either packed or unpacked).In such a case, I cannot assume I know the size of the array in advance.
i.e. I might need :
logic myBit;
logic [7:0] myByte;
logic [31:0] myWord;

MyTask(myBit,0); //Argument is the signal
MyTask(MyByte,6); //Argument is bit #6 of the signal
MyTask(MyWord,18); //Argument is bit #18 of the signal

in such a case, what will be the task definition?

In reply to shaygueta:

It would help to have a lot more details about what you are trying to accomplish, otherwise we are going to keep iterating.

You can place your task inside a parametrized class

class MyClass #(int size);
static MyTask(ref logic [size-1:0] signal, int position);
...
endtask

MyClass#($bits(MyBit))::Mytask(MyBit,0);
MyClass#($bits(MyByte))::Mytask(MyByte,6);
MyClass#($bits(MyWord))::Mytask(MyWord,18);

If you only need to be informed about a changing bit, you can create an event, and pass that event to the task

task Mytask(event expr);
  ...
  @expr ...
endtask

fork
  event e;
  @mybit ->e;
  Mytask(e);
join_none
fork
  event e;
  @myByte[6] ->e;
  Mytask(e);
join_none

In reply to shaygueta:

I think you can pass the bit in packet array to a logic type variable first, sort of

logic a;
a = packet_array[0];
#you can also change the data type before you call the task
task MyTask(ref logic a)