diff common/RoutingTable.bsv @ 16:7e1510b47336 pygar svn.17

[svn r17] added rest of items for core
author punk
date Tue, 27 Apr 2010 22:54:50 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/RoutingTable.bsv	Tue Apr 27 22:54:50 2010 -0400
     1.3 @@ -0,0 +1,52 @@
     1.4 +import Trace::*;
     1.5 +import Vector::*;
     1.6 +import PathTypes::*;
     1.7 +
     1.8 +function FullPath genEmptyPaths (Integer a) ;
     1.9 +   FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore};
    1.10 +   return (empt);
    1.11 +endfunction
    1.12 +
    1.13 +interface RoutingTable;
    1.14 +   method FullPath getPath(Integer voiceNo);
    1.15 +endinterface
    1.16 +
    1.17 +module mkRoutingTable(RoutingTable);
    1.18 +   Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
    1.19 +
    1.20 +   function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath);
    1.21 +      CorePath outPath = inPath;
    1.22 +      for(Integer i = 0; i < len; i = i+1)
    1.23 +	inPath[i] = cores[i];
    1.24 +      return outPath;
    1.25 +   endfunction
    1.26 +
    1.27 +   //demonstrate two ways of building the routeTable
    1.28 +   routeTable[0].startAddr = 0;  //where is this really going to come from?
    1.29 +   routeTable[0].route[0] = 3;
    1.30 +   routeTable[0].route[1] = mixerId;
    1.31 +   //rest are already initialized toinvalid
    1.32 +
    1.33 +   // or if you just want to update a straight list, this longer emplate works.
    1.34 +   function CorePath createVoice1Route();
    1.35 +      CorePath outPath = emptyCore;
    1.36 +      
    1.37 +      Integer len = 3;
    1.38 +      PathId route[len] = {1, 2, mixerId}; //route to update
    1.39 + 
    1.40 +      for(Integer i = 0; i < len; i = i+1)
    1.41 +	 outPath[i] = route[i];
    1.42 +      
    1.43 +      return outPath;
    1.44 +   endfunction
    1.45 +   routeTable[1].route = createVoice1Route;
    1.46 +   routeTable[1].startAddr = 0;
    1.47 +
    1.48 +   //remaining voices are all initialized to empty.
    1.49 +   
    1.50 +   method FullPath getPath(Integer a);
    1.51 +      return routeTable[a];
    1.52 +   endmethod
    1.53 +   
    1.54 +endmodule
    1.55 +