-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprobe_timer.sv
144 lines (119 loc) · 3.19 KB
/
probe_timer.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//Determine IPDs of packets at different sessions, and also determine the type (small or large size) of packets
module probeTimer (
input clk,
input rst,
input windowSize,
input setting,
input active,
input [31:0] interval,
input [1:0] sessionID,
output reg [1:0] pktFlag // send packet out, 1 marks small packets and 3 marks regular packets, 0 marks no packet.
);
reg [31:0] regPktCnt;
reg [31:0] smallPktCnt;
reg [31:0] totalPktCnt;
reg [31:0] intervalReg;
reg [31:0] pktNumberReg;
reg [31:0] countUp;
reg windowSizeReg;
reg activeArray [0:2];
reg [31:0] globalTimer;
reg [1:0] state;
parameter totalCycles = 120,
pktNumber = 4,
regPktMin = 20,
regPktMax = 40;
//absolute timer
always @(posedge clk) begin
if(rst)begin
globalTimer <= 0;
end
else begin
globalTimer <= globalTimer + 1;
end
end
always@(posedge clk) begin
if(setting) begin
activeArray[sessionID] <= active;
end
end
always @(posedge clk) begin
if(rst) begin
activeArray[0]<=0;
activeArray[1]<=0;
activeArray[2]<=0;
regPktCnt <= 0;
countUp <= 0;
smallPktCnt <= 0;
totalPktCnt <= 0;
intervalReg <= 0;
pktNumberReg <= 0;
windowSizeReg <= 0;
pktFlag <= 0;
state <= 0;
end
else begin //!rst
case(state)
0: begin //setting state
if(!setting && activeArray[sessionID]) begin
pktNumberReg <= pktNumber;
windowSizeReg <= windowSize;
intervalReg <= interval;
countUp <= 0;
state <= 1;
end
end
1: begin //transmission state
if(pktNumberReg == 0) begin
state <= 0;
end
else begin
if(countUp >= intervalReg) begin
if(windowSizeReg) begin
regPktCnt <= regPktCnt + 1;
pktFlag <= 3;
end
else begin
smallPktCnt <= smallPktCnt + 1;
pktFlag <= 1;
end
pktNumberReg <= pktNumberReg - 1;
countUp <= 0;
totalPktCnt <= totalPktCnt + 1;
end
else begin
pktFlag <= 0;
countUp <= countUp + 1;
end
end
end
endcase
end //for else branch
end
`ifdef FORMAL
always @(posedge clk) begin
if(!$initstate) begin
assume(rst == 0);
//Constraints
assume(sessionID<=2);
assume(active == 1);
assume(interval>=regPktMin);
if(globalTimer == totalCycles)assume(regPktCnt >= pktNumber || smallPktCnt >=pktNumber);
//-----//
//Invariant
// assume(activeArray[0] <= 1);
// assume(activeArray[1] <= 1);
// assume(activeArray[2] <= 1);
assume(regPktCnt<=totalPktCnt);
assume(smallPktCnt<=totalPktCnt);
//assume(countUp<=intervalReg);
//-----//
// a property
if(globalTimer == totalCycles ) assert(totalPktCnt >= pktNumber);
end
else begin
assume(rst);
end
end
`endif
endmodule