You are on page 1of 2

1. What will be the output for following code ?

(2m)
module test;
reg a = 3;
reg b = 1;
initial begin
repeat (a) begin
a= b + 1;
$display("a=%p,b=%p",a,b);
end
end
initial begin
$monitor("a=%p,b=%p",a,b);
end
endmodule

2. Write a program for following requirement. (5m)


a) Declare two threads which are running parallel.
b) first thread has to get completed after 5ns.
c) Second thread has to get completed after 20ns.
d) simulation has to come out at 0ns from parallel threads and should display time as 0ns.
e) display start and end time for both threads.

3. Write a program for following requirement. (3m)


a) Declare an associative array of string index with int data type.
b) Store elements in associative array.
c) Display each and every element in associative array.

4. What is the difference between while and do while. (1m)

5.Implement code to prove the behaviour of different statements according to the event region,
following statement behaviours are to be covered: Blocking assignments, Non Blocking assignments,
$display, $stobe, $monitor and expect the output.(3m)

6. What will be the output for following code ? (3m)


module fork_example();
initial begin
$display("first ",$time);
#40 $display("second ",$time);
fork
$display("third",$time);
#100 $display(“fourth",$time);
#20 $display("fifth",$time);
begin
#30 $display("sixth",$time);
#40 $display("seven",$time);
end
#40 $display("eight",$time);
join_none
$display("nine ",$time);
#80 $display("ten",$time);
end
endmodule

7. Write a program for following requirement. (3m)


a) Declare an dynamic array as int unsigned arr[][].
b) Create size as 5 and 10.
c) Store unique elements in array.
d) Display the array by using foreach.

8. Write a program for following requirement. (5m)


a) Declare two variables as clk and reset.
b) Write logic for clock generation without using always block.
c) Declare two always blocks in that, block-1 should get triggered according to posedge of clk if
reset equals to 0 and block-2 should get executed at posedge or negedge of reset.
d) use display system task inside both blocks.