annotate modules/bluespec/Pygar/core/RoutingTable.bsv @ 69:5c963ab14143 pygar svn.70

[svn r70] added an attempt at multi-fileing
author punk
date Wed, 12 May 2010 00:07:40 -0400
parents 2c8166d205d5
children
rev   line source
rlm@8 1 import Trace::*;
rlm@8 2 import Vector::*;
rlm@8 3 import PathTypes::*;
rlm@8 4
rlm@8 5 function FullPath genEmptyPaths (Integer a) ;
punk@33 6 FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore, outVol: 0};
rlm@8 7 return (empt);
rlm@8 8 endfunction
rlm@8 9
rlm@8 10 interface RoutingTable;
rlm@8 11 method FullPath getPath(Integer voiceNo);
punk@33 12 method Vector#(`MAX_VOICES, Volume) getMixerScalars();
rlm@8 13 endinterface
rlm@8 14
rlm@8 15 module mkRoutingTable(RoutingTable);
rlm@8 16 Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
rlm@8 17
rlm@8 18 function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath);
rlm@8 19 CorePath outPath = inPath;
rlm@8 20 for(Integer i = 0; i < len; i = i+1)
rlm@8 21 inPath[i] = cores[i];
rlm@8 22 return outPath;
rlm@8 23 endfunction
rlm@8 24
rlm@8 25 //demonstrate two ways of building the routeTable
rlm@8 26 routeTable[0].startAddr = 0; //where is this really going to come from?
rlm@8 27 routeTable[0].route[0] = 3;
rlm@8 28 routeTable[0].route[1] = mixerId;
punk@33 29 routeTable[0].outVol = 200;
rlm@8 30 //rest are already initialized toinvalid
rlm@8 31
punk@33 32 // or if you just want to update a straight list, this longer template works.
rlm@8 33 function CorePath createVoice1Route();
rlm@8 34 CorePath outPath = emptyCore;
rlm@8 35
rlm@8 36 Integer len = 3;
rlm@8 37 PathId route[len] = {1, 2, mixerId}; //route to update
rlm@8 38
rlm@8 39 for(Integer i = 0; i < len; i = i+1)
rlm@8 40 outPath[i] = route[i];
rlm@8 41
rlm@8 42 return outPath;
rlm@8 43 endfunction
rlm@8 44 routeTable[1].route = createVoice1Route;
punk@33 45 routeTable[1].startAddr = 0;
punk@33 46 routeTable[1].outVol = 200;
rlm@8 47
rlm@8 48 //remaining voices are all initialized to empty.
rlm@8 49
punk@33 50 method FullPath getPath(Integer a);
rlm@8 51 return routeTable[a];
rlm@8 52 endmethod
punk@33 53
punk@33 54 method Vector#(`MAX_VOICES, Volume) getMixerScalars();
punk@33 55 Vector#(`MAX_VOICES, Volume) scalars = newVector();
punk@33 56 for(Integer i = 0; i < `MAX_VOICES; i = i+1)
punk@33 57 scalars[i] = routeTable[i].outVol;
punk@33 58 return scalars;
punk@33 59 endmethod
rlm@8 60
rlm@8 61 endmodule
rlm@8 62