Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
0e17edc1
Commit
0e17edc1
authored
Jan 26, 2022
by
sfn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solve division by null for floating point zero forcing, fix fp shift
parent
631cd33f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
24 deletions
+17
-24
openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
+17
-24
No files found.
openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
View file @
0e17edc1
...
@@ -2150,24 +2150,26 @@ uint8_t nr_matrix_inverse(int32_t **a44,//Input matrix//conjH_H_elements[0]
...
@@ -2150,24 +2150,26 @@ uint8_t nr_matrix_inverse(int32_t **a44,//Input matrix//conjH_H_elements[0]
double
complex
determin_cpx
;
double
complex
determin_cpx
;
for
(
int
i
=
0
;
i
<
12
*
nb_rb
;
i
++
)
{
for
(
int
i
=
0
;
i
<
12
*
nb_rb
;
i
++
)
{
//Convert Q15 to floating point
for
(
int
rtx
=
0
;
rtx
<
size
;
rtx
++
)
{
//row
for
(
int
rtx
=
0
;
rtx
<
size
;
rtx
++
)
{
//row
for
(
int
ctx
=
0
;
ctx
<
size
;
ctx
++
)
{
//column
for
(
int
ctx
=
0
;
ctx
<
size
;
ctx
++
)
{
//column
a44_cpx
[
ctx
*
size
+
rtx
]
=
((
double
)((
short
*
)
a44
[
ctx
*
size
+
rtx
])[(
i
<<
1
)])
+
I
*
((
double
)((
short
*
)
a44
[
ctx
*
size
+
rtx
])[(
i
<<
1
)
+
1
]);
a44_cpx
[
ctx
*
size
+
rtx
]
=
((
double
)((
short
*
)
a44
[
ctx
*
size
+
rtx
])[(
i
<<
1
)])
/
(
1
<<
(
shift0
-
1
))
+
I
*
((
double
)((
short
*
)
a44
[
ctx
*
size
+
rtx
])[(
i
<<
1
)
+
1
])
/
(
1
<<
(
shift0
-
1
));
//if (i<4) printf("a44_cpx(%d,%d)= ((FP %d))%lf+(FP %d)j%lf \n",ctx,rtx,((short *)a44[ctx*size+rtx])[(i<<1)],creal(a44_cpx[ctx*size+rtx]),((short *)a44[ctx*size+rtx])[(i<<1)+1],cimag(a44_cpx[ctx*size+rtx]));
}
}
}
}
//Compute Matrix determinant (copy real value only)
//Compute Matrix determinant (copy real value only)
determin_cpx
=
nr_determin_cpx
(
a44_cpx
,
//
determin_cpx
=
nr_determin_cpx
(
a44_cpx
,
//
size
,
//size
size
,
//size
+
1
);
+
1
);
//if (i<4) printf("order %d nr_det_cpx = %lf+j%lf \n",log2_approx(creal(determin_cpx)),creal(determin_cpx)
/(1<<((size-1)*shift0)),cimag(determin_cpx)/(1<<((size-1)*shift0)
));
//if (i<4) printf("order %d nr_det_cpx = %lf+j%lf \n",log2_approx(creal(determin_cpx)),creal(determin_cpx)
,cimag(determin_cpx
));
//Round and convert to Q15 (Out in the same format as Fixed point).
//Round and convert to Q15 (Out in the same format as Fixed point).
if
(
creal
(
determin_cpx
)
>
0
)
{
//determin of the symmetric matrix is real part only
if
(
creal
(
determin_cpx
)
>
0
)
{
//determin of the symmetric matrix is real part only
((
short
*
)
ad_bc
)[
i
<<
1
]
=
(
short
)
((
creal
(
determin_cpx
)
/
(
1
<<
((
size
-
1
)
*
shift0
)))
+
0
.
5
);
//
((
short
*
)
ad_bc
)[
i
<<
1
]
=
(
short
)
((
creal
(
determin_cpx
)
*
(
1
<<
(
shift0
)))
+
0
.
5
);
//
((
short
*
)
ad_bc
)[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
determin_cpx
)
/
(
1
<<
((
size
-
1
)
*
shift0
)))
+
0
.
5
);
//
//((short*) ad_bc)[(i<<1)+1] = (short) ((cimag(determin_cpx)*(1<<(
shift0)))+0.5);//
}
else
{
}
else
{
((
short
*
)
ad_bc
)[
i
<<
1
]
=
(
short
)
((
creal
(
determin_cpx
)
/
(
1
<<
((
size
-
1
)
*
shift0
)))
-
0
.
5
);
//
((
short
*
)
ad_bc
)[
i
<<
1
]
=
(
short
)
((
creal
(
determin_cpx
)
*
(
1
<<
(
shift0
)))
-
0
.
5
);
//
((
short
*
)
ad_bc
)[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
determin_cpx
)
/
(
1
<<
((
size
-
1
)
*
shift0
)))
-
0
.
5
);
//
//((short*) ad_bc)[(i<<1)+1] = (short) ((cimag(determin_cpx)*(1<<(
shift0)))-0.5);//
}
}
//if (i<4) printf("nr_det_FP= %d+j%d \n",((short*) ad_bc)[i<<1],((short*) ad_bc)[(i<<1)+1]);
//if (i<4) printf("nr_det_FP= %d+j%d \n",((short*) ad_bc)[i<<1],((short*) ad_bc)[(i<<1)+1]);
//Compute Inversion of the H^*H matrix (normalized output divide by determinant)
//Compute Inversion of the H^*H matrix (normalized output divide by determinant)
...
@@ -2187,18 +2189,18 @@ uint8_t nr_matrix_inverse(int32_t **a44,//Input matrix//conjH_H_elements[0]
...
@@ -2187,18 +2189,18 @@ uint8_t nr_matrix_inverse(int32_t **a44,//Input matrix//conjH_H_elements[0]
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
]
=
nr_determin_cpx
(
sub_matrix_cpx
,
//
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
]
=
nr_determin_cpx
(
sub_matrix_cpx
,
//
size
-
1
,
//size
size
-
1
,
//size
((
rtx
&
1
)
==
1
?-
1
:
1
)
*
((
ctx
&
1
)
==
1
?-
1
:
1
))
/
(
determin_cpx
)
;
((
rtx
&
1
)
==
1
?-
1
:
1
)
*
((
ctx
&
1
)
==
1
?-
1
:
1
));
//if (i==0) printf("H_h_H(r%d,c%d)=%lf+j%lf --> inv_H_h_H(%d,%d) = %lf+j%lf \n",rtx,ctx,creal(a44_cpx[ctx*size+rtx]),cimag(a44_cpx[ctx*size+rtx]),ctx,rtx,creal(inv_H_h_H_cpx[rtx*size+ctx])
*(1<<18),cimag(inv_H_h_H_cpx[rtx*size+ctx])*(1<<18
));
//if (i==0) printf("H_h_H(r%d,c%d)=%lf+j%lf --> inv_H_h_H(%d,%d) = %lf+j%lf \n",rtx,ctx,creal(a44_cpx[ctx*size+rtx]),cimag(a44_cpx[ctx*size+rtx]),ctx,rtx,creal(inv_H_h_H_cpx[rtx*size+ctx])
,cimag(inv_H_h_H_cpx[rtx*size+ctx]
));
if
(
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
>
0
)
if
(
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
>
0
)
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[
i
<<
1
]
=
(
short
)
((
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
18
))
+
0
.
5
);
//Convert to Q 18
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[
i
<<
1
]
=
(
short
)
((
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
(
shift0
-
1
)
))
+
0
.
5
);
//Convert to Q 18
else
else
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[
i
<<
1
]
=
(
short
)
((
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
18
))
-
0
.
5
);
//
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[
i
<<
1
]
=
(
short
)
((
creal
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
(
shift0
-
1
)
))
-
0
.
5
);
//
if
(
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
>
0
)
if
(
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
>
0
)
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
18
))
+
0
.
5
);
//
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
(
shift0
-
1
)
))
+
0
.
5
);
//
else
else
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
18
))
-
0
.
5
);
//
((
short
*
)
inv_H_h_H
[
rtx
*
size
+
ctx
])[(
i
<<
1
)
+
1
]
=
(
short
)
((
cimag
(
inv_H_h_H_cpx
[
rtx
*
size
+
ctx
])
*
(
1
<<
(
shift0
-
1
)
))
-
0
.
5
);
//
//if (i<4) printf("inv_H_h_H_FP(%d,%d)= %d+j%d \n",ctx,rtx, ((short *) inv_H_h_H[rtx*size+ctx])[i<<1],((short *) inv_H_h_H[rtx*size+ctx])[(i<<1)+1]);
//if (i<4) printf("inv_H_h_H_FP(%d,%d)= %d+j%d \n",ctx,rtx, ((short *) inv_H_h_H[rtx*size+ctx])[i<<1],((short *) inv_H_h_H[rtx*size+ctx])[(i<<1)+1]);
}
}
...
@@ -2316,14 +2318,13 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
...
@@ -2316,14 +2318,13 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
}
}
}
}
int
fp_flag
=
1
;
//0: float point calc 1: Fixed point calc
int
fp_flag
=
1
;
//0: float point calc 1: Fixed point calc
int
fpshift
=
8
;
nr_matrix_inverse
(
conjH_H_elements
[
0
],
//Input matrix
nr_matrix_inverse
(
conjH_H_elements
[
0
],
//Input matrix
inv_H_h_H
,
//Inverse
inv_H_h_H
,
//Inverse
determ_fin
,
//determin
determ_fin
,
//determin
n_tx
,
//size
n_tx
,
//size
nb_rb_0
,
nb_rb_0
,
fp_flag
,
//fixed point flag
fp_flag
,
//fixed point flag
fpshift
);
//the out put is Q15
shift
-
(
fp_flag
==
1
?
2
:
0
)
);
//the out put is Q15
// multiply Matrix inversion pf H_h_H by the rx signal vector
// multiply Matrix inversion pf H_h_H by the rx signal vector
int32_t
outtemp
[
12
*
nb_rb_0
]
__attribute__
((
aligned
(
32
)));
int32_t
outtemp
[
12
*
nb_rb_0
]
__attribute__
((
aligned
(
32
)));
...
@@ -2344,7 +2345,7 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
...
@@ -2344,7 +2345,7 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
(
int
*
)
&
rxdataF_comp
[
ctx
*
n_rx
][
symbol
*
nb_rb
*
12
],
(
int
*
)
&
rxdataF_comp
[
ctx
*
n_rx
][
symbol
*
nb_rb
*
12
],
outtemp
,
outtemp
,
nb_rb_0
,
nb_rb_0
,
fpshift
+
(
fp_flag
?
0
:
2
));
//out in 15-fpshift
shift
-
(
fp_flag
==
1
?
2
:
0
));
nr_a_sum_b
((
__m128i
*
)
rxdataF_zforcing
[
rtx
],
nr_a_sum_b
((
__m128i
*
)
rxdataF_zforcing
[
rtx
],
(
__m128i
*
)
outtemp
,
(
__m128i
*
)
outtemp
,
nb_rb_0
);
//a =a + b
nb_rb_0
);
//a =a + b
...
@@ -2391,7 +2392,6 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
...
@@ -2391,7 +2392,6 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
for
(
int
rb
=
0
;
rb
<
3
*
nb_rb_0
;
rb
++
)
{
for
(
int
rb
=
0
;
rb
<
3
*
nb_rb_0
;
rb
++
)
{
//for symmetric H_h_H matrix, the determinant is only real values
//for symmetric H_h_H matrix, the determinant is only real values
if
(
fp_flag
)
{
mmtmpD2
=
_mm_sign_epi16
(
determ_fin_128
[
0
],
*
(
__m128i
*
)
&
nr_realpart
[
0
]);
//set imag part to 0
mmtmpD2
=
_mm_sign_epi16
(
determ_fin_128
[
0
],
*
(
__m128i
*
)
&
nr_realpart
[
0
]);
//set imag part to 0
mmtmpD3
=
_mm_shufflelo_epi16
(
mmtmpD2
,
_MM_SHUFFLE
(
2
,
3
,
0
,
1
));
mmtmpD3
=
_mm_shufflelo_epi16
(
mmtmpD2
,
_MM_SHUFFLE
(
2
,
3
,
0
,
1
));
mmtmpD3
=
_mm_shufflehi_epi16
(
mmtmpD3
,
_MM_SHUFFLE
(
2
,
3
,
0
,
1
));
mmtmpD3
=
_mm_shufflehi_epi16
(
mmtmpD3
,
_MM_SHUFFLE
(
2
,
3
,
0
,
1
));
...
@@ -2408,14 +2408,7 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
...
@@ -2408,14 +2408,7 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp,
dl_ch_mag128b_0
[
0
]
=
_mm_slli_epi16
(
dl_ch_mag128b_0
[
0
],
1
);
dl_ch_mag128b_0
[
0
]
=
_mm_slli_epi16
(
dl_ch_mag128b_0
[
0
],
1
);
dl_ch_mag128r_0
[
0
]
=
_mm_mulhi_epi16
(
dl_ch_mag128r_0
[
0
],
QAM_amp128r
);
dl_ch_mag128r_0
[
0
]
=
_mm_mulhi_epi16
(
dl_ch_mag128r_0
[
0
],
QAM_amp128r
);
dl_ch_mag128r_0
[
0
]
=
_mm_slli_epi16
(
dl_ch_mag128r_0
[
0
],
1
);
dl_ch_mag128r_0
[
0
]
=
_mm_slli_epi16
(
dl_ch_mag128r_0
[
0
],
1
);
}
else
{
dl_ch_mag128_0
[
0
]
=
QAM_amp128
;
dl_ch_mag128_0
[
0
]
=
_mm_srai_epi16
(
dl_ch_mag128_0
[
0
],
fpshift
-
1
);
dl_ch_mag128b_0
[
0
]
=
QAM_amp128b
;
dl_ch_mag128b_0
[
0
]
=
_mm_srai_epi16
(
dl_ch_mag128b_0
[
0
],
fpshift
-
1
);
dl_ch_mag128r_0
[
0
]
=
QAM_amp128r
;
dl_ch_mag128r_0
[
0
]
=
_mm_srai_epi16
(
dl_ch_mag128r_0
[
0
],
fpshift
-
1
);
}
determ_fin_128
+=
1
;
determ_fin_128
+=
1
;
dl_ch_mag128_0
+=
1
;
dl_ch_mag128_0
+=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment