diff --git a/simics-workspace/modules/afdxES/pci-register.dml b/simics-workspace/modules/afdxES/pci-register.dml
index 8a842d0..adee6f9 100644
--- a/simics-workspace/modules/afdxES/pci-register.dml
+++ b/simics-workspace/modules/afdxES/pci-register.dml
@@ -1421,45 +1421,3 @@ bank pciport{
     }
 }

-method LoadCfgTo664Middleware() {
-    local uint32 data_type = 0;
-    local uint32 cfg_table_size = 0;
-
-    data_type = ANALYSE_CFG_CAM;
-    cfg_table_size = sizeoftype(analyse_cfg_cam) * CFG_NUM;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$analyse_cfg_cam_array, uint8*), cfg_table_size);
-
-    data_type = ANALYSE_CFG_RAM;
-    cfg_table_size = sizeoftype(analyse_cfg_ram) * CFG_NUM;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$analyse_cfg_ram_array, uint8*), cfg_table_size);
-
-    data_type = TRANSMIT_CFG_RAM;
-    cfg_table_size = sizeoftype(transmit_cfg_ram) * CFG_NUM;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$transmit_cfg_ram_array, uint8*), cfg_table_size);
-
-    data_type = SCHEDULING_CFG_RAM;
-    cfg_table_size = sizeoftype(scheduling_cfg_ram) * CFG_NUM;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$scheduling_cfg_ram_array, uint8*), cfg_table_size);
-
-    data_type = RM_CFG_CAM;
-    cfg_table_size = sizeoftype(rm_cfg_cam) * RM_CFG_CAM;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$rm_cfg_cam_array, uint8*), cfg_table_size);
-
-    data_type = RM_CFG_RAM;
-    cfg_table_size = sizeoftype(rm_cfg_ram) * CFG_TYPE_SIZE;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$rm_cfg_ram_array, uint8*), cfg_table_size);
-
-    data_type = FRAGMENT_CFG_RAM;
-    cfg_table_size = sizeoftype(fragment_cfg_ram) * cfg_table_size;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-    socket_send(cast(&$fragment_cfg_ram_array, uint8*), cfg_table_size);
-
-    data_type = DO_LOAD_CONF;
-    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
-}
diff --git a/simics-workspace/modules/afdxES/tomiddleware.c b/simics-workspace/modules/afdxES/tomiddleware.c
index 577cd95..5a64230 100644
--- a/simics-workspace/modules/afdxES/tomiddleware.c
+++ b/simics-workspace/modules/afdxES/tomiddleware.c
@@ -20,7 +20,7 @@ int socket_init(void) {
     SOCKADDR_IN serveraddr;
     memset(&serveraddr, 0, sizeof(serveraddr));
     serveraddr.sin_family = AF_INET;
-    serveraddr.sin_port = htons(9750);
+    serveraddr.sin_port = htons(10087);
     serveraddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");

     if (connect(client_socket, (struct sockaddr *) &serveraddr, sizeof(serveraddr)) != 0) {
diff --git a/simics-workspace/modules/afdxES/tomiddleware.dml b/simics-workspace/modules/afdxES/tomiddleware.dml
index d6a689c..82941d7 100644
--- a/simics-workspace/modules/afdxES/tomiddleware.dml
+++ b/simics-workspace/modules/afdxES/tomiddleware.dml
@@ -22,3 +22,46 @@ method init_middleware_mode() {
         call $socket_loop_recv();
     }
 }
+
+method LoadCfgTo664Middleware() {
+    local uint32 data_type = 0;
+    local uint32 cfg_table_size = 0;
+
+    data_type = ANALYSE_CFG_CAM;
+    cfg_table_size = sizeoftype(analyse_cfg_cam) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$analyse_cfg_cam_array, uint8*), cfg_table_size);
+
+    data_type = ANALYSE_CFG_RAM;
+    cfg_table_size = sizeoftype(analyse_cfg_ram) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$analyse_cfg_ram_array, uint8*), cfg_table_size);
+
+    data_type = TRANSMIT_CFG_RAM;
+    cfg_table_size = sizeoftype(transmit_cfg_ram) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$transmit_cfg_ram_array, uint8*), cfg_table_size);
+
+    data_type = SCHEDULING_CFG_RAM;
+    cfg_table_size = sizeoftype(scheduling_cfg_ram) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$scheduling_cfg_ram_array, uint8*), cfg_table_size);
+
+    data_type = RM_CFG_CAM;
+    cfg_table_size = sizeoftype(rm_cfg_cam) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$rm_cfg_cam_array, uint8*), cfg_table_size);
+
+    data_type = RM_CFG_RAM;
+    cfg_table_size = sizeoftype(rm_cfg_ram) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$rm_cfg_ram_array, uint8*), cfg_table_size);
+
+    data_type = FRAGMENT_CFG_RAM;
+    cfg_table_size = sizeoftype(fragment_cfg_ram) * CFG_NUM;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+    socket_send(cast(&$fragment_cfg_ram_array, uint8*), cfg_table_size);
+
+    data_type = DO_LOAD_CONF;
+    socket_send(cast(&data_type, uint8*), CFG_TYPE_SIZE);
+}
diff --git a/simics-workspace/modules/afdxES/unpacket_frame.dml b/simics-workspace/modules/afdxES/unpacket_frame.dml
index cc6b6ef..e99eae1 100644
--- a/simics-workspace/modules/afdxES/unpacket_frame.dml
+++ b/simics-workspace/modules/afdxES/unpacket_frame.dml
@@ -15,8 +15,6 @@ method init_udp_flag() {
 }

 method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
-	log "info" : "called by ARINC2 to unpacket_frame";
-
 	local uint16 dest_udp;
 	local uint16 vl;
 	local uint32 dest_ip;
@@ -34,13 +32,13 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	local UDP_Item udp_item;

 	call $unpacket_ip_checksum(buffer)->(correct);		//IP checksum
-    if(correct ==  INCORRECT)
-    {
+    if (correct == INCORRECT) {
         log "info": "ip checksum error";
 		rx_mib.ip_checksum_filt_count++;
-        return ;
+        return;
     }
-	rx_mib. rx_ip_data_count++;
+
+	rx_mib.rx_ip_data_count++;
 	dest_udp =*cast((buffer + UDP_DEST_ADDR),uint16*);
 	dest_ip = *cast(buffer + IP_DEST_ADDR,uint32 *);
 	vl	= *(buffer + VL_ADDR);
@@ -64,12 +62,12 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	enable_network_A = $analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE;
 	enable_network_B = $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE;

-	if(enable_network_A !=$analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE) {
+	if (enable_network_A !=$analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE) {
 		log "info": "enable network A error!";
 		return;
 	}

-	if(enable_network_B != $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE) {
+	if (enable_network_B != $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE) {
 		log "info": "enable network B error!";
 		return;
 	}
@@ -77,7 +75,7 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	udp_item.port_type = $analyse_cfg_ram_array[port_id].ram_data.PORT_TYPE;

-	if($udp_first[port_id] == RECEIVE_UDP_FIRST) {
+	if ($udp_first[port_id] == RECEIVE_UDP_FIRST) {
 		udp_item.udp_length = *cast(buffer + UDP_LENGTH_ADDR,uint16 *);
 		rx_mib.rx_udp_data_count++;
 	} else {
@@ -91,9 +89,8 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	udp_item.mf =mf;
     udp_item.dest_udp = dest_udp;

-	if (port_id >= 0 && port_id < 128) {
+	if (port_id >= 0 && port_id < 4096) {
 		switch (udp_item.port_type) {
-
 			case 0: case 1:
 			    call $EnPortQueue(($port[port_id].queue),udp_item)->(result);
                   //for test start
diff --git a/simics-workspace/modules/afdxES2/afdxES2.dml b/simics-workspace/modules/afdxES2/afdxES2.dml
index e5f47c8..b4b931b 100644
--- a/simics-workspace/modules/afdxES2/afdxES2.dml
+++ b/simics-workspace/modules/afdxES2/afdxES2.dml
@@ -25,7 +25,7 @@ import "change_endian.dml";
 import "packet-description.dml";
 import "quick-sort.dml";
 import "binary-search.dml";
-
+import "rm-handler.dml";
 header %{
 #include <stdio.h>
 	//extern void write_mid(MAC_MIB *maca_mib,MAC_MIB *macb_mib, RX_MIB *rx_mib, TX_MIB *tx_mib);
@@ -215,98 +215,42 @@ connect phyB {

 implement ieee_802_3_mac {
 	method send_frame(uint8 *data, uint32 size) {
-		log "info" : "called by nic1";
-
         local rm_cfg_cam item;
+        local uint8 rm_index;
+        local bool is_crc_ok;
+        local RM_INFO rm_info;

-        local uint8 position;
-		local bool crc;
-
-        call $recv_crc_check(data,size,$Table)->(crc);
-
-        if(crc == false)
-        {
+        call $recv_crc_check(data,size,$Table)->(is_crc_ok);
+
+        if (is_crc_ok == false) {
             log "info":"crc check failed";
-            return ;
-        }
-
-        call $change_endian(data,size);
-
-        item.VL_ID = *cast(&data[4],uint16*);
-
-
-        for (position = 0; position < $rm_cfg_cam_index; ++position) {
-            log "info" : "The $rm_cfg_cam_array[%d].VL_ID = %x", position, $rm_cfg_cam_array[position].VL_ID;
-            log "info" : "The $rm_cfg_cam_array[%d].address = %x", position, $rm_cfg_cam_array[position].address;
+            return;
         }

-        call $BinarySearchRMCfgCamArray($rm_cfg_cam_array, item) -> (position);
+        call $change_endian(data, size);

-		position = $rm_cfg_cam_array[position].address;
-
-        local uint8 VL_ENABLE = $rm_cfg_ram_array[position].ram_data.VL_ENABLE;
-        local uint8 RM_ENABLE = $rm_cfg_ram_array[position].ram_data.RM_ENABLE;
-        local uint8 NETWORK_A_IC_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_A_IC_ENABLE;
-        local uint8 NETWORK_B_IC_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_B_IC_ENABLE;
-        local uint8 NETWORK_A_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_A_ENABLE;
-        local uint8 NETWORK_B_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_B_ENABLE;
-        local uint8 A_Interface_ID;
-        local uint8 B_Interface_ID;
-
-		log "info" : "position=%d", position;
-		log "info" : "VL_ENABLE=%d",VL_ENABLE;
-		log "info" : "RM_ENABLE=%d",RM_ENABLE;
-		log "info" : "NETWORK_A_IC_ENABLE=%d",NETWORK_A_IC_ENABLE;
-		log "info" : "NETWORK_B_IC_ENABLE=%d",NETWORK_B_IC_ENABLE;
-		log "info" : "NETWORK_A_ENABLE=%d",NETWORK_A_ENABLE;
-		log "info" : "NETWORK_B_ENABLE=%d",NETWORK_B_ENABLE;
-		log "info" : "A_Interface_ID=%d",A_Interface_ID;
-		log "info" : "B_Interface_ID=%d",B_Interface_ID;
-
-        if (VL_ENABLE == 0) {
-            return;
-        }
-        local uint8 frame_sn = data[size-5];
-		local uint8 interface_id;
-		interface_id = data[11]>>5;
-		log "info" : "interace_id = %d , frame_sn=%d", interface_id,frame_sn;
-
-        if (NETWORK_A_ENABLE == 1) {
-            A_Interface_ID = 1;
-        } else {
-            A_Interface_ID = 0;
-        }
-
-        if (NETWORK_B_ENABLE == 1) {
-            B_Interface_ID = 2;
+        item.VL_ID = data[4];
+        call $BinarySearchRMCfgCamArray($rm_cfg_cam_array, item) -> (rm_index);
+        if (rm_index == -1) {
+            log "error" : "Can't find this conf in current rm cfg cam table, please check!";
         } else {
-            B_Interface_ID = 0;
+            rm_index = $rm_cfg_cam_array[rm_index].address;
         }

-		//for mib
-		if((interface_id ==1) && (A_Interface_ID ==0))
-			$rx_mib.disable_A_filt_count++;
-		if((interface_id ==2) && (B_Interface_ID ==0))
-			$rx_mib.disable_B_filt_count++;
-
+        call $Init_RM_INFO(&rm_info, rm_index, size);

-
-	    log "info":"interface id = %d,sn = %d",interface_id,$recv_vl[position].expect_sn;
-        if ((frame_sn == $recv_vl[position].expect_sn) && ((interface_id == A_Interface_ID) || (interface_id == B_Interface_ID))) {
-			$rx_mib.size = size;
+        local uint8 interface_id = data[11] >> 5;
+        local uint8 frame_sn = data[size-5];
+        local bool is_rm_ok;
+
+        call $RM_Handler(&rm_info, interface_id, frame_sn) -> (is_rm_ok);
+        if (is_rm_ok) {
             call $unpacket_frame(data, size)->($rx_mib);
-            $recv_vl[position].expect_sn++;
-            $recv_vl[position].expect_sn %= 256;
-			if(interface_id == A_Interface_ID) call $mib_in_sum(&($maca_mib),size);
-			else if(interface_id == B_Interface_ID) call $mib_in_sum(&($macb_mib),size);
         } else {
-            if (frame_sn != $recv_vl[position].expect_sn)
-                log "info":"^^^^^^^^^^abort interface id = %d,sn = %d^^^^^^^^^^^^",interface_id,$recv_vl[position].expect_sn;
-
-            return;
+            log "error" : "Send from unkown network";
         }
     }
-
+
     method config_bandwidth(uint32 max_bandwidth) {
         $phy_max_bandwidth = max_bandwidth;
     }
@@ -325,28 +269,17 @@ attribute record_mib_cycle {

 method record_mib() {
     write_mid(&($maca_mib),&($macb_mib) ,&($rx_mib), &($tx_mib));
-    after ($record_mib_cycle) call $record_mib();
+    after ($record_mib_cycle)
+        call $record_mib();
 }

 method post_init() {
-    memset($udp_first,1,PORT_SIZE);
    	call $gen_normal_table($Table);
-    local uint32 i = 0;
-    for (; i < PORT_SIZE; ++i) {
-        call $InitPortQueue() -> ($port[i].queue);
-    }
-    local uint32 j = 0;
-    for (; j < SEND_VL_NUM; ++j) {
-        $vl_index_array[j] = new uint8;
-    }
-    local uint32 k = 0;
-    for (; k < RECV_VL_NUM; ++k) {
-        $recv_vl[k].expect_sn = 0;
-    }
-
+    call $init_port_queue();
+    call $init_udp_flag();
+    call $init_vl_cfg();
     call $record_mib();
-    log "info": "called ";
-
+
     $phy_max_bandwidth = 200;
     $record_mib_cycle = 0.1;
 }
diff --git a/simics-workspace/modules/afdxES2/port-queue.dml b/simics-workspace/modules/afdxES2/port-queue.dml
index 5d99b03..e284fa1 100644
--- a/simics-workspace/modules/afdxES2/port-queue.dml
+++ b/simics-workspace/modules/afdxES2/port-queue.dml
@@ -3,8 +3,14 @@ import "config-tables.dml";
 import "constant.dml";
 import "packet-description.dml";

-method InitPortQueue()->(PortQueue *initqueue)
-{
+method init_port_queue() {
+    local uint32 i = 0;
+    for (; i < PORT_SIZE; ++i) {
+        call $InitPortQueue() -> ($port[i].queue);
+    }
+}
+
+method InitPortQueue()->(PortQueue *initqueue) {
 	local PortQueue *queue;
 	queue = new PortQueue;
 	queue->queue_size = 0;
@@ -16,14 +22,11 @@ method InitPortQueue()->(PortQueue *initqueue)
 	initqueue = queue;
 }

-method EnPortQueue(PortQueue *queue,UDP_Item item) ->(bool result)
-{
+method EnPortQueue(PortQueue *queue,UDP_Item item) ->(bool result) {
 	local QueueItem *tail;

-	if(item.udp_length == 0)
-	{
-		if(queue->queue_full == 1)
-		{
+	if (item.udp_length == 0) {
+		if (queue->queue_full == 1) {
 			log "info" : "queue is full";
 			result = false;
 			return ;
@@ -36,20 +39,15 @@ method EnPortQueue(PortQueue *queue,UDP_Item item) ->(bool result)
 		tail->single_size = item.udp_packet_size;
 		memcpy(tail->buffer,item.buffer,item.udp_packet_size);
 		queue->tail = tail;
-		log "info" : "tail whole size = %d",tail->whole_size;
-		log "info" : "tail single size =%d",tail->single_size;
-	}
-	else
-	{
-		if(item.udp_length > PORT_ITEM_SIZE || item.udp_length + queue->queue_size > PORT_QUEUE_MAX_SIZE)
-		{
+	} else {
+		if (item.udp_length > PORT_ITEM_SIZE || item.udp_length + queue->queue_size > PORT_QUEUE_MAX_SIZE) {
 			log "info": "queue is full or single queue is too big!";
 			queue->queue_full = 1;
 			result = false;
 			return;
-		}
-		else
+		} else {
 			queue->queue_full = 0;
+        }

 		queue->tail->next = new QueueItem;
 		tail = queue->tail->next;
@@ -61,53 +59,33 @@ method EnPortQueue(PortQueue *queue,UDP_Item item) ->(bool result)
 		tail->src_ip = item.src_ip;
         tail->dest_udp = item.dest_udp;

-		// for test begin
-		log "info" : "The item.dest_udp is %d", item.dest_udp;
-		log "info" : "The tail->dest_udp is %d", tail->dest_udp;
-		// for test end
-
-		log "info" : "tail whole size =%d",tail->whole_size;
-		log "info" : "tail single size = %d",tail->single_size;
-
 		memcpy(tail->buffer,item.buffer,item.udp_packet_size);
 		queue->tail = tail;
 		queue->item_length  = tail->whole_size;
 	}

-	if(item.mf == 0)
-	{
+	if(item.mf == 0) {
 		tail->last = 1;
 		local bool check_result;
 		inline $receive_udp_check_sum(queue)->(check_result);
-		if(!check_result)
-		{
+		if(!check_result) {
 			call $LeavePortQueue(queue);
 			result = false;
 			return;
-		}
-		else
-		{
+		} else {
 			queue->queue_size += queue->item_length;
 			local PortItem port_item;
 			call $DePortQueue(queue,&port_item)->(result);
-			if(result == false)
-			{
-				//log "info":"queue is empty!";
+			if(result) {
+                $RDC.Send_To_RDC.send_to_RDC(port_item.frame+8,port_item.dest_udp,port_item.size-8);
 			}
-            log "info": "--------------driver's dest_udp = %d ------------------",port_item.dest_udp;
-			// for test begin
-            //port_item.dest_udp = 1064;
-			// for test end
-            log "info": "--------------set dest_udp :%d ------------------",port_item.dest_udp;
-			$RDC.Send_To_RDC.send_to_RDC(port_item.frame+8,port_item.dest_udp,port_item.size-8);
 		}
 	}
 	queue->tail->next = NULL;
 	result = true;
 }

-method LeavePortQueue(PortQueue *queue)
-{
+method LeavePortQueue(PortQueue *queue) {
 	local QueueItem *leaveitem;
 	local QueueItem *p;

@@ -115,47 +93,39 @@ method LeavePortQueue(PortQueue *queue)
 	queue->tail= queue->tail->prev_whole;
 	queue->tail->next = NULL;
 	queue->tail->next = NULL;
-	while(leaveitem)
-	{
-			p = leaveitem->next;
-			delete leaveitem->buffer;
-			delete leaveitem;
-			leaveitem = p;
+	while (leaveitem) {
+        p = leaveitem->next;
+        delete leaveitem->buffer;
+        delete leaveitem;
+        leaveitem = p;
 	}
 }

-method DePortQueue(PortQueue *queue,PortItem *port_item)->(bool result)
-{
+method DePortQueue(PortQueue *queue,PortItem *port_item)->(bool result) {
 	local QueueItem *item;
 	local QueueItem *delete_item;
 	local uint32 offset =0;
     local uint32 whole_size;

 	item = queue->head->next;
-	if(!item)
-	{
+	if (!item) {
 		log "info" : "queue is empty";
 		return;
 	}

-	log "info":"==================Dequeue=====================";
-	log "info":"item whole size = %d",item->whole_size;
-	log "info":"queue size = %d",queue->queue_size;
-
-	if(item->whole_size!=0 && queue->queue_size>=item->whole_size)
-	{
+	if (item->whole_size != 0 && queue->queue_size >= item->whole_size) {
 		port_item->frame = new uint8[item->whole_size];
 		port_item->size = item->whole_size;
 		port_item->dest_ip = item->dest_ip;
 		port_item->src_ip = item->src_ip;
         port_item->dest_udp = item->dest_udp;
-        log "info" : "single size is %d ,whole size is %d",item->single_size,item->whole_size;
 		whole_size = item->whole_size;
-        while(item)
-		{
-            if(whole_size < item->single_size)
+
+        while (item) {
+            if (whole_size < item->single_size) {
                 item->single_size = whole_size;
-             whole_size -= item->single_size;
+            }
+            whole_size -= item->single_size;

 			memcpy(port_item->frame + offset, item->buffer, item->single_size);
 			delete_item = item;
@@ -164,8 +134,7 @@ method DePortQueue(PortQueue *queue,PortItem *port_item)->(bool result)

 			delete delete_item;

-			if(item && item->whole_size!=0)
-			{
+			if (item && item->whole_size!=0) {
 				queue->head->next = item;
 				item->prev_whole = queue->head;
 				queue->queue_size -=port_item->size;
@@ -174,54 +143,43 @@ method DePortQueue(PortQueue *queue,PortItem *port_item)->(bool result)
 			}
 		}

-		//for test start
-		local uint32 i;
-		for(i=0;i<port_item->size;i++)
-			log "info": "frame[%d]=%d",i,port_item->frame[i];
-		//for test end
-
 		queue->head->next = NULL;
 		queue->tail = queue->head;
 		queue->head->prev_whole = NULL;
 		queue->queue_size -= port_item->size;
 		result = true;
-	}
-	else
-	{
+	} else {
 		result = false;
 	}
 }

-method IsPortQueueEmpty(PortQueue *queue) ->(bool result)
-{
+method IsPortQueueEmpty(PortQueue *queue) -> (bool result) {
 	result = queue->head == queue->tail;
 }

-method RefreshPortData(Receive_Port *port, UDP_Item udp_item)
-{
+method RefreshPortData(Receive_Port *port, UDP_Item udp_item) {
 	port->port_type = 2;

-	if (port->frame != NULL)
+	if (port->frame != NULL) {
 		dbuffer_free(port->dbuf);
+    }

 	port->dbuf = new_dbuffer();
 	port->frame = dbuffer_append(port->dbuf, udp_item.udp_length);

 	memcpy(port->frame, udp_item.buffer, udp_item.udp_length);
-	$rx_regs.rx_sampling_port_freshness = 0;  // ÐÂÏʵÄ
+	$rx_regs.rx_sampling_port_freshness = 0;
 }

-
-method IsPortSampleEmpty(Receive_Port *port) -> (bool result)
-{
-	if (port->frame == NULL)
+method IsPortSampleEmpty(Receive_Port *port) -> (bool result) {
+	if (port->frame == NULL) {
 		result = true;
-	else
+    } else {
 		result = false;
+    }
 }

-struct Receive_Port
-{
+struct Receive_Port {
 	uint2 port_type;
 	PortQueue *queue;
 	dbuffer_t *dbuf;
diff --git a/simics-workspace/modules/afdxES2/unpacket_frame.dml b/simics-workspace/modules/afdxES2/unpacket_frame.dml
index bbd9b61..9785ac1 100644
--- a/simics-workspace/modules/afdxES2/unpacket_frame.dml
+++ b/simics-workspace/modules/afdxES2/unpacket_frame.dml
@@ -10,6 +10,10 @@ import "packet-description.dml";

 data uint8 udp_first[PORT_SIZE];   //init with 1;

+method init_udp_flag() {
+    memset($udp_first,1,PORT_SIZE);
+}
+
 method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	local uint8 correct;
 	local uint16 dest_udp;
@@ -27,15 +31,12 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	local UDP_Item udp_item;

 	call $unpacket_ip_checksum(buffer)->(correct);		//IP checksum
-	if(correct == INCORRECT)
-	{
+	if (correct == INCORRECT) {
 		log "info": "ip checksum error!";
 		rx_mib.ip_checksum_filt_count++;
 		return ;
-	}
-	else
-	{
-	log "info": "ip checksum correct!";
+	} else {
+        log "info": "ip checksum correct!";
 	}
 	rx_mib.rx_ip_data_count++;
 	dest_udp =*cast((buffer + UDP_DEST_ADDR),uint16*);
@@ -51,8 +52,6 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	T.cam_data_part3.DEST_UDP = dest_udp;
 	//find port through  item group. single has IP dest address ,mulitple hasn't IP dest address

-
-
 	call $BinarySearchAnalyseCfgCamArray(($analyse_cfg_cam_array), T) -> (port_id);
     if (port_id == -1) {
         log "error" : "Can't find this conf in current analyse cfg cam table, please check!";
@@ -63,19 +62,19 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	enable_network_A =$analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE;
 	enable_network_B = $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE;

-	if(enable_network_A !=$analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE) {
+	if (enable_network_A != $analyse_cfg_ram_array[port_id].ram_data.NETWORK_A_ENABLE) {
 		log "info": "enable network A error!";
 		return;
 	}

-	if(enable_network_B != $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE) {
+	if (enable_network_B != $analyse_cfg_ram_array[port_id].ram_data.NETWORK_B_ENABLE) {
 		log "info": "enable network B error!";
 		return;
 	}

 	udp_item.port_type = $analyse_cfg_ram_array[port_id].ram_data.PORT_TYPE;

-	if($udp_first[port_id] == RECEIVE_UDP_FIRST) {
+	if ($udp_first[port_id] == RECEIVE_UDP_FIRST) {
 		udp_item.udp_length = *cast(buffer + UDP_LENGTH_ADDR,uint16 *);
 		rx_mib.rx_udp_data_count++;
 	} else {
@@ -96,8 +95,7 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 		switch (udp_item.port_type) {
 			case 0: case 1:
 			    call $EnPortQueue(($port[port_id].queue),udp_item)->(result);
-				if(result == false)
-				{
+				if(result == false) {
 					log "info": "port queue is full";
 				}
 				break;
@@ -111,7 +109,7 @@ method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 		log "info": "wrong port id";
 	}

-	if(mf == 0) {
+	if (mf == 0) {
 		$udp_first[port_id] = 1;
     } else {
 		$udp_first[port_id] = 0;
diff --git a/simics-workspace/modules/afdxES2/vl.dml b/simics-workspace/modules/afdxES2/vl.dml
index 61b6b39..708ffee 100644
--- a/simics-workspace/modules/afdxES2/vl.dml
+++ b/simics-workspace/modules/afdxES2/vl.dml
@@ -22,3 +22,13 @@ struct Recv_VL {
 }

 data Recv_VL recv_vl[RECV_VL_NUM];
+
+method init_vl_cfg() {
+    local uint32 i = 0;
+    for (; i < SEND_VL_NUM; ++i) {
+        $vl_index_array[i] = new uint8;
+    }
+    for (i = 0; i < RECV_VL_NUM; ++i) {
+        $recv_vl[i].expect_sn = 0;
+    }
+}
diff --git a/simics-workspace/modules/rtc_module/config.dml b/simics-workspace/modules/rtc_module/config.dml
index d601578..51a6352 100644
--- a/simics-workspace/modules/rtc_module/config.dml
+++ b/simics-workspace/modules/rtc_module/config.dml
@@ -5,7 +5,7 @@ constant ANALYSE_CFG_CAM_MAX_SIZE = 4096;
 constant ANALYSE_CFG_RAM_MAX_SIZE = 4096;

 struct analyse_cfg_cam {
-    physical_address_t address;
+    uint32 address;

     bitfields 28 {
         uint26 RETENTION                @ [27:2];   // [91:66];
@@ -90,11 +90,11 @@ data scheduling_cfg_ram scheduling_cfg_ram_array[SCHEDULING_CFG_RAM_MAX_SIZE];

 /////////////////////////////////////  rm_cfg_cam  begin  //////////////////////////////////////
-constant RM_CFG_CAM_MAX_SIZE = 128;
-constant RM_CFG_RAM_MAX_SIZE = 128;
+constant RM_CFG_CAM_MAX_SIZE = 256;
+constant RM_CFG_RAM_MAX_SIZE = 256;

 struct rm_cfg_cam {
-    physical_address_t address;
+    uint32 address;
     uint16 VL_ID;
 }
add afdxES2 rm-handler.dml