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/] [simulator.cpp] - Diff between revs 54 and 56

Show entire file | Details | Blame | View Log

Rev 54 Rev 56
Line 51... Line 51...
 
 
 
 
        /********************
        /********************
        *       initialize input
        *       initialize input
        *********************/
        *********************/
 
 
        reset=1;
        reset=1;
 
    reset_active_high=1;
        reset_all_register();
        reset_all_register();
        start_i=0;
        start_i=0;
 
 
        mcast_init();
        mcast_init();
 
 
Line 78... Line 78...
        main_time=0;
        main_time=0;
        print_parameter();
        print_parameter();
        if( thread_num>1) initial_threads();
        if( thread_num>1) initial_threads();
 
 
        while (!Verilated::gotFinish()) {
        while (!Verilated::gotFinish()) {
 
        if(main_time - saved_time < 50) {//set reset and start
                if (main_time-saved_time >= 10 ) {
            reset_active_high = ((router1[0]->router_event[0] & ACTIVE_HIGH_RST)==1)? 1 : 0;
                        reset = 0;
            if (main_time-saved_time >= 10 ) reset = (reset_active_high)? 0 :1;
                }
            else reset = reset_active_high;     ;//keep system in reset
 
 
                if(main_time == saved_time+21){ count_en=1; start_i=1;}
                if(main_time == saved_time+21){ count_en=1; start_i=1;}
                if(main_time == saved_time+23) start_i=0;
                if(main_time == saved_time+23) start_i=0;
 
        }
 
 
                if(TRAFFIC_TYPE==NETRACE) netrace_posedge_event();
                if(TRAFFIC_TYPE==NETRACE) netrace_posedge_event();
                else if(TRAFFIC_TYPE ==SYNFUL) synful_posedge_event();
                else if(TRAFFIC_TYPE ==SYNFUL) synful_posedge_event();
                else traffic_clk_posedge_event();
                else traffic_clk_posedge_event();
 
 
Line 461... Line 462...
 
 
 
 
 
 
 
 
void pck_dst_gen (      unsigned int core_num, unsigned char * inject_en) {
void pck_dst_gen (      unsigned int core_num, unsigned char * inject_en) {
 
 
        unsigned int dest = pck_dst_gen_unicast (core_num, inject_en);
        unsigned int dest = pck_dst_gen_unicast (core_num, inject_en);
 
//    printf("inject_en=%u, core_num=%u, dest=%u\n",*inject_en, core_num,dest);
        if(IS_UNICAST){
        if(IS_UNICAST){
                traffic[core_num]->dest_e_addr= dest;
                traffic[core_num]->dest_e_addr= dest;
                return;
                return;
        }
        }
        else if (*inject_en==0) return;
        else if (*inject_en==0) return;
Line 533... Line 534...
         for (i=1;i<3*HOTSPOT_NUM; i+=3){
         for (i=1;i<3*HOTSPOT_NUM; i+=3){
                new_node[i/3]. ip_num = array[i];
                new_node[i/3]. ip_num = array[i];
            new_node[i/3]. send_enable=array[i+1];
            new_node[i/3]. send_enable=array[i+1];
            new_node[i/3]. percentage =  acuum + array[i+2];
            new_node[i/3]. percentage =  acuum + array[i+2];
            acuum= new_node[i/3]. percentage;
            acuum= new_node[i/3]. percentage;
 
 
         }
         }
         if(acuum> 1000){
         if(acuum> 1000){
                        printf("Warning: The hotspot traffic summation %f exceed than 100 percent.  \n", (float) acuum /10);
                        printf("Warning: The hotspot traffic summation %f exceed than 100 percent.  \n", (float) acuum /10);
         }
         }
         hotspots=new_node;
         hotspots=new_node;
Line 760... Line 760...
                pck_dst_gen (i, &inject_en);
                pck_dst_gen (i, &inject_en);
                //traffic[i]->dest_e_addr= dest_e_addr;
                //traffic[i]->dest_e_addr= dest_e_addr;
                if(inject_en == 0) traffic[i]->stop=1;
                if(inject_en == 0) traffic[i]->stop=1;
                //printf("src=%u, des_eaddr=%x, dest=%x\n", i,dest_e_addr, endp_addr_decoder(dest_e_addr));
                //printf("src=%u, des_eaddr=%x, dest=%x\n", i,dest_e_addr, endp_addr_decoder(dest_e_addr));
                if(inject_done) traffic[i]->stop=1;
                if(inject_done) traffic[i]->stop=1;
                traffic[i]->start_delay=rnd_between(11,4*NE-12);
            traffic[i]->start_delay=rnd_between(10,500);
                if(TRAFFIC_TYPE==SYNTHETIC){
                if(TRAFFIC_TYPE==SYNTHETIC){
                        //traffic[i]->avg_pck_size_in=AVG_PACKET_SIZE;
                        //traffic[i]->avg_pck_size_in=AVG_PACKET_SIZE;
                        traffic[i]->ratio=ratio;
                        traffic[i]->ratio=ratio;
                        traffic[i]->init_weight=1;
                        traffic[i]->init_weight=1;
                }
                }
Line 1076... Line 1076...
}
}
 
 
void update_traffic_injector_st (unsigned int i){
void update_traffic_injector_st (unsigned int i){
        unsigned char inject_en;
        unsigned char inject_en;
        // a packet has been received
        // a packet has been received
        if(traffic[i]->update & ~reset){
    if(traffic[i]->update & (main_time-saved_time >= 10 )){
                total_rsv_pck_num+=1;
                total_rsv_pck_num+=1;
                update_noc_statistic (i) ;
                update_noc_statistic (i) ;
        }
        }
        // the header flit has been sent out
        // the header flit has been sent out
        if(traffic[i]->hdr_flit_sent ){
        if(traffic[i]->hdr_flit_sent ){
Line 1465... Line 1465...
        #if(DEBUG_EN)
        #if(DEBUG_EN)
                printf ("\tDebuging is enabled\n");
                printf ("\tDebuging is enabled\n");
        #else
        #else
                printf ("\tDebuging is disabled\n");
                printf ("\tDebuging is disabled\n");
        #endif
        #endif
 
 
        //if(strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)printf ("\tOutput is the average latency on sending the packet header until receiving tail\n");
        //if(strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)printf ("\tOutput is the average latency on sending the packet header until receiving tail\n");
        //else printf ("\tOutput is the average latency on sending the packet header until receiving header flit at destination node\n");
        //else printf ("\tOutput is the average latency on sending the packet header until receiving header flit at destination node\n");
        printf ("\tTraffic pattern:%s\n",TRAFFIC);
        printf ("\tTraffic pattern:%s\n",TRAFFIC);
        size_t n = sizeof(class_percentage)/sizeof(class_percentage[0]);
        size_t n = sizeof(class_percentage)/sizeof(class_percentage[0]);
        for(int p=0;p<n; p++){
        for(int p=0;p<n; p++){
Line 1708... Line 1709...
}
}
 
 
void update_router_st (
void update_router_st (
                unsigned int Pnum,
                unsigned int Pnum,
                unsigned int rid,
                unsigned int rid,
                EVENT * event
        void * event,
 
        size_t size
){
){
 
    unsigned int port_event;
 
 
        for (int p=0;p<Pnum;p++){
        for (int p=0;p<Pnum;p++){
                if(event[p] & FLIT_IN_WR_FLG ) router_stat [rid][p].flit_num_in++;
        if (size == sizeof(unsigned char)) {
                if(event[p] & PCK_IN_WR_FLG  ) router_stat [rid][p].pck_num_in++;
            unsigned char * eventArr = (unsigned char *)event;
                if(event[p] & FLIT_OUT_WR_FLG) router_stat [rid][p].flit_num_out++;
            port_event = eventArr[p];
                if(event[p] & PCK_OUT_WR_FLG ) router_stat [rid][p].pck_num_out++;
        }
                if(event[p] & FLIT_IN_BYPASSED)router_stat [rid][p].flit_num_in_bypassed++;
        if (size == sizeof(short int)) {
                else if( event[p] & FLIT_IN_WR_FLG){
            unsigned short int * eventArr = (unsigned short int *)event;
 
            port_event = eventArr[p];
 
        }
 
        if (size == sizeof(int)) {
 
            unsigned int * eventArr = (unsigned int *)event;
 
            port_event = eventArr[p];
 
        }
 
 
 
 
 
        if(port_event & FLIT_IN_WR_FLG ) router_stat [rid][p].flit_num_in++;
 
        if(port_event & PCK_IN_WR_FLG  ) router_stat [rid][p].pck_num_in++;
 
        if(port_event & FLIT_OUT_WR_FLG) router_stat [rid][p].flit_num_out++;
 
        if(port_event & PCK_OUT_WR_FLG ) router_stat [rid][p].pck_num_out++;
 
        if(port_event & FLIT_IN_BYPASSED)router_stat [rid][p].flit_num_in_bypassed++;
 
        else if(port_event & FLIT_IN_WR_FLG){
                        router_stat [rid][p].flit_num_in_buffered++;
                        router_stat [rid][p].flit_num_in_buffered++;
                        int bypassed_times = (event[p] >> BYPASS_LSB);
            unsigned int bypassed_times = (port_event >> BYPASS_LSB);
                        router_stat [rid][p].bypass_counter[bypassed_times]++;
                        router_stat [rid][p].bypass_counter[bypassed_times]++;
                }
                }
        }
        }
}
}
 
 

powered by: WebSVN 2.1.0

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