Lab on Data structures
1) Declare a data structure for the following requirements:
(i) It should function as a FIFO and LIFO buffer. Don’t use any built in functions.
(ii) Initialize the data structure with 10 elements consisting of both positive and negative
values
(iii) Find the maximum and minimum value in the data structure
(iv) Sort the elements and reverse sort the elements
(v) Separate the positive and negative elements
(vi) Find the element with first index with item ==8
2) Design a memory having a width of 16 bits which is used in network packets. Assign different
values to memory locations 34, 56, 87,100, 200, 300, 500. Display the number of memory
elements. Delete element 87. Display the number of memory elements. Display first & last
element. Find the unique values in the data structure. Shuffle the array elements. Repeat the
same process using any other data structure
3) Declare a data structure for the following requirements:
Add 50 integer values at sparse locations (between 1 to 100)
Check value at index 2 and 45 exists..?
Print the value at first index along with index.
Print the value at last index along with index.
Check the array size.
Delete 5th, 10th and 15th index if they exists
Print array size again.
4) An ALU has the opcodes shown in Table
a. Create a data type of the opcodes: opcode_e
b. Create a variable, opcode, of type opcode_e
c. Loop through all the values of variable opcode every 10ns
d. Instantiate an ALU with one 2-bit input opcode
5) Declare an aggregate data type for the following requirements:
Access the values by the following methods: by name, by place, by type and by default.
6) Declare a 5 by 31 multi dimensional data structure which holds a four state value. The array
needs to be filled with default values. Perform out of bound check for the array and comment on
the output. List the applications of your created data structure.
7) Define a subroutine which holds 3 arguments. 1st argument is device number as an input, 2nd
argument is time (time to get the device ready) as an input and 3rd is the output flag which
indicates the device is ready. Call these 3 times with different device no and time. When any of
the devices is available, resume the other processes.
8) Define a data structure. Allocate the size of 30 locations, assign random values to all. Now
double the arrays size by keeping content of initial 30 locations same as previous. Print content
of each location using foreach as well as for loop .Sort the contents of the array. Display the
maximum and minimum values in the data structure. Copy the contents to another data structure
and check whether contents are equal.
9) Write a verification plan for an Arithmetic Logic Unit (ALU) with
Asynchronous active high input reset, Input clock, 4-bit signed inputs, A and B, 5-bit signed
output C that is registered on the positive edge of input clock. 4 opcodes
– Add: A + B
– Sub: A − B
– Bit-wise invert: A
– Reduction Or: B
10) Predict the output: