Skip to content

Commit

Permalink
numpy interafce for setting eoo bits
Browse files Browse the repository at this point in the history
  • Loading branch information
drowe67 committed Nov 28, 2024
1 parent 3f8a23b commit bcb032f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions radae_rxe.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def get_sync(self):

def sum_uw_errors(self,new_uw_errors):
self.uw_errors += new_uw_errors

def get_Neoo_bits(self):
return self.model.Nseoo*self.model.bps

def do_radae_rx(self, buffer_complex, floats_out):
acq = self.acq
Expand Down Expand Up @@ -347,9 +350,9 @@ def do_radae_rx(self, buffer_complex, floats_out):
if (ret & 1) and args.use_stdout:
sys.stdout.buffer.write(floats_out)
if (ret & 2) and args.eoo_data_test:
# same RNG as tx
g = torch.Generator().manual_seed(1)
tx_bits = torch.sign(torch.rand(rx.model.Nseoo*rx.model.bps,generator=g)-0.5).detach().numpy()
# create a RNG with same sequence for BER testing with separate tx and rx
seed = 65647; rng = np.random.default_rng(seed)
tx_bits = np.sign(rng.random(rx.get_Neoo_bits())-0.5)
n_bits = len(tx_bits)
n_errors = sum(floats_out[:n_bits]*tx_bits < 0)
ber = n_errors/n_bits
Expand Down
14 changes: 9 additions & 5 deletions radae_txe.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ def get_n_floats_in(self):
def get_Nmf(self):
return self.Nmf
def get_Neoo(self):
return self.Neoo
return self.Neoo
def get_Neoo_bits(self):
return self.model.Nseoo*self.model.bps
def set_eoo_bits(self,eoo_bits):
self.model.set_eoo_bits(torch.tensor(tx_bits, dtype=torch.float32))

def do_radae_tx(self,buffer_f32,tx_out):
model = self.model
Expand Down Expand Up @@ -149,10 +153,10 @@ def do_eoo(self,tx_out):
tx = radae_tx(model_name=args.model_name, auxdata=args.auxdata, txbpf_en=args.txbpf, bypass_enc=args.bypass_enc)

if args.eoo_data_test:
# use a custom RNG to avoid upsetting some other rather delicate ctests (TODO fix this sensitvity later)
g = torch.Generator().manual_seed(1)
tx_bits = torch.sign(torch.rand(tx.model.Nseoo*tx.model.bps,generator=g)-0.5)
tx.model.set_eoo_bits(tx_bits)
# create a RNG with same sequence for BER testing with separate tx and rx
seed = 65647; rng = np.random.default_rng(seed)
tx_bits = np.sign(rng.random(tx.get_Neoo_bits())-0.5)
tx.set_eoo_bits(tx_bits)

tx_out = np.zeros(tx.Nmf,dtype=np.csingle)
while True:
Expand Down

0 comments on commit bcb032f

Please sign in to comment.