📄 parameters.bsv
字号:
//----------------------------------------------------------------------//// The MIT License // // Copyright (c) 2007 Alfred Man Cheuk Ng, mcn02@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.//----------------------------------------------------------------------//// WiMAX 802.16 Parametersimport Controls::*;import Vector::*;import FPComplex::*;import LibraryFunctions::*;import Complex::*;import DataTypes::*;import Interfaces::*;import ConvEncoder::*;import Puncturer::*;import GetPut::*;import Connectable::*;import ReedEncoder::*;// Global Parameters:typedef enum { R0, // BPSK 1/2 R1, // QPSK 1/2 R2, // QPSK 3/4 R3, // 16-QAM 1/2 R4, // 16-QAM 3/4 R5, // 64-QAM 2/3 R6 // 64-QAM 3/4} Rate deriving(Eq, Bits);// may be an extra field for DL: sendPremabletypedef struct { Bool firstSymbol; Rate rate; CPSizeCtrl cpSize;} TXGlobalCtrl deriving(Eq, Bits);typedef 2 TXFPIPrec; // fixedpoint integer precisiontypedef 14 TXFPFPrec; // fixedpoint fractional precisiontypedef 2 RXFPIPrec; // rx fixedpoint integer precisiontypedef 14 RXFPFPrec; // rx fixedpoint fractional precisiontypedef TXGlobalCtrl RXGlobalCtrl; // same as tx// Local Parameters:// Scrambler:typedef 8 ScramblerDataSz; typedef 15 ScramblerShifterSz;Bit#(ScramblerShifterSz) scramblerGenPoly = 'b110000000000000;typedef ScramblerCtrl#(ScramblerDataSz,ScramblerShifterSz) TXScramblerCtrl;typedef struct { TXScramblerCtrl scramblerCtrl; TXGlobalCtrl globalCtrl;} TXScramblerAndGlobalCtrl deriving(Eq, Bits); function TXScramblerCtrl scramblerMapCtrl(TXScramblerAndGlobalCtrl ctrl); return ctrl.scramblerCtrl;endfunctionfunction TXGlobalCtrl scramblerConvertCtrl(TXScramblerAndGlobalCtrl ctrl); return ctrl.globalCtrl;endfunction//Reed Solomon Encoder:typedef 8 ReedEncoderDataSz;function ReedSolomonCtrl#(8) reedEncoderMapCtrl(TXGlobalCtrl ctrl); return case (ctrl.rate) matches R0 : ReedSolomonCtrl{in:12, out:0}; R1 : ReedSolomonCtrl{in:24, out:8}; R2 : ReedSolomonCtrl{in:36, out:4}; R3 : ReedSolomonCtrl{in:48, out:16}; R4 : ReedSolomonCtrl{in:72, out:8}; R5 : ReedSolomonCtrl{in:96, out:12}; R6 : ReedSolomonCtrl{in:108, out:12}; endcase;endfunction// Conv. Encoder:typedef 8 ConvEncoderInDataSz;typedef TMul#(2,ConvEncoderInDataSz) ConvEncoderOutDataSz;typedef 7 ConvEncoderHistSz;Bit#(ConvEncoderHistSz) convEncoderG1 = 'b1111001;Bit#(ConvEncoderHistSz) convEncoderG2 = 'b1011011;// Puncturer:typedef ConvEncoderOutDataSz PuncturerInDataSz;typedef 24 PuncturerOutDataSz;// typedef TMul#(2,PuncturerInDataSz) PuncturerInBufSz; // to be safe 2x inDataSz// typedef TMul#(2,PuncturerOutDataSz) PuncturerOutBufSz; // to be safe 2x outDataSz // typedef TDiv#(PuncturerInDataSz,4) PuncturerF1Sz; // no. of 2/3 in parallel// typedef TDiv#(PuncturerInDataSz,6) PuncturerF2Sz; // no. of 3/4 in parallel// typedef TDiv#(PuncturerInDataSz,10) PuncturerF3Sz; // no. of 5/6 in paralleltypedef TAdd#(PuncturerInDataSz,10) PuncturerInBufSz; // to be safe 2x inDataSztypedef TAdd#(PuncturerInBufSz,PuncturerOutDataSz) PuncturerOutBufSz; // to be safe 2x outDataSz typedef 1 PuncturerF1Sz; // no. of 2/3 in paralleltypedef 1 PuncturerF2Sz; // no. of 3/4 in paralleltypedef 1 PuncturerF3Sz; // no. of 5/6 in parallelfunction Bit#(3) puncturerF1 (Bit#(4) x); return {x[3:3],x[1:0]};endfunction // Bit function Bit#(4) puncturerF2 (Bit#(6) x); return {x[4:3],x[1:0]};endfunction // Bit// not used in WiFi function Bit#(6) puncturerF3 (Bit#(10) x); return {x[8:7],x[4:3],x[1:0]};endfunction // Bitfunction PuncturerCtrl puncturerMapCtrl(TXGlobalCtrl ctrl); return case (ctrl.rate) R0: Half; R1: TwoThird; R2: FiveSixth; R3: TwoThird; R4: FiveSixth; R5: ThreeFourth; R6: FiveSixth; endcase; // case(rate)endfunction // Bit // Encoder: (Construct from ConvEncoder & Puncturer for wifi)typedef ReedEncoderDataSz EncoderInDataSz;typedef PuncturerOutDataSz EncoderOutDataSz;// Interleaver:typedef PuncturerOutDataSz InterleaverDataSz;typedef 192 MinNcbps;// used for both interleaver, mapperfunction Modulation modulationMapCtrl(TXGlobalCtrl ctrl); return case (ctrl.rate) R0: BPSK; R1: QPSK; R2: QPSK; R3: QAM_16; R4: QAM_16; R5: QAM_64; R6: QAM_64; endcase;endfunctionfunction Integer interleaverGetIdx(Modulation m, Integer k); Integer s = 1; Integer ncbps = valueOf(MinNcbps); case (m) BPSK: begin ncbps = ncbps; s = 1; end QPSK: begin ncbps = 2*ncbps; s = 1; end QAM_16: begin ncbps = 4*ncbps; s = 2; end QAM_64: begin ncbps = 6*ncbps; s = 3; end endcase // case(m) Integer i = (ncbps/12) * (k%12) + k/12; Integer f= (i/s); Integer j = s*f + (i + ncbps - (12*i/ncbps))%s; return (k >= ncbps) ? k : j;endfunction//Mapper:typedef InterleaverDataSz MapperInDataSz;typedef 192 MapperOutDataSz;// mapperNegateInput = True implies: map 1 to -ve map 0 to +ve// False implies: mape 1 to +ve map 1 to -veBool mapperNegateInput = True; //Pilot:typedef MapperOutDataSz PilotInDataSz;typedef 256 PilotOutDataSz;typedef 11 PilotPRBSSz;Bit#(PilotPRBSSz) pilotPRBSMask = 'b10100000000;Bit#(PilotPRBSSz) pilotInitSeq = 'b01010101010; // DL = 'h11111111100 (spec say 7FF, but we start after preamble)// UL = 'h01010101010 (spec say 555, but we start after preamble)function PilotInsertCtrl pilotMapCtrl(TXGlobalCtrl ctrl); return ctrl.firstSymbol ? PilotRst : PilotNorm;endfunction function Symbol#(PilotOutDataSz,TXFPIPrec,TXFPFPrec) pilotAdder(Symbol#(PilotInDataSz,TXFPIPrec,TXFPFPrec) x, Bit#(1) ppv); Integer i =0, j = 0; // assume all guards initially Symbol#(PilotOutDataSz,TXFPIPrec,TXFPFPrec) syms = replicate(cmplx(0,0)); // data carriers for(i = 29; i < 40; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 41; i < 65; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 66; i < 90 ; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 91; i < 115 ; i = i + 1, j = j + 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -