Reverse an Array
Problem Description
Write a SystemVerilog function to reverse the elements of an input array
The function should take an integer array as input and return a new array containing the elements in reverse order.
Requirements
The input array should not be modified.
The output array size should be the same as the input array size.
The solution should work for arrays of any size.
Handle empty arrays as well.
Examples
Example 1
Input:
'{1, 2, 3, 4, 5}
Output:
'{5, 4, 3, 2, 1}
Example 2
Input:
'{10, 20, 30}
Output:
'{30, 20, 10}
Example 3
Input:
'{100}
Output:
'{100}
Example 4
Input:
'{}
Output:
'{}
SystemVerilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
Output
Output goes here...
