-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCAM.cpp
More file actions
37 lines (35 loc) · 838 Bytes
/
TCAM.cpp
File metadata and controls
37 lines (35 loc) · 838 Bytes
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
#include"TCAM.h"
#include <stdio.h>
#define rule_set_Size 1000
using namespace std;
unsigned int TCAM::Capability = rule_set_Size;
unsigned int TCAM::N_current = 0;
TCAM::TCAM() {
this->entry.clear();
this->Empty_List.clear();
this->entry.resize(TCAM::Capability+1);
// = new Entry[TCAM::Capability + 1];
}
void TCAM::TCAM_Print() {
printf("Position:\tAvailable:\tthe related Node Index\n");
for (int c = 1; c <= TCAM::Capability; c++) {
if(this->entry[c].occupy == false){
printf("%d\t",c);
continue;
}
this->entry[c].Entry_Print();
}
}
Entry::Entry() {
this->occupy = false;
this->index = 0;
}
void Entry::Entry_Print() {
printf("%d\t%d\n", ~(this->occupy),this->index);
}
void TCAM::TCAM_Init(){
TCAM::N_current = 0;
this->entry.clear();
this->entry.resize(TCAM::Capability+1);
this->Empty_List.clear();
}