Esempio n. 1
0
func main() {
	seedvalue := time.Now().Unix()
	rand.Seed(seedvalue)
	runtime.GOMAXPROCS(0)
	BLOCKLENGTH := 40
	NOBLOCKS := 1000
	fmt.Printf("BLOCKLENGTH = %d \t NOBLOCKS = %d\n", BLOCKLENGTH, NOBLOCKS)
	//var output vlib.VectorB
	startTime := time.Now()
	var codec turbo.LTECodec
	berc := 0
	codec.Init("BPSK", "_13_", BLOCKLENGTH)
	variance := 1.0
	for i := 1; i <= NOBLOCKS; i++ {
		fmt.Printf("\rProcessing block no : %d", i)
		input := vlib.Randsrc(BLOCKLENGTH, 2)
		output := codec.Encode(input)
		mod := bpskmod(output)
		llr := bpskawgndemod(mod, variance)
		dec_output := codec.Decode(llr)
		//fmt.Print("Input bits = %v", input)
		//fmt.Print("\nOuput bits = %v", dec_output)
		for j := 0; j < codec.BLOCKLENGTH; j++ {
			berc = berc + input[j] ^ dec_output[j]

		}

	} //
	fmt.Printf("\nNumber of error = %d\t", berc)
	fmt.Printf("BER = %f\n", float64(berc)/(float64(BLOCKLENGTH)*float64(NOBLOCKS)))
	fmt.Printf("Time Elapsed : %v\n", time.Since(startTime))

}
Esempio n. 2
0
func main() {

	rand.Seed(time.Now().Unix())
	rand.Seed(1)

	// for i := 0; i < 256; i++ {
	// 	fmt.Printf("\n %d %c ", i, i)
	// }

	var N = 10
	bits2 := vlib.NewOnesB(10)

	fmt.Print("\nRandBits  = ", vlib.Randsrc(N, 2))

	fmt.Print("\nRandNoise  = ", vlib.RandNCVec(N, 1))
	// msg := sources.RandChars(N)
	msg := vlib.RandReadableChars(N)
	strmsg := string(msg)
	// strmsg = "Hello world, this is a message sent"

	// var msg = "HELLO SENDIL"

	fmt.Printf("\nRandChars = %s ", strmsg)
	fmt.Print("\nBit messages  = ", sources.BitsFromMessage(strmsg))
	bits3 := sources.BitsFromMessage(strmsg)
	fmt.Printf("\nBits  : %v", bits2)
	fmt.Printf("\nBits  : %v ", bits3)

	bpskModem := core.NewModem()
	// bpskModem.Init(1)
	fmt.Printf("\n%v", bpskModem)
	fmt.Printf("\n%f", bpskModem.Constellation)

	print("\n") // Legacy
	// qpskModem := modem.NewModem(2, "QPSK")

	qpskModem := new(core.Modem)
	qpskModem.Init(2, "QPSK")
	fmt.Printf("\n%v", qpskModem)
	fmt.Printf("\n%f", qpskModem.Constellation)
	qpskModem.ModulateBits(bits2)
}