# \#functions-in-system-verilog

**URL:** https://verificationacademy.com/forums/tag/functions-in-system-verilog/5135.md

[Latest](https://verificationacademy.com/forums/latest.md) · [Categories](https://verificationacademy.com/forums/categories.md) · [Tags](https://verificationacademy.com/forums/tags.md)

---

## [How can a task return a Queue?](https://verificationacademy.com/forums/t/how-can-a-task-return-a-queue/30629)

<div class="topic-metadata">

**Author:** [@szy0014](https://verificationacademy.com/forums/u/szy0014)\
**Replies:** 9\
**Last updated:** [November 26, 2024, 8:09am UTC](https://verificationacademy.com/forums/t/how-can-a-task-return-a-queue/30629 "2024-11-26T08:09:18Z")

</div>

I need a task to return a queue. How can I do this ? I was able to do this using a function in the following way typedef bit array\_type\[$\] function array\_type my\_function(); … … return queue\_of\_elements; endfunctio…

---

## [Why extern forkjoin function won't work in interface?](https://verificationacademy.com/forums/t/why-extern-forkjoin-function-wont-work-in-interface/38744)

<div class="topic-metadata">

**Author:** [@sasi\_8985](https://verificationacademy.com/forums/u/sasi_8985)\
**Replies:** 1\
**Last updated:** [February 23, 2021, 11:16pm UTC](https://verificationacademy.com/forums/t/why-extern-forkjoin-function-wont-work-in-interface/38744 "2021-02-23T23:16:45Z")

</div>

Hi all, In interfaces, we know that we can export multiple tasks from different instances of the same module. But I couldn’t understand why we can’t export function similarly. reference LRM-25.7.4 Thank you.

---

## [Unspecified size array as return type of a function](https://verificationacademy.com/forums/t/unspecified-size-array-as-return-type-of-a-function/35810)

<div class="topic-metadata">

**Author:** [@Yasmine4](https://verificationacademy.com/forums/u/Yasmine4)\
**Replies:** 2\
**Last updated:** [March 7, 2019, 9:02am UTC](https://verificationacademy.com/forums/t/unspecified-size-array-as-return-type-of-a-function/35810 "2019-03-07T09:02:36Z")

</div>

Hello everyone, VHDL has this possibility to declare and use functions which have, as return type,unsized std\_logic\_vector, something that would look like this: function myWeirdFunction(param1, param2, param3: std\_ulo…

---

## [Function arguments not initializing variable inside the body](https://verificationacademy.com/forums/t/function-arguments-not-initializing-variable-inside-the-body/31889)

<div class="topic-metadata">

**Author:** [@sanjeevs](https://verificationacademy.com/forums/u/sanjeevs)\
**Replies:** 3\
**Last updated:** [March 7, 2019, 7:57am UTC](https://verificationacademy.com/forums/t/function-arguments-not-initializing-variable-inside-the-body/31889 "2019-03-07T07:57:34Z")

</div>

Not sure why the following code is not working. (Pasted below) =================FAILING============================================= module test; function int divide(int dividend, int divisor); int i = dividend …

---

## [Static method](https://verificationacademy.com/forums/t/static-method/34895)

<div class="topic-metadata">

**Author:** [@abhishek403](https://verificationacademy.com/forums/u/abhishek403)\
**Replies:** 3\
**Last updated:** [August 21, 2018, 4:33pm UTC](https://verificationacademy.com/forums/t/static-method/34895 "2018-08-21T16:33:50Z")

</div>

class Class1; static int value; function inc(); value++; $display("value=%d",value); endfunction endclass module example; Class1 c1; Class1 c2; initial begin c1.value=2; c1.inc; c1.inc; c2.inc; …

---

## [Are functions essentially atomic?](https://verificationacademy.com/forums/t/are-functions-essentially-atomic/34589)

<div class="topic-metadata">

**Author:** [@jimmyhuang0904](https://verificationacademy.com/forums/u/jimmyhuang0904)\
**Replies:** 1\
**Last updated:** [June 19, 2018, 10:52pm UTC](https://verificationacademy.com/forums/t/are-functions-essentially-atomic/34589 "2018-06-19T22:52:04Z")

</div>

I read that a function must execute in one simulation time unit. Does that mean that functions are essentially atomic and I would not have to handle any race conditions? For example, if I had fork begin my\_funct…

---

## [Function call; fields of the object have junk value](https://verificationacademy.com/forums/t/function-call-fields-of-the-object-have-junk-value/33953)

<div class="topic-metadata">

**Author:** [@VerifEngg](https://verificationacademy.com/forums/u/VerifEngg)\
**Replies:** 5\
**Last updated:** [January 22, 2018, 5:56pm UTC](https://verificationacademy.com/forums/t/function-call-fields-of-the-object-have-junk-value/33953 "2018-01-22T17:56:32Z")

</div>

Hello, I have the following code: class Packet extends uvm\_object; \`uvm\_object\_utils(Packet) bit\[7:0\] opcode; endclass module TB; function void B(); Packet temp\_pkt; temp\_pkt = new(); temp\_…

---

## [Range width must be constant expression](https://verificationacademy.com/forums/t/range-width-must-be-constant-expression/32664)

<div class="topic-metadata">

**Author:** [@saritr](https://verificationacademy.com/forums/u/saritr)\
**Replies:** 1\
**Last updated:** [December 22, 2016, 2:11pm UTC](https://verificationacademy.com/forums/t/range-width-must-be-constant-expression/32664 "2016-12-22T14:11:38Z")

</div>

I have the following function: function void foo\_array\_vec\_bit (int seed, inout bit \[31:0\] q \[$\], input string mem\_name, int\_type curr\_int\_type, int arr\_size, const ref int vec\_bit\_size); bit \[31:0\] temp; …

---

## [Can I use .o files of compiled c files and use that to compile SV files for DPI](https://verificationacademy.com/forums/t/can-i-use-o-files-of-compiled-c-files-and-use-that-to-compile-sv-files-for-dpi/30946)

<div class="topic-metadata">

**Author:** [@Ankit\_Patel](https://verificationacademy.com/forums/u/Ankit_Patel)\
**Replies:** 10\
**Last updated:** [August 13, 2015, 2:49pm UTC](https://verificationacademy.com/forums/t/can-i-use-o-files-of-compiled-c-files-and-use-that-to-compile-sv-files-for-dpi/30946 "2015-08-13T14:49:53Z")

</div>

I have created one QT based C application. It takes few inputs from GUI and based on that input I need to call SystemVerilog function. I checked examples of DPI but for that I need to compile .c files with .sv file. So …

---

## [Parameters in System Verilog](https://verificationacademy.com/forums/t/parameters-in-system-verilog/30487)

<div class="topic-metadata">

**Author:** [@Mangalji](https://verificationacademy.com/forums/u/Mangalji)\
**Replies:** 4\
**Last updated:** [April 25, 2015, 5:05am UTC](https://verificationacademy.com/forums/t/parameters-in-system-verilog/30487 "2015-04-25T05:05:56Z")

</div>

Hello, I am using following code. \*\*module #(parameter FDEPTH=10)(…) … out=f1(FIFO); endmodule function bit \[32:0\] f1 (ref bit \[31:0\] FIFO \[FDEPTH\]) … endfunction\*\* but it is showing me an error that identifier…
