Example #1
0
func (m *CDMA) DeSpreadFn(inputChipsSamples gocomm.SComplex128AObj) (outputSample gocomm.SComplex128Obj) {

	outputSample.Ch = vlib.DotC(inputChipsSamples.Ch, m.spreadSeq)
	// fmt.Printf("Dummping output %v", outputSample.Ch)
	outputSample.MaxExpected = inputChipsSamples.MaxExpected
	outputSample.Ts = inputChipsSamples.Ts
	outputSample.Message = inputChipsSamples.Message + " DESP"
	outputSample.TimeStamp = inputChipsSamples.TimeStamp

	return outputSample
}
Example #2
0
func (m *Filter) FilterFn(sample gocomm.SComplex128Obj) (result gocomm.SComplex128Obj) {

	result = sample /// Carefull if not same ChType
	m.FilterMemory = m.FilterMemory.ShiftLeft(sample.Ch)
	foutput := vlib.DotC(m.coeff, m.FilterMemory)

	result.Ch = foutput
	result.Message = sample.Message + " Filter"
	result.Ts = sample.Ts
	result.TimeStamp = sample.TimeStamp
	result.MaxExpected = sample.MaxExpected

	return result
}
Example #3
0
func (m *MPChannel) ChannelFn(sample gocomm.SComplex128Obj) (result gocomm.SComplex128Obj) {
	/// Read your data from Input channel(s) [inputPin0]
	/// And write it to OutputChannels  [outputPin0]
	// fmt.Printf("\n Channel Param %#v  \n input = %v", m.ChannelParam, sample)

	if m.Ts == -1 {

		m.Coeff.Resize(m.pdp.Size())
		for i := 0; i < m.pdp.Size(); i++ {
			m.Coeff[i] = sources.RandNC(m.pdp[i])
		}
		if m.FeedbackCH != nil {
			var chdata gocomm.SComplex128AObj
			chdata.Ch = m.Coeff
			chdata.TimeStamp = m.TimeStamp
			chdata.MaxExpected = sample.MaxExpected
			chdata.Ts = m.Ts
			fmt.Printf("\n FAST IID generated for sample@%v with %v@%v", sample.TimeStamp, m.TimeStamp, cmplx.Abs(m.Coeff[0])*cmplx.Abs(m.Coeff[0]))
			m.FeedbackCH <- chdata
		}

	} else {

		m.updateCoeff(sample.TimeStamp)

	}
	if m.FilterMemory.Size() != m.Coeff.Size() {
		m.FilterMemory.Resize(m.Coeff.Size())
	}

	result = sample /// Carefull if not same ChType
	// m.TimeStamp = sample.TimeStamp
	m.FilterMemory = m.FilterMemory.ShiftLeft(sample.Ch)

	//dummy := vlib.ElemMultC(m.Coeff, vlib.Conj(m.Coeff))
	foutput := vlib.DotC(m.Coeff, m.FilterMemory)
	// fmt.Printf("\n CHANNEL @%v: I/P %v - Gain : %v  : O/p : %v", sample.TimeStamp, sample.Ch, cmplx.Abs(m.Coeff[0])*cmplx.Abs(m.Coeff[0]), foutput)
	result.Ch = foutput
	result.Message = sample.Message + " Filter"
	result.Ts = sample.Ts
	result.TimeStamp = sample.TimeStamp
	result.MaxExpected = sample.MaxExpected
	// fmt.Printf("\n I/O (hn =%v) : %#v --> %#v", m.Coeff, sample, result)
	return result

}
Example #4
0
func IFFT_C(samples vlib.VectorC, N int) vlib.VectorC {

	samples.Resize(N)
	fbins := vlib.NewVectorC(N)
	normalize := complex(math.Sqrt(1.0/float64(N)), 0)
	result := vlib.NewVectorC(N)
	for i := 0; i < N; i++ {
		for n := 0; n < N; n++ {
			scale := float64(i) * float64(n) / float64(N)
			binf := complex(0, 2.0*math.Pi*scale)
			fbins[n] = cmplx.Exp(binf)
		}
		// fbins = fbins.ScaleC(i)
		// fmt.Print("\ni=", i, fbins)
		result[i] = vlib.DotC(samples, fbins) * normalize
	}

	return result
}
Example #5
0
func (cdma *CDMA) DeSpreadBlock(expectedInputSize int, chInway gocomm.Complex128AChannel, OutCH gocomm.Complex128Channel) {

	despcode := vlib.Conj(cdma.SpreadSequence)

	SF := len(despcode)

	despcode = despcode.Scale(1. / (float64(SF)))

	if SF == 0 {
		panic("Spreading Code not Set")
	}
	// maxSymbols := expectedInputSize / SF
	// rxsymbols := vlib.NewVectorC(maxSymbols)
	var recentBuffer vlib.VectorC
	for cnt := 0; cnt < expectedInputSize; {

		data := <-chInway
		rxlen := len(data.Ch)
		// log.Printf("\n Received %d samples out of %d/%d ", rxlen, cnt, expectedInputSize)
		cnt += rxlen
		recentBuffer = append(recentBuffer, data.Ch...)
		for {
			if recentBuffer.Size() < SF {

				break

			} else {
				// log.Printf("\n Symbol %d Ready to Despread with %d", sym, cnt)
				rxchips := recentBuffer[0:SF]
				recentBuffer = recentBuffer[SF:]
				rxsymbols := vlib.DotC(despcode, rxchips)
				var chdataOut gocomm.SComplex128Obj
				chdataOut.Ch = rxsymbols
				OutCH <- chdataOut

			}
		}
	}

	close(chInway)
}