comparison modules/bluespec/Pygar/core/RoutingTable.bsv @ 33:2c8166d205d5 pygar svn.34

[svn r34] uses scratchpad, set up for audio through c
author punk
date Tue, 04 May 2010 10:13:53 -0400
parents 74716e9a81cc
children
comparison
equal deleted inserted replaced
32:0c775e733b81 33:2c8166d205d5
1 import Trace::*; 1 import Trace::*;
2 import Vector::*; 2 import Vector::*;
3 import PathTypes::*; 3 import PathTypes::*;
4 4
5 function FullPath genEmptyPaths (Integer a) ; 5 function FullPath genEmptyPaths (Integer a) ;
6 FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore}; 6 FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore, outVol: 0};
7 return (empt); 7 return (empt);
8 endfunction 8 endfunction
9 9
10 interface RoutingTable; 10 interface RoutingTable;
11 method FullPath getPath(Integer voiceNo); 11 method FullPath getPath(Integer voiceNo);
12 method Vector#(`MAX_VOICES, Volume) getMixerScalars();
12 endinterface 13 endinterface
13 14
14 module mkRoutingTable(RoutingTable); 15 module mkRoutingTable(RoutingTable);
15 Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths); 16 Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
16 17
23 24
24 //demonstrate two ways of building the routeTable 25 //demonstrate two ways of building the routeTable
25 routeTable[0].startAddr = 0; //where is this really going to come from? 26 routeTable[0].startAddr = 0; //where is this really going to come from?
26 routeTable[0].route[0] = 3; 27 routeTable[0].route[0] = 3;
27 routeTable[0].route[1] = mixerId; 28 routeTable[0].route[1] = mixerId;
29 routeTable[0].outVol = 200;
28 //rest are already initialized toinvalid 30 //rest are already initialized toinvalid
29 31
30 // or if you just want to update a straight list, this longer emplate works. 32 // or if you just want to update a straight list, this longer template works.
31 function CorePath createVoice1Route(); 33 function CorePath createVoice1Route();
32 CorePath outPath = emptyCore; 34 CorePath outPath = emptyCore;
33 35
34 Integer len = 3; 36 Integer len = 3;
35 PathId route[len] = {1, 2, mixerId}; //route to update 37 PathId route[len] = {1, 2, mixerId}; //route to update
38 outPath[i] = route[i]; 40 outPath[i] = route[i];
39 41
40 return outPath; 42 return outPath;
41 endfunction 43 endfunction
42 routeTable[1].route = createVoice1Route; 44 routeTable[1].route = createVoice1Route;
43 routeTable[1].startAddr = 0; 45 routeTable[1].startAddr = 0;
46 routeTable[1].outVol = 200;
44 47
45 //remaining voices are all initialized to empty. 48 //remaining voices are all initialized to empty.
46 49
47 method FullPath getPath(Integer a); 50 method FullPath getPath(Integer a);
48 return routeTable[a]; 51 return routeTable[a];
52 endmethod
53
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;
49 endmethod 59 endmethod
50 60
51 endmodule 61 endmodule
52 62