OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_verilator/] [traffic_task_graph.h] - Diff between revs 43 and 48

Show entire file | Details | Blame | View Log

Rev 43 Rev 48
Line 21... Line 21...
 
 
 
 
typedef struct TRAFFIC_TASK {
typedef struct TRAFFIC_TASK {
        char enable;
        char enable;
    unsigned int src;
    unsigned int src;
    unsigned int dst; // ID of the destination node (PE)
    unsigned int dst; // ID of the destination endpoint (PE)
    unsigned int bytes;
    unsigned int bytes;
    unsigned int initial_weight;
    unsigned int initial_weight;
    unsigned int min_pck_size;          //in flit
    unsigned int min_pck_size;          //in flit
    unsigned int max_pck_size;          //in flit
    unsigned int max_pck_size;          //in flit
 
 
Line 40... Line 40...
    unsigned int burst_sent;
    unsigned int burst_sent;
} task_t;
} task_t;
 
 
 
 
 
 
typedef struct node {
typedef struct endpt {
     task_t task;
     task_t task;
    struct node * next;
    struct endpt * next;
} node_t;
} endpt_t;
 
 
 
 
 
 
unsigned int total_active_routers=0;
unsigned int total_active_routers=0;
unsigned int task_graph_total_pck_num=0;
unsigned int task_graph_total_pck_num=0;
node_t * task_graph_data[NE];
unsigned int task_graph_min_pck_size=999999;
 
unsigned int task_graph_max_pck_size=0;
 
 
 
endpt_t * task_graph_data[NE];
index_t task_graph_abstract[NE];
index_t task_graph_abstract[NE];
 
 
 
 
 
 
 
 
void push(node_t ** head,  task_t task) {
void push(endpt_t ** head,  task_t task) {
    node_t * new_node;
    endpt_t * new_endpt;
    new_node =  (node_t *) malloc(sizeof(node_t));
    new_endpt =  (endpt_t *) malloc(sizeof(endpt_t));
    if( new_node == NULL){
    if( new_endpt == NULL){
        printf("Error: cannot allocate memory in push function\n");
        printf("ERROR: cannot allocate memory in push function\n");
            exit(1);
            exit(1);
        }
        }
    new_node->task=task;
    new_endpt->task=task;
    new_node->next = *head;
    new_endpt->next = *head;
    *head = new_node;
    *head = new_endpt;
}
}
 
 
int pop(node_t ** head) {
int pop(endpt_t ** head) {
   // int retval = -1;
   // int retval = -1;
    node_t * next_node = NULL;
    endpt_t * next_endpt = NULL;
 
 
    if (*head == NULL) {
    if (*head == NULL) {
        return -1;
        return -1;
    }
    }
 
 
    next_node = (*head)->next;
    next_endpt = (*head)->next;
    //retval = (*head)->val;
    //retval = (*head)->val;
    free(*head);
    free(*head);
    *head = next_node;
    *head = next_endpt;
        return 1;
        return 1;
    //return retval;
    //return retval;
}
}
 
 
 
 
int remove_by_index(node_t ** head, int n) {
int remove_by_index(endpt_t ** head, int n) {
    int i = 0;
    int i = 0;
   // int retval = -1;
   // int retval = -1;
    node_t * current = *head;
    endpt_t * current = *head;
    node_t * temp_node = NULL;
    endpt_t * temp_endpt = NULL;
 
 
    if (n == 0) {
    if (n == 0) {
        return pop(head);
        return pop(head);
    }
    }
 
 
Line 101... Line 104...
            return -1;
            return -1;
        }
        }
        current = current->next;
        current = current->next;
    }
    }
 
 
    temp_node = current->next;
    temp_endpt = current->next;
    //retval = temp_node->val;
    //retval = temp_endpt->val;
    current->next = temp_node->next;
    current->next = temp_endpt->next;
    free(temp_node);
    free(temp_endpt);
    return 1;
    return 1;
 
 
}
}
 
 
 
 
int update_by_index(node_t * head,int loc,  task_t  task) {
int update_by_index(endpt_t * head,int loc,  task_t  task) {
    node_t * current = head;
    endpt_t * current = head;
        int i;
        int i;
        for (i=0;i<loc && current != NULL;i++){
        for (i=0;i<loc && current != NULL;i++){
                current = current->next;
                current = current->next;
 
 
        }
        }
Line 124... Line 127...
    return 1;
    return 1;
 
 
}
}
 
 
 
 
int read(node_t * head, int loc,  task_t  * task ) {
int read(endpt_t * head, int loc,  task_t  * task ) {
    node_t * current = head;
    endpt_t * current = head;
        int i;
        int i;
        for (i=0;i<loc && current != NULL;i++){
        for (i=0;i<loc && current != NULL;i++){
                current = current->next;
                current = current->next;
 
 
        }
        }
Line 152... Line 155...
 
 
int extract_traffic_data ( char * str,  task_t*  st)
int extract_traffic_data ( char * str,  task_t*  st)
{
{
 
 
        unsigned int src;
        unsigned int src;
        unsigned int dst; // ID of the destination node (PE)
        unsigned int dst; // ID of the destination endpt (PE)
        unsigned int bytes;
        unsigned int bytes;
        unsigned int initial_weight;
        unsigned int initial_weight;
        unsigned int min_pck_size;              //in flit
        unsigned int min_pck_size;              //in flit
        unsigned int max_pck_size;              //in flit
        unsigned int max_pck_size;              //in flit
        unsigned int burst;
        unsigned int burst;
Line 180... Line 183...
        //
        //
        st->avg_pck_size=  (st->min_pck_size + st->max_pck_size)/2;
        st->avg_pck_size=  (st->min_pck_size + st->max_pck_size)/2;
        st->estimated_total_pck_num = (bytes*8) /(st->avg_pck_size*Fpay);
        st->estimated_total_pck_num = (bytes*8) /(st->avg_pck_size*Fpay);
        if(st->estimated_total_pck_num==0) st->estimated_total_pck_num= 1;
        if(st->estimated_total_pck_num==0) st->estimated_total_pck_num= 1;
        task_graph_total_pck_num=task_graph_total_pck_num+st->estimated_total_pck_num;
        task_graph_total_pck_num=task_graph_total_pck_num+st->estimated_total_pck_num;
 
        if(task_graph_min_pck_size > st->min_pck_size ) task_graph_min_pck_size=  st->min_pck_size;
 
        if(task_graph_max_pck_size < st->max_pck_size ) task_graph_max_pck_size=  st->max_pck_size;
 
 
        st->pck_sent=0;
        st->pck_sent=0;
        st->byte_sent=0;
        st->byte_sent=0;
    st->burst_sent=0;
    st->burst_sent=0;
 
 
   return 1;
   return 1;
}
}
 
 
int calcualte_traffic_parameters(node_t * head[NE],index_t (* info)){
int calcualte_traffic_parameters(endpt_t * head[NE],index_t (* info)){
        int i,j;
        int i,j;
         task_t  task;
         task_t  task;
 
 
        unsigned int max_bytes=0,accum[NE];
        unsigned int max_bytes=0,accum[NE];
        unsigned int min_total[NE];
        unsigned int min_total[NE];
Line 237... Line 242...
 
 
 
 
 
 
 
 
 
 
void load_traffic_file(char * file, node_t * head[NE], index_t (* info)){
void load_traffic_file(char * file, endpt_t * head[NE], index_t (* info)){
        FILE * in;
        FILE * in;
        char * line = NULL;
        char * line = NULL;
 
 
     task_t st;
     task_t st;
    char l[MAX_LINE_LEN];
    char l[MAX_LINE_LEN];
    in = fopen(file,"rb");
    in = fopen(file,"rb");
    int n,i;
    int n,i;
 
 
    if(in == NULL){
    if(in == NULL){
        printf("Error: cannot open %s file in read mode!\n",file);
        fprintf(stderr,"ERROR: cannot open %s file in read mode!\n",file);
            exit(1);
            exit(1);
        }
        }
 
 
    for(i=0;i<NE;i++){
    for(i=0;i<NE;i++){
                        head[i]=NULL;
                        head[i]=NULL;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.