├── doc ├── .gitignore └── Makefile ├── .gitignore ├── src ├── .gitignore ├── examples │ ├── anynet │ │ ├── anynet_file │ │ ├── README │ │ └── anynet_config │ ├── torus88 │ ├── cmeshconfig │ ├── singleconfig │ ├── mesh88_lat │ ├── dragonflyconfig │ ├── fattree_config │ └── flatflyconfig ├── power │ ├── techfile.txt │ ├── switch_monitor.hpp │ ├── buffer_monitor.hpp │ ├── switch_monitor.cpp │ └── buffer_monitor.cpp ├── config.y ├── config.l ├── rng_wrapper.cpp ├── misc_utils.hpp ├── rng_double_wrapper.cpp ├── booksim.hpp ├── allocators │ ├── pim.hpp │ ├── loa.hpp │ ├── islip.hpp │ ├── selalloc.hpp │ ├── maxsize.hpp │ ├── separable_output_first.hpp │ ├── wavefront.hpp │ ├── separable_input_first.hpp │ ├── separable.hpp │ ├── separable.cpp │ ├── loa.cpp │ ├── pim.cpp │ ├── separable_input_first.cpp │ └── separable_output_first.cpp ├── misc_utils.cpp ├── timed_module.hpp ├── booksim_config.hpp ├── globals.hpp ├── credit.hpp ├── packet_reply_info.hpp ├── random_utils.cpp ├── packet_reply_info.cpp ├── networks │ ├── fly.hpp │ ├── kncube.hpp │ ├── qtree.hpp │ ├── fattree.hpp │ ├── tree4.hpp │ ├── anynet.hpp │ ├── dragonfly.hpp │ ├── cmesh.hpp │ └── flatfly_onchip.hpp ├── routefunc.hpp ├── arbiters │ ├── prio_arb.hpp │ ├── matrix_arb.hpp │ ├── tree_arb.hpp │ ├── roundrobin_arb.hpp │ ├── roundrobin_arb.cpp │ └── arbiter.hpp ├── module.hpp ├── credit.cpp ├── outputset.hpp ├── stats.hpp ├── injection.hpp ├── random_utils.hpp ├── batchtrafficmanager.hpp ├── Makefile ├── buffer.cpp ├── flit.hpp ├── module.cpp ├── pipefifo.hpp ├── flitchannel.cpp ├── config_utils.hpp ├── flit.cpp ├── flitchannel.hpp ├── vc.hpp ├── channel.hpp └── stats.cpp ├── runfiles ├── dragonflyconfig ├── meshconfig ├── immutable ├── immutabletest ├── ftreeconfig ├── flatflyconfig1 ├── knconfig ├── cmeshconfig └── flatflyconfig ├── README.md └── LICENSE.md /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | *.pdf 4 | *.toc 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#*# 3 | ._* 4 | .Apple* 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | booksim 2 | lex.yy.c 3 | y.tab.c 4 | y.tab.h 5 | *.o 6 | *.d 7 | -------------------------------------------------------------------------------- /src/examples/anynet/anynet_file: -------------------------------------------------------------------------------- 1 | router 0 node 0 node 1 node 2 router 1 2 | router 1 node 3 node 4 node 5 3 | router 2 node 6 node 7 node 8 router 1 router 0 4 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | pdflatex manual.tex 3 | pdflatex manual.tex 4 | pdflatex manual.tex 5 | clean: 6 | rm -f manual.pdf 7 | rm -f manual.aux 8 | rm -f manual.dvi 9 | rm -f manual.log 10 | rm -f manual.toc 11 | rm -f *~ 12 | -------------------------------------------------------------------------------- /src/power/techfile.txt: -------------------------------------------------------------------------------- 1 | // 2007 ITRS predictions for a 32nm high-performance library 2 | H_INVD2 = 8;//int 3 | W_INVD2 = 3;//int 4 | H_DFQD1 = 8;//int 5 | W_DFQD1 = 16;//int 6 | H_ND2D1 = 8;//int 7 | W_ND2D1 = 3;//int 8 | H_SRAM = 8;//int 9 | W_SRAM = 6;//int 10 | Vdd = 0.9;//float 11 | R = 606.321;//float 12 | IoffSRAM = 0.00000032;//float 13 | // 70 C 14 | IoffP = 0.00000102;//float 15 | IoffN = 0.00000102;//float 16 | Cg_pwr = 0.000000000000000534;//float 17 | Cd_pwr = 0.000000000000000267;//float 18 | Cgdl = 0.0000000000000001068;//float 19 | Cg = 0.000000000000000534;//float 20 | Cd = 0.000000000000000267;//float 21 | LAMBDA = 0.016;//float 22 | MetalPitch = 0.000080;//float 23 | Rw = 0.720044;//float 24 | Cw_gnd = 0.000000000000267339;//float 25 | Cw_cpl = 0.000000000000267339;//float 26 | wire_length = 2.0;//float -------------------------------------------------------------------------------- /src/config.y: -------------------------------------------------------------------------------- 1 | %{ 2 | 3 | int yylex(void); 4 | void yyerror(char * msg); 5 | void config_assign_string( char const * field, char const * value ); 6 | void config_assign_int( char const * field, int value ); 7 | void config_assign_float( char const * field, double value ); 8 | 9 | #ifdef _WIN32 10 | #pragma warning ( disable : 4102 ) 11 | #pragma warning ( disable : 4244 ) 12 | #endif 13 | 14 | %} 15 | 16 | %union { 17 | char *name; 18 | int num; 19 | double fnum; 20 | } 21 | 22 | %token STR 23 | %token NUM 24 | %token FNUM 25 | 26 | %% 27 | 28 | commands : commands command 29 | | command 30 | ; 31 | 32 | command : STR '=' STR ';' { config_assign_string( $1, $3 ); free( $1 ); free( $3 ); } 33 | | STR '=' NUM ';' { config_assign_int( $1, $3 ); free( $1 ); } 34 | | STR '=' FNUM ';' { config_assign_float( $1, $3 ); free( $1 ); } 35 | ; 36 | 37 | %% 38 | -------------------------------------------------------------------------------- /runfiles/dragonflyconfig: -------------------------------------------------------------------------------- 1 | // Dragonfly 2 | // 3 | // Flow co1 ntrol 4 | // 5 | 6 | // Total number of VCs must match the above assignments 7 | num_vcs = 3; 8 | 9 | vc_buf_size = 256; 10 | 11 | wait_for_tail_credit = 0; 12 | 13 | // 14 | // Router architecture 15 | // 16 | vc_allocator = islip; 17 | sw_allocator = islip; 18 | alloc_iters = 4; 19 | 20 | credit_delay = 2; 21 | routing_delay = 0; 22 | vc_alloc_delay = 1; 23 | sw_alloc_delay = 1; 24 | st_final_delay = 1; 25 | 26 | input_speedup = 1; 27 | output_speedup = 1; 28 | internal_speedup = 1.7; 29 | 30 | 31 | //iq_routing_delay = 0; 32 | //row_routing_delay = 0; 33 | //subsw_alloc_delay = 0; 34 | //out_alloc_delay = 0; 35 | 36 | warmup_periods = 3; 37 | sim_count = 1; 38 | 39 | sample_period = 1000; 40 | 41 | 42 | routing_function = min; 43 | 44 | priority = none; 45 | traffic = uniform ; 46 | 47 | injection_rate =0.2; 48 | packet_size = 1; 49 | 50 | topology = dragonflynew; 51 | 52 | k = 4; 53 | n = 1; 54 | 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BookSim Interconnection Network Simulator 2 | ========================================= 3 | 4 | BookSim is a cycle-accurate interconnection network simulator. 5 | Originally developed for and introduced with the [Principles and Practices of Interconnection Networks](http://cva.stanford.edu/books/ppin/) book, its functionality has since been continuously extended. 6 | The current major release, BookSim 2.0, supports a wide range of topologies such as mesh, torus and flattened butterfly networks, provides diverse routing algorithms and includes numerous options for customizing the network's router microarchitecture. 7 | 8 | --- 9 | 10 | If you use BookSim in your research, we would appreciate the following citation in any publications to which it has contributed: 11 | 12 | Nan Jiang, Daniel U. Becker, George Michelogiannakis, James Balfour, Brian Towles, John Kim and William J. Dally. A Detailed and Flexible Cycle-Accurate Network-on-Chip Simulator. In *Proceedings of the 2013 IEEE International Symposium on Performance Analysis of Systems and Software*, 2013. -------------------------------------------------------------------------------- /src/config.l: -------------------------------------------------------------------------------- 1 | %option noinput 2 | %option nounput 3 | 4 | %{ 5 | 6 | #include 7 | 8 | #include "y.tab.h" 9 | 10 | static unsigned int lineno = 1; 11 | 12 | void config_error(char * msg, int lineno); 13 | void yyerror(char * msg); 14 | 15 | extern int config_input(char *, int); 16 | #undef YY_INPUT 17 | #define YY_INPUT(b, r, ms) (r = config_input(b, ms)) 18 | 19 | %} 20 | 21 | Digit [0-9] 22 | Exponent [eE][+-]?{Digit}+ 23 | DblConst ({Digit}*\.)?{Digit}+{Exponent}? 24 | StrConst [A-Za-z_\-/\.][A-Za-z0-9_\-/\.\+(\{\,)\}]* 25 | 26 | %% 27 | 28 | /* Ignore comments and all spaces */ 29 | 30 | \/\/[^\n]* ; 31 | [ \t\r]* ; 32 | 33 | \n { lineno++; } 34 | 35 | /* Commands */ 36 | 37 | \{[A-Za-z0-9_\-\.(\{\,)\}]+(\,[A-Za-z0-9_\-\.(\{\,)\}]+)*\} { yylval.name = strdup( yytext ); return STR; } 38 | 39 | -?[0-9]+ { yylval.num = atoi( yytext ); return NUM; } 40 | 41 | -?[0-9]*\.[0-9]+ { yylval.fnum = atof( yytext ); return FNUM; } 42 | 43 | -?{DblConst} { yylval.fnum = atof( yytext ); return FNUM;} 44 | 45 | {StrConst} { yylval.name = strdup( yytext ); return STR; } 46 | 47 | . { return yytext[0]; } 48 | 49 | %% 50 | 51 | void yyerror( char * msg ) 52 | { 53 | config_error( msg, lineno ); 54 | } 55 | 56 | int yywrap() 57 | { 58 | return 1; 59 | } 60 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior 2 | University 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/rng_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define main rng_main 29 | #include "rng.c" 30 | 31 | long ran_next( ) 32 | { 33 | return ran_arr_next( ); 34 | } 35 | -------------------------------------------------------------------------------- /src/misc_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MISC_UTILS_HPP_ 29 | #define _MISC_UTILS_HPP_ 30 | 31 | int log_two( int x ); 32 | int powi( int x, int y ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/rng_double_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define main rng_double_main 29 | #include "rng-double.c" 30 | 31 | double ranf_next( ) 32 | { 33 | return ranf_arr_next( ); 34 | } 35 | -------------------------------------------------------------------------------- /src/examples/torus88: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | //simple 8X8 torus under injection mode 28 | 29 | 30 | // Topology 31 | topology = torus; 32 | k = 8; 33 | n = 2; 34 | // Routing 35 | routing_function = dim_order; 36 | // Flow control 37 | num_vcs = 2; 38 | // Traffic 39 | traffic = uniform; 40 | injection_rate = 0.15; 41 | -------------------------------------------------------------------------------- /src/booksim.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BOOKSIM_HPP_ 29 | #define _BOOKSIM_HPP_ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #ifdef _WIN32_ 37 | #pragma warning (disable: 4786) 38 | #include 39 | #endif 40 | 41 | using namespace std; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/allocators/pim.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PIM_HPP_ 29 | #define _PIM_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class PIM : public DenseAllocator { 36 | int _PIM_iter; 37 | 38 | public: 39 | PIM( Module *parent, const string& name, 40 | int inputs, int outputs, int iters ); 41 | 42 | ~PIM( ); 43 | 44 | void Allocate( ); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/misc_utils.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include "misc_utils.hpp" 30 | 31 | int powi( int x, int y ) // compute x to the y 32 | { 33 | int r = 1; 34 | 35 | for ( int i = 0; i < y; ++i ) { 36 | r *= x; 37 | } 38 | 39 | return r; 40 | } 41 | 42 | int log_two( int x ) 43 | { 44 | int r = 0; 45 | 46 | x >>= 1; 47 | while( x ) { 48 | r++; x >>= 1; 49 | } 50 | 51 | return r; 52 | } 53 | -------------------------------------------------------------------------------- /src/timed_module.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _TIMED_MODULE_HPP_ 29 | #define _TIMED_MODULE_HPP_ 30 | 31 | #include "module.hpp" 32 | 33 | class TimedModule : public Module { 34 | 35 | public: 36 | TimedModule(Module * parent, string const & name) : Module(parent, name) {} 37 | virtual ~TimedModule() {} 38 | 39 | virtual void ReadInputs() = 0; 40 | virtual void Evaluate() = 0; 41 | virtual void WriteOutputs() = 0; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/allocators/loa.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _LOA_HPP_ 29 | #define _LOA_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class LOA : public DenseAllocator { 36 | vector _counts; 37 | vector _req; 38 | 39 | vector _rptr; 40 | vector _gptr; 41 | 42 | public: 43 | LOA( Module *parent, const string& name, 44 | int inputs, int outputs ); 45 | 46 | void Allocate( ); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/allocators/islip.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ISLIP_HPP_ 29 | #define _ISLIP_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class iSLIP_Sparse : public SparseAllocator { 36 | int _iSLIP_iter; 37 | 38 | vector _gptrs; 39 | vector _aptrs; 40 | 41 | public: 42 | iSLIP_Sparse( Module *parent, const string& name, 43 | int inputs, int outputs, int iters ); 44 | 45 | void Allocate( ); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/examples/cmeshconfig: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | //concentrated mesh configuration file running batch mode 28 | //xr, yr, x, y, are use to indicate how the concnetration is formed. 29 | 30 | topology = cmesh; 31 | 32 | k = 4; 33 | n = 2; 34 | c = 4; 35 | xr = 2; 36 | yr = 2; 37 | 38 | x = 4; 39 | y = 4; 40 | 41 | routing_function = dor_no_express; 42 | 43 | traffic = bitcomp; 44 | 45 | use_read_write = 0; 46 | 47 | batch_size = 2000; 48 | -------------------------------------------------------------------------------- /src/booksim_config.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BOOKSIM_CONFIG_HPP_ 29 | #define _BOOKSIM_CONFIG_HPP_ 30 | 31 | #include "config_utils.hpp" 32 | 33 | class BookSimConfig : public Configuration { 34 | protected: 35 | 36 | public: 37 | BookSimConfig( ); 38 | }; 39 | 40 | #endif 41 | 42 | #ifndef _POWER_CONFIG_HPP_ 43 | #define _POWER_CONFIG_HPP_ 44 | 45 | #include "config_utils.hpp" 46 | 47 | class PowerConfig : public Configuration { 48 | public: 49 | PowerConfig( ); 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/globals.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _GLOBALS_HPP_ 29 | #define _GLOBALS_HPP_ 30 | #include 31 | #include 32 | #include 33 | 34 | /*all declared in main.cpp*/ 35 | 36 | int GetSimTime(); 37 | 38 | class Stats; 39 | Stats * GetStats(const std::string & name); 40 | 41 | extern bool gPrintActivity; 42 | 43 | extern int gK; 44 | extern int gN; 45 | extern int gC; 46 | 47 | extern int gNodes; 48 | 49 | extern bool gTrace; 50 | 51 | extern std::ostream * gWatchOut; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/credit.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _CREDIT_HPP_ 29 | #define _CREDIT_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | class Credit { 35 | 36 | public: 37 | 38 | set vc; 39 | 40 | // these are only used by the event router 41 | bool head, tail; 42 | int id; 43 | 44 | void Reset(); 45 | 46 | static Credit * New(); 47 | void Free(); 48 | static void FreeAll(); 49 | static int OutStanding(); 50 | private: 51 | 52 | static stack _all; 53 | static stack _free; 54 | 55 | Credit(); 56 | ~Credit() {} 57 | 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/examples/singleconfig: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | //A single cross 10X10 cross bar under injection mode 28 | 29 | topology = fly; 30 | 31 | k = 10; 32 | n = 1; 33 | 34 | num_vcs = 8; 35 | 36 | vc_buf_size = 8; 37 | 38 | vc_allocator = separable_input_first; 39 | sw_allocator = separable_input_first; 40 | 41 | routing_function = dest_tag; 42 | 43 | traffic = uniform; 44 | 45 | use_read_write = 0; 46 | 47 | injection_rate = 1.0; 48 | 49 | 50 | 51 | 52 | sample_period = 100000; 53 | 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | -------------------------------------------------------------------------------- /src/allocators/selalloc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _SELALLOC_HPP_ 29 | #define _SELALLOC_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class SelAlloc : public SparseAllocator { 36 | int _iter; 37 | 38 | vector _aptrs; 39 | vector _gptrs; 40 | 41 | vector _outmask; 42 | 43 | public: 44 | SelAlloc( Module *parent, const string& name, 45 | int inputs, int outputs, int iters ); 46 | 47 | void Allocate( ); 48 | 49 | void MaskOutput( int out, int mask = 1 ); 50 | 51 | virtual void PrintRequests( ostream * os = NULL ) const; 52 | 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/packet_reply_info.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PACKET_REPLY_INFO_HPP_ 29 | #define _PACKET_REPLY_INFO_HPP_ 30 | 31 | #include 32 | 33 | #include "flit.hpp" 34 | 35 | //register the requests to a node 36 | class PacketReplyInfo { 37 | 38 | public: 39 | int source; 40 | int time; 41 | bool record; 42 | Flit::FlitType type; 43 | 44 | static PacketReplyInfo* New(); 45 | void Free(); 46 | static void FreeAll(); 47 | 48 | private: 49 | 50 | static stack _all; 51 | static stack _free; 52 | 53 | PacketReplyInfo() {} 54 | ~PacketReplyInfo() {} 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/allocators/maxsize.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MAXSIZE_HPP_ 29 | #define _MAXSIZE_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class MaxSizeMatch : public DenseAllocator { 36 | vector _from; // array to hold breadth-first tree 37 | int *_s; // stack of leaf nodes in tree 38 | int *_ns; // next stack 39 | int _prio; // priority pointer to ensure fairness 40 | 41 | bool _ShortestAugmenting( ); 42 | 43 | public: 44 | MaxSizeMatch( Module *parent, const string& name, 45 | int inputs, int ouputs ); 46 | ~MaxSizeMatch( ); 47 | 48 | void Allocate( ); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/random_utils.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "random_utils.hpp" 29 | #include 30 | #include 31 | 32 | extern long ran_x[]; 33 | extern double ran_u[]; 34 | #define KK 100 35 | 36 | void SaveRandomState( std::vector & save_x, std::vector & save_u ) { 37 | save_x.assign(ran_x, ran_x + KK); 38 | save_u.assign(ran_u, ran_u + KK); 39 | } 40 | 41 | void RestoreRandomState( std::vector const & save_x, std::vector const & save_u) { 42 | assert(save_x.size() == KK); 43 | std::copy(save_x.begin(), save_x.end(), ran_x); 44 | assert(save_u.size() == KK); 45 | std::copy(save_u.begin(), save_u.end(), ran_u); 46 | } 47 | -------------------------------------------------------------------------------- /src/packet_reply_info.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "packet_reply_info.hpp" 29 | 30 | stack PacketReplyInfo::_all; 31 | stack PacketReplyInfo::_free; 32 | 33 | PacketReplyInfo * PacketReplyInfo::New() 34 | { 35 | PacketReplyInfo * pr; 36 | if(_free.empty()) { 37 | pr = new PacketReplyInfo(); 38 | _all.push(pr); 39 | } else { 40 | pr = _free.top(); 41 | _free.pop(); 42 | } 43 | return pr; 44 | } 45 | 46 | void PacketReplyInfo::Free() 47 | { 48 | _free.push(this); 49 | } 50 | 51 | void PacketReplyInfo::FreeAll() 52 | { 53 | while(!_all.empty()) { 54 | delete _all.top(); 55 | _all.pop(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/networks/fly.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FLY_HPP_ 29 | #define _FLY_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | class KNFly : public Network { 34 | 35 | int _k; 36 | int _n; 37 | 38 | void _ComputeSize( const Configuration &config ); 39 | void _BuildNet( const Configuration &config ); 40 | 41 | int _OutChannel( int stage, int addr, int port ) const; 42 | int _InChannel( int stage, int addr, int port ) const; 43 | 44 | public: 45 | KNFly( const Configuration &config, const string & name ); 46 | 47 | int GetN( ) const; 48 | int GetK( ) const; 49 | static void RegisterRoutingFunctions(){}; 50 | double Capacity( ) const; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/routefunc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ROUTEFUNC_HPP_ 29 | #define _ROUTEFUNC_HPP_ 30 | 31 | #include "flit.hpp" 32 | #include "router.hpp" 33 | #include "outputset.hpp" 34 | #include "config_utils.hpp" 35 | 36 | typedef void (*tRoutingFunction)( const Router *, const Flit *, int in_channel, OutputSet *, bool ); 37 | 38 | void InitializeRoutingMap( const Configuration & config ); 39 | 40 | extern map gRoutingFunctionMap; 41 | 42 | extern int gNumVCs; 43 | extern int gReadReqBeginVC, gReadReqEndVC; 44 | extern int gWriteReqBeginVC, gWriteReqEndVC; 45 | extern int gReadReplyBeginVC, gReadReplyEndVC; 46 | extern int gWriteReplyBeginVC, gWriteReplyEndVC; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/allocators/separable_output_first.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableOutputFirstAllocator: Separable Output-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_OUTPUT_FIRST_HPP_ 35 | #define _SEPARABLE_OUTPUT_FIRST_HPP_ 36 | 37 | #include "separable.hpp" 38 | 39 | class SeparableOutputFirstAllocator : public SeparableAllocator { 40 | 41 | public: 42 | 43 | SeparableOutputFirstAllocator( Module* parent, const string& name, int inputs, 44 | int outputs, const string& arb_type ) ; 45 | 46 | virtual void Allocate() ; 47 | 48 | } ; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/allocators/wavefront.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _WAVEFRONT_HPP_ 29 | #define _WAVEFRONT_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class Wavefront : public DenseAllocator { 36 | 37 | private: 38 | int _last_in; 39 | int _last_out; 40 | set > _priorities; 41 | bool _skip_diags; 42 | 43 | protected: 44 | int _square; 45 | int _pri; 46 | int _num_requests; 47 | 48 | public: 49 | Wavefront( Module *parent, const string& name, 50 | int inputs, int outputs, bool skip_diags = false ); 51 | 52 | virtual void AddRequest( int in, int out, int label = 1, 53 | int in_pri = 0, int out_pri = 0 ); 54 | virtual void Allocate( ); 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/allocators/separable_input_first.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableInputFirstAllocator: Separable Input-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_INPUT_FIRST_HPP_ 35 | #define _SEPARABLE_INPUT_FIRST_HPP_ 36 | 37 | #include 38 | 39 | #include "separable.hpp" 40 | 41 | class SeparableInputFirstAllocator : public SeparableAllocator { 42 | 43 | public: 44 | 45 | SeparableInputFirstAllocator( Module* parent, const string& name, int inputs, 46 | int outputs, const string& arb_type ) ; 47 | 48 | virtual void Allocate() ; 49 | 50 | } ; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/examples/anynet/README: -------------------------------------------------------------------------------- 1 | The "anynet" option in booksim2.0 gives you some ability setup arbitrary topology. Attached is a config file and a listing file for the "anynet". The listing file describes the connections between modules in the network (routers and nodes). For example, the first line of the file 2 | "router 0 node 0 node 1 node 2 router 1" 3 | means router0 is connected to node0, node1 node2, and router1. This also implies that router1 is connected to router 0, so on second line of the listing file, which describes the connections to router1, router0 can be omitted. There should be no restriction on the numbering of router and nodes, as long as they are unique. The only restriction is that a node can only be connected to a single router. 4 | 5 | After booksim parses and builds the network from the listing file, it builds a routing table in each router, which describes the minimal path between any two nodes. As a result there is no path diversity, there is a single path between any two nodes in the network. Of course you can change this by writing your own routing function. 6 | 7 | When you run booksim with these config files, it will print out a bunch of information on the connectivity and routing of the network. Check to makes sure it is what you expect. 8 | 9 | This feature is very experimental, be careful when you are using it, and double check to make sure the results is what you expected. 10 | 11 | It has been about 2 years since I last used this, so definitely becareful. If your topology is regular, I recommend using it as a topology class instead of using anynet. 12 | 13 | 14 | ==================================== 15 | 16 | 17 | I just made a major change to anynet. In addition to better pathfinding and parser. Now it recognize link weights. The new format is 18 | 19 | Router 0 Router 1 10 Router 2 5 20 | 21 | Router 0 is connected to router 1 with a 10-cycle channel and router 2 with a 5-cycle channel. If link latency is not present it assumes single cycle channel. 22 | 23 | Also the channel latency specification between routers are not bi-directional. In the example above, the channel from router 1 back to router 0 is single-cycle because it was not explicitly specified. -------------------------------------------------------------------------------- /src/examples/anynet/anynet_config: -------------------------------------------------------------------------------- 1 | // $Id: singleconfig 1535 2009-09-16 16:21:01Z dub $ 2 | 3 | // Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // Neither the name of the Stanford University nor the names of its contributors 15 | // may be used to endorse or promote products derived from this software without 16 | // specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | // POSSIBILITY OF SUCH DAMAGE. 29 | 30 | //A single cross 10X10 cross bar under injection mode 31 | 32 | topology = anynet; 33 | 34 | 35 | routing_function = min; 36 | network_file = anynet_file; 37 | traffic = uniform; 38 | 39 | use_read_write = 0; 40 | 41 | sample_period = 10000; 42 | injection_rate = 0.01; 43 | 44 | 45 | vc_allocator = separable_input_first; 46 | sw_allocator = separable_input_first; 47 | alloc_iters = 1; 48 | 49 | num_vcs = 1; 50 | vc_buf_size = 3; 51 | -------------------------------------------------------------------------------- /src/allocators/separable.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableAllocator: Separable Allocator Base Class 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_HPP_ 35 | #define _SEPARABLE_HPP_ 36 | 37 | #include 38 | 39 | #include "allocator.hpp" 40 | 41 | class Arbiter; 42 | 43 | class SeparableAllocator : public SparseAllocator { 44 | 45 | protected: 46 | 47 | vector _input_arb ; 48 | vector _output_arb ; 49 | 50 | public: 51 | 52 | SeparableAllocator( Module* parent, const string& name, int inputs, 53 | int outputs, const string& arb_type ) ; 54 | 55 | virtual ~SeparableAllocator() ; 56 | 57 | virtual void Clear() ; 58 | 59 | } ; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/arbiters/prio_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PRIO_ARB_HPP_ 29 | #define _PRIO_ARB_HPP_ 30 | 31 | #include 32 | 33 | #include "module.hpp" 34 | #include "config_utils.hpp" 35 | 36 | class PriorityArbiter : public Module { 37 | int _rr_ptr; 38 | 39 | protected: 40 | const int _inputs; 41 | 42 | struct sRequest { 43 | int in; 44 | int label; 45 | int pri; 46 | }; 47 | 48 | list _requests; 49 | 50 | int _match; 51 | 52 | public: 53 | PriorityArbiter( const Configuration &config, 54 | Module *parent, const string& name, 55 | int inputs ); 56 | 57 | void Clear( ); 58 | 59 | void AddRequest( int in, int label = 0, int pri = 0 ); 60 | void RemoveRequest( int in, int label = 0 ); 61 | 62 | int Match( ) const; 63 | 64 | void Arbitrate( ); 65 | void Update( ); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/networks/kncube.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _KNCUBE_HPP_ 29 | #define _KNCUBE_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | class KNCube : public Network { 34 | 35 | bool _mesh; 36 | 37 | int _k; 38 | int _n; 39 | 40 | void _ComputeSize( const Configuration &config ); 41 | void _BuildNet( const Configuration &config ); 42 | 43 | int _LeftChannel( int node, int dim ); 44 | int _RightChannel( int node, int dim ); 45 | 46 | int _LeftNode( int node, int dim ); 47 | int _RightNode( int node, int dim ); 48 | 49 | public: 50 | KNCube( const Configuration &config, const string & name, bool mesh ); 51 | static void RegisterRoutingFunctions(); 52 | 53 | int GetN( ) const; 54 | int GetK( ) const; 55 | 56 | double Capacity( ) const; 57 | 58 | void InsertRandomFaults( const Configuration &config ); 59 | 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/module.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MODULE_HPP_ 29 | #define _MODULE_HPP_ 30 | 31 | #include "booksim.hpp" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class Module { 38 | private: 39 | string _name; 40 | string _fullname; 41 | 42 | vector _children; 43 | 44 | protected: 45 | void _AddChild( Module *child ); 46 | 47 | public: 48 | Module( Module *parent, const string& name ); 49 | virtual ~Module( ) { } 50 | 51 | inline const string & Name() const { return _name; } 52 | inline const string & FullName() const { return _fullname; } 53 | 54 | void DisplayHierarchy( int level = 0, ostream & os = cout ) const; 55 | 56 | void Error( const string& msg ) const; 57 | void Debug( const string& msg ) const; 58 | 59 | virtual void Display( ostream & os = cout ) const; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/examples/mesh88_lat: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | //8X8 mesh with 20 flits per packet under injection mode 28 | //injection rate here is packet per cycle, NOT flit per cycle 29 | 30 | // Topology 31 | 32 | topology = mesh; 33 | k = 8; 34 | n = 2; 35 | 36 | // Routing 37 | routing_function = dor; 38 | 39 | // Flow control 40 | num_vcs = 8; 41 | vc_buf_size = 8; 42 | wait_for_tail_credit = 1; 43 | 44 | // Router architecture 45 | vc_allocator = islip; 46 | sw_allocator = islip; 47 | alloc_iters = 1; 48 | 49 | credit_delay = 2; 50 | routing_delay = 0; 51 | vc_alloc_delay = 1; 52 | sw_alloc_delay = 1; 53 | 54 | input_speedup = 2; 55 | output_speedup = 1; 56 | internal_speedup = 1.0; 57 | 58 | 59 | // Traffic 60 | traffic = transpose; 61 | packet_size = 20; 62 | 63 | 64 | // Simulation 65 | sim_type = latency; 66 | 67 | injection_rate = 0.005; 68 | 69 | -------------------------------------------------------------------------------- /src/credit.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*credit.cpp 29 | * 30 | *A class for credits 31 | */ 32 | 33 | #include "booksim.hpp" 34 | #include "credit.hpp" 35 | 36 | stack Credit::_all; 37 | stack Credit::_free; 38 | 39 | Credit::Credit() 40 | { 41 | Reset(); 42 | } 43 | 44 | void Credit::Reset() 45 | { 46 | vc.clear(); 47 | head = false; 48 | tail = false; 49 | id = -1; 50 | } 51 | 52 | Credit * Credit::New() { 53 | Credit * c; 54 | if(_free.empty()) { 55 | c = new Credit(); 56 | _all.push(c); 57 | } else { 58 | c = _free.top(); 59 | c->Reset(); 60 | _free.pop(); 61 | } 62 | return c; 63 | } 64 | 65 | void Credit::Free() { 66 | _free.push(this); 67 | } 68 | 69 | void Credit::FreeAll() { 70 | while(!_all.empty()) { 71 | delete _all.top(); 72 | _all.pop(); 73 | } 74 | } 75 | 76 | 77 | int Credit::OutStanding(){ 78 | return _all.size()-_free.size(); 79 | } 80 | -------------------------------------------------------------------------------- /runfiles/meshconfig: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | 28 | // 29 | // Flow control 30 | // 31 | 32 | num_vcs = 16; 33 | vc_buf_size = 8; 34 | 35 | wait_for_tail_credit = 1; 36 | 37 | 38 | vc_allocator = islip; 39 | sw_allocator = islip; 40 | alloc_iters = 2; 41 | 42 | credit_delay = 2; 43 | routing_delay = 0; 44 | vc_alloc_delay = 1; 45 | sw_alloc_delay = 1; 46 | st_final_delay = 1; 47 | 48 | input_speedup = 1; 49 | output_speedup = 1; 50 | internal_speedup = 1.0; 51 | 52 | // 53 | // Traffic 54 | // 55 | 56 | sim_type = latency; 57 | 58 | warmup_periods = 3; 59 | 60 | sample_period = 1000; 61 | 62 | sim_count = 1; 63 | 64 | 65 | 66 | //topoogy 67 | 68 | topology = mesh; 69 | k = 8; 70 | n = 2; 71 | // 72 | // Routing 73 | 74 | 75 | routing_function = dor; 76 | 77 | packet_size = 1; 78 | 79 | use_read_write = 0; 80 | 81 | traffic = uniform; 82 | 83 | injection_rate = 0.2; 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/examples/dragonflyconfig: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | // Dragonfly 28 | // 29 | 30 | 31 | 32 | 33 | vc_buf_size = 256; 34 | 35 | 36 | wait_for_tail_credit = 0; 37 | 38 | // 39 | // Router architecture 40 | // 41 | vc_allocator = separable_input_first; 42 | sw_allocator = separable_input_first; 43 | alloc_iters = 1; 44 | 45 | credit_delay = 2; 46 | routing_delay = 0; 47 | vc_alloc_delay = 1; 48 | sw_alloc_delay = 1; 49 | st_final_delay = 1; 50 | 51 | input_speedup = 1; 52 | output_speedup = 1; 53 | internal_speedup = 2.0; 54 | 55 | 56 | warmup_periods = 3; 57 | sim_count = 1; 58 | 59 | sample_period = 10000; 60 | 61 | 62 | 63 | routing_function = min; 64 | num_vcs = 2; 65 | 66 | priority = none; 67 | traffic = uniform; 68 | 69 | injection_rate = 0.8; 70 | packet_size = 10; 71 | injection_rate_uses_flits=1; 72 | 73 | topology = dragonflynew; 74 | 75 | k = 4; 76 | n = 1; 77 | 78 | watch_out=-; 79 | 80 | -------------------------------------------------------------------------------- /src/examples/fattree_config: -------------------------------------------------------------------------------- 1 | // $Id: dragonflyconfig 3555 2011-05-16 23:37:55Z dub $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | 28 | hold_switch_for_packet=1; 29 | 30 | vc_buf_size = 16; 31 | 32 | 33 | wait_for_tail_credit = 0; 34 | 35 | // 36 | // Router architecture 37 | // 38 | vc_allocator = separable_input_first; 39 | sw_allocator = separable_input_first; 40 | alloc_iters = 1; 41 | 42 | credit_delay = 2; 43 | routing_delay = 0; 44 | vc_alloc_delay = 1; 45 | sw_alloc_delay = 1; 46 | st_final_delay = 1; 47 | 48 | input_speedup = 1; 49 | output_speedup = 1; 50 | internal_speedup = 1.0; 51 | 52 | 53 | warmup_periods = 3; 54 | sim_count = 1; 55 | 56 | sample_period = 10000; 57 | 58 | 59 | 60 | routing_function = nca; 61 | num_vcs = 4; 62 | 63 | priority = none; 64 | traffic = uniform; 65 | 66 | injection_rate = 0.6; 67 | packet_size = 1; 68 | injection_rate_uses_flits=1; 69 | 70 | topology = fattree; 71 | 72 | 73 | k = 4; 74 | n = 3; 75 | 76 | watch_out=-; -------------------------------------------------------------------------------- /src/outputset.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _OUTPUTSET_HPP_ 29 | #define _OUTPUTSET_HPP_ 30 | 31 | #include 32 | 33 | class OutputSet { 34 | 35 | 36 | public: 37 | struct sSetElement { 38 | int vc_start; 39 | int vc_end; 40 | int pri; 41 | int output_port; 42 | }; 43 | 44 | void Clear( ); 45 | void Add( int output_port, int vc, int pri = 0 ); 46 | void AddRange( int output_port, int vc_start, int vc_end, int pri = 0 ); 47 | 48 | bool OutputEmpty( int output_port ) const; 49 | int NumVCs( int output_port ) const; 50 | 51 | const set & GetSet() const; 52 | 53 | int GetVC( int output_port, int vc_index, int *pri = 0 ) const; 54 | bool GetPortVC( int *out_port, int *out_vc ) const; 55 | private: 56 | set _outputs; 57 | }; 58 | 59 | inline bool operator<(const OutputSet::sSetElement & se1, 60 | const OutputSet::sSetElement & se2) { 61 | return se1.pri > se2.pri; // higher priorities first! 62 | } 63 | 64 | #endif 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/power/switch_monitor.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _SWITCH_MONITOR_HPP_ 29 | #define _SWITCH_MONITOR_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | class Flit; 37 | 38 | class SwitchMonitor { 39 | int _cycles ; 40 | int _inputs ; 41 | int _outputs ; 42 | int _classes ; 43 | vector _event ; 44 | int index( int input, int output, int cl ) const ; 45 | public: 46 | SwitchMonitor( int inputs, int outputs, int classes ) ; 47 | void cycle() ; 48 | vector const & GetActivity() const { 49 | return _event; 50 | } 51 | inline int const & NumInputs() const { 52 | return _inputs; 53 | } 54 | inline int const & NumOutputs() const { 55 | return _outputs; 56 | } 57 | inline int const & NumClasses() const { 58 | return _classes; 59 | } 60 | void traversal( int input, int output, Flit const * f ) ; 61 | void display(ostream & os) const; 62 | } ; 63 | 64 | ostream & operator<<( ostream & os, SwitchMonitor const & obj ) ; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/power/buffer_monitor.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BUFFER_MONITOR_HPP_ 29 | #define _BUFFER_MONITOR_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | class Flit; 37 | 38 | class BufferMonitor { 39 | int _cycles ; 40 | int _inputs ; 41 | int _classes ; 42 | vector _reads ; 43 | vector _writes ; 44 | int index( int input, int cl ) const ; 45 | public: 46 | BufferMonitor( int inputs, int classes ) ; 47 | void cycle() ; 48 | void write( int input, Flit const * f ) ; 49 | void read( int input, Flit const * f ) ; 50 | inline const vector & GetReads() const { 51 | return _reads; 52 | } 53 | inline const vector & GetWrites() const { 54 | return _writes; 55 | } 56 | inline int NumInputs() const { 57 | return _inputs; 58 | } 59 | inline int NumClasses() const { 60 | return _classes; 61 | } 62 | void display(ostream & os) const; 63 | 64 | } ; 65 | 66 | ostream & operator<<( ostream & os, BufferMonitor const & obj ) ; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/stats.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _STATS_HPP_ 29 | #define _STATS_HPP_ 30 | 31 | #include "module.hpp" 32 | 33 | class Stats : public Module { 34 | int _num_samples; 35 | double _sample_sum; 36 | double _sample_squared_sum; 37 | 38 | //bool _reset; 39 | double _min; 40 | double _max; 41 | 42 | int _num_bins; 43 | double _bin_size; 44 | 45 | vector _hist; 46 | 47 | public: 48 | Stats( Module *parent, const string &name, 49 | double bin_size = 1.0, int num_bins = 10 ); 50 | 51 | void Clear( ); 52 | 53 | double Average( ) const; 54 | double Variance( ) const; 55 | double Max( ) const; 56 | double Min( ) const; 57 | double Sum( ) const; 58 | double SquaredSum( ) const; 59 | int NumSamples( ) const; 60 | 61 | void AddSample( double val ); 62 | inline void AddSample( int val ) { 63 | AddSample( (double)val ); 64 | } 65 | 66 | int GetBin(int b){ return _hist[b];} 67 | 68 | void Display( ostream & os = cout ) const; 69 | 70 | friend ostream & operator<<(ostream & os, const Stats & s); 71 | 72 | }; 73 | 74 | ostream & operator<<(ostream & os, const Stats & s); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/injection.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _INJECTION_HPP_ 29 | #define _INJECTION_HPP_ 30 | 31 | #include "config_utils.hpp" 32 | 33 | using namespace std; 34 | 35 | class InjectionProcess { 36 | protected: 37 | int _nodes; 38 | double _rate; 39 | InjectionProcess(int nodes, double rate); 40 | public: 41 | virtual ~InjectionProcess() {} 42 | virtual bool test(int source) = 0; 43 | virtual void reset(); 44 | static InjectionProcess * New(string const & inject, int nodes, double load, 45 | Configuration const * const config = NULL); 46 | }; 47 | 48 | class BernoulliInjectionProcess : public InjectionProcess { 49 | public: 50 | BernoulliInjectionProcess(int nodes, double rate); 51 | virtual bool test(int source); 52 | }; 53 | 54 | class OnOffInjectionProcess : public InjectionProcess { 55 | private: 56 | double _alpha; 57 | double _beta; 58 | double _r1; 59 | vector _initial; 60 | vector _state; 61 | public: 62 | OnOffInjectionProcess(int nodes, double rate, double alpha, double beta, 63 | double r1, vector initial); 64 | virtual void reset(); 65 | virtual bool test(int source); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /runfiles/immutable: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 5; 33 | write_reply_begin_vc = 2; 34 | write_reply_end_vc = 7; 35 | read_reply_begin_vc = 8; 36 | read_reply_end_vc = 12; 37 | write_request_begin_vc = 10; 38 | write_request_end_vc = 15; 39 | 40 | // Total number of VCs must match the above assignments 41 | num_vcs = 16; 42 | vc_buf_size = 8; 43 | 44 | wait_for_tail_credit = 0; 45 | 46 | // 47 | // Router architectureq 48 | // 49 | vc_allocator = islip; 50 | sw_allocator = islip; 51 | alloc_iters = 2; 52 | 53 | credit_delay = 2; 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | 59 | input_speedup = 1; 60 | output_speedup = 1; 61 | internal_speedup = 1.0; 62 | 63 | // 64 | // Traffic 65 | // 66 | 67 | sim_type = latency; 68 | 69 | warmup_periods = 3; 70 | 71 | sample_period = 10000; 72 | 73 | sim_count = 1; 74 | 75 | ///////////////////END IMMUTABLE//////////////////////////////// 76 | -------------------------------------------------------------------------------- /src/networks/qtree.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // QTree: A Quad-Tree Indirect Network. 31 | // 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/05/17 17:14:07 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef _QTREE_HPP_ 43 | #define _QTREE_HPP_ 44 | #include 45 | #include "network.hpp" 46 | 47 | class QTree : public Network { 48 | 49 | int _k; 50 | int _n; 51 | 52 | void _ComputeSize( const Configuration& config ); 53 | void _BuildNet( const Configuration& config ); 54 | 55 | int _RouterIndex( int height, int pos ); 56 | int _InputIndex( int height, int pos, int port ); 57 | int _OutputIndex( int height, int pos, int port ); 58 | 59 | public: 60 | 61 | QTree( const Configuration& config, const string & name ); 62 | static void RegisterRoutingFunctions() ; 63 | 64 | static int HeightFromID( int id ); 65 | static int PosFromID( int id ); 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /runfiles/immutabletest: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 15; 33 | write_reply_begin_vc = 0; 34 | write_reply_end_vc = 15; 35 | read_reply_begin_vc = 0; 36 | read_reply_end_vc = 15; 37 | write_request_begin_vc = 0; 38 | write_request_end_vc = 15; 39 | 40 | // Total number of VCs must match the above assignments 41 | num_vcs = 16; 42 | vc_buf_size = 8; 43 | 44 | wait_for_tail_credit = 1; 45 | 46 | // 47 | // Router architectureq 48 | // 49 | vc_allocator = islip; 50 | sw_allocator = islip; 51 | alloc_iters = 2; 52 | 53 | credit_delay = 2; 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | 59 | input_speedup = 1; 60 | output_speedup = 1; 61 | internal_speedup = 1.7; 62 | 63 | // 64 | // Traffic 65 | // 66 | 67 | sim_type = latency; 68 | 69 | warmup_periods = 3; 70 | 71 | sample_period = 1000; 72 | 73 | sim_count = 1; 74 | 75 | ///////////////////END IMMUTABLE//////////////////////////////// 76 | -------------------------------------------------------------------------------- /src/arbiters/matrix_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // Matrix: Matrix Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _MATRIX_ARB_HPP_ 35 | #define _MATRIX_ARB_HPP_ 36 | 37 | #include 38 | 39 | #include "arbiter.hpp" 40 | 41 | using namespace std; 42 | 43 | class MatrixArbiter : public Arbiter { 44 | 45 | // Priority matrix 46 | vector > _matrix ; 47 | 48 | int _last_req ; 49 | 50 | public: 51 | 52 | // Constructors 53 | MatrixArbiter( Module *parent, const string &name, int size ) ; 54 | 55 | // Print priority matrix to standard output 56 | virtual void PrintState() const ; 57 | 58 | // Update priority matrix based on last aribtration result 59 | virtual void UpdateState() ; 60 | 61 | // Arbitrate amongst requests. Returns winning input and 62 | // updates pointers to metadata when valid pointers are passed 63 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 64 | 65 | virtual void AddRequest( int input, int id, int pri ) ; 66 | 67 | virtual void Clear(); 68 | 69 | } ; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/networks/fattree.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // FatTree 31 | // 32 | //////////////////////////////////////////////////////////////////////// 33 | // 34 | // RCS Information: 35 | // $Author: jbalfour $ 36 | // $Date: 2007/06/26 22:49:23 $ 37 | // $Id$ 38 | // 39 | //////////////////////////////////////////////////////////////////////// 40 | 41 | #ifndef _FatTree_HPP_ 42 | #define _FatTree_HPP_ 43 | 44 | #include "network.hpp" 45 | 46 | class FatTree : public Network { 47 | 48 | int _k; 49 | int _n; 50 | 51 | 52 | void _ComputeSize( const Configuration& config ); 53 | void _BuildNet( const Configuration& config ); 54 | 55 | Router*& _Router( int depth, int pos ); 56 | 57 | int _mapSize; 58 | int* _inputChannelMap; 59 | int* _outputChannelMap; 60 | int* _latencyMap; 61 | 62 | 63 | 64 | public: 65 | 66 | FatTree( const Configuration& config ,const string & name ); 67 | static void RegisterRoutingFunctions() ; 68 | 69 | // 70 | // Methods to Assit Routing Functions 71 | // 72 | static int PreferedPort( const Router* r, int index ); 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/arbiters/tree_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // TreeArbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _TREE_ARB_HPP_ 35 | #define _TREE_ARB_HPP_ 36 | 37 | #include "arbiter.hpp" 38 | 39 | class TreeArbiter : public Arbiter { 40 | 41 | int _group_size ; 42 | 43 | vector _group_arbiters; 44 | Arbiter * _global_arbiter; 45 | 46 | vector _group_reqs; 47 | 48 | public: 49 | 50 | // Constructors 51 | TreeArbiter( Module *parent, const string &name, int size, int groups, const string & arb_type ) ; 52 | 53 | ~TreeArbiter(); 54 | 55 | // Print priority matrix to standard output 56 | virtual void PrintState() const ; 57 | 58 | // Update priority matrix based on last aribtration result 59 | virtual void UpdateState() ; 60 | 61 | // Arbitrate amongst requests. Returns winning input and 62 | // updates pointers to metadata when valid pointers are passed 63 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 64 | 65 | virtual void AddRequest( int input, int id, int pri ) ; 66 | 67 | virtual void Clear(); 68 | 69 | } ; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/random_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _RANDOM_UTILS_HPP_ 29 | #define _RANDOM_UTILS_HPP_ 30 | 31 | #include 32 | 33 | // interface to Knuth's RANARRAY RNG 34 | void ran_start(long seed); 35 | long ran_next( ); 36 | void ranf_start(long seed); 37 | double ranf_next( ); 38 | 39 | inline void RandomSeed( long seed ) { 40 | ran_start( seed ); 41 | ranf_start( seed ); 42 | } 43 | 44 | inline unsigned long RandomIntLong( ) { 45 | return ran_next( ); 46 | } 47 | 48 | // Returns a random integer in the range [0,max] 49 | inline int RandomInt( int max ) { 50 | return ( ran_next( ) % (max+1) ); 51 | } 52 | 53 | // Returns a random floating-point value in the rage [0,1] 54 | inline double RandomFloat( ) { 55 | return ranf_next( ); 56 | } 57 | 58 | // Returns a random floating-point value in the rage [0,max] 59 | inline double RandomFloat( double max ) { 60 | return ( ranf_next( ) * max ); 61 | } 62 | 63 | // Saves the current generator state 64 | void SaveRandomState( std::vector & save_x, std::vector & save_u ); 65 | 66 | // Restores the generator state from previously saved values 67 | void RestoreRandomState( std::vector const & save_x, std::vector const & save_u ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/networks/tree4.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // Tree4: Network with 64 Terminal Nodes arranged in a tree topology 31 | // with 4 routers at the root of the tree 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/06/26 22:49:23 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef _TREE4_HPP_ 43 | #define _TREE4_HPP_ 44 | #include 45 | #include "network.hpp" 46 | 47 | class Tree4 : public Network { 48 | 49 | int _k; 50 | int _n; 51 | 52 | int _channelWidth; 53 | 54 | void _ComputeSize( const Configuration& config ); 55 | void _BuildNet( const Configuration& config ); 56 | 57 | 58 | Router*& _Router( int height, int pos ); 59 | 60 | int _WireLatency( int height1, int pos1, int height2, int pos2 ); 61 | 62 | public: 63 | 64 | Tree4( const Configuration& config, const string & name ); 65 | static void RegisterRoutingFunctions() ; 66 | 67 | static int HeightFromID( int id ); 68 | static int PosFromID( int id ); 69 | static int SpeedUp( int height ); 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/power/switch_monitor.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "switch_monitor.hpp" 29 | 30 | #include "flit.hpp" 31 | 32 | SwitchMonitor::SwitchMonitor( int inputs, int outputs, int classes ) 33 | : _cycles(0), _inputs(inputs), _outputs(outputs), _classes(classes) { 34 | _event.resize(inputs * outputs * classes, 0) ; 35 | } 36 | 37 | int SwitchMonitor::index( int input, int output, int cl ) const { 38 | assert((input >= 0) && (input < _inputs)); 39 | assert((output >= 0) && (output < _outputs)); 40 | assert((cl >= 0) && (cl < _classes)); 41 | return cl + _classes * ( output + _outputs * input ) ; 42 | } 43 | 44 | void SwitchMonitor::cycle() { 45 | _cycles++ ; 46 | } 47 | 48 | void SwitchMonitor::traversal( int input, int output, Flit const * f ) { 49 | _event[ index( input, output, f->cl) ]++ ; 50 | } 51 | 52 | void SwitchMonitor::display(ostream & os) const { 53 | for ( int i = 0 ; i < _inputs ; i++ ) { 54 | for ( int o = 0 ; o < _outputs ; o++) { 55 | os << "[" << i << " -> " << o << "] " ; 56 | for ( int c = 0 ; c < _classes ; c++ ) { 57 | os << c << ":" << _event[index(i,o,c)] << " " ; 58 | } 59 | os << endl ; 60 | } 61 | } 62 | } 63 | 64 | ostream & operator<<( ostream & os, SwitchMonitor const & obj ) { 65 | obj.display(os); 66 | return os ; 67 | } 68 | -------------------------------------------------------------------------------- /src/power/buffer_monitor.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "buffer_monitor.hpp" 29 | 30 | #include "flit.hpp" 31 | 32 | BufferMonitor::BufferMonitor( int inputs, int classes ) 33 | : _cycles(0), _inputs(inputs), _classes(classes) { 34 | _reads.resize(inputs * classes, 0) ; 35 | _writes.resize(inputs * classes, 0) ; 36 | } 37 | 38 | int BufferMonitor::index( int input, int cl ) const { 39 | assert((input >= 0) && (input < _inputs)); 40 | assert((cl >= 0) && (cl < _classes)); 41 | return cl + _classes * input ; 42 | } 43 | 44 | void BufferMonitor::cycle() { 45 | _cycles++ ; 46 | } 47 | 48 | void BufferMonitor::write( int input, Flit const * f ) { 49 | _writes[ index(input, f->cl) ]++ ; 50 | } 51 | 52 | void BufferMonitor::read( int input, Flit const * f ) { 53 | _reads[ index(input, f->cl) ]++ ; 54 | } 55 | 56 | void BufferMonitor::display(ostream & os) const { 57 | for ( int i = 0 ; i < _inputs ; i++ ) { 58 | os << "[ " << i << " ] " ; 59 | for ( int c = 0 ; c < _classes ; c++ ) { 60 | os << "Type=" << c 61 | << ":(R#" << _reads[ index( i, c) ] << "," 62 | << "W#" << _writes[ index( i, c) ] << ")" << " " ; 63 | } 64 | os << endl ; 65 | } 66 | } 67 | 68 | ostream & operator<<( ostream & os, BufferMonitor const & obj ) { 69 | obj.display(os); 70 | return os ; 71 | } 72 | -------------------------------------------------------------------------------- /src/batchtrafficmanager.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BATCHTRAFFICMANAGER_HPP_ 29 | #define _BATCHTRAFFICMANAGER_HPP_ 30 | 31 | #include 32 | 33 | #include "config_utils.hpp" 34 | #include "stats.hpp" 35 | #include "trafficmanager.hpp" 36 | 37 | class BatchTrafficManager : public TrafficManager { 38 | 39 | protected: 40 | 41 | int _max_outstanding; 42 | int _batch_size; 43 | int _batch_count; 44 | int _last_id; 45 | int _last_pid; 46 | 47 | Stats * _batch_time; 48 | double _overall_min_batch_time; 49 | double _overall_avg_batch_time; 50 | double _overall_max_batch_time; 51 | 52 | ostream * _sent_packets_out; 53 | 54 | virtual void _RetireFlit( Flit *f, int dest ); 55 | 56 | virtual int _IssuePacket( int source, int cl ); 57 | virtual void _ClearStats( ); 58 | virtual bool _SingleSim( ); 59 | 60 | virtual void _UpdateOverallStats( ); 61 | 62 | virtual string _OverallStatsCSV(int c = 0) const; 63 | 64 | public: 65 | 66 | BatchTrafficManager( const Configuration &config, const vector & net ); 67 | virtual ~BatchTrafficManager( ); 68 | 69 | virtual void WriteStats( ostream & os = cout ) const; 70 | virtual void DisplayStats( ostream & os = cout ) const; 71 | virtual void DisplayOverallStats( ostream & os = cout ) const; 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/networks/anynet.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ANYNET_HPP_ 29 | #define _ANYNET_HPP_ 30 | 31 | #include "network.hpp" 32 | #include "routefunc.hpp" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | class AnyNet : public Network { 39 | 40 | string file_name; 41 | //associtation between nodes and routers 42 | map node_list; 43 | //[link type][src router][dest router]=(port, latency) 44 | vector > > > router_list; 45 | //stores minimal routing information from every router to every node 46 | //[router][dest_node]=port 47 | vector > routing_table; 48 | 49 | void _ComputeSize( const Configuration &config ); 50 | void _BuildNet( const Configuration &config ); 51 | void readFile(); 52 | void buildRoutingTable(); 53 | void route(int r_start); 54 | 55 | public: 56 | AnyNet( const Configuration &config, const string & name ); 57 | ~AnyNet(); 58 | 59 | int GetN( ) const{ return -1;} 60 | int GetK( ) const{ return -1;} 61 | 62 | static void RegisterRoutingFunctions(); 63 | double Capacity( ) const {return -1;} 64 | void InsertRandomFaults( const Configuration &config ){} 65 | }; 66 | 67 | void min_anynet( const Router *r, const Flit *f, int in_channel, 68 | OutputSet *outputs, bool inject ); 69 | #endif 70 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # $Id $ 2 | 3 | # Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | # POSSIBILITY OF SUCH DAMAGE. 26 | 27 | LEX = flex 28 | YACC = bison -y 29 | DEFINE = 30 | INCPATH = -I. -Iarbiters -Iallocators -Irouters -Inetworks -Ipower 31 | CPPFLAGS += -Wall $(INCPATH) $(DEFINE) 32 | CPPFLAGS += -O3 33 | CPPFLAGS += -g 34 | LFLAGS += 35 | 36 | PROG := booksim 37 | 38 | # simulator source files 39 | CPP_SRCS = $(wildcard *.cpp) $(wildcard */*.cpp) 40 | CPP_HDRS = $(wildcard *.hpp) $(wildcard */*.hpp) 41 | CPP_DEPS = $(CPP_SRCS:.cpp=.d) 42 | CPP_OBJS = $(CPP_SRCS:.cpp=.o) 43 | 44 | LEX_SRCS = lex.yy.c 45 | LEX_OBJS = lex.yy.o 46 | 47 | YACC_SRCS = y.tab.c 48 | YACC_HDRS = y.tab.h 49 | YACC_OBJS = y.tab.o 50 | 51 | OBJS := $(CPP_OBJS) $(LEX_OBJS) $(YACC_OBJS) 52 | 53 | .PHONY: clean 54 | 55 | all: $(PROG) 56 | 57 | $(PROG): $(OBJS) 58 | $(CXX) $(LFLAGS) $^ -o $@ 59 | 60 | $(LEX_SRCS): config.l 61 | $(LEX) $< 62 | 63 | $(YACC_SRCS) $(YACC_HDRS): config.y 64 | $(YACC) -d $< 65 | 66 | $(LEX_OBJS): $(LEX_SRCS) $(YACC_HDRS) 67 | $(CC) $(CPPFLAGS) -c $< -o $@ 68 | 69 | $(YACC_OBJS): $(YACC_SRCS) 70 | $(CC) $(CPPFLAGS) -c $< -o $@ 71 | 72 | %.o: %.cpp 73 | $(CXX) $(CPPFLAGS) -MMD -c $< -o $@ 74 | 75 | clean: 76 | rm -f $(YACC_SRCS) $(YACC_HDRS) 77 | rm -f $(LEX_SRCS) 78 | rm -f $(CPP_DEPS) 79 | rm -f $(OBJS) 80 | rm -f $(PROG) 81 | 82 | distclean: clean 83 | rm -f *~ */*~ 84 | rm -f *.o */*.o 85 | rm -f *.d */*.d 86 | 87 | -include $(CPP_DEPS) 88 | -------------------------------------------------------------------------------- /src/buffer.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | #include "globals.hpp" 31 | #include "booksim.hpp" 32 | #include "buffer.hpp" 33 | 34 | Buffer::Buffer( const Configuration& config, int outputs, 35 | Module *parent, const string& name ) : 36 | Module( parent, name ), _occupancy(0) 37 | { 38 | int num_vcs = config.GetInt( "num_vcs" ); 39 | 40 | _size = config.GetInt("buf_size"); 41 | if(_size < 0) { 42 | _size = num_vcs * config.GetInt( "vc_buf_size" ); 43 | }; 44 | 45 | _vc.resize(num_vcs); 46 | 47 | for(int i = 0; i < num_vcs; ++i) { 48 | ostringstream vc_name; 49 | vc_name << "vc_" << i; 50 | _vc[i] = new VC(config, outputs, this, vc_name.str( ) ); 51 | } 52 | 53 | #ifdef TRACK_BUFFERS 54 | int classes = config.GetInt("classes"); 55 | _class_occupancy.resize(classes, 0); 56 | #endif 57 | } 58 | 59 | Buffer::~Buffer() 60 | { 61 | for(vector::iterator i = _vc.begin(); i != _vc.end(); ++i) { 62 | delete *i; 63 | } 64 | } 65 | 66 | void Buffer::AddFlit( int vc, Flit *f ) 67 | { 68 | if(_occupancy >= _size) { 69 | Error("Flit buffer overflow."); 70 | } 71 | ++_occupancy; 72 | _vc[vc]->AddFlit(f); 73 | #ifdef TRACK_BUFFERS 74 | ++_class_occupancy[f->cl]; 75 | #endif 76 | } 77 | 78 | void Buffer::Display( ostream & os ) const 79 | { 80 | for(vector::const_iterator i = _vc.begin(); i != _vc.end(); ++i) { 81 | (*i)->Display(os); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/networks/dragonfly.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | 27 | 28 | #ifndef _DragonFly_HPP_ 29 | #define _DragonFly_HPP_ 30 | 31 | #include "network.hpp" 32 | #include "routefunc.hpp" 33 | 34 | class DragonFlyNew : public Network { 35 | 36 | int _m; 37 | int _n; 38 | int _r; 39 | int _k; 40 | int _p, _a, _g; 41 | int _radix; 42 | int _net_size; 43 | int _stageout; 44 | int _numinput; 45 | int _stages; 46 | int _num_of_switch; 47 | int _grp_num_routers; 48 | int _grp_num_nodes; 49 | 50 | 51 | void _ComputeSize( const Configuration &config ); 52 | void _BuildNet( const Configuration &config ); 53 | 54 | 55 | 56 | public: 57 | DragonFlyNew( const Configuration &config, const string & name ); 58 | 59 | int GetN( ) const; 60 | int GetK( ) const; 61 | 62 | double Capacity( ) const; 63 | static void RegisterRoutingFunctions(); 64 | void InsertRandomFaults( const Configuration &config ); 65 | 66 | }; 67 | int dragonfly_port(int rID, int source, int dest); 68 | 69 | void ugal_dragonflynew( const Router *r, const Flit *f, int in_channel, 70 | OutputSet *outputs, bool inject ); 71 | void min_dragonflynew( const Router *r, const Flit *f, int in_channel, 72 | OutputSet *outputs, bool inject ); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/flit.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FLIT_HPP_ 29 | #define _FLIT_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | #include "booksim.hpp" 35 | #include "outputset.hpp" 36 | 37 | class Flit { 38 | 39 | public: 40 | 41 | const static int NUM_FLIT_TYPES = 5; 42 | enum FlitType { READ_REQUEST = 0, 43 | READ_REPLY = 1, 44 | WRITE_REQUEST = 2, 45 | WRITE_REPLY = 3, 46 | ANY_TYPE = 4 }; 47 | FlitType type; 48 | 49 | int vc; 50 | 51 | int cl; 52 | 53 | bool head; 54 | bool tail; 55 | 56 | int ctime; 57 | int itime; 58 | int atime; 59 | 60 | int id; 61 | int pid; 62 | 63 | bool record; 64 | 65 | int src; 66 | int dest; 67 | 68 | int pri; 69 | 70 | int hops; 71 | bool watch; 72 | int subnetwork; 73 | 74 | // intermediate destination (if any) 75 | mutable int intm; 76 | 77 | // phase in multi-phase algorithms 78 | mutable int ph; 79 | 80 | // Fields for arbitrary data 81 | void* data ; 82 | 83 | // Lookahead route info 84 | OutputSet la_route_set; 85 | 86 | void Reset(); 87 | 88 | static Flit * New(); 89 | void Free(); 90 | static void FreeAll(); 91 | 92 | private: 93 | 94 | Flit(); 95 | ~Flit() {} 96 | 97 | static stack _all; 98 | static stack _free; 99 | 100 | }; 101 | 102 | ostream& operator<<( ostream& os, const Flit& f ); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /src/module.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*module.cpp 29 | * 30 | *The basic class that is extended by all other components of the network 31 | *Provides the basic hierarchy structure and basic fuctions 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | 38 | #include "booksim.hpp" 39 | #include "module.hpp" 40 | 41 | Module::Module( Module *parent, const string& name ) 42 | { 43 | _name = name; 44 | 45 | if ( parent ) { 46 | parent->_AddChild( this ); 47 | _fullname = parent->_fullname + "/" + name; 48 | } else { 49 | _fullname = name; 50 | } 51 | } 52 | 53 | void Module::_AddChild( Module *child ) 54 | { 55 | _children.push_back( child ); 56 | } 57 | 58 | void Module::DisplayHierarchy( int level, ostream & os ) const 59 | { 60 | vector::const_iterator mod_iter; 61 | 62 | for ( int l = 0; l < level; l++ ) { 63 | os << " "; 64 | } 65 | 66 | os << _name << endl; 67 | 68 | for ( mod_iter = _children.begin( ); 69 | mod_iter != _children.end( ); mod_iter++ ) { 70 | (*mod_iter)->DisplayHierarchy( level + 1 ); 71 | } 72 | } 73 | 74 | void Module::Error( const string& msg ) const 75 | { 76 | cout << "Error in " << _fullname << " : " << msg << endl; 77 | exit( -1 ); 78 | } 79 | 80 | void Module::Debug( const string& msg ) const 81 | { 82 | cout << "Debug (" << _fullname << ") : " << msg << endl; 83 | } 84 | 85 | void Module::Display( ostream & os ) const 86 | { 87 | os << "Display method not implemented for " << _fullname << endl; 88 | } 89 | -------------------------------------------------------------------------------- /src/arbiters/roundrobin_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // RoundRobin: Round Robin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _ROUNDROBIN_HPP_ 35 | #define _ROUNDROBIN_HPP_ 36 | 37 | #include "arbiter.hpp" 38 | 39 | class RoundRobinArbiter : public Arbiter { 40 | 41 | // Priority pointer 42 | int _pointer ; 43 | 44 | public: 45 | 46 | // Constructors 47 | RoundRobinArbiter( Module *parent, const string &name, int size ) ; 48 | 49 | // Print priority matrix to standard output 50 | virtual void PrintState() const ; 51 | 52 | // Update priority matrix based on last aribtration result 53 | virtual void UpdateState() ; 54 | 55 | // Arbitrate amongst requests. Returns winning input and 56 | // updates pointers to metadata when valid pointers are passed 57 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 58 | 59 | virtual void AddRequest( int input, int id, int pri ) ; 60 | 61 | virtual void Clear(); 62 | 63 | static inline bool Supersedes(int input1, int pri1, int input2, int pri2, int offset, int size) 64 | { 65 | // in a round-robin scheme with the given number of positions and current 66 | // offset, should a request at input1 with priority pri1 supersede a 67 | // request at input2 with priority pri2? 68 | return ((pri1 > pri2) || 69 | ((pri1 == pri2) && 70 | (((input1 - offset + size) % size) < ((input2 - offset + size) % size)))); 71 | } 72 | 73 | } ; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /runfiles/ftreeconfig: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 5; 33 | write_reply_begin_vc = 2; 34 | write_reply_end_vc = 7; 35 | read_reply_begin_vc = 8; 36 | read_reply_end_vc = 12; 37 | write_request_begin_vc = 10; 38 | write_request_end_vc = 15; 39 | 40 | // Total number of VCs must match the above assignments 41 | num_vcs = 16; 42 | vc_buf_size = 8; 43 | 44 | wait_for_tail_credit = 1; 45 | 46 | // 47 | // Router architectureq 48 | // 49 | vc_allocator = islip; 50 | sw_allocator = islip; 51 | alloc_iters = 2; 52 | 53 | credit_delay = 2; 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | 59 | input_speedup = 1; 60 | output_speedup = 1; 61 | internal_speedup = 1.0; 62 | 63 | // 64 | // Traffic 65 | // 66 | 67 | sim_type = latency; 68 | 69 | max_outstanding_requests = 8; 70 | 71 | warmup_periods = 3; 72 | 73 | sample_period = 1000; 74 | 75 | sim_count = 1; 76 | 77 | ///////////////////END IMMUTABLE//////////////////////////////// 78 | 79 | 80 | 81 | // Fat tree 82 | 83 | topology = fattree; 84 | 85 | 86 | k = 4; 87 | n = 3; 88 | xr = 2; 89 | yr = 2; 90 | 91 | // 92 | // Routing 93 | // 94 | 95 | routing_function = nca; 96 | 97 | packet_size = 1; 98 | 99 | traffic = bitcomp; 100 | 101 | injection_rate = 0.29; 102 | -------------------------------------------------------------------------------- /src/arbiters/roundrobin_arb.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // RoundRobin: RoundRobin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "roundrobin_arb.hpp" 35 | #include 36 | #include 37 | 38 | using namespace std ; 39 | 40 | RoundRobinArbiter::RoundRobinArbiter( Module *parent, const string &name, 41 | int size ) 42 | : Arbiter( parent, name, size ), _pointer( 0 ) { 43 | } 44 | 45 | void RoundRobinArbiter::PrintState() const { 46 | cout << "Round Robin Priority Pointer: " << endl ; 47 | cout << " _pointer = " << _pointer << endl ; 48 | } 49 | 50 | void RoundRobinArbiter::UpdateState() { 51 | // update priority matrix using last grant 52 | if ( _selected > -1 ) 53 | _pointer = ( _selected + 1 ) % _size ; 54 | } 55 | 56 | void RoundRobinArbiter::AddRequest( int input, int id, int pri ) 57 | { 58 | if(!_request[input].valid || (_request[input].pri < pri)) { 59 | if((_num_reqs == 0) || 60 | Supersedes(input, pri, _best_input, _highest_pri, _pointer,_size )) { 61 | _highest_pri = pri; 62 | _best_input = input; 63 | } 64 | } 65 | Arbiter::AddRequest(input, id, pri); 66 | } 67 | 68 | int RoundRobinArbiter::Arbitrate( int* id, int* pri ) { 69 | 70 | _selected = _best_input; 71 | 72 | return Arbiter::Arbitrate(id, pri); 73 | } 74 | 75 | void RoundRobinArbiter::Clear() 76 | { 77 | _highest_pri = numeric_limits::min(); 78 | _best_input = -1; 79 | Arbiter::Clear(); 80 | } 81 | -------------------------------------------------------------------------------- /src/arbiters/arbiter.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // Arbiter: Base class for Matrix and Round Robin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _ARBITER_HPP_ 35 | #define _ARBITER_HPP_ 36 | 37 | #include 38 | 39 | #include "module.hpp" 40 | 41 | class Arbiter : public Module { 42 | 43 | protected: 44 | 45 | typedef struct { 46 | bool valid ; 47 | int id ; 48 | int pri ; 49 | } entry_t ; 50 | 51 | vector _request ; 52 | int _size ; 53 | 54 | int _selected ; 55 | int _highest_pri; 56 | int _best_input; 57 | 58 | public: 59 | int _num_reqs ; 60 | // Constructors 61 | Arbiter( Module *parent, const string &name, int size ) ; 62 | 63 | // Print priority matrix to standard output 64 | virtual void PrintState() const = 0 ; 65 | 66 | // Register request with arbiter 67 | virtual void AddRequest( int input, int id, int pri ) ; 68 | 69 | // Update priority matrix based on last aribtration result 70 | virtual void UpdateState() = 0 ; 71 | 72 | // Arbitrate amongst requests. Returns winning input and 73 | // updates pointers to metadata when valid pointers are passed 74 | virtual int Arbitrate( int* id = 0, int* pri = 0 ) ; 75 | 76 | virtual void Clear(); 77 | 78 | inline int LastWinner() const { 79 | return _selected; 80 | } 81 | 82 | static Arbiter *NewArbiter( Module *parent, const string &name, 83 | const string &arb_type, int size ); 84 | } ; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/pipefifo.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PIPEFIFO_HPP_ 29 | #define _PIPEFIFO_HPP_ 30 | 31 | #include 32 | 33 | #include "module.hpp" 34 | 35 | template class PipelineFIFO : public Module { 36 | int _lanes; 37 | int _depth; 38 | 39 | int _pipe_len; 40 | int _pipe_ptr; 41 | 42 | vector > _data; 43 | 44 | public: 45 | PipelineFIFO( Module *parent, const string& name, int lanes, int depth ); 46 | ~PipelineFIFO( ); 47 | 48 | void Write( T* val, int lane = 0 ); 49 | void WriteAll( T* val ); 50 | 51 | T* Read( int lane = 0 ); 52 | 53 | void Advance( ); 54 | }; 55 | 56 | template PipelineFIFO::PipelineFIFO( Module *parent, 57 | const string& name, 58 | int lanes, int depth ) : 59 | Module( parent, name ), 60 | _lanes( lanes ), _depth( depth ) 61 | { 62 | _pipe_len = depth + 1; 63 | _pipe_ptr = 0; 64 | 65 | _data.resize(_lanes); 66 | for ( int l = 0; l < _lanes; ++l ) { 67 | _data[l].resize(_pipe_len, 0); 68 | } 69 | } 70 | 71 | template PipelineFIFO::~PipelineFIFO( ) 72 | { 73 | } 74 | 75 | template void PipelineFIFO::Write( T* val, int lane ) 76 | { 77 | _data[lane][_pipe_ptr] = val; 78 | } 79 | 80 | template void PipelineFIFO::WriteAll( T* val ) 81 | { 82 | for ( int l = 0; l < _lanes; ++l ) { 83 | _data[l][_pipe_ptr] = val; 84 | } 85 | } 86 | 87 | template T* PipelineFIFO::Read( int lane ) 88 | { 89 | return _data[lane][_pipe_ptr]; 90 | } 91 | 92 | template void PipelineFIFO::Advance( ) 93 | { 94 | _pipe_ptr = ( _pipe_ptr + 1 ) % _pipe_len; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/allocators/separable.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableAllocator: Separable Allocator Base Class 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable.hpp" 35 | 36 | #include 37 | 38 | #include "arbiter.hpp" 39 | 40 | SeparableAllocator::SeparableAllocator( Module* parent, const string& name, 41 | int inputs, int outputs, 42 | const string& arb_type ) 43 | : SparseAllocator( parent, name, inputs, outputs ) 44 | { 45 | 46 | _input_arb.resize(inputs); 47 | 48 | for (int i = 0; i < inputs; ++i) { 49 | ostringstream arb_name("arb_i"); 50 | arb_name << i; 51 | _input_arb[i] = Arbiter::NewArbiter(this, arb_name.str(), arb_type, outputs); 52 | } 53 | 54 | _output_arb.resize(outputs); 55 | 56 | for (int i = 0; i < outputs; ++i) { 57 | ostringstream arb_name("arb_o"); 58 | arb_name << i; 59 | _output_arb[i] = Arbiter::NewArbiter(this, arb_name.str( ), arb_type, inputs); 60 | } 61 | 62 | } 63 | 64 | SeparableAllocator::~SeparableAllocator() { 65 | 66 | for (int i = 0; i < _inputs; ++i) { 67 | delete _input_arb[i]; 68 | } 69 | 70 | for (int i = 0; i < _outputs; ++i) { 71 | delete _output_arb[i]; 72 | } 73 | 74 | } 75 | 76 | void SeparableAllocator::Clear() { 77 | for ( int i = 0 ; i < _inputs ; i++ ) { 78 | if(_input_arb[i]-> _num_reqs) 79 | _input_arb[i]->Clear(); 80 | } 81 | for ( int o = 0; o < _outputs; o++ ) { 82 | if(_output_arb[o]->_num_reqs) 83 | _output_arb[o]->Clear(); 84 | } 85 | SparseAllocator::Clear(); 86 | } 87 | -------------------------------------------------------------------------------- /runfiles/flatflyconfig1: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | 28 | 29 | // Flatfly 30 | // 31 | // #node = k^(n+1) 32 | // 33 | // x, y, specifies the arrangement of routers in x and y dim 34 | // xr, yr specifiies the arayment of clients in a router 35 | // 36 | topology = flatfly; 37 | 38 | 39 | c = 4; 40 | k = 4; 41 | n = 2; 42 | x = 4; 43 | y = 4; 44 | xr = 2; 45 | yr = 2; 46 | limit = 64; 47 | 48 | 49 | // 50 | // Routing 51 | // 52 | routing_function = ran_min; 53 | //routing_function = ugal; 54 | // 55 | // Flow co1 ntrol 56 | // 57 | read_request_begin_vc = 0; 58 | read_request_end_vc = 5; 59 | write_reply_begin_vc = 2; 60 | write_reply_end_vc = 7; 61 | 62 | read_reply_begin_vc = 8; 63 | read_reply_end_vc = 12; 64 | write_request_begin_vc = 10; 65 | write_request_end_vc = 15; 66 | 67 | // Total number of VCs must match the above assignments 68 | num_vcs = 16; 69 | vc_buf_size = 8; 70 | 71 | wait_for_tail_credit = 1; 72 | 73 | // 74 | // Router architecture 75 | // 76 | vc_allocator = select; 77 | sw_allocator = select; 78 | alloc_iters = 1; 79 | 80 | credit_delay = 2; 81 | routing_delay = 0; 82 | vc_alloc_delay = 1; 83 | sw_alloc_delay = 1; 84 | st_final_delay = 1; 85 | 86 | input_speedup = 1; 87 | output_speedup = 1; 88 | internal_speedup = 1.0; 89 | 90 | // 91 | // Traffic 92 | // 93 | //sim_type = latency; 94 | //max_samples = 10; 95 | //batch_size = 100; 96 | 97 | max_outstanding_requests = 8; 98 | traffic = bitcomp; 99 | warmup_periods = 3; 100 | injection_rate = 0.49; 101 | sample_period = 10000; 102 | sim_count = 1; 103 | -------------------------------------------------------------------------------- /runfiles/knconfig: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 5; 33 | write_reply_begin_vc = 2; 34 | write_reply_end_vc = 7; 35 | read_reply_begin_vc = 8; 36 | read_reply_end_vc = 12; 37 | write_request_begin_vc = 10; 38 | write_request_end_vc = 15; 39 | 40 | // Total number of VCs must match the above assignments 41 | num_vcs = 16; 42 | vc_buf_size = 8; 43 | 44 | wait_for_tail_credit = 1; 45 | 46 | // 47 | // Router architectureq 48 | // 49 | vc_allocator = islip; 50 | sw_allocator = islip; 51 | alloc_iters = 2; 52 | 53 | credit_delay = 2; 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | 59 | input_speedup = 1; 60 | output_speedup = 1; 61 | internal_speedup = 1.0; 62 | 63 | // 64 | // Traffic 65 | // 66 | 67 | sim_type = latency; 68 | 69 | warmup_periods = 3; 70 | 71 | sample_period = 1000; 72 | 73 | sim_count = 1; 74 | 75 | ///////////////////END IMMUTABLE//////////////////////////////// 76 | 77 | 78 | 79 | // Flatfly 80 | // 81 | // #node = k^(n+1) 82 | // 83 | // x, y, specifies the arrangement of routers in x and y dim 84 | // xr, yr specifiies the arayment of clients in a router 85 | // 86 | topology = flatfly; 87 | 88 | 89 | c = 8; 90 | k = 8; 91 | n = 1; 92 | x = 4; 93 | y = 2; 94 | xr = 2; 95 | yr = 4; 96 | limit = 64; 97 | 98 | 99 | // 100 | // Routing 101 | // 102 | routing_function = ugal; 103 | 104 | packet_size = 8; 105 | 106 | traffic = diagonal; 107 | 108 | injection_rate = 0.01; 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/networks/cmesh.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // CMesh: Mesh topology with concentration and express links along the 31 | // edge of the network 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/06/26 22:49:23 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | #ifndef _CMESH_HPP_ 42 | #define _CMESH_HPP_ 43 | 44 | #include "network.hpp" 45 | #include "routefunc.hpp" 46 | 47 | class CMesh : public Network { 48 | public: 49 | CMesh( const Configuration &config, const string & name ); 50 | int GetN() const; 51 | int GetK() const; 52 | 53 | static int NodeToRouter( int address ) ; 54 | static int NodeToPort( int address ) ; 55 | 56 | static void RegisterRoutingFunctions() ; 57 | 58 | private: 59 | 60 | static int _cX ; 61 | static int _cY ; 62 | 63 | static int _memo_NodeShiftX ; 64 | static int _memo_NodeShiftY ; 65 | static int _memo_PortShiftY ; 66 | 67 | void _ComputeSize( const Configuration &config ); 68 | void _BuildNet( const Configuration& config ); 69 | 70 | int _k ; 71 | int _n ; 72 | int _c ; 73 | int _xcount; 74 | int _ycount; 75 | int _xrouter; 76 | int _yrouter; 77 | bool _express_channels; 78 | }; 79 | 80 | // 81 | // Routing Functions 82 | // 83 | void xy_yx_cmesh( const Router *r, const Flit *f, int in_channel, 84 | OutputSet *outputs, bool inject ) ; 85 | 86 | void xy_yx_no_express_cmesh( const Router *r, const Flit *f, int in_channel, 87 | OutputSet *outputs, bool inject ) ; 88 | 89 | void dor_cmesh( const Router *r, const Flit *f, int in_channel, 90 | OutputSet *outputs, bool inject ) ; 91 | 92 | void dor_no_express_cmesh( const Router *r, const Flit *f, int in_channel, 93 | OutputSet *outputs, bool inject ) ; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /src/examples/flatflyconfig: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | //A flattened butterfly configurate file with many tweaks from the 28 | //default settings. 29 | 30 | 31 | // Flow control 32 | // Total number of VCs must match the above assignments 33 | num_vcs = 8; 34 | vc_buf_size = 4; 35 | 36 | wait_for_tail_credit = 0; 37 | 38 | // 39 | // Router architectureq 40 | // 41 | vc_allocator = islip; 42 | sw_allocator = islip; 43 | alloc_iters = 1; 44 | 45 | credit_delay = 2; 46 | routing_delay = 0; 47 | vc_alloc_delay = 1; 48 | sw_alloc_delay = 1; 49 | st_final_delay = 1; 50 | 51 | input_speedup = 1; 52 | output_speedup = 1; 53 | internal_speedup = 1.0; 54 | 55 | // 56 | // Traffic 57 | // 58 | 59 | warmup_periods = 3; 60 | 61 | sample_period = 1000; 62 | 63 | sim_count = 1; 64 | 65 | traffic = uniform; 66 | 67 | 68 | // Flatfly 69 | // 70 | // #node = k^(n+1) 71 | // 72 | // x, y, specifies the arrangement of routers in x and y dim 73 | // xr, yr specifiies the arayment of clients in a router 74 | // 75 | topology = flatfly; 76 | subnets = 1; 77 | 78 | c = 4; 79 | k = 4; 80 | n = 2; 81 | 82 | x = 4; 83 | y = 4; 84 | xr = 2; 85 | yr = 2; 86 | 87 | // 88 | // Routing 89 | // 90 | 91 | routing_function = ran_min; 92 | 93 | //1: batch mode, 0: injection mode 94 | use_read_write = 0; 95 | 96 | //for injection mode 97 | packet_size = 1; 98 | injection_rate = 0.1; 99 | 100 | //for batch mode 101 | read_request_size=1; 102 | write_request_size=1; 103 | read_reply_size=1; 104 | write_reply_size=1; 105 | 106 | read_request_begin_vc = 0; 107 | read_request_end_vc = 3; 108 | write_reply_begin_vc = 4; 109 | write_reply_end_vc = 7; 110 | read_reply_begin_vc = 4; 111 | read_reply_end_vc = 7; 112 | write_request_begin_vc = 0; 113 | write_request_end_vc = 3; 114 | 115 | //latency: drains all packet, throughput:no drain? 116 | sim_type = latency; 117 | -------------------------------------------------------------------------------- /src/flitchannel.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // File Name: flitchannel.cpp 31 | // Author: James Balfour, Rebecca Schultz 32 | // 33 | // ---------------------------------------------------------------------- 34 | 35 | #include "flitchannel.hpp" 36 | 37 | #include 38 | #include 39 | 40 | #include "router.hpp" 41 | #include "globals.hpp" 42 | 43 | // ---------------------------------------------------------------------- 44 | // $Author: jbalfour $ 45 | // $Date: 2007/06/27 23:10:17 $ 46 | // $Id$ 47 | // ---------------------------------------------------------------------- 48 | FlitChannel::FlitChannel(Module * parent, string const & name, int classes) 49 | : Channel(parent, name), _routerSource(NULL), _routerSourcePort(-1), 50 | _routerSink(NULL), _routerSinkPort(-1), _idle(0) { 51 | _active.resize(classes, 0); 52 | } 53 | 54 | void FlitChannel::SetSource(Router const * const router, int port) { 55 | _routerSource = router; 56 | _routerSourcePort = port; 57 | } 58 | 59 | void FlitChannel::SetSink(Router const * const router, int port) { 60 | _routerSink = router; 61 | _routerSinkPort = port; 62 | } 63 | 64 | void FlitChannel::Send(Flit * f) { 65 | if(f) { 66 | ++_active[f->cl]; 67 | } else { 68 | ++_idle; 69 | } 70 | Channel::Send(f); 71 | } 72 | 73 | void FlitChannel::ReadInputs() { 74 | Flit const * const & f = _input; 75 | if(f && f->watch) { 76 | *gWatchOut << GetSimTime() << " | " << FullName() << " | " 77 | << "Beginning channel traversal for flit " << f->id 78 | << " with delay " << _delay 79 | << "." << endl; 80 | } 81 | Channel::ReadInputs(); 82 | } 83 | 84 | void FlitChannel::WriteOutputs() { 85 | Channel::WriteOutputs(); 86 | if(_output && _output->watch) { 87 | *gWatchOut << GetSimTime() << " | " << FullName() << " | " 88 | << "Completed channel traversal for flit " << _output->id 89 | << "." << endl; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/config_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _CONFIG_UTILS_HPP_ 29 | #define _CONFIG_UTILS_HPP_ 30 | 31 | #include "booksim.hpp" 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | extern "C" int yyparse(); 39 | 40 | class Configuration { 41 | static Configuration * theConfig; 42 | FILE * _config_file; 43 | string _config_string; 44 | 45 | protected: 46 | map _str_map; 47 | map _int_map; 48 | map _float_map; 49 | 50 | public: 51 | Configuration(); 52 | 53 | void AddStrField(string const & field, string const & value); 54 | 55 | void Assign(string const & field, string const & value); 56 | void Assign(string const & field, int value); 57 | void Assign(string const & field, double value); 58 | 59 | string GetStr(string const & field) const; 60 | int GetInt(string const & field) const; 61 | double GetFloat(string const & field) const; 62 | 63 | vector GetStrArray(const string & field) const; 64 | vector GetIntArray(const string & field) const; 65 | vector GetFloatArray(const string & field) const; 66 | 67 | void ParseFile(string const & filename); 68 | void ParseString(string const & str); 69 | int Input(char * line, int max_size); 70 | void ParseError(string const & msg, unsigned int lineno = 0) const; 71 | 72 | void WriteFile(string const & filename); 73 | void WriteMatlabFile(ostream * o) const; 74 | 75 | inline const map & GetStrMap() const { 76 | return _str_map; 77 | } 78 | inline const map & GetIntMap() const { 79 | return _int_map; 80 | } 81 | inline const map & GetFloatMap() const { 82 | return _float_map; 83 | } 84 | 85 | static Configuration * GetTheConfig(); 86 | 87 | }; 88 | 89 | bool ParseArgs(Configuration * cf, int argc, char **argv); 90 | 91 | vector tokenize_str(string const & data); 92 | vector tokenize_int(string const & data); 93 | vector tokenize_float(string const & data); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /src/flit.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*flit.cpp 29 | * 30 | *flit struct is a flit, carries all the control signals that a flit needs 31 | *Add additional signals as necessary. Flits has no concept of length 32 | *it is a singluar object. 33 | * 34 | *When adding objects make sure to set a default value in this constructor 35 | */ 36 | 37 | #include "booksim.hpp" 38 | #include "flit.hpp" 39 | 40 | stack Flit::_all; 41 | stack Flit::_free; 42 | 43 | ostream& operator<<( ostream& os, const Flit& f ) 44 | { 45 | os << " Flit ID: " << f.id << " (" << &f << ")" 46 | << " Packet ID: " << f.pid 47 | << " Type: " << f.type 48 | << " Head: " << f.head 49 | << " Tail: " << f.tail << endl; 50 | os << " Source: " << f.src << " Dest: " << f.dest << " Intm: "<Reset(); 93 | _free.pop(); 94 | } 95 | return f; 96 | } 97 | 98 | void Flit::Free() { 99 | _free.push(this); 100 | } 101 | 102 | void Flit::FreeAll() { 103 | while(!_all.empty()) { 104 | delete _all.top(); 105 | _all.pop(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /runfiles/cmeshconfig: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 5; 33 | write_reply_begin_vc = 2; 34 | write_reply_end_vc = 7; 35 | 36 | read_reply_begin_vc = 8; 37 | read_reply_end_vc = 13; 38 | write_request_begin_vc = 10; 39 | write_request_end_vc = 15; 40 | 41 | // Total number of VCs must match the above assignments 42 | num_vcs = 16; 43 | vc_buf_size = 8; 44 | 45 | wait_for_tail_credit = 1; 46 | 47 | // 48 | // Router architectureq 49 | // 50 | vc_allocator = islip; 51 | sw_allocator = islip; 52 | alloc_iters = 1; 53 | 54 | credit_delay = 2; 55 | routing_delay = 0; 56 | vc_alloc_delay = 1; 57 | sw_alloc_delay = 1; 58 | st_final_delay = 1; 59 | 60 | input_speedup = 1; 61 | output_speedup = 1; 62 | internal_speedup = 1.0; 63 | 64 | // 65 | // Traffic 66 | // 67 | 68 | sim_type = latency; 69 | 70 | warmup_periods = 3; 71 | 72 | sample_period = 1000; 73 | 74 | sim_count = 1; 75 | 76 | ///////////////////END IMMUTABLE//////////////////////////////// 77 | 78 | 79 | // 80 | // CMesh 81 | // 82 | // #node = K^n*c 83 | // 84 | topology = cmesh; 85 | 86 | k = 4; 87 | n = 2; 88 | c = 4; 89 | // 90 | // Routing 91 | // 92 | routing_function = dor_no_express; 93 | 94 | physical_subnetworks = 1; 95 | 96 | x = 4; 97 | y = 4; 98 | xr = 2; 99 | yr = 2; 100 | 101 | //the nodes above "limit" does not emit or receiv traffic 102 | limit = 0; 103 | 104 | 105 | 106 | use_read_write = 1; 107 | 108 | packet_size = 1; 109 | 110 | read_reply_size = 1; 111 | read_request_size = 1; 112 | write_reply_size = 1; 113 | write_request_size = 1; 114 | 115 | traffic = bitcomp; 116 | 117 | injection_rate = 0.1; //ignored on batch mode 118 | 119 | speculative = 0; 120 | 121 | batch_size = 2000; 122 | 123 | print_activity =0; 124 | 125 | max_outstanding_requests = 4; 126 | -------------------------------------------------------------------------------- /src/networks/flatfly_onchip.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FlatFlyOnChip_HPP_ 29 | #define _FlatFlyOnChip_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | #include "routefunc.hpp" 34 | #include 35 | 36 | 37 | class FlatFlyOnChip : public Network { 38 | 39 | int _m; 40 | int _n; 41 | int _r; 42 | int _k; 43 | int _c; 44 | int _radix; 45 | int _net_size; 46 | int _stageout; 47 | int _numinput; 48 | int _stages; 49 | int _num_of_switch; 50 | 51 | void _ComputeSize( const Configuration &config ); 52 | void _BuildNet( const Configuration &config ); 53 | 54 | int _OutChannel( int stage, int addr, int port, int outputs ) const; 55 | int _InChannel( int stage, int addr, int port ) const; 56 | 57 | public: 58 | FlatFlyOnChip( const Configuration &config, const string & name ); 59 | 60 | int GetN( ) const; 61 | int GetK( ) const; 62 | 63 | static void RegisterRoutingFunctions() ; 64 | double Capacity( ) const; 65 | void InsertRandomFaults( const Configuration &config ); 66 | }; 67 | void adaptive_xyyx_flatfly( const Router *r, const Flit *f, int in_channel, 68 | OutputSet *outputs, bool inject ); 69 | void xyyx_flatfly( const Router *r, const Flit *f, int in_channel, 70 | OutputSet *outputs, bool inject ); 71 | void min_flatfly( const Router *r, const Flit *f, int in_channel, 72 | OutputSet *outputs, bool inject ); 73 | void ugal_xyyx_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 74 | OutputSet *outputs, bool inject ); 75 | void ugal_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 76 | OutputSet *outputs, bool inject ); 77 | void ugal_pni_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 78 | OutputSet *outputs, bool inject ); 79 | void valiant_flatfly( const Router *r, const Flit *f, int in_channel, 80 | OutputSet *outputs, bool inject ); 81 | 82 | int find_distance (int src, int dest); 83 | int find_ran_intm (int src, int dest); 84 | int flatfly_outport(int dest, int rID); 85 | int flatfly_transformation(int dest); 86 | int flatfly_outport_yx(int dest, int rID); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/allocators/loa.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include 30 | 31 | #include "loa.hpp" 32 | #include "random_utils.hpp" 33 | 34 | LOA::LOA( Module *parent, const string& name, 35 | int inputs, int outputs ) : 36 | DenseAllocator( parent, name, inputs, outputs ) 37 | { 38 | _req.resize(inputs); 39 | _counts.resize(outputs); 40 | 41 | _rptr.resize(inputs); 42 | _gptr.resize(outputs); 43 | } 44 | 45 | void LOA::Allocate( ) 46 | { 47 | int input; 48 | int output; 49 | 50 | int input_offset; 51 | int output_offset; 52 | 53 | int lonely; 54 | int lonely_cnt; 55 | 56 | // Count phase --- the number of requests 57 | // per output is counted 58 | 59 | for ( int j = 0; j < _outputs; ++j ) { 60 | _counts[j] = 0; 61 | for ( int i = 0; i < _inputs; ++i ) { 62 | _counts[j] += ( _request[i][j].label != -1 ) ? 1 : 0; 63 | } 64 | } 65 | 66 | // Request phase 67 | for ( input = 0; input < _inputs; ++input ) { 68 | 69 | // Find the lonely output 70 | output_offset = _rptr[input]; 71 | lonely = -1; 72 | lonely_cnt = _inputs + 1; 73 | 74 | for ( int o = 0; o < _outputs; ++o ) { 75 | output = ( o + output_offset ) % _outputs; 76 | 77 | if ( ( _request[input][output].label != -1 ) && 78 | ( _counts[output] < lonely_cnt ) ) { 79 | lonely = output; 80 | lonely_cnt = _counts[output]; 81 | } 82 | } 83 | 84 | // Request the lonely output (-1 for no request) 85 | _req[input] = lonely; 86 | } 87 | 88 | // Grant phase 89 | for ( output = 0; output < _outputs; ++output ) { 90 | input_offset = _gptr[output]; 91 | 92 | for ( int i = 0; i < _inputs; ++i ) { 93 | input = ( i + input_offset ) % _inputs; 94 | 95 | if ( _req[input] == output ) { 96 | // Grant! 97 | 98 | _inmatch[input] = output; 99 | _outmatch[output] = input; 100 | 101 | _rptr[input] = ( _rptr[input] + 1 ) % _outputs; 102 | _gptr[output] = ( _gptr[output] + 1 ) % _inputs; 103 | 104 | break; 105 | } 106 | } 107 | } 108 | 109 | 110 | } 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/flitchannel.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // File Name: flitchannel.hpp 31 | // 32 | // The FlitChannel models a flit channel with a multi-cycle 33 | // transmission delay. The channel latency can be specified as 34 | // an integer number of simulator cycles. 35 | // ---------------------------------------------------------------------- 36 | 37 | #ifndef FLITCHANNEL_HPP 38 | #define FLITCHANNEL_HPP 39 | 40 | // ---------------------------------------------------------------------- 41 | // $Author: jbalfour $ 42 | // $Date: 2007/06/27 23:10:17 $ 43 | // $Id$ 44 | // ---------------------------------------------------------------------- 45 | 46 | #include "channel.hpp" 47 | #include "flit.hpp" 48 | 49 | using namespace std; 50 | 51 | class Router ; 52 | 53 | class FlitChannel : public Channel { 54 | public: 55 | FlitChannel(Module * parent, string const & name, int classes); 56 | 57 | void SetSource(Router const * const router, int port) ; 58 | inline Router const * const GetSource() const { 59 | return _routerSource; 60 | } 61 | inline int const & GetSourcePort() const { 62 | return _routerSourcePort; 63 | } 64 | void SetSink(Router const * const router, int port) ; 65 | inline Router const * const GetSink() const { 66 | return _routerSink; 67 | } 68 | inline int const & GetSinkPort() const { 69 | return _routerSinkPort; 70 | } 71 | inline vector const & GetActivity() const { 72 | return _active; 73 | } 74 | 75 | // Send flit 76 | virtual void Send(Flit * flit); 77 | 78 | virtual void ReadInputs(); 79 | virtual void WriteOutputs(); 80 | 81 | private: 82 | 83 | //////////////////////////////////////// 84 | // 85 | // Power Models OBSOLETE 86 | // 87 | //////////////////////////////////////// 88 | 89 | Router const * _routerSource; 90 | int _routerSourcePort; 91 | Router const * _routerSink; 92 | int _routerSinkPort; 93 | 94 | // Statistics for Activity Factors 95 | vector _active; 96 | int _idle; 97 | }; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /runfiles/flatflyconfig: -------------------------------------------------------------------------------- 1 | // $Id $ 2 | 3 | // Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ///////////////////BEGIN IMMUTABLE//////////////////////////////// 28 | // 29 | // Flow control 30 | // 31 | read_request_begin_vc = 0; 32 | read_request_end_vc = 5; 33 | write_reply_begin_vc = 2; 34 | write_reply_end_vc = 7; 35 | read_reply_begin_vc = 8; 36 | read_reply_end_vc = 12; 37 | write_request_begin_vc = 10; 38 | write_request_end_vc = 15; 39 | 40 | // Total number of VCs must match the above assignments 41 | num_vcs = 16; 42 | vc_buf_size = 8; 43 | 44 | wait_for_tail_credit = 0; 45 | 46 | // 47 | // Router architectureq 48 | // 49 | vc_allocator = max_size; 50 | sw_allocator = max_size; 51 | alloc_iters = 2; 52 | 53 | credit_delay = 2; 54 | routing_delay = 0; 55 | vc_alloc_delay = 1; 56 | sw_alloc_delay = 1; 57 | st_final_delay = 1; 58 | 59 | input_speedup = 1; 60 | output_speedup = 1; 61 | internal_speedup = 1.0; 62 | 63 | // 64 | // Traffic 65 | // 66 | 67 | sim_type = latency; 68 | 69 | warmup_periods = 3; 70 | 71 | 72 | sim_count = 1; 73 | 74 | ///////////////////END IMMUTABLE//////////////////////////////// 75 | 76 | 77 | 78 | // Flatfly 79 | // 80 | // #node = k^(n+1) 81 | // 82 | // x, y, specifies the arrangement of routers in x and y dim 83 | // xr, yr specifiies the arayment of clients in a router 84 | // 85 | topology = flatfly; 86 | subnets = 1; 87 | 88 | c = 4; 89 | k = 4; 90 | n = 2; 91 | 92 | x = 4; 93 | y = 4; 94 | xr = 2; 95 | yr = 2; 96 | 97 | //the nodes above "limit" does not emit or receiv traffic 98 | limit = 64; 99 | 100 | 101 | // 102 | // Routing 103 | // 104 | 105 | routing_function = ran_min; 106 | 107 | packet_size = 1; 108 | 109 | traffic = uniform; 110 | 111 | sample_period = 10000; 112 | 113 | use_read_write = 0; 114 | 115 | batch_size = 10000; 116 | 117 | injection_rate = 0.78; 118 | 119 | sim_type = latency; 120 | 121 | speculative = 0; 122 | 123 | print_activity = 0; 124 | 125 | 126 | 127 | read_request_size=1; 128 | read_reply_size=4; 129 | write_request_size=4; 130 | write_reply_size=1; 131 | 132 | sim_power = 0; 133 | -------------------------------------------------------------------------------- /src/allocators/pim.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include 30 | 31 | #include "pim.hpp" 32 | #include "random_utils.hpp" 33 | 34 | //#define DEBUG_PIM 35 | 36 | PIM::PIM( Module *parent, const string& name, 37 | int inputs, int outputs, int iters ) : 38 | DenseAllocator( parent, name, inputs, outputs ), 39 | _PIM_iter(iters) 40 | { 41 | } 42 | 43 | PIM::~PIM( ) 44 | { 45 | } 46 | 47 | void PIM::Allocate( ) 48 | { 49 | int input; 50 | int output; 51 | 52 | int input_offset; 53 | int output_offset; 54 | 55 | for ( int iter = 0; iter < _PIM_iter; ++iter ) { 56 | // Grant phase --- outputs randomly choose 57 | // between one of their requests 58 | 59 | vector grants(_outputs, -1); 60 | 61 | for ( output = 0; output < _outputs; ++output ) { 62 | 63 | // A random arbiter between input requests 64 | input_offset = RandomInt( _inputs - 1 ); 65 | 66 | for ( int i = 0; i < _inputs; ++i ) { 67 | input = ( i + input_offset ) % _inputs; 68 | 69 | if ( ( _request[input][output].label != -1 ) && 70 | ( _inmatch[input] == -1 ) && 71 | ( _outmatch[output] == -1 ) ) { 72 | 73 | // Grant 74 | grants[output] = input; 75 | break; 76 | } 77 | } 78 | } 79 | 80 | // Accept phase -- inputs randomly choose 81 | // between input_speedup of their grants 82 | 83 | for ( input = 0; input < _inputs; ++input ) { 84 | 85 | // A random arbiter between output grants 86 | output_offset = RandomInt( _outputs - 1 ); 87 | 88 | for ( int o = 0; o < _outputs; ++o ) { 89 | output = ( o + output_offset ) % _outputs; 90 | 91 | if ( grants[output] == input ) { 92 | 93 | // Accept 94 | _inmatch[input] = output; 95 | _outmatch[output] = input; 96 | 97 | break; 98 | } 99 | } 100 | } 101 | } 102 | 103 | #ifdef DEBUG_PIM 104 | if ( _outputs == 8 ) { 105 | cout << "input match: " << endl; 106 | for ( int i = 0; i < _inputs; ++i ) { 107 | cout << " from " << i << " to " << _inmatch[i] << endl; 108 | } 109 | cout << endl; 110 | } 111 | 112 | cout << "output match: "; 113 | for ( int j = 0; j < _outputs; ++j ) { 114 | cout << _outmatch[j] << " "; 115 | } 116 | cout << endl; 117 | #endif 118 | } 119 | 120 | 121 | -------------------------------------------------------------------------------- /src/allocators/separable_input_first.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableInputFirstAllocator: Separable Input-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable_input_first.hpp" 35 | 36 | #include "booksim.hpp" 37 | #include "arbiter.hpp" 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | SeparableInputFirstAllocator:: 44 | SeparableInputFirstAllocator( Module* parent, const string& name, int inputs, 45 | int outputs, const string& arb_type ) 46 | : SeparableAllocator( parent, name, inputs, outputs, arb_type ) 47 | {} 48 | 49 | void SeparableInputFirstAllocator::Allocate() { 50 | 51 | set::const_iterator port_iter = _in_occ.begin(); 52 | while(port_iter != _in_occ.end()) { 53 | 54 | const int & input = *port_iter; 55 | 56 | // add requests to the input arbiter 57 | 58 | map::const_iterator req_iter = _in_req[input].begin(); 59 | while(req_iter != _in_req[input].end()) { 60 | 61 | const sRequest & req = req_iter->second; 62 | 63 | _input_arb[input]->AddRequest(req.port, req.label, req.in_pri); 64 | 65 | ++req_iter; 66 | } 67 | 68 | // Execute the input arbiters and propagate the grants to the 69 | // output arbiters. 70 | 71 | int label = -1; 72 | const int output = _input_arb[input]->Arbitrate(&label, NULL); 73 | assert(output > -1); 74 | 75 | const sRequest & req = _out_req[output][input]; 76 | assert((req.port == input) && (req.label == label)); 77 | 78 | _output_arb[output]->AddRequest(req.port, req.label, req.out_pri); 79 | 80 | ++port_iter; 81 | } 82 | 83 | port_iter = _out_occ.begin(); 84 | while(port_iter != _out_occ.end()) { 85 | 86 | const int & output = *port_iter; 87 | 88 | // Execute the output arbiters. 89 | 90 | const int input = _output_arb[output]->Arbitrate(NULL, NULL); 91 | 92 | if(input > -1) { 93 | assert((_inmatch[input] == -1) && (_outmatch[output] == -1)); 94 | 95 | _inmatch[input] = output ; 96 | _outmatch[output] = input ; 97 | _input_arb[input]->UpdateState() ; 98 | _output_arb[output]->UpdateState() ; 99 | } 100 | 101 | ++port_iter; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/allocators/separable_output_first.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableOutputFirstAllocator: Separable Output-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable_output_first.hpp" 35 | 36 | #include "booksim.hpp" 37 | #include "arbiter.hpp" 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | SeparableOutputFirstAllocator:: 44 | SeparableOutputFirstAllocator( Module* parent, const string& name, int inputs, 45 | int outputs, const string& arb_type ) 46 | : SeparableAllocator( parent, name, inputs, outputs, arb_type ) 47 | {} 48 | 49 | void SeparableOutputFirstAllocator::Allocate() { 50 | 51 | set::const_iterator port_iter = _out_occ.begin(); 52 | while(port_iter != _out_occ.end()) { 53 | 54 | const int & output = *port_iter; 55 | 56 | // add requests to the output arbiter 57 | 58 | map::const_iterator req_iter = _out_req[output].begin(); 59 | while(req_iter != _out_req[output].end()) { 60 | 61 | const sRequest & req = req_iter->second; 62 | 63 | _output_arb[output]->AddRequest(req.port, req.label, req.out_pri); 64 | 65 | ++req_iter; 66 | } 67 | 68 | // Execute the output arbiter and propagate the grants to the 69 | // input arbiters. 70 | 71 | int label = -1; 72 | const int input = _output_arb[output]->Arbitrate(&label, NULL); 73 | assert(input > -1); 74 | 75 | const sRequest & req = _in_req[input][output]; 76 | assert((req.port == output) && (req.label == label)); 77 | 78 | _input_arb[input]->AddRequest(req.port, req.label, req.in_pri); 79 | 80 | ++port_iter; 81 | } 82 | 83 | port_iter = _in_occ.begin(); 84 | while(port_iter != _in_occ.end()) { 85 | 86 | const int & input = *port_iter; 87 | 88 | // Execute the input arbiters. 89 | 90 | const int output = _input_arb[input]->Arbitrate(NULL, NULL); 91 | 92 | if(output > -1) { 93 | assert((_inmatch[input] == -1) && (_outmatch[output] == -1)); 94 | 95 | _inmatch[input] = output; 96 | _outmatch[output] = input; 97 | _input_arb[input]->UpdateState() ; 98 | _output_arb[output]->UpdateState() ; 99 | } 100 | 101 | ++port_iter; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/vc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _VC_HPP_ 29 | #define _VC_HPP_ 30 | 31 | #include 32 | 33 | #include "flit.hpp" 34 | #include "outputset.hpp" 35 | #include "routefunc.hpp" 36 | #include "config_utils.hpp" 37 | 38 | class VC : public Module { 39 | public: 40 | enum eVCState { state_min = 0, idle = state_min, routing, vc_alloc, active, 41 | state_max = active }; 42 | struct state_info_t { 43 | int cycles; 44 | }; 45 | static const char * const VCSTATE[]; 46 | 47 | private: 48 | 49 | deque _buffer; 50 | 51 | eVCState _state; 52 | 53 | OutputSet *_route_set; 54 | int _out_port, _out_vc; 55 | 56 | enum ePrioType { local_age_based, queue_length_based, hop_count_based, none, other }; 57 | 58 | ePrioType _pri_type; 59 | 60 | int _pri; 61 | 62 | int _priority_donation; 63 | 64 | bool _watched; 65 | 66 | int _expected_pid; 67 | 68 | int _last_id; 69 | int _last_pid; 70 | 71 | bool _lookahead_routing; 72 | 73 | public: 74 | 75 | VC( const Configuration& config, int outputs, 76 | Module *parent, const string& name ); 77 | ~VC(); 78 | 79 | void AddFlit( Flit *f ); 80 | inline Flit *FrontFlit( ) const 81 | { 82 | return _buffer.empty() ? NULL : _buffer.front(); 83 | } 84 | 85 | Flit *RemoveFlit( ); 86 | 87 | 88 | inline bool Empty( ) const 89 | { 90 | return _buffer.empty( ); 91 | } 92 | 93 | inline VC::eVCState GetState( ) const 94 | { 95 | return _state; 96 | } 97 | 98 | 99 | void SetState( eVCState s ); 100 | 101 | const OutputSet *GetRouteSet( ) const; 102 | void SetRouteSet( OutputSet * output_set ); 103 | 104 | void SetOutput( int port, int vc ); 105 | 106 | inline int GetOutputPort( ) const 107 | { 108 | return _out_port; 109 | } 110 | 111 | 112 | inline int GetOutputVC( ) const 113 | { 114 | return _out_vc; 115 | } 116 | 117 | void UpdatePriority(); 118 | 119 | inline int GetPriority( ) const 120 | { 121 | return _pri; 122 | } 123 | void Route( tRoutingFunction rf, const Router* router, const Flit* f, int in_channel ); 124 | 125 | inline int GetOccupancy() const 126 | { 127 | return (int)_buffer.size(); 128 | } 129 | 130 | // ==== Debug functions ==== 131 | 132 | void SetWatch( bool watch = true ); 133 | bool IsWatched( ) const; 134 | void Display( ostream & os = cout ) const; 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /src/channel.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | ////////////////////////////////////////////////////////////////////// 29 | // 30 | // File Name: channel.hpp 31 | // 32 | // The Channel models a generic channel with a multi-cycle 33 | // transmission delay. The channel latency can be specified as 34 | // an integer number of simulator cycles. 35 | // 36 | ///// 37 | #ifndef _CHANNEL_HPP 38 | #define _CHANNEL_HPP 39 | 40 | #include 41 | #include 42 | 43 | #include "globals.hpp" 44 | #include "module.hpp" 45 | #include "timed_module.hpp" 46 | 47 | using namespace std; 48 | 49 | template 50 | class Channel : public TimedModule { 51 | public: 52 | Channel(Module * parent, string const & name); 53 | virtual ~Channel() {} 54 | 55 | // Physical Parameters 56 | void SetLatency(int cycles); 57 | int GetLatency() const { return _delay ; } 58 | 59 | // Send data 60 | virtual void Send(T * data); 61 | 62 | // Receive data 63 | virtual T * Receive(); 64 | 65 | virtual void ReadInputs(); 66 | virtual void Evaluate() {} 67 | virtual void WriteOutputs(); 68 | 69 | protected: 70 | int _delay; 71 | T * _input; 72 | T * _output; 73 | queue > _wait_queue; 74 | 75 | }; 76 | 77 | template 78 | Channel::Channel(Module * parent, string const & name) 79 | : TimedModule(parent, name), _delay(1), _input(0), _output(0) { 80 | } 81 | 82 | template 83 | void Channel::SetLatency(int cycles) { 84 | if(cycles <= 0) { 85 | Error("Channel must have positive delay."); 86 | } 87 | _delay = cycles ; 88 | } 89 | 90 | template 91 | void Channel::Send(T * data) { 92 | _input = data; 93 | } 94 | 95 | template 96 | T * Channel::Receive() { 97 | return _output; 98 | } 99 | 100 | template 101 | void Channel::ReadInputs() { 102 | if(_input) { 103 | _wait_queue.push(make_pair(GetSimTime() + _delay - 1, _input)); 104 | _input = 0; 105 | } 106 | } 107 | 108 | template 109 | void Channel::WriteOutputs() { 110 | _output = 0; 111 | if(_wait_queue.empty()) { 112 | return; 113 | } 114 | pair const & item = _wait_queue.front(); 115 | int const & time = item.first; 116 | if(GetSimTime() < time) { 117 | return; 118 | } 119 | assert(GetSimTime() == time); 120 | _output = item.second; 121 | assert(_output); 122 | _wait_queue.pop(); 123 | } 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /src/stats.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*stats.cpp 29 | * 30 | *class stores statistics gnerated by the trafficmanager such as the latency 31 | *hope count of the the flits 32 | * 33 | *reset option resets the min and max alues of this statistiscs 34 | */ 35 | 36 | #include "booksim.hpp" 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "stats.hpp" 44 | 45 | Stats::Stats( Module *parent, const string &name, 46 | double bin_size, int num_bins ) : 47 | Module( parent, name ), _num_bins( num_bins ), _bin_size( bin_size ) 48 | { 49 | Clear(); 50 | } 51 | 52 | void Stats::Clear( ) 53 | { 54 | _num_samples = 0; 55 | _sample_sum = 0.0; 56 | _sample_squared_sum = 0.0; 57 | 58 | _hist.assign(_num_bins, 0); 59 | 60 | _min = numeric_limits::quiet_NaN(); 61 | _max = -numeric_limits::quiet_NaN(); 62 | 63 | // _reset = true; 64 | } 65 | 66 | double Stats::Average( ) const 67 | { 68 | return _sample_sum / (double)_num_samples; 69 | } 70 | 71 | double Stats::Variance( ) const 72 | { 73 | return (_sample_squared_sum * (double)_num_samples - _sample_sum * _sample_sum) / ((double)_num_samples * (double)_num_samples); 74 | } 75 | 76 | double Stats::Min( ) const 77 | { 78 | return _min; 79 | } 80 | 81 | double Stats::Max( ) const 82 | { 83 | return _max; 84 | } 85 | 86 | double Stats::Sum( ) const 87 | { 88 | return _sample_sum; 89 | } 90 | 91 | double Stats::SquaredSum( ) const 92 | { 93 | return _sample_squared_sum; 94 | } 95 | 96 | int Stats::NumSamples( ) const 97 | { 98 | return _num_samples; 99 | } 100 | 101 | void Stats::AddSample( double val ) 102 | { 103 | ++_num_samples; 104 | _sample_sum += val; 105 | 106 | // NOTE: the negation ensures that NaN values are handled correctly! 107 | _max = !(val <= _max) ? val : _max; 108 | _min = !(val >= _min) ? val : _min; 109 | 110 | //double clamp between 0 and num_bins-1 111 | int b = (int)fmax(floor( val / _bin_size ), 0.0); 112 | b = (b >= _num_bins) ? (_num_bins - 1) : b; 113 | 114 | _hist[b]++; 115 | } 116 | 117 | void Stats::Display( ostream & os ) const 118 | { 119 | os << *this << endl; 120 | } 121 | 122 | ostream & operator<<(ostream & os, const Stats & s) { 123 | vector const & v = s._hist; 124 | os << "[ "; 125 | for(size_t i = 0; i < v.size(); ++i) { 126 | os << v[i] << " "; 127 | } 128 | os << "]"; 129 | return os; 130 | } 131 | --------------------------------------------------------------------------------