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