• Ingen resultater fundet

Common NoC files

In document Multiprocessor in a FPGA (Sider 82-147)

70 HDL files

A.2 Common NoC files 71

A.2.1 no c fifo.vhd

1-------------------------------------------------------------------- 2-- 3--FifoforNOC 4--Editor:NikolajTørring-s042505 5--Version:1.3 6--Datalastmodified:24/5-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13--v1.1:Changedtousecaseinsteadifif/elsif 14--v1.2:Primaryusesstd_logicnowinsteadofintegers 15--v1.3:Usingtwoifstatementsinsteadofacasestatement 16-- 17--------------------------------------------------------------------- 18 19libraryIEEE; 20useIEEE.std_logic_1164.ALL; 21useIEEE.std_logic_arith.ALL; 22usework.types.all; 23 24entitynoc_fifois 25 26port( 27--CommonI/Osignals 28clk:inbit_t; 29rst:inbit_t; 30data_i:innoc_data; 31data_o:outnoc_data; 32 33--Controlsignals 34push:inbit_t;

72 HDL files

35pop:inbit_t; 36 37--Statussignals 38count:outFifoAddr 39); 40 41endnoc_fifo; 42 43architecturestrucofnoc_fifois 44 45--SIGNAL 46SIGNALmem:FifoData; 47 48--FIFOpointer 49SIGNALtop:fifo_vector; 50SIGNALbottom:fifo_vector; 51SIGNALcounter:fifo_vector; 52 53--Addsignal 54SIGNALone:std_logic_vector(1downto0):=conv_std_logic_vector(1,2); 55 56begin 57count<=conv_integer(unsigned(counter)); 58data_o<=mem(conv_integer(unsigned(bottom))); 59 60--SynchronousFIFO 61fifo:process(clk,rst) 62begin 63ifrst=0then 64top<=(OTHERS=>0); 65bottom<=(OTHERS=>0); 66counter<=(OTHERS=>0); 67elsifclkeventandclk=1then 68if(push=1)then 69mem(conv_integer(unsigned(top)))<=data_i; 70top<=unsigned(top)+unsigned(one);

A.2 Common NoC files 73

71if(pop/=1)then 72counter<=unsigned(counter)+unsigned(one); 73endif; 74endif; 75if(pop=1)then 76bottom<=unsigned(bottom)+unsigned(one); 77if(push/=1)then 78counter<=unsigned(counter)-unsigned(one); 79endif; 80endif; 81endif; 82endprocessfifo; 83 84endstruc;

74 HDL files

A.2.2 no c na master.vhd

1-------------------------------------------------------------------- 2-- 3--NOCnetworkadapterformatercomponent 4--Editor:NikolajTørring-s042505 5--Version:1.1 6--Datalastmodified:23/5-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13--v1.1:Somesmalloptimisationsmade 14-- 15--------------------------------------------------------------------- 16 17libraryIEEE; 18useIEEE.std_logic_1164.ALL; 19useIEEE.std_logic_arith.ALL; 20usework.types.all; 21 22entitynoc_na_masteris 23 24generic( 25X:integer:=0; 26Y:integer:=0 27); 28 29port( 30--CommonWishBonesignals 31wb_clk_i:inbit_t; 32wb_rst_i:inbit_t; 33wb_data_i:inword_t; 34wb_data_o:outword_t;

A.2 Common NoC files 75

35 36--WishBoneMaster 37wb_ack_o:outbit_t; 38wb_adr_i:inword_t; 39wb_cyc_i:inbit_t; 40wb_err_o:outbit_t; 41wb_rty_o:outbit_t; 42wb_sel_i:instd_logic_vector(3downto0); 43wb_we_i:inbit_t; 44wb_stb_i:inbit_t; 45 46--NoCsignals 47noc_in:innoc_data; 48noc_out:outnoc_data 49); 50 51endnoc_na_master; 52 53architecturestrucofnoc_na_masteris 54 55componentnoc_table 56generic( 57--Source 58x_s:integer:=X; 59y_s:integer:=y 60); 61port( 62address:instd_logic_vector(addr_wdth-1downto0); 63route:outstd_logic_vector(route_wdth-1downto0) 64); 65endcomponent; 66 67 68SIGNALroute:std_logic_vector(route_wdth-1downto0); 69--Stateregister 70typestateis(STATE_INIT,STATE_WAIT,STATE_OUTPUT,STATE_RESPOND);--StatesforFSM

76 HDL files

71SIGNALcurrent_state:state; 72SIGNALnext_state:state; 73 74 75--NOCregisters 76SIGNALreg_in:noc_data; 77 78 79begin--struc 80 81wb_data_o<=reg_in(dat_start+data_wdth-1downtodat_start); 82wb_err_o<=reg_in(err_start); 83wb_rty_o<=reg_in(rty_start); 84 85 86table:noc_table 87portmap( 88address=>wb_adr_i, 89route=>route 90); 91 92 93fsm:process(noc_in,wb_stb_i,current_state,wb_data_i,wb_adr_i,wb_cyc_i,wb_sel_i,wb_we_i, route) 94begin 95wb_ack_o<=0; 96noc_out<=(OTHERS=>0); 97case(current_state)is 98whenSTATE_INIT=>--Initialstate 99if(wb_stb_i=1)then 100next_state<=STATE_OUTPUT; 101else 102next_state<=STATE_INIT; 103endif; 104whenSTATE_OUTPUT=> 105next_state<=STATE_WAIT;

A.2 Common NoC files 77

106noc_out<=route&wb_data_i&"0"&wb_adr_i&"1100"&wb_sel_i&wb_we_i; 107whenSTATE_WAIT=> 108if(noc_in(ack_start)=1)then 109next_state<=STATE_RESPOND; 110else 111next_state<=STATE_WAIT; 112endif; 113whenSTATE_RESPOND=> 114wb_ack_o<=1; 115next_state<=STATE_INIT; 116whenOTHERS=> 117next_state<=STATE_INIT; 118endcase; 119endprocess; 120 121 122next_state_register:process(wb_clk_i,wb_rst_i) 123begin 124ifwb_rst_i=0then--asynchronousreset(activelow) 125current_state<=STATE_INIT; 126elsifwb_clk_ieventandwb_clk_i=1then 127current_state<=next_state; 128if(current_state=STATE_WAIT)then 129reg_in<=noc_in; 130elsif(current_state=STATE_INIT)then 131reg_in<=(OTHERS=>0); 132endif; 133endif; 134endprocessnext_state_register; 135 136endstruc;

78 HDL files

A.2.3 no c na sla v e.vhd

1-------------------------------------------------------------------- 2-- 3--Networkadapterforslavecomponent 4--Editor:NikolajTørring-s042505 5--Version:1.1 6--Datalastmodified:23/5-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13--v1.0:Somesmalloptimizationsmade 14-- 15--------------------------------------------------------------------- 16 17libraryIEEE; 18useIEEE.std_logic_1164.ALL; 19useIEEE.std_logic_arith.ALL; 20usework.types.all; 21 22entitynoc_na_slaveis 23 24port( 25--CommonWishBonesignals 26wb_clk_i:inbit_t; 27wb_rst_i:inbit_t; 28wb_data_i:inword_t; 29wb_data_o:outword_t; 30 31--WishBoneMaster 32wb_ack_i:inbit_t; 33wb_adr_o:outword_t; 34wb_cyc_o:outbit_t;

A.2 Common NoC files 79

35wb_stb_o:outbit_t; 36wb_err_i:inbit_t; 37wb_rty_i:inbit_t; 38wb_sel_o:outstd_logic_vector(3downto0); 39wb_we_o:outbit_t; 40 41--NoCsignals 42noc_in:innoc_data; 43noc_out:outnoc_data 44); 45 46endnoc_na_slave; 47 48architecturestrucofnoc_na_slaveis 49 50componentnoc_fifo 51port( 52--CommonI/Osignals 53clk:inbit_t; 54rst:inbit_t; 55data_i:innoc_data; 56data_o:outnoc_data; 57 58--Controlsignals 59push:inbit_t; 60pop:inbit_t; 61 62--Statussignals 63count:outFifoAddr 64); 65endcomponent; 66 67--Stateregister 68typestateis(STATE_INIT,STATE_WAIT,STATE_OUTPUT);--StatesforFSM 69SIGNALcurrent_state:state; 70SIGNALnext_state:state;

80 HDL files

71 72 73--Fifodata 74SIGNALfifo_out:noc_data; 75 76--Fifostatussignals 77SIGNALcount:FifoAddr; 78 79--Fifocontrolsignals 80SIGNALpush:bit_t; 81SIGNALpop:bit_t; 82 83--returnroute 84SIGNALroute:std_logic_vector(route_wdth-1downto0); 85 86 87begin--struc 88 89wb_data_o<=fifo_out(dat_start+data_wdth-1downtodat_start); 90wb_adr_o<=fifo_out(adr_start+addr_wdth-1downtoadr_start); 91wb_cyc_o<=fifo_out(cyc_start); 92wb_sel_o<=fifo_out(sel_start+3downtosel_start); 93wb_we_o<=fifo_out(we_start); 94push<=1WHENnoc_in(stb_start)=1else 950; 96 97fifo:noc_fifo 98portmap( 99--CommonI/Osignals 100clk=>wb_clk_i, 101rst=>wb_rst_i, 102data_i=>noc_in, 103data_o=>fifo_out, 104 105--Controlsignals 106push=>push,

A.2 Common NoC files 81

107pop=>pop, 108 109--Statussignals 110count=>count 111); 112 113fsm:process(wb_ack_i,wb_err_i,wb_rty_i,wb_data_i,current_state,count,fifo_out,route) 114begin 115wb_stb_o<=0; 116route<=(OTHERS=>0); 117noc_out<=(OTHERS=>0); 118pop<=0; 119case(current_state)is 120whenSTATE_INIT=>--Initialstate 121if(count/=0)then 122next_state<=STATE_WAIT; 123else 124next_state<=STATE_INIT; 125endif; 126whenSTATE_WAIT=> 127--reverseroute 128foriin0to(route_wdth-dest_wdth)/2loop 129route(i*dest_wdth+dest_wdth-1downtoi*dest_wdth)<=fifo_out(NOC_DATA_WIDTH-dest_wdth-i* dest_wdth+1downtoNOC_DATA_WIDTH-dest_wdth-i*dest_wdth); 130endloop; 131wb_stb_o<=1; 132if(wb_ack_i=1)then 133next_state<=STATE_OUTPUT; 134else 135next_state<=STATE_WAIT; 136endif; 137noc_out<=route&wb_data_i&wb_ack_i&CONV_STD_LOGIC_VECTOR(0,addr_wdth)&"00"&wb_err_i &wb_rty_i&"00000"; 138whenSTATE_OUTPUT=> 139next_state<=STATE_INIT; 140pop<=1;

82 HDL files

141whenOTHERS=> 142next_state<=STATE_INIT; 143endcase; 144endprocess; 145 146next_state_register:process(wb_clk_i,wb_rst_i) 147begin 148ifwb_rst_i=0then--asynchronousreset(activelow) 149current_state<=STATE_INIT; 150elsifwb_clk_ieventandwb_clk_i=1then 151current_state<=next_state; 152endif; 153endprocessnext_state_register; 154 155endstruc;

A.2 Common NoC files 83

A.2.4 no c router.vhd

1-------------------------------------------------------------------- 2-- 3--Routerfornetwork 4--Editor:NikolajTørring-s042505 5--Version:1.0 6--Datalastmodified:14/3-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13-- 14--------------------------------------------------------------------- 15 16libraryIEEE; 17useIEEE.std_logic_1164.ALL; 18useIEEE.std_logic_arith.ALL; 19usework.types.all; 20 21entitynoc_routeris 22 23port( 24--I/Oports 25clk_i:inbit_t; 26rst_i:inbit_t; 27 28--NoCsignals 29--North 30noc_n_i:innoc_data; 31noc_n_o:outnoc_data; 32 33--South 34noc_s_i:innoc_data;

84 HDL files

35noc_s_o:outnoc_data; 36 37--East 38noc_e_i:innoc_data; 39noc_e_o:outnoc_data; 40 41--West 42noc_w_i:innoc_data; 43noc_w_o:outnoc_data; 44 45--IP 46ip_i:innoc_data; 47ip_o:outnoc_data 48); 49 50endnoc_router; 51 52architecturestrucofnoc_routeris 53 54componentnoc_router_mux 55port( 56--Sourceselector 57select_north_i:insource; 58select_south_i:insource; 59select_east_i:insource; 60select_west_i:insource; 61select_ip_i:insource; 62 63--datain 64north_i:innoc_data; 65south_i:innoc_data; 66east_i:innoc_data; 67west_i:innoc_data; 68ip_i:innoc_data; 69 70--dataout

A.2 Common NoC files 85

71north_o:outnoc_data; 72south_o:outnoc_data; 73east_o:outnoc_data; 74west_o:outnoc_data; 75ip_o:outnoc_data 76); 77endcomponent; 78 79componentnoc_arbiter 80port( 81--I/Oports 82clk_i:inbit_t; 83rst_i:inbit_t; 84 85--NoCsignals 86--North 87rout_north:indest; 88count_north:inFifoAddr; 89select_north_o:outsource; 90pop_north:outbit_t; 91 92--South 93rout_south:indest; 94count_south:inFifoAddr; 95select_south_o:outsource; 96pop_south:outbit_t; 97 98--East 99rout_east:indest; 100count_east:inFifoAddr; 101select_east_o:outsource; 102pop_east:outbit_t; 103 104--West 105rout_west:indest; 106count_west:inFifoAddr;

86 HDL files

107select_west_o:outsource; 108pop_west:outbit_t; 109 110--IP 111rout_ip:indest; 112count_ip:inFifoAddr; 113select_ip_o:outsource; 114pop_ip:outbit_t 115); 116endcomponent; 117 118componentnoc_fifo 119port( 120--CommonI/Osignals 121clk:inbit_t; 122rst:inbit_t; 123data_i:innoc_data; 124data_o:outnoc_data; 125 126--Controlsignals 127push:inbit_t; 128pop:inbit_t; 129 130--Statussignals 131count:outFifoAddr 132); 133endcomponent; 134 135--Selectsignals 136SIGNALselect_north:source; 137SIGNALselect_south:source; 138SIGNALselect_east:source; 139SIGNALselect_west:source; 140SIGNALselect_ip:source; 141 142--Fifodata

A.2 Common NoC files 87

143SIGNALfifo_north:noc_data; 144SIGNALfifo_south:noc_data; 145SIGNALfifo_east:noc_data; 146SIGNALfifo_west:noc_data; 147SIGNALfifo_ip:noc_data; 148 149--Fifostatussignals 150SIGNALcount_north:FifoAddr; 151SIGNALcount_south:FifoAddr; 152SIGNALcount_east:FifoAddr; 153SIGNALcount_west:FifoAddr; 154SIGNALcount_ip:FifoAddr; 155 156--Fifocontrolsignals 157SIGNALpush_north:bit_t; 158SIGNALpush_south:bit_t; 159SIGNALpush_east:bit_t; 160SIGNALpush_west:bit_t; 161SIGNALpush_ip:bit_t; 162SIGNALpop_north:bit_t; 163SIGNALpop_south:bit_t; 164SIGNALpop_east:bit_t; 165SIGNALpop_west:bit_t; 166SIGNALpop_ip:bit_t; 167 168begin 169north_fifo:noc_fifo 170portmap( 171--CommonI/Osignals 172clk=>clk_i, 173rst=>rst_i, 174data_i=>noc_n_i, 175data_o=>fifo_north, 176 177--Controlsignals 178push=>push_north,

88 HDL files

179pop=>pop_north, 180 181--Statussignals 182count=>count_north 183); 184 185south_fifo:noc_fifo 186portmap( 187--CommonI/Osignals 188clk=>clk_i, 189rst=>rst_i, 190data_i=>noc_s_i, 191data_o=>fifo_south, 192 193--Controlsignals 194push=>push_south, 195pop=>pop_south, 196 197--Statussignals 198count=>count_south 199); 200 201east_fifo:noc_fifo 202portmap( 203--CommonI/Osignals 204clk=>clk_i, 205rst=>rst_i, 206data_i=>noc_e_i, 207data_o=>fifo_east, 208 209--Controlsignals 210push=>push_east, 211pop=>pop_east, 212 213--Statussignals 214count=>count_east

A.2 Common NoC files 89

215); 216 217west_fifo:noc_fifo 218portmap( 219--CommonI/Osignals 220clk=>clk_i, 221rst=>rst_i, 222data_i=>noc_w_i, 223data_o=>fifo_west, 224 225--Controlsignals 226push=>push_west, 227pop=>pop_west, 228 229--Statussignals 230count=>count_west 231); 232 233ip_fifo:noc_fifo 234portmap( 235--CommonI/Osignals 236clk=>clk_i, 237rst=>rst_i, 238data_i=>ip_i, 239data_o=>fifo_ip, 240 241--Controlsignals 242push=>push_ip, 243pop=>pop_ip, 244 245--Statussignals 246count=>count_ip 247); 248 249arbiter:noc_arbiter 250portmap(

90 HDL files

251--I/Oports 252clk_i=>clk_i, 253rst_i=>rst_i, 254 255--NoCsignals 256--North 257rout_north=>fifo_north(NOC_DATA_WIDTH-1downtoNOC_DATA_WIDTH-2), 258count_north=>count_north, 259select_north_o=>select_north, 260pop_north=>pop_north, 261 262--South 263rout_south=>fifo_south(NOC_DATA_WIDTH-1downtoNOC_DATA_WIDTH-2), 264count_south=>count_south, 265select_south_o=>select_south, 266pop_south=>pop_south, 267 268--East 269rout_east=>fifo_east(NOC_DATA_WIDTH-1downtoNOC_DATA_WIDTH-2), 270count_east=>count_east, 271select_east_o=>select_east, 272pop_east=>pop_east, 273 274--West 275rout_west=>fifo_west(NOC_DATA_WIDTH-1downtoNOC_DATA_WIDTH-2), 276count_west=>count_west, 277select_west_o=>select_west, 278pop_west=>pop_west, 279 280--IP 281rout_ip=>fifo_ip(NOC_DATA_WIDTH-1downtoNOC_DATA_WIDTH-2), 282count_ip=>count_ip, 283select_ip_o=>select_ip, 284pop_ip=>pop_ip 285 286);

A.2 Common NoC files 91

287 288mux:noc_router_mux 289portmap( 290--Sourceselector 291select_north_i=>select_north, 292select_south_i=>select_south, 293select_east_i=>select_east, 294select_west_i=>select_west, 295select_ip_i=>select_ip, 296 297--datain 298north_i=>fifo_north, 299south_i=>fifo_south, 300east_i=>fifo_east, 301west_i=>fifo_west, 302ip_i=>fifo_ip, 303 304--dataout 305north_o=>noc_n_o, 306south_o=>noc_s_o, 307east_o=>noc_e_o, 308west_o=>noc_w_o, 309ip_o=>ip_o 310 311); 312 313link_controller:process(noc_n_i,noc_s_i,noc_e_i,noc_w_i,ip_i) 314begin 315push_north<=0; 316push_south<=0; 317push_east<=0; 318push_west<=0; 319push_ip<=0; 320if(noc_n_i(stb_start)=1ornoc_n_i(ack_start)=1)then 321push_north<=1; 322endif;

92 HDL files

323if(noc_s_i(stb_start)=1ornoc_s_i(ack_start)=1)then 324push_south<=1; 325endif; 326if(noc_e_i(stb_start)=1ornoc_e_i(ack_start)=1)then 327push_east<=1; 328endif; 329if(noc_w_i(stb_start)=1ornoc_w_i(ack_start)=1)then 330push_west<=1; 331endif; 332if(ip_i(stb_start)=1orip_i(ack_start)=1)then 333push_ip<=1; 334endif; 335endprocesslink_controller; 336 337endstruc;

A.2 Common NoC files 93

A.2.5 no c router arbiter.vhd

1-------------------------------------------------------------------- 2-- 3--Arbiterforrouter 4--Editor:NikolajTørring-s042505 5--Version:1.1 6--Datalastmodified:23/5-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13--v1.1:Optimizedforarea 14-- 15--------------------------------------------------------------------- 16 17libraryIEEE; 18useIEEE.std_logic_1164.ALL; 19useIEEE.std_logic_arith.ALL; 20usework.types.all; 21 22entitynoc_arbiteris 23 24port( 25--I/Oports 26clk_i:inbit_t; 27rst_i:inbit_t; 28 29--NoCsignals 30--North 31rout_north:indest; 32count_north:inFifoAddr; 33select_north_o:outsource; 34pop_north:outbit_t;

94 HDL files

35 36--South 37rout_south:indest; 38count_south:inFifoAddr; 39select_south_o:outsource; 40pop_south:outbit_t; 41 42--East 43rout_east:indest; 44count_east:inFifoAddr; 45select_east_o:outsource; 46pop_east:outbit_t; 47 48--West 49rout_west:indest; 50count_west:inFifoAddr; 51select_west_o:outsource; 52pop_west:outbit_t; 53 54--IP 55rout_ip:indest; 56count_ip:inFifoAddr; 57select_ip_o:outsource; 58pop_ip:outbit_t 59); 60 61endnoc_arbiter; 62 63architecturestrucofnoc_arbiteris 64 65--Statesignals 66SIGNALnorth_state:source:=source_none; 67SIGNALnorth_next_state:source:=source_none; 68SIGNALsouth_state:source:=source_none; 69SIGNALsouth_next_state:source:=source_none; 70SIGNALeast_state:source:=source_none;

A.2 Common NoC files 95

71SIGNALeast_next_state:source:=source_none; 72SIGNALwest_state:source:=source_none; 73SIGNALwest_next_state:source:=source_none; 74SIGNALip_state:source:=source_none; 75SIGNALip_next_state:source:=source_none; 76 77--Popsignals 78SIGNALnorth_pop_south:bit_t; 79SIGNALnorth_pop_east:bit_t; 80SIGNALnorth_pop_west:bit_t; 81SIGNALnorth_pop_ip:bit_t; 82SIGNALsouth_pop_north:bit_t; 83SIGNALsouth_pop_east:bit_t; 84SIGNALsouth_pop_west:bit_t; 85SIGNALsouth_pop_ip:bit_t; 86SIGNALeast_pop_north:bit_t; 87SIGNALeast_pop_south:bit_t; 88SIGNALeast_pop_west:bit_t; 89SIGNALeast_pop_ip:bit_t; 90SIGNALwest_pop_north:bit_t; 91SIGNALwest_pop_south:bit_t; 92SIGNALwest_pop_east:bit_t; 93SIGNALwest_pop_ip:bit_t; 94SIGNALip_pop_north:bit_t; 95SIGNALip_pop_south:bit_t; 96SIGNALip_pop_east:bit_t; 97SIGNALip_pop_west:bit_t; 98 99 100 101 102begin 103 104--Popsignals 105pop_north<=south_pop_northoreast_pop_northorwest_pop_northorip_pop_north; 106pop_south<=north_pop_southoreast_pop_southorwest_pop_southorip_pop_south;

96 HDL files

107pop_east<=north_pop_eastorsouth_pop_eastorwest_pop_eastorip_pop_east; 108pop_west<=north_pop_westorsouth_pop_westoreast_pop_westorip_pop_west; 109pop_ip<=north_pop_iporsouth_pop_iporeast_pop_iporwest_pop_ip; 110--Roundrobinimplementation 111 112--Arbiterfornorthgate 113 114north:process(north_state,rout_south,rout_east,rout_west,rout_ip,count_south,count_east, count_west,count_ip) 115begin 116north_pop_south<=0; 117north_pop_east<=0; 118north_pop_west<=0; 119north_pop_ip<=0; 120north_next_state<=north_state; 121case(north_state)is 122whensource_ip=>--LastwasIPcore 123ifrout_south=dest_northandcount_south/=0then 124north_next_state<=source_south;--Choosesouth 125north_pop_south<=1; 126elsifrout_east=dest_northandcount_east/=0then 127north_next_state<=source_east;--Chooseeast 128north_pop_east<=1; 129elsifrout_west=dest_northandcount_west/=0then 130north_next_state<=source_west;--Choosewest 131north_pop_west<=1; 132elsifrout_ip=dest_northandcount_ip/=0then 133north_next_state<=source_ip;--ChooseIPcore 134north_pop_ip<=1; 135else 136north_next_state<=source_none;--Choosenothing 137endif; 138whensource_south=>--Lastwassouth 139ifrout_east=dest_northandcount_east/=0then 140north_next_state<=source_east;--Chooseeast 141north_pop_east<=1;

A.2 Common NoC files 97

142elsifrout_west=dest_northandcount_west/=0then 143north_next_state<=source_west;--Choosewest 144north_pop_west<=1; 145elsifrout_ip=dest_northandcount_ip/=0then 146north_next_state<=source_ip;--ChooseIPcore 147north_pop_ip<=1; 148elsifrout_south=dest_northandcount_south/=0then 149north_next_state<=source_south;--Choosesouth 150north_pop_south<=1; 151else 152north_next_state<=source_none;--Choosenothing 153endif; 154whensource_east=>--Lastwaseast 155ifrout_west=dest_northandcount_west/=0then 156north_next_state<=source_west;--Choosewest 157north_pop_west<=1; 158elsifrout_ip=dest_northandcount_ip/=0then 159north_next_state<=source_ip;--ChooseIPcore 160north_pop_ip<=1; 161elsifrout_south=dest_northandcount_south/=0then 162north_next_state<=source_south;--Choosesouth 163north_pop_south<=1; 164elsifrout_east=dest_northandcount_east/=0then 165north_next_state<=source_east;--Chooseeast 166north_pop_east<=1; 167else 168north_next_state<=source_none;--Choosenothing 169endif; 170whenothers=>--Lastwaswestornone 171ifrout_ip=dest_northandcount_ip/=0then 172north_next_state<=source_ip;--ChooseIPcore 173north_pop_ip<=1; 174elsifrout_south=dest_northandcount_south/=0then 175north_next_state<=source_south;--Choosesouth 176north_pop_south<=1; 177elsifrout_east=dest_northandcount_east/=0then

98 HDL files

178north_next_state<=source_east;--Chooseeast 179north_pop_east<=1; 180elsifrout_west=dest_northandcount_west/=0then 181north_next_state<=source_west;--Choosewest 182north_pop_west<=1; 183else 184north_next_state<=source_none;--Choosenothing 185endif; 186endcase; 187endprocessnorth; 188 189--Arbiterforsouthgate 190 191south:process(south_state,rout_north,rout_east,rout_west,rout_ip,count_north,count_east, count_west,count_ip) 192begin 193south_pop_north<=0; 194south_pop_east<=0; 195south_pop_west<=0; 196south_pop_ip<=0; 197south_next_state<=south_state; 198case(south_state)is 199whensource_ip=>--LastwasIPcore 200ifrout_north=dest_southandcount_north/=0then 201south_next_state<=source_north;--Choosenorth 202south_pop_north<=1; 203elsifrout_east=dest_southandcount_east/=0then 204south_next_state<=source_east;--Chooseeast 205south_pop_east<=1; 206elsifrout_west=dest_southandcount_west/=0then 207south_next_state<=source_west;--Choosewest 208south_pop_west<=1; 209elsifrout_ip=dest_southandcount_ip/=0then 210south_next_state<=source_ip;--ChooseIPcore 211south_pop_ip<=1; 212else

A.2 Common NoC files 99

213south_next_state<=source_none;--Choosenothing 214endif; 215whensource_north=>--Lastwassouth 216ifrout_east=dest_southandcount_east/=0then 217south_next_state<=source_east;--Chooseeast 218south_pop_east<=1; 219elsifrout_west=dest_southandcount_west/=0then 220south_next_state<=source_west;--Choosewest 221south_pop_west<=1; 222elsifrout_ip=dest_southandcount_ip/=0then 223south_next_state<=source_ip;--ChooseIPcore 224south_pop_ip<=1; 225elsifrout_north=dest_southandcount_north/=0then 226south_next_state<=source_north;--Choosenorth 227south_pop_north<=1; 228else 229south_next_state<=source_none;--Choosenothing 230endif; 231whensource_east=>--Lastwaseast 232ifrout_west=dest_southandcount_west/=0then 233south_next_state<=source_west;--Choosewest 234south_pop_west<=1; 235elsifrout_ip=dest_southandcount_ip/=0then 236south_next_state<=source_ip;--ChooseIPcore 237south_pop_ip<=1; 238elsifrout_north=dest_southandcount_north/=0then 239south_next_state<=source_north;--Choosenorth 240south_pop_north<=1; 241elsifrout_east=dest_southandcount_east/=0then 242south_next_state<=source_east;--Chooseeast 243south_pop_east<=1; 244else 245south_next_state<=source_none;--Choosenothing 246endif; 247whenothers=>--Lastwaswestornone 248ifrout_ip=dest_southandcount_ip/=0then

100 HDL files

249south_next_state<=source_ip;--ChooseIPcore 250south_pop_ip<=1; 251elsifrout_north=dest_southandcount_north/=0then 252south_next_state<=source_north;--Choosenorth 253south_pop_north<=1; 254elsifrout_east=dest_southandcount_east/=0then 255south_next_state<=source_east;--Chooseeast 256south_pop_east<=1; 257elsifrout_west=dest_southandcount_west/=0then 258south_next_state<=source_west;--Choosewest 259south_pop_west<=1; 260else 261south_next_state<=source_none;--Choosenothing 262endif; 263endcase; 264endprocesssouth; 265 266--Arbiterforeastgate 267 268east:process(east_state,rout_north,rout_south,rout_west,rout_ip,count_north,count_south, count_west,count_ip) 269begin 270east_pop_north<=0; 271east_pop_south<=0; 272east_pop_west<=0; 273east_pop_ip<=0; 274east_next_state<=east_state; 275case(east_state)is 276whensource_ip=>--LastwasIPcore 277ifrout_north=dest_eastandcount_north/=0then 278east_next_state<=source_north;--Choosenorth 279east_pop_north<=1; 280elsifrout_south=dest_eastandcount_south/=0then 281east_next_state<=source_south;--Choosesouth 282east_pop_south<=1; 283elsifrout_west=dest_eastandcount_west/=0then

A.2 Common NoC files 101

284east_next_state<=source_west;--Choosewest 285east_pop_west<=1; 286elsifrout_ip=dest_eastandcount_ip/=0then 287east_next_state<=source_ip;--ChooseIPcore 288east_pop_ip<=1; 289else 290east_next_state<=source_none;--Choosenothing 291endif; 292whensource_north=>--Lastwasnorth 293ifrout_south=dest_eastandcount_south/=0then 294east_next_state<=source_south;--Choosesouth 295east_pop_south<=1; 296elsifrout_west=dest_eastandcount_west/=0then 297east_next_state<=source_west;--Choosewest 298east_pop_west<=1; 299elsifrout_ip=dest_eastandcount_ip/=0then 300east_next_state<=source_ip;--ChooseIPcore 301east_pop_ip<=1; 302elsifrout_north=dest_eastandcount_north/=0then 303east_next_state<=source_north;--Choosenorth 304east_pop_north<=1; 305else 306east_next_state<=source_none;--Choosenothing 307endif; 308whensource_south=>--Lastwassouth 309ifrout_west=dest_eastandcount_west/=0then 310east_next_state<=source_west;--Choosewest 311east_pop_west<=1; 312elsifrout_ip=dest_eastandcount_ip/=0then 313east_next_state<=source_ip;--ChooseIPcore 314east_pop_ip<=1; 315elsifrout_north=dest_eastandcount_north/=0then 316east_next_state<=source_north;--Choosenorth 317east_pop_north<=1; 318elsifrout_south=dest_eastandcount_south/=0then 319east_next_state<=source_south;--Choosesouth

102 HDL files

320east_pop_south<=1; 321else 322east_next_state<=source_none;--Choosenothing 323endif; 324whenothers=>--Lastwaswestornone 325ifrout_ip=dest_eastandcount_ip/=0then 326east_next_state<=source_ip;--ChooseIPcore 327east_pop_ip<=1; 328elsifrout_north=dest_eastandcount_north/=0then 329east_next_state<=source_north;--Choosenorth 330east_pop_north<=1; 331elsifrout_south=dest_eastandcount_south/=0then 332east_next_state<=source_south;--Choosesouth 333east_pop_south<=1; 334elsifrout_west=dest_eastandcount_west/=0then 335east_next_state<=source_west;--Choosewest 336east_pop_west<=1; 337else 338east_next_state<=source_none;--Choosenothing 339endif; 340endcase; 341endprocesseast; 342 343--Arbiterforwestgate 344 345west:process(west_state,rout_north,rout_south,rout_east,rout_ip,count_north,count_south, count_east,count_ip) 346begin 347west_pop_north<=0; 348west_pop_south<=0; 349west_pop_east<=0; 350west_pop_ip<=0; 351west_next_state<=west_state; 352case(west_state)is 353whensource_ip=>--LastwasIPcore 354ifrout_north=dest_westandcount_north/=0then

A.2 Common NoC files 103

355west_next_state<=source_north;--Choosenorth 356west_pop_north<=1; 357elsifrout_south=dest_westandcount_south/=0then 358west_next_state<=source_south;--Choosesouth 359west_pop_south<=1; 360elsifrout_east=dest_westandcount_east/=0then 361west_next_state<=source_east;--Chooseeast 362west_pop_east<=1; 363elsifrout_ip=dest_westandcount_ip/=0then 364west_next_state<=source_ip;--ChooseIPcore 365west_pop_ip<=1; 366else 367west_next_state<=source_none;--Choosenothing 368endif; 369whensource_north=>--Lastwasnorth 370ifrout_south=dest_westandcount_south/=0then 371west_next_state<=source_south;--Choosesouth 372west_pop_south<=1; 373elsifrout_east=dest_westandcount_east/=0then 374west_next_state<=source_east;--Chooseeast 375west_pop_east<=1; 376elsifrout_ip=dest_westandcount_ip/=0then 377west_next_state<=source_ip;--ChooseIPcore 378west_pop_ip<=1; 379elsifrout_north=dest_westandcount_north/=0then 380west_next_state<=source_north;--Choosenorth 381west_pop_north<=1; 382else 383west_next_state<=source_none;--Choosenothing 384endif; 385whensource_south=>--Lastwassouth 386ifrout_east=dest_westandcount_east/=0then 387west_next_state<=source_east;--Chooseeast 388west_pop_east<=1; 389elsifrout_ip=dest_westandcount_ip/=0then 390west_next_state<=source_ip;--ChooseIPcore

104 HDL files

391west_pop_ip<=1; 392elsifrout_north=dest_westandcount_north/=0then 393west_next_state<=source_north;--Choosenorth 394west_pop_north<=1; 395elsifrout_south=dest_westandcount_south/=0then 396west_next_state<=source_south;--Choosesouth 397west_pop_south<=1; 398else 399west_next_state<=source_none;--Choosenothing 400endif; 401whenothers=>--Lastwaseastornone 402ifrout_ip=dest_westandcount_ip/=0then 403west_next_state<=source_ip;--ChooseIPcore 404west_pop_ip<=1; 405elsifrout_north=dest_westandcount_north/=0then 406west_next_state<=source_north;--Choosenorth 407west_pop_north<=1; 408elsifrout_south=dest_westandcount_south/=0then 409west_next_state<=source_south;--Choosesouth 410west_pop_south<=1; 411elsifrout_east=dest_westandcount_east/=0then 412west_next_state<=source_east;--Chooseeast 413west_pop_east<=1; 414else 415west_next_state<=source_none;--Choosenothing 416endif; 417endcase; 418endprocesswest; 419 420--Arbiterforipgate 421 422ip:process(ip_state,rout_north,rout_south,rout_east,rout_west,count_north,count_south, count_east,count_west) 423begin 424ip_pop_north<=0; 425ip_pop_south<=0;

A.2 Common NoC files 105

426ip_pop_east<=0; 427ip_pop_west<=0; 428ip_next_state<=ip_state; 429case(ip_state)is 430whensource_west=>--LastwasIPcore 431ifrout_north=dest_northandcount_north/=0then 432ip_next_state<=source_north;--Choosenorth 433ip_pop_north<=1; 434elsifrout_south=dest_southandcount_south/=0then 435ip_next_state<=source_south;--Choosesouth 436ip_pop_south<=1; 437elsifrout_east=dest_eastandcount_east/=0then 438ip_next_state<=source_east;--Chooseeast 439ip_pop_east<=1; 440elsifrout_west=dest_westandcount_west/=0then 441ip_next_state<=source_west;--Choosewest 442ip_pop_west<=1; 443else 444ip_next_state<=source_none;--Choosenothing 445endif; 446whensource_north=>--Lastwassouth 447ifrout_south=dest_southandcount_south/=0then 448ip_next_state<=source_south;--Choosesouth 449ip_pop_south<=1; 450elsifrout_east=dest_eastandcount_east/=0then 451ip_next_state<=source_east;--Chooseeast 452ip_pop_east<=1; 453elsifrout_west=dest_westandcount_west/=0then 454ip_next_state<=source_west;--Choosewest 455ip_pop_west<=1; 456elsifrout_north=dest_northandcount_north/=0then 457ip_next_state<=source_north;--Choosenorth 458ip_pop_north<=1; 459else 460ip_next_state<=source_none;--Choosenothing 461endif;

106 HDL files

462whensource_south=>--Lastwassouth 463ifrout_east=dest_eastandcount_east/=0then 464ip_next_state<=source_east;--Chooseeast 465ip_pop_east<=1; 466elsifrout_west=dest_westandcount_west/=0then 467ip_next_state<=source_west;--Choosewest 468ip_pop_west<=1; 469elsifrout_north=dest_northandcount_north/=0then 470ip_next_state<=source_north;--Choosenorth 471ip_pop_north<=1; 472elsifrout_south=dest_southandcount_south/=0then 473ip_next_state<=source_south;--Choosesouth 474ip_pop_south<=1; 475else 476ip_next_state<=source_none;--Choosenothing 477endif; 478whenothers=>--Lastwaseastornone 479ifrout_west=dest_westandcount_west/=0then 480ip_next_state<=source_west;--Choosewest 481ip_pop_west<=1; 482elsifrout_north=dest_northandcount_north/=0then 483ip_next_state<=source_north;--Choosenorth 484ip_pop_north<=1; 485elsifrout_south=dest_southandcount_south/=0then 486ip_next_state<=source_south;--Choosesouth 487ip_pop_south<=1; 488elsifrout_east=dest_eastandcount_east/=0then 489ip_next_state<=source_east;--Chooseeast 490ip_pop_east<=1; 491else 492ip_next_state<=source_none;--Choosenothing 493endif; 494endcase; 495endprocessip; 496 497next_state_register:process(clk_i,rst_i)

A.2 Common NoC files 107

498begin 499ifrst_i=0then--asynchronousreset(activelow) 500north_state<=source_none; 501south_state<=source_none; 502east_state<=source_none; 503west_state<=source_none; 504ip_state<=source_none; 505elsifclk_ieventandclk_i=1then 506north_state<=north_next_state; 507south_state<=south_next_state; 508east_state<=east_next_state; 509west_state<=west_next_state; 510ip_state<=ip_next_state; 511endif; 512endprocessnext_state_register; 513 514select_north_o<=north_next_state; 515select_south_o<=south_next_state; 516select_east_o<=east_next_state; 517select_west_o<=west_next_state; 518select_ip_o<=ip_next_state; 519 520endstruc;

108 HDL files

A.2.6 no c router m ux.vhd

1-------------------------------------------------------------------- 2-- 3--Arbiterforrouter 4--Editor:NikolajTørring-s042505 5--Version:1.3 6--Datalastmodified:23/5-2007 7-- 8--------------------------------------------------------------------- 9-- 10--VersionHistory 11-- 12--v1.0:Firstworkingversion 13--v1.1:Someoptimisationstoimprovespace 14--v1.2:Furtheroptimizations,didnotaffectusedarea 15--v1.3:joinedthewithstatements 16-- 17--------------------------------------------------------------------- 18 19 20libraryIEEE; 21useIEEE.std_logic_1164.ALL; 22useIEEE.std_logic_arith.ALL; 23usework.types.all; 24 25entitynoc_router_muxis 26 27port( 28--Sourceselector 29select_north_i:insource; 30select_south_i:insource; 31select_east_i:insource; 32select_west_i:insource; 33select_ip_i:insource; 34

A.2 Common NoC files 109

35--datain 36north_i:innoc_data; 37south_i:innoc_data; 38east_i:innoc_data; 39west_i:innoc_data; 40ip_i:innoc_data; 41 42--dataout 43north_o:outnoc_data; 44south_o:outnoc_data; 45east_o:outnoc_data; 46west_o:outnoc_data; 47ip_o:outnoc_data 48); 49endnoc_router_mux; 50 51architecturestrucofnoc_router_muxis 52 53begin 54 55--Northdata 56WITHselect_north_iSELECT 57north_o<= 58south_i(NOC_DATA_WIDTH-3downtoNOC_DATA_WIDTH-route_wdth)&dest_south&south_i(NOC_DATA_WIDTH- route_wdth-1downto0) 59whensource_south, 60east_i(NOC_DATA_WIDTH-3downtoNOC_DATA_WIDTH-route_wdth)&dest_east&east_i(NOC_DATA_WIDTH- route_wdth-1downto0) 61whensource_east, 62west_i(NOC_DATA_WIDTH-3downtoNOC_DATA_WIDTH-route_wdth)&dest_west&west_i(NOC_DATA_WIDTH- route_wdth-1downto0) 63whensource_west, 64ip_i(NOC_DATA_WIDTH-3downtoNOC_DATA_WIDTH-route_wdth)&dest_north&ip_i(NOC_DATA_WIDTH- route_wdth-1downto0) 65whensource_ip, 66(OTHERS=>0)whensource_none,

In document Multiprocessor in a FPGA (Sider 82-147)