view modules/bluespec/Pygar/core/RoutingTable.bsv @ 73:0f86d486e38e pygar svn.74

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