URL
https://opencores.org/ocsvn/bluespec-80211atransmitter/bluespec-80211atransmitter/trunk
Subversion Repositories bluespec-80211atransmitter
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 1 to Rev 2
- ↔ Reverse comparison
Rev 1 → Rev 2
/trunk/IFFT.bsv
0,0 → 1,119
// The MIT License |
// |
// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu) |
// |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to deal |
// in the Software without restriction, including without limitation the rights |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
// copies of the Software, and to permit persons to whom the Software is |
// furnished to do so, subject to the following conditions: |
// |
// The above copyright notice and this permission notice shall be included in |
// all copies or substantial portions of the Software. |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
// THE SOFTWARE. |
|
|
|
|
import ComplexF::*; |
import DataTypes::*; |
import Interfaces::*; |
import IFFT_Library::*; |
|
import Pipelines::*; |
import FIFO::*; |
import FIFOF::*; |
import Vector::*; |
|
|
(* synthesize *) |
module mkIFFT_Circ(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Circ(2'd3, 2'd1, stagefunction)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Pipe(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Sync(2'd3, 2'd1, stagefunction)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Comb(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Comb(2'd3, 2'd1, stagefunction)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Circ_w_1Radix(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Circ(6'd48, 6'd1, stagefunction2)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Circ_w_2Radix(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Circ(6'd48, 6'd2, stagefunction2)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Circ_w_4Radix(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Circ(6'd48, 6'd4, stagefunction2)); |
return (_x); |
endmodule |
|
(* synthesize *) |
module mkIFFT_Circ_w_8Radix(IFFT#(64)); |
let _x <- mkIFFT(mkPipeline_Circ(6'd48, 6'd8, stagefunction2)); |
return (_x); |
endmodule |
|
|
module [Module] mkIFFT#(Module#(Pipeline#(IFFTData)) mkP) |
(IFFT#(64)); |
|
Pipeline#(IFFTData) p <- mkP(); |
|
method Action fromMapper(MsgComplexFVec#(64) x); |
IFFTData data = x.data; |
IFFTData reordered_data = newVector(); |
for(Integer i = 0; i < 64; i = i + 1) |
begin |
// note swapped values |
reordered_data[i].i = data[63-reorder[i]].q; |
reordered_data[i].q = data[63-reorder[i]].i; |
end |
p.put(reordered_data); |
endmethod |
|
// output to cyclic extend queue method |
|
method ActionValue#(MsgComplexFVec#(64)) toCyclicExtender(); |
|
IFFTData data <- p.get(); |
|
IFFTData data_out = newVector(); |
for(Integer i = 0; i < 64; i = i + 1) |
begin |
data_out[i].i = data[63-i].q; |
data_out[i].q = data[63-i].i; |
end |
return(MsgComplexFVec{ |
new_message: True, |
data : data_out |
}); |
endmethod |
|
|
|
|
|
endmodule |
/trunk/Pipelines.bsv
0,0 → 1,293
// The MIT License |
// |
// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu) |
// |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to deal |
// in the Software without restriction, including without limitation the rights |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
// copies of the Software, and to permit persons to whom the Software is |
// furnished to do so, subject to the following conditions: |
// |
// The above copyright notice and this permission notice shall be included in |
// all copies or substantial portions of the Software. |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
// THE SOFTWARE. |
|
|
|
|
////////////////////////////////////////////////////////////////////////////////// |
|
// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu) |
|
// Permission is hereby granted, free of charge, to any person obtaining |
// a copy of this software and associated documentation files (the |
// "Software"), to deal in the Software without restriction, including |
// without limitation the rights to use, copy, modify, merge, publish, |
// distribute, sublicense, and/or sell copies of the Software, and to |
// permit persons to whom the Software is furnished to do so, subject to |
// the following conditions: |
|
// The above copyright notice and this permission notice shall be |
// included in all copies or substantial portions of the Software. |
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
////////////////////////////////////////////////////////////////////////////////// |
|
import FIFO::*; |
import FIFOF::*; |
import Vector::*; |
|
interface Pipeline#(type alpha); |
method Action put(alpha x); |
method ActionValue#(alpha) get(); |
endinterface |
|
function alpha repeatFN(Bit#(b) reps, function alpha f(Bit#(b) stage, alpha fx), Bit#(b) stage, alpha in); |
alpha new_in = f(stage, in); |
return (reps == 0) ? in : repeatFN(reps - 1, f, stage+1, new_in); |
endfunction |
|
module mkPipeline_Circ#(Bit#(b) numstages, |
Bit#(b) step, |
function alpha sf(Bit#(b) s, alpha x)) |
(Pipeline#(alpha)) |
provisos |
(Bits#(alpha, asz)); |
|
// input queue |
FIFOF#(alpha) inputQ <- mkLFIFOF(); |
|
// internal state |
Reg#(Bit#(b)) stage <- mkReg(0); |
Reg#(alpha) s <- mkRegU; |
|
// output queue |
FIFO#(alpha) outputQ <- mkLFIFO(); |
|
rule compute(True); |
// get input (implicitly stalls if no input) |
|
alpha s_in = s; // default is from register |
if (stage == 0) |
begin |
s_in = inputQ.first(); |
inputQ.deq(); |
end |
|
//do stage |
let s_out = repeatFN(step, sf, stage, s_in); |
|
// store output |
stage <= (stage + step == numstages) ? 0 : stage + step; |
|
if(stage + step == numstages) |
outputQ.enq(s_out); |
else |
s <= s_out; |
endrule |
|
// The Interface |
|
method Action put(alpha x); |
inputQ.enq(x); |
endmethod |
|
method ActionValue#(alpha) get(); |
outputQ.deq(); |
return outputQ.first(); |
endmethod |
|
endmodule |
|
module mkPipeline_Sync#(Bit#(b) numstages, |
Bit#(b) step, |
function alpha sf(Bit#(b) s, alpha x)) |
(Pipeline#(alpha)) |
provisos |
(Bits#(alpha, asz),Add#(b,k,32)); |
|
// input queue |
FIFOF#(alpha) inputQ <- mkLFIFOF(); |
|
// internal state |
// This is an over estimate of the space we need |
// we're artificially restricted because there is no |
// "reasonable way to pass a "static" parameter. |
// We will only create/initialize the used registers though. |
|
Vector#(TExp#(b), Reg#(Maybe#(alpha))) piperegs = newVector(); |
|
for(Bit#(b) i = 0; i < numstages; i = i + step) |
begin |
let pipereg <- mkReg(Nothing); |
piperegs[i] = pipereg; |
end |
|
// output queue |
FIFO#(alpha) outputQ <- mkLFIFO(); |
|
rule compute(True); |
for(Bit#(b) stage = 0; stage < numstages; stage = stage + step) |
begin |
//Determine Inputs |
|
Maybe#(alpha) in = Nothing; // Default Value Is Nothing |
|
if (stage != 0) // Not-First Stage takes from reg |
in = (piperegs[stage - step])._read; |
else if(inputQ.notEmpty) // take from queue at stage 0 |
begin |
in = Just(inputQ.first()); |
inputQ.deq(); |
end |
alpha s_in = fromMaybe(?,in); |
|
//do stage |
|
alpha s_out = repeatFN(step, sf, stage, s_in); |
|
//deal with outputs |
if (stage + step < numstages) // it's not the last stage |
(piperegs[stage]) <= isJust(in) ? Just(s_out): Nothing; |
else if(isValid(in)) // && stage == 2 |
outputQ.enq(s_out); |
else |
noAction; |
end |
endrule |
|
// The Interface |
method Action put(alpha x); |
inputQ.enq(x); |
endmethod |
|
method ActionValue#(alpha) get(); |
outputQ.deq(); |
return outputQ.first(); |
endmethod |
|
endmodule |
|
|
module mkPipeline_Comb#(Bit#(b) numstages, |
Bit#(b) step, |
function alpha sf(Bit#(b) s, alpha x)) |
(Pipeline#(alpha)) |
provisos |
(Bits#(alpha, asz)); |
|
// input queue |
FIFOF#(alpha) inputQ <- mkLFIFOF(); |
|
// output queue |
FIFO#(alpha) outputQ <- mkLFIFO(); |
|
rule compute(True); |
alpha stage_in, stage_out; |
|
stage_in = inputQ.first(); |
inputQ.deq(); |
|
for(Bit#(b) stage = 0; stage < numstages; stage = stage + step) |
begin |
//do stage |
stage_out = repeatFN(step, sf, stage, stage_in); |
|
//deal with outputs |
stage_in = stage_out; |
end |
|
outputQ.enq(stage_out); |
endrule |
|
// The Interface |
method Action put(alpha x); |
inputQ.enq(x); |
endmethod |
|
method ActionValue#(alpha) get(); |
outputQ.deq(); |
return outputQ.first(); |
endmethod |
|
endmodule |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/trunk/80211.pdf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
trunk/80211.pdf
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/LibraryFunctions.bsv
===================================================================
--- trunk/LibraryFunctions.bsv (nonexistent)
+++ trunk/LibraryFunctions.bsv (revision 2)
@@ -0,0 +1,88 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import Vector::*;
+
+function Bit#(1) getParity(Bit#(n) v) provisos(Add#(1, k, n));
+ function Bit#(1) _xor(Bit#(1) x, Bit#(1) y);
+ return (x ^ y);
+ endfunction
+
+ Vector#(n,Bit#(1)) vv = unpack(v);
+ Bit#(1) parity = Vector::fold(_xor, vv);
+ return(parity);
+endfunction
+
+function Bit#(n) reverseBits(Bit#(n) x);
+ Vector#(n, Bit#(1)) vx = unpack(x);
+ Vector#(n, Bit#(1)) rvx = Vector::reverse(vx);
+ Bit#(n) prvx = pack(rvx);
+ return(prvx);
+endfunction
+
+function Bit#(1) signBit(Bit#(n) x) provisos(Add#(1,k,n));
+ match {.signbit,.rest} = split(x);
+ return(signbit);
+endfunction
+
+function Vector#(sz, any_e) zipWith4(function any_e f(any_a a, any_b b, any_c c, any_d d),
+ Vector#(sz, any_a) va, Vector#(sz, any_b) vb,
+ Vector#(sz, any_c) vc, Vector#(sz, any_d) vd);
+
+ Vector#(sz, any_e) ve = replicate(?);
+
+ for(Integer i = 0; i < valueOf(sz); i = i + 1)
+ ve[i] = f(va[i],vb[i],vc[i],vd[i]);
+
+ return(ve);
+
+endfunction
+
+function Vector#(n, Bit#(m)) bitBreak(Bit#(nm) x) provisos(Mul#(n,m,nm));
+ return unpack(x);
+endfunction
+
+function Bit#(nm) bitMerge(Vector#(n, Bit#(m)) x) provisos(Mul#(n,m,nm));
+ return pack(x);
+endfunction
+
+function Vector#(n, alpha) v_truncate(Vector#(m, alpha) in) provisos(Add#(n,k,m));
+ Vector#(n, alpha) retval = newVector();
+ for(Integer i = valueOf(n) - 1, Integer j = valueOf(m) - 1; i >= 0; i = i - 1, j = j - 1)
+ begin
+ retval[i] = in[j];
+ end
+
+ return (retval);
+endfunction
+
+function Vector#(n, alpha) v_rtruncate(Vector#(m, alpha) in) provisos(Add#(n,k,m));
+ Vector#(n, alpha) retval = newVector();
+ for(Integer i = 0; i < valueOf(n); i = i + 1)
+ begin
+ retval[i] = in[i];
+ end
+ return (retval);
+endfunction
\ No newline at end of file
Index: trunk/DataTypes.bsv
===================================================================
--- trunk/DataTypes.bsv (nonexistent)
+++ trunk/DataTypes.bsv (revision 2)
@@ -0,0 +1,78 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import Vector::*;
+import ComplexF::*;
+
+typedef enum{// 1 = 6Mbits/s, 2 = 12Mbits/s, 4 = 24Mbits/s
+ RNone = 0,
+ R1 = 1,
+ R2 = 2,
+ R4 = 4
+}
+ Rate deriving(Eq,Bits);
+
+typedef Bit#(n) Header#(type n);
+
+
+
+
+// Data in the queues between the TX MAC and Controller
+typedef struct{
+ Rate rate;
+ Bit#(12) length; //in bytes
+}
+ TXMAC2ControllerInfo deriving (Eq, Bits);
+
+
+
+// Data in the queues between the TX MAC and Controller
+typedef struct{
+ Rate rate;
+ Bit#(12) length; //in bytes
+ Bit#(n) data;
+}
+ TXMAC2ControllerData#(type n) deriving (Eq, Bits);
+
+typedef struct{
+ Bit#(n) data;
+}
+ Data#(type n) deriving (Eq, Bits);
+
+typedef struct{
+ Rate rate;
+ Bit#(n) data;
+}
+ RateData#(type n) deriving (Eq, Bits);
+
+typedef struct{
+ Bool new_message;
+ Vector#(n,ComplexF#(16)) data;
+}
+MsgComplexFVec#(type n) deriving (Eq, Bits);
+
+typedef Vector#(64,ComplexF#(16)) IFFTData;
+typedef Vector#( 4,ComplexF#(16)) Radix4Data;
+typedef Vector#( 3,ComplexF#(16)) OmegaData;
\ No newline at end of file
Index: trunk/MFIFO.bsv
===================================================================
--- trunk/MFIFO.bsv (nonexistent)
+++ trunk/MFIFO.bsv (revision 2)
@@ -0,0 +1,57 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import FIFOF::*;
+
+interface MFIFO#(type alpha);
+ method Action enq(alpha x);
+ method Action deq();
+ method Maybe#(alpha) first();
+ method Action clear();
+endinterface
+
+module mkMFIFO(MFIFO#(alpha)) provisos(Bits#(alpha, asx));
+
+ FIFOF#(alpha) f <- mkUGFIFOF();
+
+ method Action enq(x) if(f.notFull);
+ f.enq(x);
+ endmethod
+
+ method Action deq();
+ if (f.notEmpty)
+ f.deq();
+ endmethod
+
+ method Maybe#(alpha) first();
+ return (f.notEmpty) ? Just(f.first()) : Nothing;
+ endmethod
+
+ method Action clear();
+ f.clear();
+ endmethod
+
+endmodule
+
Index: trunk/ConvEncoder.bsv
===================================================================
--- trunk/ConvEncoder.bsv (nonexistent)
+++ trunk/ConvEncoder.bsv (revision 2)
@@ -0,0 +1,161 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+// *************************************************************************
+// ConvEncoder.bsv
+// *************************************************************************
+import DataTypes::*;
+import Interfaces::*;
+
+import LibraryFunctions::*;
+import FIFO::*;
+
+(* synthesize *)
+module mkConvEncoder_24_48(ConvEncoder#(24, 48));
+ let _c <- mkConvEncoder();
+ return(_c);
+endmodule
+
+// n has to be 24 here
+module mkConvEncoder(ConvEncoder#(n, nn))
+ provisos
+ (Add#(n,n,nn),Add#(6,n,n6));
+
+ //-----------------------------------------
+ // State
+ //-----------------------------------------
+
+ // input queues
+ FIFO#(Header#(n)) headerQ <- mkLFIFO();
+ FIFO#(RateData#(n)) dataQ <- mkLFIFO();
+
+ // internal state
+ FIFO#(RateData#(n)) orderedQ <- mkLFIFO();
+ Reg#(Bool) getHeader <- mkReg(True);
+ Reg#(Bit#(5)) timeOut <- mkReg(24);
+ Reg#(Bit#(6)) histVal <- mkReg(0);
+
+ // output queue
+ FIFO#(RateData#(nn)) outputQ <- mkLFIFO();
+
+ //-----------------------------------------
+ // Rules
+ //-----------------------------------------
+
+ rule sort(True);
+
+ // look at heads of header and data input queues
+ Header#(n) header = headerQ.first();
+ RateData#(n) data = dataQ.first();
+
+ // if we've not started a header and the data rate is nonzero, enq a header
+ if(getHeader && data.rate != RNone)
+ begin
+ orderedQ.enq(RateData{
+ rate: R1,
+ data: header
+ });
+ headerQ.deq();
+ let ntimeOut = (timeOut - fromInteger(valueOf(n)));
+
+ timeOut <= (ntimeOut > 0) ? ntimeOut : 24; // reset
+
+ if (!(ntimeOut > 0))
+ getHeader <= False;
+ end
+ else // otherwise, enq a data
+ begin
+ if (data.rate != RNone) // newpacket
+ getHeader <= True;
+
+ dataQ.deq();
+ orderedQ.enq(data);
+ end
+ endrule
+
+ rule compute(True);
+
+ // get input out of input queues
+ Bit#(n) input_data = reverseBits((orderedQ.first).data);
+ Rate input_rate = (orderedQ.first).rate;
+ orderedQ.deq();
+
+ // if this is a new message, reset history
+
+ Bit#(n6) history;
+
+ if(input_rate == RNone) // new entry
+ history = {input_data, histVal};
+ else
+ history = {input_data, 6'b0};
+
+ // local variables
+ Bit#(nn) rev_output_data = 0;
+ Bit#(1) shared = 0;
+ Bit#(6) newHistVal = histVal;
+
+ // convolutionally encode data
+ for(Integer i = 0; i < valueOf(n); i = i + 1)
+ begin
+ shared = input_data[i] ^ history[i + 4] ^ history[i + 3] ^ history[i + 0];
+ rev_output_data[(2*i) + 0] = shared ^ history[i + 1];
+ rev_output_data[(2*i) + 1] = shared ^ history[i + 5];
+ newHistVal = {input_data[i], newHistVal[5:1]}; // only last update will be saved
+ end
+
+ // enqueue result
+ RateData#(nn) retval = RateData{
+ rate: input_rate,
+ data: reverseBits(rev_output_data)
+ };
+ outputQ.enq(retval);
+
+ // setup for next cycle
+ histVal <= newHistVal;
+ endrule
+
+
+ //-----------------------------------------
+ // Methods
+ //-----------------------------------------
+
+ // input from controller queue method
+ method Action encode_fromController(Header#(n) header);
+ headerQ.enq(header);
+ endmethod
+
+ // input from scrambler queue method
+ method Action encode_fromScrambler(RateData#(n) data);
+ dataQ.enq(data);
+ endmethod
+
+ // output to interleaver queue method
+ method ActionValue#(RateData#(nn)) getOutput();
+ outputQ.deq();
+ return(outputQ.first());
+ endmethod
+
+endmodule
+
Index: trunk/CyclicExtender.bsv
===================================================================
--- trunk/CyclicExtender.bsv (nonexistent)
+++ trunk/CyclicExtender.bsv (revision 2)
@@ -0,0 +1,57 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import ComplexF::*;
+import DataTypes::*;
+import Interfaces::*;
+import LibraryFunctions::*;
+
+
+import Vector::*;
+import FIFO::*;
+
+(* synthesize *)
+module mkCyclicExtender(CyclicExtender#(64,81));
+
+ FIFO#(MsgComplexFVec#(64)) fifoQ <- mkLFIFO();
+
+ method Action fromIFFT(MsgComplexFVec#(64) x);
+ fifoQ.enq(x);
+ endmethod
+
+ method ActionValue#(MsgComplexFVec#(81)) toAnalogTX();
+ fifoQ.deq();
+ Vector#(64, ComplexF#(16)) v = (fifoQ.first().data);
+ Vector#(1 , ComplexF#(16)) last = v_truncate(v);
+ Vector#(16, ComplexF#(16)) prefix = v_rtruncate(v);
+
+ return MsgComplexFVec{
+ new_message : True,
+ data : Vector::append(Vector::append(last,v),prefix)
+ };
+
+ endmethod
+
+endmodule
Index: trunk/Scrambler.bsv
===================================================================
--- trunk/Scrambler.bsv (nonexistent)
+++ trunk/Scrambler.bsv (revision 2)
@@ -0,0 +1,88 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+// *************************************************************************
+// Scrambler.bsv
+// *************************************************************************
+import DataTypes::*;
+import Interfaces::*;
+
+import LibraryFunctions::*;
+import FIFO::*;
+
+
+interface Scrambler#(type n);
+ //inputs
+ method Action fromControl(RateData#(n) x);
+
+ //outputs
+ method ActionValue#(RateData#(n)) toEncoder();
+endinterface
+
+(* synthesize *)
+module mkScrambler_48(Scrambler#(24));
+ let _s <- mkScrambler();
+ return (_s);
+endmodule
+
+module mkScrambler(Scrambler#(n));
+
+ Reg#(Bit#(7)) seqR <- mkRegU;
+ FIFO#(RateData#(n)) outQ <- mkFIFO();
+
+ method Action fromControl(RateData#(n) x);
+ Bit#(7) headSeq = case (x.rate)
+ R1 : return 7'b1001011;
+ R2 : return 7'b1001011;
+ R4 : return 7'b1001011;
+ RNone: return seqR;
+ endcase;
+
+ Bit#(7) scram_seq = headSeq;
+
+ Bit#(1) newS;
+ Bit#(n) inData = x.data;
+ Bit#(n) outData = 0;
+
+ for(Integer i = 0; i < valueOf(n); i = i + 1)
+ begin
+ newS = scram_seq[0] ^ scram_seq[3];
+ outData[i] = newS ^ inData[i];
+ scram_seq = {newS,scram_seq[6:1]};
+ end
+
+ outQ.enq(RateData{
+ rate: x.rate,
+ data: outData
+ });
+
+ endmethod
+
+ method ActionValue#(RateData#(n)) toEncoder();
+ outQ.deq();
+ return(outQ.first());
+ endmethod
+
+endmodule
Index: trunk/IFFT_Library.bsv
===================================================================
--- trunk/IFFT_Library.bsv (nonexistent)
+++ trunk/IFFT_Library.bsv (revision 2)
@@ -0,0 +1,424 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import ComplexF::*;
+import DataTypes::*;
+
+import LibraryFunctions::*;
+import Vector::*;
+
+
+//This function just serves as a short hand for grabbing 4 consecutive indices in
+//a vector
+function Vector#(4, a) take4(Vector#(n, a) sv, alpha idx)
+ provisos (Add#(4,k,n), Log#(n,logn),
+ Eq#(alpha), Literal#(alpha), Arith#(alpha), Ord#(alpha),
+ PrimIndex#(alpha, beta)
+ );
+ Vector#(4,a) retval = newVector();
+
+ for(alpha i = 0; i < 4; i = i + 1)
+ retval[i] = sv[idx+i];
+ return retval;
+endfunction
+
+
+// The Radix function. Note that it is noinlined, because
+// there's no point in doing a per-instance optimizations
+(* noinline *)
+function Radix4Data radix4(OmegaData omegas,
+ Radix4Data xs);
+
+ Radix4Data retval = newVector();
+
+ ComplexF#(16) alpha = xs[0];
+ ComplexF#(16) beta = omegas[0] * xs[1];
+ ComplexF#(16) gamma = omegas[1] * xs[2];
+ ComplexF#(16) delta = omegas[2] * xs[3];
+
+ ComplexF#(16) tao_0 = alpha + gamma;
+ ComplexF#(16) tao_1 = alpha - gamma;
+ ComplexF#(16) tao_2 = beta + delta;
+ ComplexF#(16) tao_3 = beta - delta;
+
+ // rotate tao_3 by 90 degrees
+ ComplexF#(16) tao_3_rot90;
+ tao_3_rot90.i = -tao_3.q;
+ tao_3_rot90.q = tao_3.i;
+
+ retval[0] = tao_0 + tao_2;
+ retval[1] = tao_1 - tao_3_rot90;
+ retval[2] = tao_0 - tao_2;
+ retval[3] = tao_1 + tao_3_rot90;
+
+ return retval;
+endfunction
+
+
+
+//This describes a permutation such that
+//If the ith value in this is j, then the
+//ith value of the output will be the jth
+// input value.
+
+// This permutation is used on the values directly into the IFFT
+
+function Vector#(64, Integer) reorder();
+ Vector#(64, Integer) retval = replicate(?);
+
+ retval[ 0] = 0;
+ retval[ 1] = 16;
+ retval[ 2] = 32;
+ retval[ 3] = 48;
+ retval[ 4] = 4;
+ retval[ 5] = 20;
+ retval[ 6] = 36;
+ retval[ 7] = 52;
+ retval[ 8] = 8;
+ retval[ 9] = 24;
+ retval[10] = 40;
+ retval[11] = 56;
+ retval[12] = 12;
+ retval[13] = 28;
+ retval[14] = 44;
+ retval[15] = 60;
+
+ retval[16] = 1;
+ retval[17] = 17;
+ retval[18] = 33;
+ retval[19] = 49;
+ retval[20] = 5;
+ retval[21] = 21;
+ retval[22] = 37;
+ retval[23] = 53;
+ retval[24] = 9;
+ retval[25] = 25;
+ retval[26] = 41;
+ retval[27] = 57;
+ retval[28] = 13;
+ retval[29] = 29;
+ retval[30] = 45;
+ retval[31] = 61;
+
+ retval[32] = 2;
+ retval[33] = 18;
+ retval[34] = 34;
+ retval[35] = 50;
+ retval[36] = 6;
+ retval[37] = 22;
+ retval[38] = 38;
+ retval[39] = 54;
+ retval[40] = 10;
+ retval[41] = 26;
+ retval[42] = 42;
+ retval[43] = 58;
+ retval[44] = 14;
+ retval[45] = 30;
+ retval[46] = 46;
+ retval[47] = 62;
+
+ retval[48] = 3;
+ retval[49] = 19;
+ retval[50] = 35;
+ retval[51] = 51;
+ retval[52] = 7;
+ retval[53] = 23;
+ retval[54] = 39;
+ retval[55] = 55;
+ retval[56] = 11;
+ retval[57] = 27;
+ retval[58] = 43;
+ retval[59] = 59;
+ retval[60] = 15;
+ retval[61] = 31;
+ retval[62] = 47;
+ retval[63] = 63;
+
+ return retval;
+endfunction
+
+// Similiar to the reorder ipermuation. However, this is used after each set of 16 radices
+function Vector#(64, Integer) permute();
+ Vector#(64, Integer) retval = replicate(?);
+
+ retval[ 0] = 0;
+ retval[ 1] = 4;
+ retval[ 2] = 8;
+ retval[ 3] = 12;
+ retval[ 4] = 16;
+ retval[ 5] = 20;
+ retval[ 6] = 24;
+ retval[ 7] = 28;
+ retval[ 8] = 32;
+ retval[ 9] = 36;
+ retval[10] = 40;
+ retval[11] = 44;
+ retval[12] = 48;
+ retval[13] = 52;
+ retval[14] = 56;
+ retval[15] = 60;
+
+ retval[16] = 1;
+ retval[17] = 5;
+ retval[18] = 9;
+ retval[19] = 13;
+ retval[20] = 17;
+ retval[21] = 21;
+ retval[22] = 25;
+ retval[23] = 29;
+ retval[24] = 33;
+ retval[25] = 37;
+ retval[26] = 41;
+ retval[27] = 45;
+ retval[28] = 49;
+ retval[29] = 53;
+ retval[30] = 57;
+ retval[31] = 61;
+
+ retval[32] = 2;
+ retval[33] = 6;
+ retval[34] = 10;
+ retval[35] = 14;
+ retval[36] = 18;
+ retval[37] = 22;
+ retval[38] = 26;
+ retval[39] = 30;
+ retval[40] = 34;
+ retval[41] = 38;
+ retval[42] = 42;
+ retval[43] = 46;
+ retval[44] = 50;
+ retval[45] = 54;
+ retval[46] = 58;
+ retval[47] = 62;
+
+ retval[48] = 3;
+ retval[49] = 7;
+ retval[50] = 11;
+ retval[51] = 15;
+ retval[52] = 19;
+ retval[53] = 23;
+ retval[54] = 27;
+ retval[55] = 31;
+ retval[56] = 35;
+ retval[57] = 39;
+ retval[58] = 43;
+ retval[59] = 47;
+ retval[60] = 51;
+ retval[61] = 55;
+ retval[62] = 59;
+ retval[63] = 63;
+
+ return retval;
+endfunction
+
+// Calculate the correct omegas. This gets sent into the
+// radix4 block
+function Vector#(3, ComplexF#(16)) omega(Bit#(2) stage, Bit#(4) index);
+
+ Vector#(3, ComplexF#(16)) retval = replicate(?);
+
+ case(stage)
+ // stage 1
+ 0:
+ begin
+ retval[0].i = 16'h7fff; retval[0].q = 16'h0000;
+ retval[1].i = 16'h7fff; retval[1].q = 16'h0000;
+ retval[2].i = 16'h7fff; retval[2].q = 16'h0000;
+ end
+ // stage 2
+ 1:
+ case(index >> 2)
+ 0: begin
+ retval[0].i = 16'h7fff; retval[0].q = 16'h0000;
+ retval[1].i = 16'h7fff; retval[1].q = 16'h0000;
+ retval[2].i = 16'h7fff; retval[2].q = 16'h0000;
+ end
+ 1: begin
+ retval[0].i = 16'h7640; retval[0].q = 16'hcf05;
+ retval[1].i = 16'h5a81; retval[1].q = 16'ha57f;
+ retval[2].i = 16'h30fb; retval[2].q = 16'h89c0;
+ end
+ 2: begin
+ retval[0].i = 16'h5a81; retval[0].q = 16'ha57f;
+ retval[1].i = 16'h0000; retval[1].q = 16'h8000;
+ retval[2].i = 16'ha57f; retval[2].q = 16'ha57f;
+ end
+ 3: begin
+ retval[0].i = 16'h30fb; retval[0].q = 16'h89c0;
+ retval[1].i = 16'ha57f; retval[1].q = 16'ha57f;
+ retval[2].i = 16'h89c0; retval[2].q = 16'h30fb;
+ end
+ endcase
+ // stage 3
+ 2:
+ case(index)
+ 0: begin
+ retval[0].i = 16'h7fff; retval[0].q = 16'h0000;
+ retval[1].i = 16'h7fff; retval[1].q = 16'h0000;
+ retval[2].i = 16'h7fff; retval[2].q = 16'h0000;
+ end
+ 1: begin
+ retval[0].i = 16'h7f61; retval[0].q = 16'hf375;
+ retval[1].i = 16'h7d89; retval[1].q = 16'he708;
+ retval[2].i = 16'h7a7c; retval[2].q = 16'hdad9;
+ end
+ 2: begin
+ retval[0].i = 16'h7d89; retval[0].q = 16'he708;
+ retval[1].i = 16'h7640; retval[1].q = 16'hcf05;
+ retval[2].i = 16'h6a6c; retval[2].q = 16'hb8e4;
+ end
+ 3: begin
+ retval[0].i = 16'h7a7c; retval[0].q = 16'hdad9;
+ retval[1].i = 16'h6a6c; retval[1].q = 16'hb8e4;
+ retval[2].i = 16'h5133; retval[2].q = 16'h9d0f;
+ end
+ 4: begin
+ retval[0].i = 16'h7640; retval[0].q = 16'hcf05;
+ retval[1].i = 16'h5a81; retval[1].q = 16'ha57f;
+ retval[2].i = 16'h30fb; retval[2].q = 16'h89c0;
+ end
+ 5: begin
+ retval[0].i = 16'h70e1; retval[0].q = 16'hc3aa;
+ retval[1].i = 16'h471c; retval[1].q = 16'h9594;
+ retval[2].i = 16'h0c8b; retval[2].q = 16'h809f;
+ end
+ 6: begin
+ retval[0].i = 16'h6a6c; retval[0].q = 16'hb8e4;
+ retval[1].i = 16'h30fb; retval[1].q = 16'h89c0;
+ retval[2].i = 16'he708; retval[2].q = 16'h8277;
+ end
+ 7: begin
+ retval[0].i = 16'h62f1; retval[0].q = 16'haecd;
+ retval[1].i = 16'h18f8; retval[1].q = 16'h8277;
+ retval[2].i = 16'hc3aa; retval[2].q = 16'h8f1f;
+ end
+ 8: begin
+ retval[0].i = 16'h5a81; retval[0].q = 16'ha57f;
+ retval[1].i = 16'h0000; retval[1].q = 16'h8000;
+ retval[2].i = 16'ha57f; retval[2].q = 16'ha57f;
+ end
+ 9: begin
+ retval[0].i = 16'h5133; retval[0].q = 16'h9d0f;
+ retval[1].i = 16'he708; retval[1].q = 16'h8277;
+ retval[2].i = 16'h8f1f; retval[2].q = 16'hc3aa;
+ end
+ 10: begin
+ retval[0].i = 16'h471c; retval[0].q = 16'h9594;
+ retval[1].i = 16'hcf05; retval[1].q = 16'h89c0;
+ retval[2].i = 16'h8277; retval[2].q = 16'he708;
+ end
+ 11: begin
+ retval[0].i = 16'h3c56; retval[0].q = 16'h8f1f;
+ retval[1].i = 16'hb8e4; retval[1].q = 16'h9594;
+ retval[2].i = 16'h809f; retval[2].q = 16'h0c8b;
+ end
+ 12: begin
+ retval[0].i = 16'h30fb; retval[0].q = 16'h89c0;
+ retval[1].i = 16'ha57f; retval[1].q = 16'ha57f;
+ retval[2].i = 16'h89c0; retval[2].q = 16'h30fb;
+ end
+ 13: begin
+ retval[0].i = 16'h2527; retval[0].q = 16'h8584;
+ retval[1].i = 16'h9594; retval[1].q = 16'hb8e4;
+ retval[2].i = 16'h9d0f; retval[2].q = 16'h5133;
+ end
+ 14: begin
+ retval[0].i = 16'h18f8; retval[0].q = 16'h8277;
+ retval[1].i = 16'h89c0; retval[1].q = 16'hcf05;
+ retval[2].i = 16'hb8e4; retval[2].q = 16'h6a6c;
+ end
+ 15: begin
+ retval[0].i = 16'h0c8b; retval[0].q = 16'h809f;
+ retval[1].i = 16'h8277; retval[1].q = 16'he708;
+ retval[2].i = 16'hdad9; retval[2].q = 16'h7a7c;
+ end
+ endcase
+ endcase
+
+ return retval;
+endfunction
+
+
+// This is the stage function which does the IFFT in 3 stages
+(* noinline *)
+function IFFTData stagefunction(Bit#(2) stage, IFFTData s_in);
+
+ IFFTData s_mid = newVector();
+ for(Integer i = 0; i < 16; i = i + 1)
+ begin
+ Nat four_i = fromInteger(4*i);
+ Radix4Data temp = radix4(omega(stage, fromInteger(i)),
+ take4(s_in, four_i));
+ for(Integer j = 0; j < 4; j = j + 1)
+ s_mid[4*i+j] = temp[j];
+ end
+
+ // permute
+ IFFTData s_out = newVector();
+ for(Integer i = 0; i < 64; i = i + 1)
+ s_out[i] = s_mid[permute[i]];
+
+ return (s_out);
+
+endfunction
+
+//These two functions are little hacks which prevent the compiler
+//from optimizing past these function boundaries.
+(* noinline *)
+function IFFTData stopOpt64(IFFTData s_in);
+ return s_in;
+endfunction
+
+function Vector#(4, ComplexF#(16)) stopOpt4(Vector#(4, ComplexF#(16)) s_in);
+ return s_in;
+endfunction
+
+// This is a stage function which does the IFFT in 48 stages, doing
+// 1 radix4 each stage and permuting the values every 16 cycles.
+
+(* noinline *)
+function IFFTData stagefunction2(Bit#(6) stage, IFFTData s_in);
+
+ IFFTData s_mid = stopOpt64(s_in);
+ Bit#(4) step = stage[3:0];
+ Bit#(6) step4 = {step,2'b00};
+
+ Radix4Data temp = radix4(omega(stage[5:4],step),
+ take4(s_in, step4));
+
+ for(Bit#(6) j = 0; j < 4; j = j + 1)
+ s_mid = update(s_mid, step4+j,temp[j]);
+
+ // permute
+ IFFTData s_mid2 = stopOpt64(s_mid);
+ IFFTData s_out = newVector();
+
+ for(Integer i = 0; i < 64; i = i + 1)
+ s_out[i] = s_mid2[permute[i]];
+
+ return ((step == 15) ? s_out : s_mid2);
+
+endfunction
Index: trunk/Transmitter.bsv
===================================================================
--- trunk/Transmitter.bsv (nonexistent)
+++ trunk/Transmitter.bsv (revision 2)
@@ -0,0 +1,152 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import ComplexF::*;
+import DataTypes::*;
+import Interfaces::*;
+import LibraryFunctions::*;
+import Vector::*;
+import FIFO::*;
+
+
+import Controller::*;
+import ConvEncoder::*;
+import CyclicExtender::*;
+import IFFT::*;
+import Interleaver::*;
+import LibraryFunctions::*;
+import Mapper::*;
+import Scrambler::*;
+
+
+(* synthesize *)
+module mkTransmitter_Pipe(Transmitter#(24,81));
+ let ifft <- mkIFFT_Pipe();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+(* synthesize *)
+module mkTransmitter_Comb(Transmitter#(24,81));
+ let ifft <- mkIFFT_Comb();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+(* synthesize *)
+module mkTransmitter_Circ(Transmitter#(24,81));
+ let ifft <- mkIFFT_Circ();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+(* synthesize *)
+module mkTransmitter_1Radix(Transmitter#(24,81));
+ let ifft <- mkIFFT_Circ_w_1Radix();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+(* synthesize *)
+module mkTransmitter_2Radix(Transmitter#(24,81));
+ let ifft <- mkIFFT_Circ_w_2Radix();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+
+(* synthesize *)
+module mkTransmitter_4Radix(Transmitter#(24,81));
+ let ifft <- mkIFFT_Circ_w_4Radix();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+(* synthesize *)
+module mkTransmitter_8Radix(Transmitter#(24,81));
+ let ifft <- mkIFFT_Circ_w_8Radix();
+ let _x <- mkTransmitter(ifft);
+ return _x;
+endmodule
+
+module [Module] mkTransmitter#(IFFT#(64) ifft)(Transmitter#(24,81));
+
+ function Action stitch(ActionValue#(a) x, function Action f(a v));
+ action
+ let v <- x;
+ f(v);
+ endaction
+ endfunction
+
+ let controller <- mkController();
+ let scrambler <- mkScrambler_48();
+ let conv_encoder <- mkConvEncoder_24_48();
+ let interleaver <- mkInterleaver();
+ let mapper <- mkMapper_48_64();
+ // let ifft <- mkIFFT();
+ let cyc_extender <- mkCyclicExtender();
+
+ rule controller2scrambler(True);
+ stitch(controller.getData, scrambler.fromControl);
+ endrule
+
+ rule controller2conv_encoder(True);
+ stitch(controller.getHeader,conv_encoder.encode_fromController);
+ endrule
+
+ rule scrambler2conv_encoder(True);
+ stitch(scrambler.toEncoder, conv_encoder.encode_fromScrambler);
+ endrule
+
+ rule conv_encoder2interleaver(True);
+ stitch(conv_encoder.getOutput, interleaver.fromEncoder);
+ endrule
+
+ rule interleaver2mapper(True);
+ stitch(interleaver.toMapper, mapper.fromInterleaver);
+ endrule
+
+ rule mapper2ifft(True);
+ stitch(mapper.toIFFT, ifft.fromMapper);
+ endrule
+
+ rule ifft2cyclicExtender(True);
+ stitch(ifft.toCyclicExtender, cyc_extender.fromIFFT);
+ endrule
+
+ method ActionValue#(MsgComplexFVec#(81)) toAnalogTX() if(True);
+ let x <- cyc_extender.toAnalogTX();
+ return(x);
+ endmethod
+
+ method Action getFromMAC(TXMAC2ControllerInfo x);
+ controller.getFromMAC(x);
+ endmethod
+
+ method Action getDataFromMAC(Data#(24) x);
+ controller.getDataFromMAC(x);
+ endmethod
+
+endmodule
\ No newline at end of file
Index: trunk/ComplexF.bsv
===================================================================
--- trunk/ComplexF.bsv (nonexistent)
+++ trunk/ComplexF.bsv (revision 2)
@@ -0,0 +1,156 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+typedef struct{
+ Bit#(n) i;
+ Bit#(n) q;
+}
+ ComplexF#(numeric type n) deriving(Eq, Bits);
+
+
+function Int#(n) toInt(Bit#(n) x)= unpack(x);
+function Bit#(n) toBit(Int#(n) x)= pack(x);
+
+instance Literal#(ComplexF#(n));
+ function ComplexF#(n) fromInteger(Integer x);
+ return error("Can't use Literal");
+ endfunction
+endinstance
+
+
+instance Bounded#(ComplexF#(n));
+ function ComplexF#(n) minBound();
+ Int#(n) mb = minBound;
+ return ComplexF{i: pack(mb),q: pack(mb)};
+ endfunction
+ function ComplexF#(n) maxBound();
+ Int#(n) mb = maxBound;
+ return ComplexF{i: pack(mb),q: pack(mb)};
+ endfunction
+endinstance
+
+instance BitExtend#(n,m, ComplexF) provisos(Add#(k,n,m));
+ function ComplexF#(m) zeroExtend(ComplexF#(n) x);
+ return ComplexF{
+ i: zeroExtend(x.i),
+ q: zeroExtend(x.q)
+ };
+ endfunction
+ function ComplexF#(m) signExtend(ComplexF#(n) x);
+ return ComplexF{
+ i: signExtend(x.i),
+ q: signExtend(x.q)
+ };
+ endfunction
+ function ComplexF#(n) truncate(ComplexF#(m) x);
+ Nat rmax = fromInteger(valueOf(m) -1);
+ Nat rmin = fromInteger(valueOf(m) - valueOf(n));
+ return ComplexF{
+ i: x.i[rmax:rmin],
+ q: x.q[rmax:rmin]
+ };
+ endfunction
+endinstance
+
+function Bit#(n) complex_add(Bit#(n) x, Bit#(n) y) provisos(Add#(1,k,n), Add#(1,n, TAdd#(1,n)));
+ Nat si = fromInteger(valueOf(n) - 1);
+ Nat si_p_1 = fromInteger(valueOf(n));
+ Bit#(1) sx = pack(x)[si];
+ Bit#(1) sy = pack(y)[si];
+ Int#(TAdd#(1,n)) ix = unpack({sx,x});
+ Int#(TAdd#(1,n)) iy = unpack({sy,y});
+ Int#(TAdd#(1,n)) ir = ix + iy + 1;
+ Bit#(n) res = (pack(ir))[si_p_1:1];
+return res;
+endfunction
+
+function Bit#(n) complex_sub(Bit#(n) x, Bit#(n) y) provisos(Add#(1,k,n), Add#(1,n, TAdd#(1,n)));
+ Nat si = fromInteger(valueOf(n) - 1);
+ Nat si_p_1 = fromInteger(valueOf(n));
+ Bit#(1) sx = pack(x)[si];
+ Bit#(1) sy = pack(y)[si];
+ Int#(TAdd#(1,n)) ix = unpack({sx,x});
+ Int#(TAdd#(1,n)) iy = unpack({sy,y});
+ Int#(TAdd#(1,n)) ir = ix - iy + 1;
+ Bit#(n) res = (pack(ir))[si_p_1:1];
+ return res;
+endfunction
+
+
+function Bit#(n) complex_mult(Bit#(n) x, Bit#(n) y) provisos(Add#(k,n,TAdd#(n,n)));
+ Nat si = fromInteger(valueOf(n) - 1) ;
+ Nat si2 = fromInteger(2*(valueOf(n) - 1));
+ Nat si_1 = fromInteger(valueOf(n) - 2); // 14 for 16
+ Bit#(TAdd#(n,n)) half = 1 << (si_1);
+
+ Int#(TAdd#(n,n)) ix = unpack(signExtend(x));
+ Int#(TAdd#(n,n)) iy = unpack(signExtend(y));
+
+ Bit#(TAdd#(n,n)) t1 = pack(ix*iy);
+ Bit#(TAdd#(n,n)) t2 = t1 + half;
+ Bit#(n) t3 = t2[si2:si];
+ Int#(n) it3 = unpack(t3);
+ Bit#(n) res = pack((it3 == minBound) ? maxBound : it3);
+
+ return res;
+endfunction
+
+
+instance Arith#(ComplexF#(n)) provisos(Add#(1,k,n), Add#(k2,n,TAdd#(n,n)), Add#(1,n,TAdd#(1,n)));
+
+ function ComplexF#(n) \+ (ComplexF#(n) x, ComplexF#(n) y);
+ return ComplexF{
+ i: complex_add(x.i, y.i),
+ q: complex_add(x.q, y.q)
+ };
+ endfunction
+
+ function ComplexF#(n) \- (ComplexF#(n) x, ComplexF#(n) y);
+ return ComplexF{
+ i: complex_sub(x.i, y.i),
+ q: complex_sub(x.q, y.q)
+ };
+ endfunction
+
+ function ComplexF#(n) \* (ComplexF#(n) x, ComplexF#(n) y) provisos(Add#(k2,n,TAdd#(n,n)));
+ Bit#(n) ii = complex_mult(x.i, y.i);
+ Bit#(n) qq = complex_mult(x.q, y.q);
+ Bit#(n) iq = complex_mult(x.i, y.q);
+ Bit#(n) qi = complex_mult(x.q, y.i);
+
+ return ComplexF{
+ i: complex_add(ii, qq),
+ q: complex_sub(qi, iq)
+ };
+ endfunction
+
+ function ComplexF#(n) negate (ComplexF#(n) x);
+ return ComplexF{
+ i: negate(x.i),
+ q: negate(x.q)
+ };
+ endfunction
+
+endinstance
Index: trunk/Interleaver.bsv
===================================================================
--- trunk/Interleaver.bsv (nonexistent)
+++ trunk/Interleaver.bsv (revision 2)
@@ -0,0 +1,134 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+// *************************************************************************
+// Scrambler.bsv
+// *************************************************************************
+import DataTypes::*;
+import Interfaces::*;
+
+import LibraryFunctions::*;
+import FIFO::*;
+import RWire::*;
+import Vector::*;
+
+interface Interleaver#(type n, type m );
+ //inputs
+ method Action fromEncoder(RateData#(n) txSVec);
+
+ //outputs
+ method ActionValue#(RateData#(m)) toMapper();
+endinterface
+
+(* synthesize *)
+module mkInterleaver(Interleaver#(48, 48));
+
+ Reg#(Bit#(2)) outCnt <- mkReg(0);
+ FIFO#(Tuple2#(Rate, Bit#(192))) buff <- mkFIFO();
+
+ match {.buff_rate, .buff_data} = buff.first();
+
+ Reg#(Rate) cur_rate <- mkReg(RNone);
+ Reg#(Bit#(2)) inCnt <- mkReg(0);
+ Reg#(Bit#(192)) mapR <- mkReg(0);
+
+ method Action fromEncoder(RateData#(48) i);
+ //calc new value
+ Rate this_rate = (i.rate == RNone) ? cur_rate : i.rate;
+ Bit#(48) in = i.data;
+
+ cur_rate <= this_rate;
+
+ function Bit#(48) f1(Bit#(48) x);
+ Vector#(16, Bit#(1)) va = bitBreak(x[47:32]),
+ vb = bitBreak(x[31:16]),
+ vc = bitBreak(x[15: 0]);
+ function merge(a,b,c) = {a,b,c};
+
+ let data_out = bitMerge(zipWith3(merge,va,vb,vc));
+
+ return data_out;
+ endfunction
+
+ function Bit#(96) f2(Bit#(48) x, Bit#(48) y);
+ Vector#(16, Bit#(3)) va = bitBreak(y),
+ vb = bitBreak(f1(x));
+
+ function merge(a,b) = {a,b};
+
+ let data_out = bitMerge(zipWith(merge,va,vb));
+
+ return {data_out,0};
+ endfunction
+
+ function Bit#(192) switchBits(Bit#(192) x);
+ Vector#(8 , Bit#(24)) va = bitBreak(x);
+
+ function Bit#(24) swap(Bit#(24) b) = {b[23:10],b[8],b[9],b[7:4],b[2],b[3],b[1:0]};
+
+ let out = bitMerge(map(swap,va));
+
+ return out;
+ endfunction
+
+ Bit#(192) new_mapR =
+ case (inCnt)
+ 0 : return {?,f1(in)};
+ 1 : return {f2(in,mapR[47:0]),?};
+ 2 : return {mapR[191:96],?,f1(in)};
+ 3 : return switchBits({mapR[191:96],f2(in, mapR[47:0])});
+ endcase;
+
+ Bit#(2) new_inCnt = pack(tuple2(cur_rate == R4, cur_rate != R1)) & (inCnt + 1);
+ inCnt <= new_inCnt;
+
+ if (new_inCnt == 2'b00) // we're done
+ buff.enq(tuple2(cur_rate,new_mapR));
+ else //store
+ mapR <= new_mapR;
+
+ endmethod
+
+ method ActionValue#(RateData#(48)) toMapper();
+ Bit#(48) res = case (outCnt)
+ 2'b00: return buff_data[191:144];
+ 2'b01: return buff_data[143:96];
+ 2'b10: return buff_data[95:48];
+ 2'b11: return buff_data[47:0];
+ endcase;
+ Bit#(2) new_outCnt = pack(tuple2(buff_rate == R4, buff_rate != R1)) & (outCnt + 1);
+ outCnt <= new_outCnt;
+
+ if(new_outCnt == 2'b00)
+ buff.deq();
+
+ return RateData{
+ rate: buff_rate,
+ data: res
+ };
+ endmethod
+
+
+endmodule
\ No newline at end of file
Index: trunk/Controller.bsv
===================================================================
--- trunk/Controller.bsv (nonexistent)
+++ trunk/Controller.bsv (revision 2)
@@ -0,0 +1,87 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import FIFO::*;
+import DataTypes::*;
+import Interfaces::*;
+import LibraryFunctions::*;
+
+function Header#(24) makeHeader(Rate rate, Bit#(12) length);
+ function Bit#(4) translate_rate(Rate r);
+ case (r)
+ R1: return 4'b1101;
+ R2: return 4'b1111;
+ R4: return 4'b0101;
+ default: return ?;
+ endcase
+ endfunction
+
+ function Bit#(12) translate_length (Bit#(12) x) = reverseBits(x);
+
+ Bit#(1) parity = getParity({translate_rate(rate),length});
+
+ return({translate_rate(rate),1'b0,translate_length(length),parity,6'b0});
+
+endfunction
+
+
+(* synthesize *)
+module mkController(Controller#(24,24,24));
+ FIFO#(RateData#(24)) toS <- mkFIFO();
+ FIFO#(Header#(24)) toC <- mkFIFO();
+
+ Reg#(Bool) active <- mkReg(False);
+ Reg#(Bit#(12)) length <- mkRegU;
+ Reg#(Rate) rate <- mkRegU;
+
+ method Action getFromMAC(TXMAC2ControllerInfo x) if (!active);
+ active <= True;
+ length <= x.length();
+ rate <= x.rate();
+ toC.enq( makeHeader(x.rate, x.length));
+ endmethod
+
+ method Action getDataFromMAC(Data#(24) x) if (active);
+ toS.enq(RateData{
+ rate: rate,
+ data: x.data
+ });
+ rate <= RNone;
+ length <= length - 3;
+ if (length <= 3 )
+ active <= False;
+ endmethod
+
+ method ActionValue#(Header#(24)) getHeader();
+ toC.deq();
+ return(toC.first);
+ endmethod
+
+ method ActionValue#(RateData#(24)) getData();
+ toS.deq();
+ return(toS.first);
+ endmethod
+
+endmodule
Index: trunk/Interfaces.bsv
===================================================================
--- trunk/Interfaces.bsv (nonexistent)
+++ trunk/Interfaces.bsv (revision 2)
@@ -0,0 +1,93 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+import DataTypes::*;
+
+interface ConvEncoder#(type n, type m);
+ //inputs
+ method Action encode_fromController(Header#(n) fc);
+ method Action encode_fromScrambler (RateData#(n) fs);
+
+ //outputs
+ method ActionValue#(RateData#(m)) getOutput();
+endinterface
+
+interface Scrambler#(type n);
+ //inputs
+ method Action fromControl(RateData#(n) x);
+
+ //outputs
+ method ActionValue#(RateData#(n)) toEncoder();
+endinterface
+
+interface Interleaver#(type n, type m );
+ //inputs
+ method Action fromEncoder(RateData#(n) txVec);
+
+ //outputs
+ method ActionValue#(RateData#(m)) toMapper();
+endinterface
+
+interface Mapper#(type n, type m);
+ //inputs
+ method Action fromInterleaver(RateData#(n) txVec);
+
+ //outputs
+ method ActionValue#(MsgComplexFVec#(m)) toIFFT();
+endinterface
+
+interface IFFT#(type n);
+ //inputs
+ method Action fromMapper(MsgComplexFVec#(n) x);
+
+ //outputs
+ method ActionValue#(MsgComplexFVec#(n)) toCyclicExtender();
+endinterface
+
+interface CyclicExtender#(type n, type m);
+ //inputs
+ method Action fromIFFT(MsgComplexFVec#(n) x);
+
+ //outputs
+ method ActionValue#(MsgComplexFVec#(m)) toAnalogTX();
+endinterface
+
+interface Controller#(type inN, type hdrN, type dataN);
+ //inputs
+ method Action getFromMAC(TXMAC2ControllerInfo x);
+ method Action getDataFromMAC(Data#(inN) x);
+
+ //outputs
+
+ method ActionValue#(Header#(hdrN)) getHeader();
+ method ActionValue#(RateData#(dataN)) getData();
+endinterface
+
+interface Transmitter#(type inN, type out);
+ method Action getFromMAC(TXMAC2ControllerInfo x);
+ method Action getDataFromMAC(Data#(inN) x);
+
+ method ActionValue#(MsgComplexFVec#(out)) toAnalogTX();
+endinterface
Index: trunk/Mapper.bsv
===================================================================
--- trunk/Mapper.bsv (nonexistent)
+++ trunk/Mapper.bsv (revision 2)
@@ -0,0 +1,282 @@
+// The MIT License
+//
+// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+
+
+// *************************************************************************
+// Mapper.bsv
+// *************************************************************************
+import ComplexF::*;
+import DataTypes::*;
+import Interfaces::*;
+
+import LibraryFunctions::*;
+import FIFO::*;
+import RWire::*;
+import Vector::*;
+
+function ComplexF#(16) r1_getMappedValue(Bit#(1) b0);
+ return (ComplexF{
+ i : (b0 == 1) ? 16'h7FFF : 16'h8000,
+ q : 0
+ });
+endfunction
+
+function ComplexF#(16) r2_getMappedValue(Bit#(2) b0);
+ return (ComplexF{
+ i : (b0[1] == 1) ? 16'h5A82 : 16'hA57E,
+ q : (b0[0] == 1) ? 16'h5A82 : 16'hA57E
+ });
+endfunction
+
+function ComplexF#(16) r4_getMappedValue(Bit#(4) b0);
+ function f(x);
+ case (x)
+ 2'b00: return(16'h8692);
+ 2'b01: return(16'hD786);
+ 2'b10: return(16'h796E);
+ 2'b11: return(16'h287A);
+ endcase
+ endfunction
+
+ return (ComplexF{
+ i : f(b0[3:2]),
+ q : f(b0[1:0])
+ });
+endfunction
+
+
+function Vector#(64, ComplexF#(16)) expandCFs(Bit#(1) ppv, Vector#(48, ComplexF#(16)) x);
+ ComplexF#(16) zero = ComplexF{i: 0, q: 0};
+
+ Integer i =0, j = 0;
+ Vector#(64, ComplexF#(16)) syms = Vector::replicate(zero);
+
+ //six zeros
+ i = i + 6;
+
+ for(i = 6; i < 11; i = i + 1, j = j + 1) // [6:10] = 5
+ syms[i] = x[j];
+
+ //pilot
+ syms[i] = r1_getMappedValue(ppv); // [11] = 1
+ i = i + 1;
+
+ for(i = 12; i < 25; i = i + 1, j = j + 1) // [12:24] = 13
+ syms[i] = x[j];
+
+ //pilot
+ syms[i] = r1_getMappedValue(ppv); // [25] = 1
+ i = i + 1;
+
+ for(i = 26; i < 32 ; i = i + 1, j = j + 1) // [26:31] = 6
+ syms[i] = x[j];
+
+ // pilot 0 // [32] = 1
+ i = i + 1;
+
+ for(i = 33; i < 39 ; i = i + 1, j = j + 1) // [33:38] = 6
+ syms[i] = x[j];
+
+ //pilot 7
+ syms[i] = r1_getMappedValue(ppv); // [39] = 1
+ i = i + 1;
+
+ for(i = 40; i < 53 ; i = i + 1, j = j + 1) // [40:52] = 13
+ syms[i] = x[j];
+
+ //pilot 21 NOTICE reversed value
+ syms[i] = r1_getMappedValue(~ppv); // [53] = 1
+ i = i + 1;
+
+ for(i = 54; i < 59 ; i = i + 1, j = j + 1) // [54:58] = 5
+ syms[i] = x[j];
+
+
+ return syms; // YYY: ndave this may need to be reversed
+endfunction
+
+(* synthesize *)
+module mkMapper_48_64(Mapper#(48, 64));
+
+ Bit#(127) ppv_init = truncate(128'hF10D36FDD9D149f32b184bd505AE4700 >> 1); // shift needed for alignment
+ Reg#(Bit#(127)) pilotPolarityVector <- mkReg(ppv_init); // NOTE that 0s represet -1.
+
+ Reg#(Rate) cur_rate <- mkReg(RNone);
+ Reg#(Bit#(2)) inM_cnt <- mkReg(0);
+
+ Reg#(Vector#(48,ComplexF#(16))) curM <- mkRegU();
+ FIFO#(MsgComplexFVec#(64)) outQ <- mkFIFO();
+
+
+ method Action fromInterleaver(RateData#(48) i);
+ Rate rate = (i.rate == RNone) ? cur_rate : i.rate;
+
+ //update placement regs
+ cur_rate <= rate;
+ Bit#(2) new_inM_cnt = pack(tuple2(rate == R4, rate != R1)) & (inM_cnt + 1);
+ inM_cnt <= new_inM_cnt;
+
+ Vector#(48,ComplexF#(16)) cfs = newVector();
+
+ //generate values
+ case (rate)
+ R1:
+ begin
+ Vector#(48, Bit#(1)) va = bitBreak(i.data);
+ cfs = Vector::map(r1_getMappedValue, va);
+ end
+ R2:
+ begin
+ Vector#(24, Bit#(2)) va = bitBreak(i.data);
+ Vector#(24 ,ComplexF#(16)) cs = Vector::map(r2_getMappedValue, va);
+ cfs = v_truncate(Vector::append(curM, cs));
+ end
+ R4:
+ begin
+ Vector#(12, Bit#(4)) va = bitBreak(i.data);
+ Vector#(12 ,ComplexF#(16)) cs = Vector::map(r4_getMappedValue, va);
+ cfs = v_truncate(Vector::append(curM, cs));
+ end
+ endcase
+
+ if (new_inM_cnt == 2'b00)
+ begin
+ MsgComplexFVec#(64) p = MsgComplexFVec{
+ new_message: True,
+ data: expandCFs(pilotPolarityVector[126], cfs)
+ };
+ outQ.enq(p);
+ //rotate ppvs
+ pilotPolarityVector <= {pilotPolarityVector[125:0], pilotPolarityVector[126]};
+ end
+
+
+
+ endmethod
+
+ method ActionValue#(MsgComplexFVec#(64)) toIFFT();
+ outQ.deq();
+ return (outQ.first());
+ endmethod
+
+endmodule
+
+
+
+
+
+
+(* synthesize *)
+module mkMapper_48_16(Mapper#(48, 16));
+
+ Bit#(127) ppv_init = truncate(128'hF10D36FDD9D149f32b184bd505AE4700 >> 1); // shift needed for alignment
+ Reg#(Bit#(127)) pilotPolarityVector <- mkReg(ppv_init); // NOTE that 0s represet -1.
+
+ Reg#(Rate) cur_rate <- mkReg(RNone);
+ Reg#(Bit#(2)) inM_cnt <- mkReg(0);
+
+ Reg#(Vector#(48, ComplexF#(16))) curM <- mkRegU();
+ FIFO#(Vector#(64, ComplexF#(16))) outQ <- mkFIFO();
+ Reg#(Bit#(2)) outM_cnt <- mkReg(0);
+
+ method Action fromInterleaver(RateData#(48) i);
+ Rate rate = (i.rate == RNone) ? cur_rate : i.rate;
+
+ //update placement regs
+ cur_rate <= rate;
+ Bit#(2) new_inM_cnt = pack(tuple2(rate == R4, rate != R1)) & (inM_cnt + 1);
+ inM_cnt <= new_inM_cnt;
+
+ Vector#(48,ComplexF#(16)) cfs = newVector();
+
+ //generate values
+ case (rate)
+ R1:
+ begin
+ Vector#(48, Bit#(1)) va = bitBreak(i.data);
+ cfs = Vector::map(r1_getMappedValue, va);
+ end
+ R2:
+ begin
+ Vector#(24, Bit#(2)) va = bitBreak(i.data);
+ Vector#(24 ,ComplexF#(16)) cs = Vector::map(r2_getMappedValue, va);
+ cfs = v_truncate(Vector::append(curM, cs));
+ end
+ R4:
+ begin
+ Vector#(12, Bit#(4)) va = bitBreak(i.data);
+ Vector#(12 ,ComplexF#(16)) cs = Vector::map(r4_getMappedValue, va);
+ cfs = v_truncate(Vector::append(curM, cs));
+ end
+ endcase
+
+ if (new_inM_cnt == 2'b00)
+ begin
+ Vector#(64, ComplexF#(16)) p = expandCFs(pilotPolarityVector[126], cfs);
+ outQ.enq(p);
+ //rotate ppvs
+ pilotPolarityVector <= {pilotPolarityVector[125:0], pilotPolarityVector[126]};
+ end
+
+ endmethod
+
+ method ActionValue#(MsgComplexFVec#(16)) toIFFT();
+ outM_cnt <= outM_cnt + 1;
+
+ Vector#(48, ComplexF#(16)) t1 = v_truncate(outQ.first);
+ Vector#(32, ComplexF#(16)) t2 = v_truncate(outQ.first);
+
+ Vector#(16, ComplexF#(16)) v1 = v_rtruncate(outQ.first);
+ Vector#(16, ComplexF#(16)) v2 = v_rtruncate(t1);
+ Vector#(16, ComplexF#(16)) v3 = v_rtruncate(t2);
+ Vector#(16, ComplexF#(16)) v4 = v_truncate(t2);
+
+ let r = case (outM_cnt)
+ 2'b00: return v1;
+ 2'b01: return v2;
+ 2'b10: return v3;
+ 2'b11: return v4;
+ endcase;
+
+ outQ.deq();
+ return (MsgComplexFVec{
+ new_message: (outM_cnt == 2'b00),
+ data: r
+ });
+ endmethod
+
+
+endmodule
+
+
+
+
+
+
+
+
+
+
+
+