-
Notifications
You must be signed in to change notification settings - Fork 3
/
data_bucket.sv
39 lines (35 loc) · 1.48 KB
/
data_bucket.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
`timescale 1ns/1fs
import SystemVerilogCSP::*;
module data_bucket (interface r);
parameter WIDTH = 12;
parameter BL = 2; //ideal environment
logic [WIDTH-1:0] ReceiveValue = 0;
logic [3:0] Value;
//Variables added for performance measurements
real cycleCounter=0, //# of cycles = Total number of times a value is received
timeOfReceive=0, //Simulation time of the latest Receive
cycleTime=0; // time difference between the last two receives
real averageThroughput=0, averageCycleTime=0, sumOfCycleTimes=0;
always
begin
//$display("START module data_bucket and time is %d", $time);
//Save the simulation time when Receive starts
timeOfReceive = $time;
r.Receive(ReceiveValue);
//value=ReceiveValue[];
//$display("ReceiveValue is %d",ReceiveValue);
//$display("ReceiveTime is %d",timeOfReceive);
#BL;
cycleCounter += 1;
//Measuring throughput: calculate the number of Receives per unit of time
//CycleTime stores the time it takes from the begining to the end of the always block
/***cycleTime = $time - timeOfReceive;
averageThroughput = cycleCounter/$time;
sumOfCycleTimes += cycleTime;
averageCycleTime = sumOfCycleTimes / cycleCounter;
$display("Execution cycle= %d, Cycle Time= %d,
Average CycleTime=%f, Average Throughput=%f", cycleCounter, cycleTime,
averageCycleTime, averageThroughput);***/
//$display("End module data_bucket and time is %d", $time);
end
endmodule