PUSCH with LUT working in Matlab

master
ismagom 9 years ago
commit e3499aff55

@ -1,24 +1,25 @@
clear
ueConfig=struct('NCellID',1,'CyclicPrefixUL','Normal','NTxAnts',1);
puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',0,'Shortened',0);
puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',(0:15)','Shortened',0);
addpath('../../build/srslte/lib/phch/test')
TBs=40;
cqilen=0;
mods={'QPSK'};
rvs=0;
betas=0;
for i=1:length(TBs)
for i=0:26
for m=1:length(mods)
for r=1:length(rvs)
for bri=1:length(betas)
for back=1:length(betas)
for c=1:length(cqilen)
trblkin=randi(2,TBs(i),1)-1;
TBs=lteTBS(length(puschConfig.PRBSet),i);
trblkin=randi(2,TBs,1)-1;
puschConfig.Modulation = mods{m};
puschConfig.RV = rvs(r);
puschConfig.BetaCQI = 5;
@ -36,7 +37,7 @@ for i=1:length(TBs)
ack_bit=[];
end
if (cqilen(c)>0 || TBs(i)>0)
if (cqilen(c)>0 || TBs>0)
[lib]=srslte_ulsch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit);
lib(lib==192)=3;
lib(lib==48)=2;

@ -58,16 +58,16 @@ SRSLTE_API void srslte_bit_interleave_w_offset(uint8_t *input,
uint32_t nof_bits,
uint32_t w_offset);
SRSLTE_API void srslte_bit_unpack_vector(uint8_t *srslte_bit_packed,
uint8_t *bits_packed,
int nof_bits);
SRSLTE_API void srslte_bit_pack_vector(uint8_t *bits_packed,
uint8_t *srslte_bit_packed,
SRSLTE_API void srslte_bit_unpack_vector(uint8_t *packed,
uint8_t *unpacked,
int nof_bits);
SRSLTE_API void srslte_bit_pack_vector(uint8_t *unpacked,
uint8_t *packed,
int nof_bits);
SRSLTE_API uint32_t srslte_bit_pack(uint8_t **bits,
int nof_bits);
int nof_bits);
SRSLTE_API uint64_t srslte_bit_pack_l(uint8_t **bits,
int nof_bits);

@ -200,14 +200,17 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, uint8_t *input, uint8_t *parity, ui
parity[i] = tcod_lut_output[cblen_idx][state0][input[i]];
state0 = tcod_lut_next_state[cblen_idx][state0][input[i]] % 8;
}
parity[long_cb/8] = 0; // will put tail here later
/* Interleave input */
srslte_bit_interleave(input, h->temp, tcod_per_fw[cblen_idx], long_cb);
/* Parity bits for the 2nd constituent encoders */
uint8_t state1 = 0;
for (uint32_t i=0;i<long_cb/8;i++) {
parity[long_cb/8+i] = tcod_lut_output[cblen_idx][state1][h->temp[i]];
uint8_t out = tcod_lut_output[cblen_idx][state1][h->temp[i]];
parity[long_cb/8+i] |= (out&0xf0)>>4;
parity[long_cb/8+i+1] = (out&0xf)<<4;
state1 = tcod_lut_next_state[cblen_idx][state1][h->temp[i]] % 8;
}
@ -268,11 +271,14 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, uint8_t *input, uint8_t *parity, ui
}
}
uint8_t *x = tailv[0];
input[long_cb/8] = srslte_bit_pack(&x, 4);
printf("tail0: ");
srslte_vec_fprint_b(stdout, tailv[0], 4);
input[long_cb/8] = (srslte_bit_pack(&x, 4)<<4);
printf("0x%x\n", input[long_cb/8]);
x = tailv[1];
parity[long_cb/8] = srslte_bit_pack(&x, 4);
parity[long_cb/8] |= (srslte_bit_pack(&x, 4)<<4);
x = tailv[2];
parity[2*long_cb/8] = srslte_bit_pack(&x, 4);
parity[2*long_cb/8] |= (srslte_bit_pack(&x, 4)&0xf);
return 3*long_cb+TOTALTAIL;
} else {

@ -93,8 +93,8 @@ int main(int argc, char **argv) {
srslte_rm_turbo_gentables();
//for (cb_idx=0;cb_idx<188;cb_idx++) {
// for (rv_idx=0;rv_idx<4;rv_idx++) {
for (cb_idx=0;cb_idx<188;cb_idx++) {
for (rv_idx=0;rv_idx<4;rv_idx++) {
printf("cb_len=%d, rv_idx=%d\n", cb_idx, rv_idx);
@ -197,8 +197,8 @@ int main(int argc, char **argv) {
exit(-1);
}
}
//}
//}
}
}
printf("OK\n");
exit(0);

@ -109,11 +109,11 @@ int srslte_sch_init(srslte_sch_t *q) {
srslte_rm_turbo_gentables();
// Allocate floats for reception (LLRs)
q->cb_in = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_TCOD_MAX_LEN_CB);
q->cb_in = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_TCOD_MAX_LEN_CB+4);
if (!q->cb_in) {
goto clean;
}
q->cb_temp = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_TCOD_MAX_LEN_CB);
q->cb_temp = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_TCOD_MAX_LEN_CB+4);
if (!q->cb_temp) {
goto clean;
}
@ -161,6 +161,7 @@ uint32_t srslte_sch_last_noi(srslte_sch_t *q) {
}
uint8_t temp[64*1024];
/* Encode a transport block according to 36.212 5.3.2
*
@ -273,23 +274,25 @@ static int encode_tb(srslte_sch_t *q,
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("CB#%d encoded: ", i);
srslte_vec_fprint_b(stdout, q->cb_out, 3*cb_len+12);
srslte_vec_fprint_byte(stdout, q->cb_out, 2*cb_len/8);
}
}
/* Rate matching */
if (srslte_rm_turbo_tx_lut(soft_buffer->buffer_b[i], q->cb_in, (uint8_t*) q->cb_out, &e_bits[wp], cblen_idx, n_e, rv))
if (srslte_rm_turbo_tx_lut(soft_buffer->buffer_b[i], q->cb_in, (uint8_t*) q->cb_out, &temp[wp], cblen_idx, n_e, rv))
{
fprintf(stderr, "Error in rate matching\n");
return SRSLTE_ERROR;
}
/* Set read/write pointers */
rp += rlen;
wp += n_e;
}
INFO("END CB#%d: wp: %d, rp: %d\n", i, wp, rp);
srslte_bit_unpack_vector(temp, e_bits, nof_e_bits);
ret = SRSLTE_SUCCESS;
}
return ret;

@ -53,13 +53,26 @@ void srslte_bit_interleave_w_offset(uint8_t *input, uint8_t *output, uint32_t *i
w_offset_p=8-w_offset;
}
for (uint32_t i=st;i<nof_bits/8;i++) {
output[i] = 0;
for (uint32_t j=0;j<8;j++) {
uint32_t i_p = interleaver[i*8+j-w_offset_p];
if (input[i_p/8] & mask[i_p%8]) {
output[i] |= mask[j];
}
}
uint32_t i_p0 = interleaver[i*8+0-w_offset_p];
uint32_t i_p1 = interleaver[i*8+1-w_offset_p];
uint32_t i_p2 = interleaver[i*8+2-w_offset_p];
uint32_t i_p3 = interleaver[i*8+3-w_offset_p];
uint32_t i_p4 = interleaver[i*8+4-w_offset_p];
uint32_t i_p5 = interleaver[i*8+5-w_offset_p];
uint32_t i_p6 = interleaver[i*8+6-w_offset_p];
uint32_t i_p7 = interleaver[i*8+7-w_offset_p];
uint8_t out0 = (input[i_p0/8] & mask[i_p0%8])?mask[0]:0;
uint8_t out1 = (input[i_p1/8] & mask[i_p1%8])?mask[1]:0;
uint8_t out2 = (input[i_p2/8] & mask[i_p2%8])?mask[2]:0;
uint8_t out3 = (input[i_p3/8] & mask[i_p3%8])?mask[3]:0;
uint8_t out4 = (input[i_p4/8] & mask[i_p4%8])?mask[4]:0;
uint8_t out5 = (input[i_p5/8] & mask[i_p5%8])?mask[5]:0;
uint8_t out6 = (input[i_p6/8] & mask[i_p6%8])?mask[6]:0;
uint8_t out7 = (input[i_p7/8] & mask[i_p7%8])?mask[7]:0;
output[i] = out0 | out1 | out2 | out3 | out4 | out5 | out6 | out7;
}
for (uint32_t j=0;j<nof_bits%8;j++) {
uint32_t i_p = interleaver[(nof_bits/8)*8+j-w_offset];
@ -213,15 +226,15 @@ void srslte_bit_copy(uint8_t *dst, uint32_t dst_offset, uint8_t *src, uint32_t s
}
}
void srslte_bit_unpack_vector(uint8_t *bits_unpacked, uint8_t *bits_packed, int nof_bits)
void srslte_bit_unpack_vector(uint8_t *packed, uint8_t *unpacked, int nof_bits)
{
uint32_t i, nbytes;
nbytes = nof_bits/8;
for (i=0;i<nbytes;i++) {
srslte_bit_unpack(bits_unpacked[i], &bits_packed, 8);
srslte_bit_unpack(packed[i], &unpacked, 8);
}
if (nof_bits%8) {
srslte_bit_unpack(bits_unpacked[i], &bits_packed, nof_bits%8);
srslte_bit_unpack(packed[i]>>(nof_bits%8), &unpacked, nof_bits%8);
}
}
@ -245,16 +258,16 @@ void srslte_bit_unpack(uint32_t value, uint8_t **bits, int nof_bits)
*bits += nof_bits;
}
void srslte_bit_pack_vector(uint8_t *bits_packed, uint8_t *bits_unpacked, int nof_bits)
void srslte_bit_pack_vector(uint8_t *unpacked, uint8_t *packed, int nof_bits)
{
uint32_t i, nbytes;
nbytes = nof_bits/8;
for (i=0;i<nbytes;i++) {
bits_unpacked[i] = srslte_bit_pack(&bits_packed, 8);
packed[i] = srslte_bit_pack(&unpacked, 8);
}
if (nof_bits%8) {
bits_unpacked[i] = srslte_bit_pack(&bits_packed, nof_bits%8);
bits_unpacked[i] <<= 8-(nof_bits%8);
packed[i] = srslte_bit_pack(&unpacked, nof_bits%8);
packed[i] <<= 8-(nof_bits%8);
}
}

Loading…
Cancel
Save