changeset 4:c4438eca4bc4 pygar svn.5

[svn r5] Updates to PathTypes and addition of RoutingTable
author punk
date Wed, 21 Apr 2010 06:51:11 -0400
parents 5e0595db14f6
children 26cd0ed8e72c
files core/src/PathTypes.bsv core/src/RoutingTable.bsv
diffstat 2 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/core/src/PathTypes.bsv	Tue Apr 20 20:09:46 2010 -0400
     1.2 +++ b/core/src/PathTypes.bsv	Wed Apr 21 06:51:11 2010 -0400
     1.3 @@ -20,15 +20,12 @@
     1.4  
     1.5  // Path is array of path ids
     1.6  typedef Vector#(`MAX_PATH_LENGTH,  PathId) CorePath;
     1.7 +CorePath emptyCore = replicate(endId);
     1.8 +
     1.9  typedef struct
    1.10  {
    1.11 +  VoiceId   voice;
    1.12    MemAddr   startAddr;
    1.13    CorePath  route;
    1.14 - } FullPath deriving(Eq, Bits);
    1.15 -	     
    1.16 -vector#(`MAX_VOICES, FullPath) routeTable;
    1.17 -CorePath aroute = {1, 2};
    1.18 -routeTable  =  {{12, aroute},{1, aroute}};
    1.19 +} FullPath deriving (Bits, Eq);
    1.20  
    1.21 - 
    1.22 -	     
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/core/src/RoutingTable.bsv	Wed Apr 21 06:51:11 2010 -0400
     2.3 @@ -0,0 +1,52 @@
     2.4 +import Trace::*;
     2.5 +import Vector::*;
     2.6 +import PathTypes::*;
     2.7 +
     2.8 +function FullPath genEmptyPaths (Integer a) ;
     2.9 +   FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore};
    2.10 +   return (empt);
    2.11 +endfunction
    2.12 +
    2.13 +interface RoutingTable;
    2.14 +   method FullPath getPath(Integer voiceNo);
    2.15 +endinterface
    2.16 +
    2.17 +module mkRoutingTable(RoutingTable);
    2.18 +   Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
    2.19 +
    2.20 +   function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath);
    2.21 +      CorePath outPath = inPath;
    2.22 +      for(Integer i = 0; i < len; i = i+1)
    2.23 +	inPath[i] = cores[i];
    2.24 +      return outPath;
    2.25 +   endfunction
    2.26 +
    2.27 +   //demonstrate two ways of building the routeTable
    2.28 +   routeTable[0].startAddr = 0;  //where is this really going to come from?
    2.29 +   routeTable[0].route[0] = 3;
    2.30 +   routeTable[0].route[1] = mixerId;
    2.31 +   //rest are already initialized toinvalid
    2.32 +
    2.33 +   // or if you just want to update a straight list, this longer emplate works.
    2.34 +   function CorePath createVoice1Route();
    2.35 +      CorePath outPath = emptyCore;
    2.36 +      
    2.37 +      Integer len = 3;
    2.38 +      PathId route[len] = {1, 2, mixerId}; //route to update
    2.39 + 
    2.40 +      for(Integer i = 0; i < len; i = i+1)
    2.41 +	 outPath[i] = route[i];
    2.42 +      
    2.43 +      return outPath;
    2.44 +   endfunction
    2.45 +   routeTable[1].route = createVoice1Route;
    2.46 +   routeTable[1].startAddr = 0;
    2.47 +
    2.48 +   //remaining voices are all initialized to empty.
    2.49 +   
    2.50 +   method FullPath getPath(Integer a);
    2.51 +      return routeTable[a];
    2.52 +   endmethod
    2.53 +   
    2.54 +endmodule
    2.55 +