예제 #1
0
func main() {
	var channel core.MPChannel
	channel.InitializeChip()
	N := 100

	param := core.NewIIDChannel()
	param.Ts = 4
	pdp := vlib.VectorF{1, .1}
	param.SetPDP(pdp)
	param.Mode = ""
	channel.InitParam(param)
	// samples := vlib.VectorC(sources.RandNCVec(N, 1))
	samples := vlib.NewOnesC(N)

	var data gocomm.SComplex128Obj
	data.Ts = 2
	for i := 0; i < N; i++ {
		data.Ch = samples[i]
		// fmt.Printf("\n Input %d = %v", i, data)
		chout := channel.ChannelFn(data)
		fmt.Printf("\n  %d I/O : %v ==> %v", i, data.Ch, chout.Ch)
		data.UpdateTimeStamp()
	}

}
예제 #2
0
파일: mpchannel.go 프로젝트: postfix/gocomm
func NewIIDChannel() ChannelParam {
	var result ChannelParam
	result.Ts = -1
	result.Mode = "IID"
	result.pdp = vlib.NewOnesF(1)
	result.Coeff = vlib.NewOnesC(1)
	return result
}
예제 #3
0
파일: mpchannel.go 프로젝트: postfix/gocomm
func (m *ChannelParam) Validate() {

	if m.Ts == -1 {
		m.Mode = "IID"
	}
	if m.Ts == 0 {
		m.Mode = "AWGN"
	}
	if m.pdp.Size() == 0 && m.Coeff.Size() == 0 {
		m.pdp = vlib.NewOnesF(1)
		m.Coeff = vlib.NewOnesC(1)
	}
	if m.pdp.Size() == 0 && m.Coeff.Size() != 0 {
		m.pdp = vlib.NewOnesF(m.Coeff.Size())
	}
	m.FilterMemory = vlib.NewOnesC(m.Coeff.Size())
	m.TimeStamp = -1
}
예제 #4
0
파일: mpchannel.go 프로젝트: postfix/gocomm
func DefaultChannel() ChannelParam {
	var result ChannelParam
	result.Ts = 0
	result.Mode = "AWGN"
	result.pdp = vlib.NewOnesF(1)
	result.PowerInDBm = 0
	result.Coeff = vlib.NewOnesC(1)
	return result
}
예제 #5
0
파일: cdma.go 프로젝트: postfix/gocomm
func main() {

	N := 20 /// 20 samples
	L := 4  /// 5tap channel
	begin := time.Now()

	var cdma core.CDMA
	cdma.InitializeChip()
	cdma.SetSpreadCode(vlib.NewOnesC(L), true)

	samples := vlib.VectorC(sources.RandNCVec(N, 1))
	var data gocomm.SComplex128Obj
	/// METHOD A
	data.Ts = 1
	data.TimeStamp = 0
	data.MaxExpected = N
	data.Message = ""
	for i := 0; i < N; i++ {
		data.Next(samples[i])
		chips := cdma.SpreadFn(data)
		output := cdma.DeSpreadFn(chips)
		fmt.Printf("\nTxSymbol %v ", data)
		// fmt.Printf("\nTx %v ", chips)
		fmt.Printf("\nRxSymbol %v ", output)
	}

	/// METHOD B
	// dataArray.MaxExpected = samples.Size()
	// inCHA := gocomm.NewComplex128Channel()
	// outputPin := filter.PinByID(1)

	// go filter.Filter(inCHA)
	// go chipset.Sink(outputPin)
	// /// Actual data pushing
	// for i := 0; i < N; i++ {
	// 	dataArray.MaxExpected = N
	// 	dataArray.Ch = samples[i]
	// 	inCHA <- dataArray
	// }

	//fmt.Printf("\nFilter Residues %v", filter.FilterMemory)

	//  Of code
	fmt.Printf("\nTime Elapsed : %v\n", time.Since(begin))
}
예제 #6
0
func (s *setup) Run() {
	s.snr_ber = make(map[float64]float64)
	s.snr_block = make(map[float64]float64)
	s.snr_ber1 = make(map[float64]float64)
	s.snr_block1 = make(map[float64]float64)
	hn := vlib.NewOnesF(1)

	spcode := vlib.NewOnesC(s.SF)
	// snr = vlib.VectorF{0, 10, 100}
	// snr = vlib.ToVectorF("0:2:20")
	fmt.Printf("\nSNR : %v", s.snr)
	fmt.Printf("\nhn : %v", hn)
	// linkresult := make(map[float64]float64, 1)
	// linkresult1 := make(map[float64]float64, 1)

	outCH := make([]gocomm.FloatChannel, s.snr.Size())
	// outCH1 := make([]gocomm.FloatChannel, snr.Size())
	fmt.Printf("\n SNR ")
	for i := 0; i < len(s.snr); i++ {
		// blocks := s.snr_block[snr[i]] + 1
		fmt.Printf("%2.2f ", s.snr[i])
	}

	fmt.Printf("\n")
	for i := 0; i < s.snr.Size(); i++ {
		// s.wg.Add(1)
		outCH[i] = gocomm.NewFloatChannel()
		// outCH1[i] = gocomm.NewFloatChannel()
		s.wg.Add(1)
		go s.SimulateLinkFn(s.snr[i], hn, spcode, outCH[i], 0)
		// go s.SimulateLinkFn(snr[i]-2, hn, spcode, outCH1[i], 1)

	}

	s.wg.Wait()

	log.Printf("\nSNR : %v", s.snr)
	log.Printf("\nBER : %v", s.snr_ber)
	log.Printf("\nhn : %v", hn)
	s.Results = string(Print(s.snr_ber, "", ""))
	log.Printf("Result %v", s.Results)
}