Mercurial > pygar
changeset 2:996f1d6cd010 pygar svn.3
[svn r3] added pseudo code for Mixer, and defined Samples and VoiceID in PathTypes.
author | rlm |
---|---|
date | Wed, 14 Apr 2010 15:02:32 -0400 |
parents | 91a1f76ddd62 |
children | 5e0595db14f6 |
files | common/Mixer.bsv core/src/PathTypes.bsv |
diffstat | 2 files changed, 45 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/common/Mixer.bsv Wed Apr 14 15:02:32 2010 -0400 1.3 @@ -0,0 +1,42 @@ 1.4 +import FIFOF::*; 1.5 +import FIFO::*; 1.6 + 1.7 + 1.8 +interface Mixer; 1.9 + method Action feed(Sample samp, VoiceId id); // feed in a sample to a specific FIFOF 1.10 + method Action stream(); // Outputs muxed data. 1.11 +endinterface 1.12 + 1.13 + 1.14 +method vectorFull?(Vector#(FIFOF#(Sample)) vect) 1.15 + 1.16 + (reduce .notEmpty vect) 1.17 + 1.18 +endmethod 1.19 + 1.20 + 1.21 + 1.22 +module mkMixer(Mixer); 1.23 + 1.24 + FIFO output = mkFIFO(); 1.25 + 1.26 + 1.27 + // make vector of fifos, length = MAX_VOICES 1.28 + fifo_vect Vector#(FIFOF#(Sample)) = mkVector(`MAX_VOICES); 1.29 + 1.30 + 1.31 + for $i(1 .. `MAX_VOICES) 1.32 + begin 1.33 + fifo_vect[$i] = mkFIFOF(); 1.34 + end 1.35 + 1.36 + rule(vectorFull?(fifo_vect)) 1.37 + 1.38 + Sample out = (/ (reduce + fofo_vector) `MAX_VOICES) 1.39 + output.enq(out); 1.40 + 1.41 + endrule 1.42 + 1.43 + 1.44 +endmodule 1.45 +
2.1 --- a/core/src/PathTypes.bsv Tue Apr 13 17:34:33 2010 -0400 2.2 +++ b/core/src/PathTypes.bsv Wed Apr 14 15:02:32 2010 -0400 2.3 @@ -10,6 +10,9 @@ 2.4 2.5 typedef Bit#(32) MemAddr; 2.6 typedef Int#(TLog#(`MAX_PATH_IDS)) PathId; 2.7 +typedef Int#(24) Sample; 2.8 +typedef Int#(TLog#(`MAX_VOICES)) VoiceId; 2.9 + 2.10 2.11 //The mixer is identified as PathId 0, path end is max 2.12 PathId mixerId = 0;