rlm@8: import Trace::*; rlm@8: import Vector::*; rlm@8: import PathTypes::*; rlm@8: rlm@8: function FullPath genEmptyPaths (Integer a) ; punk@33: FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore, outVol: 0}; rlm@8: return (empt); rlm@8: endfunction rlm@8: rlm@8: interface RoutingTable; rlm@8: method FullPath getPath(Integer voiceNo); punk@33: method Vector#(`MAX_VOICES, Volume) getMixerScalars(); rlm@8: endinterface rlm@8: rlm@8: module mkRoutingTable(RoutingTable); rlm@8: Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths); rlm@8: rlm@8: function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath); rlm@8: CorePath outPath = inPath; rlm@8: for(Integer i = 0; i < len; i = i+1) rlm@8: inPath[i] = cores[i]; rlm@8: return outPath; rlm@8: endfunction rlm@8: rlm@8: //demonstrate two ways of building the routeTable rlm@8: routeTable[0].startAddr = 0; //where is this really going to come from? rlm@8: routeTable[0].route[0] = 3; rlm@8: routeTable[0].route[1] = mixerId; punk@33: routeTable[0].outVol = 200; rlm@8: //rest are already initialized toinvalid rlm@8: punk@33: // or if you just want to update a straight list, this longer template works. rlm@8: function CorePath createVoice1Route(); rlm@8: CorePath outPath = emptyCore; rlm@8: rlm@8: Integer len = 3; rlm@8: PathId route[len] = {1, 2, mixerId}; //route to update rlm@8: rlm@8: for(Integer i = 0; i < len; i = i+1) rlm@8: outPath[i] = route[i]; rlm@8: rlm@8: return outPath; rlm@8: endfunction rlm@8: routeTable[1].route = createVoice1Route; punk@33: routeTable[1].startAddr = 0; punk@33: routeTable[1].outVol = 200; rlm@8: rlm@8: //remaining voices are all initialized to empty. rlm@8: punk@33: method FullPath getPath(Integer a); rlm@8: return routeTable[a]; rlm@8: endmethod punk@33: punk@33: method Vector#(`MAX_VOICES, Volume) getMixerScalars(); punk@33: Vector#(`MAX_VOICES, Volume) scalars = newVector(); punk@33: for(Integer i = 0; i < `MAX_VOICES; i = i+1) punk@33: scalars[i] = routeTable[i].outVol; punk@33: return scalars; punk@33: endmethod rlm@8: rlm@8: endmodule rlm@8: