0% found this document useful (0 votes)
2 views5 pages

EITRA IPC Assignment

The document outlines an inter-process communication exercise involving various tasks such as waiting for signals, sampling data, and managing memory access between two controllers. It includes code snippets that demonstrate the use of threads, events, and semaphores, along with expected outputs and modifications needed to achieve desired behaviors. The exercise emphasizes understanding synchronization and communication in a concurrent programming environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

EITRA IPC Assignment

The document outlines an inter-process communication exercise involving various tasks such as waiting for signals, sampling data, and managing memory access between two controllers. It includes code snippets that demonstrate the use of threads, events, and semaphores, along with expected outputs and modifications needed to achieve desired behaviors. The exercise emphasizes understanding synchronization and communication in a concurrent programming environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Inter-process Communication Exercise

1. Write a logic that will wait for AWVALID to be asserted and remains
same until AWREADY asserts. Shout a protocol violation error if
AWREADY does not asserts in 20 clock cycles.
2. Write a logic to sample WDATA, WVALID and WLAST; Samples
AWVALID and AWADDR and send it to another component using
mailbox once address and data both are sampled.
3. As given below in figure, Two controllers are connected to same
memory.

Controller 1 Controller 2

Bounded
mailbox

Memory

Both are trying to access the memory at the same time. (Parallel
threads). Use a semaphore to regularized the memory operation
and allow only one controller at a time.
4. List the output of below code:

module fork_join_none();
initial begin
for (int i = 0;i < 5;i++) begin
fork
thread(i); // here thread is any subroutine ,which display the value of i.
join_none
end
wait fork;
end

task thread(int idx);


$display("Thread is invoked with index : %0d", idx);
endtask
endmodule: fork_join_none

Page 1 of 5
Here, thread is expected to be called with all indexes (0 to 4). Do
necessary changes in code to serve the purpose.
5. States the output of below code:

module top();
initial begin
fork
begin
// Extra logic
thread1();
end
begin
// Extra logic
thread2();
end
join_any
$display(“Anyone of the thread 1 or 2 is completed”);

fork
begin
// Extra logic
thread3();
end
begin
// Extra logic
thread4();
end
join_any
$display(“Anyone of the thread 3 or 4 is completed”);
disable fork;
$display(“Remaining thread should be killed from 3 and 4”);
#50;
end

task thread1();
#5;
$display(“thread 1 is completed”);
endtask

task thread2();
#35;
$display(“thread 2 is completed”);
endtask

task thread3();
#10;
$display(“thread 3 is completed”);
endtask

task thread4();
#20;
$display(“thread 4 is completed”);
endtask
endmodule

Page 2 of 5
Here, Expected that, Disable fork should not disable any of thead1
or thread2, it should run in background. Change your code to serve
the purpose.
6. Use disable label is prohibited in exercise 5 and serve the purpose.
7. States the output of below code:
class signal_monitor;
bit intr;
string type_name;

function new(string name = "signal_monitor");


type_name = name;
endfunction

task run();
fork : l1
begin
wait(intr == 1);
$display("%0s : intrrupt is asserted", type_name);
end
begin
#10;
$error("%0s : intrrupt is not asserted in 10 time steps",type_name);
end
join
disable l1;
$display("%0s disable l1 is called",type_name);
endtask
endclass

module tb_top;
signal_monitor mon1, mon2;

initial begin
mon1 = new("mon1");
mon2 = new("mon2");
fork
begin
mon1.run();
end
begin
mon2.run();
end
join_none
#4;
mon1.intr = 1;
#100;
$finish;
end
endmodule

Here, fork should be disabled for mon1 only. If it disables for


mon2 as well, then do the necessary changes in code to serve the
purpose.

Page 3 of 5
8. States the output of following codes and list the difference:
A.
module tb_top;
event e;
initial begin
fork
begin // Process 1
#3;
->e;
$display("%0t, Event triggered",$time);
end
begin // Process 2
#2; @e;
$display("%0t, Wait event is unblocked",$time);
end
join
end
endmodule

B.
module tb_top;
event e;
initial begin
fork
begin // Process 1
#2;
->e;
$display("%0t, Event triggered",$time);
end
begin // Process 2
#2; wait(e.triggered);
$display("%0t, Wait event is unblocked",$time);
end
join
end
endmodule

C.
module tb_top;
event e;
initial begin
fork
begin // Process 1
#2;
->e;
$display("%0t, Event triggered",$time);
end
begin // Process 2
#2; @e;
$display("%0t, Wait event is unblocked",$time);
end
join
end
endmodule

Page 4 of 5
D.
module tb_top;
event e;
initial begin
fork
begin // Process 1
#1;
->e;
$display("%0t, Event triggered",$time);
end
begin // Process 2
#2; wait(e.triggered);
$display("%0t, Wait event is unblocked",$time);
end
join
end
endmodule

E.
module tb_top;
event e;
initial begin
fork
begin // Process 1
#1;
->e;
$display("%0t, Event triggered",$time);
end
begin // Process 2
#2; @e;
$display("%0t, Wait event is unblocked",$time);
end
join
end
endmodule

Page 5 of 5

You might also like