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 41 and 42

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 41 Rev 42
Line 28... Line 28...
 
 
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit)))
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit)))
 
 
#include "traffic_task_graph.h"
#include "traffic_task_graph.h"
 
 
 
#define STND_DEV_EN 1
 
 
 
 
//Vrouter *router;
//Vrouter *router;
Vrouter                 *router[NC];                     // Instantiation of module
Vrouter                 *router[NC];                     // Instantiation of module
Vnoc                    *noc;
Vnoc                    *noc;
Line 79... Line 79...
 
 
 
 
 
 
 
 
#if (STND_DEV_EN)
#if (STND_DEV_EN)
        #include <math.h>
        //#include <math.h>
 
        double sqroot (double s){
 
                int i;
 
                double root = s/3;
 
                if (s<=0) return 0;
 
                for(i=0;i<32;i++) root = (root +s/root)/2;
 
                return root;
 
        }
 
 
        double       sum_clk_pow2=0;
        double       sum_clk_pow2=0;
        double       sum_clk_pow2_per_class[C]={0};
        double       sum_clk_pow2_per_class[C];
        double standard_dev( double , unsigned int, double);
        double standard_dev( double , unsigned int, double);
#endif
#endif
 
 
void update_noc_statistic (
void update_noc_statistic (
        int
        int
Line 613... Line 621...
                        avg_latency_flit   = (double)sum_clk_h2h/total_pck_num;
                        avg_latency_flit   = (double)sum_clk_h2h/total_pck_num;
                        avg_latency_pck    = (double)sum_clk_h2t/total_pck_num;
                        avg_latency_pck    = (double)sum_clk_h2t/total_pck_num;
                        if(ratio==RATIO_INIT) first_avg_latency_flit=avg_latency_flit;
                        if(ratio==RATIO_INIT) first_avg_latency_flit=avg_latency_flit;
#if (STND_DEV_EN)
#if (STND_DEV_EN)
                        std_dev= standard_dev( sum_clk_pow2,total_pck_num, avg_latency_flit);
                        std_dev= standard_dev( sum_clk_pow2,total_pck_num, avg_latency_flit);
 
                        printf(" standard_dev = %f\n",std_dev);
 
 
                       // sprintf(file_name,"%s_std.txt",out_file_name);
                       // sprintf(file_name,"%s_std.txt",out_file_name);
                        //update_file( file_name,avg_throughput,std_dev);
                        //update_file( file_name,avg_throughput,std_dev);
 
 
#endif
#endif
                        avg_latency_per_hop    = (double)sum_clk_per_hop/total_pck_num;
                        avg_latency_per_hop    = (double)sum_clk_per_hop/total_pck_num;
Line 774... Line 784...
 *      standard_dev
 *      standard_dev
 *
 *
 * ******************/
 * ******************/
 
 
#if (STND_DEV_EN)
#if (STND_DEV_EN)
 
/************************
 
 * std_dev = sqrt[(B-A^2/N)/N]  = sqrt [(B/N)- (A/N)^2] = sqrt [B/N - mean^2]
 
 * A = sum of the values
 
 * B = sum of the squarded values
 
 * *************/
 
 
double standard_dev( double sum_pow2, unsigned int  total_num, double average){
double standard_dev( double sum_pow2, unsigned int  total_num, double average){
        double std_dev;
        double std_dev;
 
 
        std_dev = sum_pow2/(double)total_num;
        /*
        std_dev -= (average*average);
        double  A, B, N;
        std_dev = sqrt(std_dev);
        N= total_num;
 
        A= average * N;
 
        B= sum_pow2;
 
 
 
        A=(A*A)/N;
 
        std_dev = (B-A)/N;
 
        std_dev = sqrt(std_dev);
 
*/
 
 
 
        std_dev = sum_pow2/(double)total_num; //B/N
 
        std_dev -= (average*average);// (B/N) - mean^2
 
        std_dev = sqroot(std_dev);// sqrt [B/N - mean^2]
 
 
        return std_dev;
        return std_dev;
 
 
}
}
 
 

powered by: WebSVN 2.1.0

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