📄 channelestimatortest.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.//----------------------------------------------------------------------//import Complex::*;import Controls::*;import DataTypes::*;import GetPut::*;import Interfaces::*;import LibraryFunctions::*;import PilotInsert::*;import Vector::*;import ChannelEstimator::*;function t idFunc (t in); return in;endfunctionfunction Symbol#(64,2,14) pilotAdder(Symbol#(48,2,14) x, Bit#(1) ppv); Integer i =0, j = 0; // assume all guards initially Symbol#(64,2,14) syms = replicate(cmplx(0,0)); // data subcarriers for(i = 6; i < 11; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 12; i < 25; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 26; i < 32 ; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 33; i < 39 ; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 40; i < 53 ; i = i + 1, j = j + 1) syms[i] = x[j]; for(i = 54; i < 59 ; i = i + 1, j = j + 1) syms[i] = x[j]; //pilot subcarriers syms[11] = mapBPSK(False, ppv); // map 1 to -1, 0 to 1 syms[25] = mapBPSK(False, ppv); // map 1 to -1, 0 to 1 syms[39] = mapBPSK(False, ppv); // map 1 to -1, 0 to 1 syms[53] = mapBPSK(True, ppv); // map 0 to -1, 1 to 1 return syms;endfunctionfunction Symbol#(48,2,14) pilotRemover(Symbol#(64,2,14) x); Integer i =0, j = 0; // assume all guards initially Symbol#(48,2,14) syms = newVector; // data subcarriers for(i = 6; i < 11; i = i + 1, j = j + 1) syms[j] = x[i]; for(i = 12; i < 25; i = i + 1, j = j + 1) syms[j] = x[i]; for(i = 26; i < 32 ; i = i + 1, j = j + 1) syms[j] = x[i]; for(i = 33; i < 39 ; i = i + 1, j = j + 1) syms[j] = x[i]; for(i = 40; i < 53 ; i = i + 1, j = j + 1) syms[j] = x[i]; for(i = 54; i < 59 ; i = i + 1, j = j + 1) syms[j] = x[i]; return syms;endfunction(* synthesize *)module mkChannelEstimatorTest(Empty); PilotInsert#(PilotInsertCtrl,48,64,2,14) pilotInsert; pilotInsert <- mkPilotInsert(idFunc, pilotAdder, 7'b1001000, 7'b1111111); ChannelEstimator#(PilotInsertCtrl,64,48,2,14) channelEstimator; channelEstimator <- mkChannelEstimator(pilotRemover); Reg#(Bit#(32)) cycle <- mkReg(0); rule putIntput(True); PilotInsertMesg#(PilotInsertCtrl,48,2,14) iMesg; iMesg = Mesg{ control: (cycle[2:0] == 0) ? PilotRst : PilotNorm, data: replicate(cmplx(1,1))}; pilotInsert.in.put(iMesg); $display("Pilot Insert Input: %h",iMesg.data); endrule rule putChannel(True); let oMesg <- pilotInsert.out.get; channelEstimator.in.put(oMesg); $display("Pilot Insert Output: %h",oMesg.data); endrule rule getOutput(True); let oMesg <- channelEstimator.out.get; $display("Channel Estimator Output: %h",oMesg.data); endrule rule tick(True); cycle <= cycle + 1; if (cycle == 100000) $finish; $display("Cycle: %d",cycle); endrule endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -