### 系統晶片設計

```Advisor:Chau-Lieh Chen
Student:張君睿

Packet進入時間
Packet離開時間
packet
IFS
IFS
Transmission time
Time
yes
start
Packet delay

delay_bound
no

qsta的packet
mac_delay=0
flow_txop = 0取得新

Txop剩餘時

no

TXOP

packet傳輸

Return 排程

yes

TXOP


deque:
// get the head of line packet. If the queue is empty

// return NO_PKT and move to the next TXOP.

queue[schedTx_.tid_][schedTx_.dst_]->top (p, h);

if(!p) {

//沒有packet

//先傳此qsta的packet mac_delay=0

//flow_txop = 0

//在取得新的flow作傳輸

//=============================================

total_delay=0;



if (schedTx_.dst_ == 6) {
flow_txop=111;
now_qsta=6;
}
if (schedTx_.dst_ == 7) {
flow_txop=174;
now_qsta=7;
}
if (schedTx_.dst_ == 8) {
flow_txop=209;
now_qsta=8;
}


// 判斷Packet delay是否大於delay_bound
if(time + transmit_time - HDR_CMN(p)->timestamp() > desc->db + 0.0001 &&
mac_->drop (p, "DBN");

queue[schedTx_.tid_][schedTx_.dst_]->pop();

goto deque;


}
//Txop剩餘時間是否小於傳輸時間
if(time_left + phymib_.getPIFS() < transmit_time) {

//此為txop剩下的時間不夠傳輸一筆packet

//所以取得新的flow作傳輸。


schedTx_.subtype_ = NO_PKT;
first_deque = 1;

map_builder_->next_txop(next_qsta);

continue;
}
transmit_time = mac_->txtime(HDR_CMN(p)->size()
+ phymib_.getHdrLen11e(),mac_->getDataRate())
+ phymib_.getSIFS()
+ mac_->txtime(phymib_.getHdrLen11e(), mac_>getDataRate())
+ phymib_.getSIFS();
total_delay =int((Scheduler::instance().clock()-HDR_CMN(p)>timestamp()+transmit_time)/20e-6);

//計算packet的delay為packet離開的時間(Scheduler::instance().clock())減掉packet進入的時間(HDR_CMN(p)->timestamp())加上
packet傳輸的時間
(transmit_time)最後除以slot time

total_delay =int((Scheduler::instance().clock()-HDR_CMN(p)->timestamp()+transmit_time)/20e-6);

//將此flow的總txop時間傳給matlab


//以下的數值在檔案mac-hccasched_map_ref.cc內副程式createMap()計算單位為slot time

if (schedTx_.dst_ == 6) {





if (total_delay > transmit_time){
flow_txop = (double)((total_delay/transmit_time)/1000);
now_qsta=6;
}
else {
flow_txop = (double)(transmit_time);
now_qsta=6;
}
}
if (schedTx_.dst_ == 7) {
if (total_delay > transmit_time){
flow_txop = (double)((total_delay/transmit_time)/1000);
now_qsta=7;
}
else {
flow_txop = (double)(transmit_time);
now_qsta=7;
}
}
if (schedTx_.dst_ == 8) {
if (total_delay > transmit_time){
flow_txop = (double)((total_delay/transmit_time)/1000);
now_qsta=8;
}
else {
flow_txop = (double)(transmit_time);
now_qsta=8;
}
}
```