annotate core/src/RoutingTable.bsv @ 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
children 7393cd19371e
rev   line source
punk@4 1 import Trace::*;
punk@4 2 import Vector::*;
punk@4 3 import PathTypes::*;
punk@4 4
punk@4 5 function FullPath genEmptyPaths (Integer a) ;
punk@4 6 FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore};
punk@4 7 return (empt);
punk@4 8 endfunction
punk@4 9
punk@4 10 interface RoutingTable;
punk@4 11 method FullPath getPath(Integer voiceNo);
punk@4 12 endinterface
punk@4 13
punk@4 14 module mkRoutingTable(RoutingTable);
punk@4 15 Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
punk@4 16
punk@4 17 function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath);
punk@4 18 CorePath outPath = inPath;
punk@4 19 for(Integer i = 0; i < len; i = i+1)
punk@4 20 inPath[i] = cores[i];
punk@4 21 return outPath;
punk@4 22 endfunction
punk@4 23
punk@4 24 //demonstrate two ways of building the routeTable
punk@4 25 routeTable[0].startAddr = 0; //where is this really going to come from?
punk@4 26 routeTable[0].route[0] = 3;
punk@4 27 routeTable[0].route[1] = mixerId;
punk@4 28 //rest are already initialized toinvalid
punk@4 29
punk@4 30 // or if you just want to update a straight list, this longer emplate works.
punk@4 31 function CorePath createVoice1Route();
punk@4 32 CorePath outPath = emptyCore;
punk@4 33
punk@4 34 Integer len = 3;
punk@4 35 PathId route[len] = {1, 2, mixerId}; //route to update
punk@4 36
punk@4 37 for(Integer i = 0; i < len; i = i+1)
punk@4 38 outPath[i] = route[i];
punk@4 39
punk@4 40 return outPath;
punk@4 41 endfunction
punk@4 42 routeTable[1].route = createVoice1Route;
punk@4 43 routeTable[1].startAddr = 0;
punk@4 44
punk@4 45 //remaining voices are all initialized to empty.
punk@4 46
punk@4 47 method FullPath getPath(Integer a);
punk@4 48 return routeTable[a];
punk@4 49 endmethod
punk@4 50
punk@4 51 endmodule
punk@4 52