{'fraction_non_alphanumeric': 0.04404604520684874, 'fraction_numerical': 0.01486473414374617, 'mean_word_length': 3.9861736334405147, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Two-Step Codeword Design for Millimeter Wave Massive MIMO Systems with Quantized Phase Shifters

In this paper, a two-step codeword design approach for millimeter wave (mmWave) massive MIMO systems is presented. Ideal codewords are first designed, which ignores the hardware constraints in terms of phase shifter resolution and the number of RF chains. Based on the ideal codewords, practical codewords are then obtained taking the hardware constraints into consideration. For the ideal codeword design in the first step, additional phase is introduced to the beam gain to provide extra degree of freedom. We develop a phase-shifted ideal codeword design (PS-ICD) method, which is based on alternative minimization with each iteration having a closed-form solution and can be extended to design more general beamforming vectors with different beam patterns. Once the ideal codewords are obtained in the first step, the practical codeword design problem in the second step is to approach the ideal codewords by considering the hardware constraints of the hybrid precoding structure in terms of phase shifter resolution and the number of RF chains. We propose a fast search based alternative minimization (FS-AltMin) algorithm that alternatively designs the analog precoder and digital precoder. Simulation results verify the effectiveness of the proposed methods and show that the codewords designed based on the two-step approach outperform those designed by the existing approaches.


I. INTRODUCTION
Millimeter wave (mmWave) communications have drawn extensive attention due to its rich spectrum resource to meet increasing demand in data traffic [1]- [6]. Its short wave length enables a large antenna array to be packed into a small area, which facilitates massive multi-input multi-output (MIMO) transmission to compensate the path loss induced by high frequency and support parallel transmission of data streams [7], [8]. As shown in Fig. 1, mmWave massive MIMO usually employs hybrid precoding where a small number of RF chains are connected to a large number of antennas [9]. Hybrid precoding is typically a cascade of analog precoding and digital precoding. Analog precoding uses a phase shifter and achieves directional transmission, usually with constant envelop and limited resolution [10]. Digital precoding, which functions similarly as in the convention MIMO, is employed to mitigate the mutual interference among different data steams.
To acquire channel state information needed by hybrid precoding, beam training based on codebook is usually adopted, where the codebook is made up of a number of codewords that can simply implemented by channel steering vectors [11]- [13]. To reduce the overhead of beam training, hierarchical codebook is introduced [14]. Normally, a hierarchical codebook consists of a small number of low-resolution codewords covering wide angle at the upper layer of the codebook and a large number of high-resolution codewords offering high directional gain at the lower layer of the codebook [15]. Several hierarchical codebook design schemes have already been proposed [15]- [17]. In [15], given the absolute beam gain as an objective, the least squares (LS) method is first applied to obtain an ideal codeword, which is generally named as LS ideal codeword design (LS-ICD). Based on the ideal codeword, the orthogonal matching pursuit (OMP) algorithm is used to obtain a practical codeword by considering the limited number of RF chains and the limited resolution of phase shifters. In [16], a phase-shifted discrete Fourier transform (PS-DFT) scheme is proposed, where the codewords are formed by the weighted summation of channel steering vectors. Although the hardware constraints in terms of RF chains and phase shifters are implicitly taken into account in the channel steering vectors, PS-DFT needs a large number of RF chains to achieve low-resolution codewords. In [17], a beam widening via single RF chain subarray (BMW-SS) is proposed, where the antenna array is divided into several subarrays and the codeword is designed via weighted summation of different beams formed by different sub-arrays.
In this paper, we present a two-step codeword design approach for mmWave massive MIMO. In the first step, we design ideal codewords regardless of hardware constraints in terms of phase shifter resolution and the number of RF chains. We then design practical codewords based on ideal codewords by considering the hardware constraints in the second step. The main contribution of this paper is summarized as follows: • For the ideal codeword design, we introduce additional phase to the beam gain to provide extra degree of freedom and propose a phase-shifted ideal codeword design (PS-ICD) method.  we derive. The proposed PS-ICD can also be extended to design more general beamforming vectors with different beam patterns. • Given the ideal codewords designed in the first step, the practical codeword design problem in the second step is to approach the ideal codewords by considering the hardware constraints of the hybrid precoding structure in terms of phase shifter resolution and the number of RF chains. We propose a fast search based alternative minimization (FS-AltMin) algorithm that alternatively designs the analog precoder and digital precoder. The rest of this paper is organized as follows. The problem of codeword design is formulated in Section II. The ideal codeword design and practical codeword design are presented in Section III and Section IV, respectively. Simulation results are provided in Section V. Finally, Section VI concludes this paper.
[a] n , [A] n,: , [A] :,m and [A] n,m denote the nth entry of vector a, the nth row of matrix A, the mth column of matrix A, and the entry on the nth row and mth column of matrix A, respectively. Re{·} and Im{·} denote the real part and imaginary part of a complex number, respectively.

II. PROBLEM FORMULATION
After briefly introducing mmWave massive MIMO and beam training, in this section, we will formulate the problem of codeword design.

A. MmWave Massive MIMO
As shown in Fig. 1, we consider a mmWave massive MIMO system with N t and N r antennas at the transmitter and receiver, respectively. Without loss of generality, we assume N t ≥ N r . The antennas at both sides are placed in uniform linear arrays with half wavelength intervals. The mmWave massive MIMO system is equipped with the same number of N RF RF chains at the transmitter and the receiver [15]. At the transmitter, each RF chain is fully connected to N t antennas via quantized phase shifters, signal combiners, and power amplifiers. At the receiver, each RF chain is fully connected to N r antennas via quantized phase shifters, signal combiners, and low-noise amplifiers. We will consider the phase shifters usually with limited resolution, e.g., six bits [10].
When transmitting N DT (1 ≤ N DT ≤ N RF ) data streams x ∈ C NDT in parallel, the received signal y ∈ C NDT can be expressed as , H ∈ C Nr×Nt , and η ∈ C Nr denote the digital precoder, the analog precoder, the digital combiner, the analog combiner, the mmWave MIMO channel matrix, and the additive white Gaussian noise vector with η ∼ CN 0, σ 2 η I Nr , respectively. Suppose the total power of the transmitter is P and the transmit signal vector x is normalized such that E xx H = 1 NDT I NDT . The hybrid precoder, including the digital precoder and the analog precoder has no power gain, i.e., F RF F BB 2 = 1. Similarly, the hybrid combiner, including the digital combiner and the analog combiner has no power gain either, i.e., W RF W BB 2 = 1.
According to the widely used Saleh-Valenzuela channel model [18], the mmWave MIMO channel matrix H can be expressed as where L, µ l , Ω r l and Ω t l denote the number of multipath, the channel gain, the channel angle-of-arrival (AoA), and channel angle-of-departure (AoD) of the lth path, respectively. In fact, we have Ω t l = cos (ω t l ) and Ω r l = cos (ω r l ), where ω t l and ω r l denote the physical AoA and AoD of the lth path, respectively.
Since ω t l ∈ [0, 2π) and ω r l ∈ [0, 2π), we have Ω t l ∈ [−1, 1] and Ω r l ∈ [−1, 1]. The channel steering vector a is defined as where N is the number of antennas and Ω is the AoA or AoD.

B. Beam Training
Before the data transmission, the beam training tests all pairs of transmitting beam and receiving beam to find the pair best fit for the mmWave MIMO channel [19]. During the beam training stage, we only need to send a training symbol x by setting N DT = 1, which implies that we only need to use one column of F BB with all the other columns being zero. Therefore we can replace F BB x by f BB x in (1). Correspondingly, to receive the training symbol, we only need to use one column of W BB with all the other columns being zero. Similarly, we can replace W BB by w BB in (1). Then where v F RF f BB denotes the transmitting beam with the constraint v 2 = 1 and w W RF w BB denotes the receiving beam with the constraint w 2 = 1. In fact, either v or w is essentially a codeword. The beam training aims at finding the pair of v and w best fit for the mmWave MIMO channel, which can be expressed as where V t and V r denote the codebook generated at the transmitter and the receiver, respectively. However, in practice it is impossible to find v and w directly from (5) due to the existence of the channel noise η. We can only measure the power of y to find the best pair of v and w, which can be expressed as arg max The solution of (5) and (6) may be the same or different. If they are same, we call that the beam training is successful; otherwise, we say that the beam training is failed. The ratio of the number of successful beam training over the total number of beam training is defined as the success rate. Success rate of beam training is an important metric to evaluate V t and V r . In fact, a straightforward method to solve (6) is to exhaustively search all pairs of v and w to find the best one. But such a method takes a long time for beam training. To improve the efficiency, beam training based on hierarchical codebooks is adopted [20], [21]. As shown in Fig. 2, a hierarchical codebook typically consists of a small number of low-resolution codewords covering wide angle at the upper layer of the codebook and a large number of high-resolution codewords offering high directional gain at the lower layer of the codebook. The main feature of such a hierarchical codebook can be summarized as: 1) The beams formed by the codewords in the same layer have the same width. 2) The overall coverage of all codewords in the same layer is [−1, 1].
3) Each beam formed by an upper layer codeword covers M narrower beams formed by the lower layer codewords, where M is called as hierarchical factor [22]. Fig. 2 illustrates an example of hierarchical codebook V with M = 2 and S = 3. In general, S is the layer of the codebook and is determined by S = log M N t . Compared to the exhaustive tests, the beam training for one data stream based on the hierarchical codebook can reduce the number of tests from [15]. For example, for an mmWave MIMO system with N t = 16, N r = 8 and M = 2, the training overhead is reduced by 89% . On the other hand, due to the low beam gain of the codewords at the upper layers of the hierarchical codebook, beam training may have lower success rate. Therefore, how to design a hierarchical codebook, especially the upper layer codewords is the focus of this paper.
Once the beam training is finished, F RF and W RF can be designed. Then we send pilot sequences to estimate the equivalent channel matrix which is a product of F RF , H and W RF . Once the equivalent channel matrix is estimated, we can design F BB and W BB . Note that we do not directly estimate H. We only find the transmit beam and the receive beam best fit for the real channel matrix and then estimate the equivalent channel matrix [22].

C. Problem Formulation
Note that the codebook is made up of a number of codewords. Therefore, in this paper, we focus on the codeword design. All the codewords in the codebook can be designed based on this work. In this paper, two important issues on codeword design are to be considered. One issue is the design of ideal codewords without consideration of hardware constraints in terms of phase shifter resolution and the number of RF chains. The other issue is the design of practical codewords based on the ideal codeword regarding the hardware constraint.
As in [11] and [15], the design of an ideal codeword v ∈ C Nt with v 2 = 1 commonly considers the following two objectives: 1) If the steering vector a(N t , Ω) is covered by v, the absolute beam gain along the direction of Ω is a constant. 2) If a(N t , Ω) is not covered by v, the beam gain is zero. The beam gain of v along Ω is denoted as a function of v and Ω as Then from the aforementioned two objectives, we have where the absolute beam gain C v is determined by v and is independent of Ω. This means that C v is the same for all possible Ω within the beam coverage Since it is impossible to find a codeword strictly satisfying (8), we can only design ideal codewords that approach (8) [23].
We will introduce additional phase to G(v, Ω) to provide additional degree of freedom for ideal codeword design.
Once the ideal codewords are obtained, we can design practical codewords considering the hardware constraints in terms of phase shifter resolution and the number of RF chains [24]- [26]. Given an ideal codeword v ∈ C Nt , the design of a practical codeword v p F RF f BB ∈ C Nt is essentially to find F RF and f BB , such that where the constraint of (9b) indicates that the hybrid precoder provide no power gain, and the constraint of (9c) indicates each entry of the analog precoder satisfies the hardware restrictions of the phase shifters. If there are b bits for quantized phase shifters, then (10) In the following, we will propose a two-step codeword design approach for mmWave massive MIMO, which first designs ideal codewords regardless of hardware constraints and then designs practical codewords based on the ideal ones taking the hardware constraints into consideration.

III. IDEAL CODEWORD DESIGN
In this section, as the first step of the two-step codeword design approach, we propose a phase-shifted ideal codeword design (PS-ICD) method. Additional phase is introduced to the beam gain to provide extra degree of freedom for ideal codeword design. To determine the additional phase, an alternative minimization method is used, where each iteration of the method is based on a closed-form solution we derive. The proposed PS-ICD can also be extended to design more general beamforming vectors with different beam patterns.
According to (8), the beam coverage of an ideal codeword where we may temporarily omit the power constraint of v 2 = 1 and assume C v = 1. Then (8) can be simplified as Denote where g(Ω) = |G(v, Ω)| and f (Ω) = ∠G(v, Ω) are both functions of Ω. From (11), we have Note that the condition in (11) has nothing to do with the phase f (Ω). Therefore, in our PS-ICD method, we introduce additional phase to increase the degree of freedom.
We define as a matrix made up of K(K ≥ N t ) channel steering vectors, where is the quantized channel AoD with equal interval. Note that the rank of A is N t .
To clearly represent G(v, Ω k ), for k = 1, 2, . . . , K, we define a vector g ∈ C K , with The objective of the ideal codeword design is where . . , f (Ω K )] T . Given g,v can be obtained by LS asv Direct calculation from (14) yields AA H = KI Nt . Thenv in (18) can be simplified aŝ The objective in (17) can be converted to Note that Since g 2 2 is predefined, we can further convert (20) to max From (22), only the phases of g are involved. Without the constraint of (13), the solution of (22) is the eigenvector corresponding to the largest eigenvalue of A. However, it is difficult to solve (22) with the constraint of (13).
Since the phases of g are mutually independent, we can use the alternative minimization method to iteratively optimize each phase variable [24], [26]. To be specific, we alternatively optimize where are independent of α and β, and are fixed once As a result, the closed-form solution for (27) can be expressed as We can obtain [Ω] k as Based on the steps from (23) to (29), we iteratively optimize The stop condition is that the number of iterations equals a predefined maximum number of iterations R max 1 . We denoteΩ as the optimized Ω after finishing the R max iterations. We can obtainĝ via (16) and then obtainv via (19). Since the power constraint of v 2 = 1 is temporarily omitted in (11), the designed ideal codeword will be v =v v 2 . 1 Note that the ideal codeword design problem can also be treated as the design of FIR filter without special specifications [27], which essentially solves a series of convex optimization problems. Since our PS-ICD scheme has close-form solutions, it is much faster than solving convex optimization problems. Obtain k = mod (i − 1, K) + 1.
As shown in Algorithm 1, we summarize the steps of PS-ICD algorithm.
In fact, this part of work can be extended to design more general beamforming vectors with various beam patterns, which may be applied for beam training [21]. Given a beam pattern g(Ω), the beamforming vector can be designed via (30) with g obtained via alternative minimization algorithm. In Section V, we will provide two examples to design general beamforming vectors, e.g., triangular beamforming vector and step beamforming vector.

IV. PRACTICAL CODEWORD DESIGN
In this section, we will design practical codewords based on the ideal ones designed in Section III, by considering the hardware constraints in terms of phase shifter resolution and the number of RF chains. We will propose a fast search based alternative minimization (FS-AltMin) algorithm for the practical codeword design. [24], [25] In practice, we usually design F RF first, based on which we then design f BB [15] [24]. Therefore, we may temporarily ignore (9b) to design F RF since we can always satisfy (9b) by carefully adjusting f BB . Then we have n = 1, 2, . . . , N t , i = 1, 2, . . . , N RF .
Although the OMP algorithm can be used to solve (31) and obtain a well fit for v, it requires a large number of RF chains [15], [25], which occupies large hardware resource and reduce the energy efficiency. In this paper, we focus on how to solve (31) with a small number of RF chains compared to the OMP algorithm. In the case of N RF = 1, we can simply set f BB = 1/ √ N t to normalize the power and set [ F RF ] n = e j[ θ]n where [ θ] n = arg min [θ]n∈Φ b ,n=1,2,··· ,Nt Note that F RF is essentially reduced to be a vector in dimension, since there is only one RF chain. The entries of F RF are mutually independent, indicating that there are limited degrees of freedom that can be explored for pracitcal codeword design.
In the case of N RF ≥ 2, since both f BB and F RF need to be designed, the problem in (31) can be solved by an alternative minimization method, which can minimize (31a) by designing f BB with a fixed F RF and then designing F RF with a fixed f BB [24], [26].

A. Initialization
First of all, an initial value is required to start the alternative minimization method. We may initialize either F RF or f BB . Note that there are hardware constraints for F RF while there is no constraint for f BB . We can initialize each entry of F RF by randomly selecting an entry from Φ b .
B. Design of f BB with a fixed F RF Given a fixed F RF , the problem in (31) can be converted to min It is a typical least squares problem with the solution expressed as C. Design of F RF with a fixed f BB Given a fixed f BB obtained via (34), we can focus on the discrete optimization in terms of the quantized phase shifters. Then (31) is converted into It is observed that the entries of the vector (v − F RF f BB ) are mutually independent, because the entries of F RF are independent to each other. Therefore, the minimization of v − F RF f BB 2 can be converted to the minimization of the absolute value of each entry of (v − F RF f BB ). Then (35) can be converted to N t subproblems, where the n(n = 1, 2, . . . , N t )th subproblem can be expressed as min [F RF ]n,: where α n ∈ [0, v max ] and β n ∈ [−π, π) are the amplitude and the phase of [v] n , respectively. Since the method to solve (36) is exactly the same for different n, we can omit the subscript n and define e jθi [F RF ] n,i . Then (36) can be rewritten as min θ1,θ2,...,θ N RF To solve (38), we consider two different cases, N RF = 2 and N RF > 2.
If we consider the constrains of θ 1 , θ 2 ∈ Φ b , then we can design θ 1 and θ 2 as which is essentially to find two entries from Φ b closest toθ 1 andθ 2 , respectively.
2) N RF > 2: In case of N RF > 2, there are more than two variables in (38). If we first ignore the constraints in (38b) to solve (38a), just as the case of N RF = 2, the problem will be underdetermined, where there are more unknown variables than the equations. Although the method in [24] can be used to solve the problem without the constraint in (38b), it can only obtain a solution with continuous phase. When the solution is directly quantized, it suffers from the quantization errors. Motivated by the case of N RF = 2, we incorporate the calculation of (45) into the case of N RF > 2 and rewrite (38) as min θ1,θ2,...,θ N RF γ n e jφn − ζ 1 e jψ1 e jθ1 − ζ 2 e jψ2 e jθ2 where γ n e jφn α n e jβn − NRF i=3 with γ n and φ n representing the amplitude and the phase, respectively.
Given θ 3 , . . . , θ NRF , e.g., selecting any N RF −2 entries from Φ b asθ 3 , . . . ,θ NRF , we can find θ 1 , θ 2 ∈ Φ b by min θ1,θ2∈Φ b γ n e jφn − ζ 1 e jψ1 e jθ1 − ζ 2 e jψ2 e jθ2 (48) whereγ n e jφn α n e jβn − NRF i=3 [f BB ] i e jθi , using the method as in the case of N RF = 2. Our motivation is that we always leave two degrees of freedom such as θ 1 and θ 2 , to best match the given θ 3 , . . . , θ NRF by solving (48). Denote the solution of (48) asθ 1 ,θ 2 . With the givenθ 3 , . . . ,θ NRF and the computedθ 1 ,θ 2 in (48), we can compute the following objective as From the above discussion, θ 1 and θ 2 can be computed for given θ 3 , . . . , θ NRF . Now (46) can be converted into the following optimization problem as min θ3,...,θ N RF where θ 1 and θ 2 can be determined with the given θ 3 , . . . , θ NRF via (48). To obtain the solution to (50), one straightforward method is the exhaustive search, which tests all the combinations of θ 3 , . . . , θ NRF and select the one with the minimum objective. Since each θ i , i = 3, . . . , N RF has 2 b possibilities, the exhaustive search needs totally 2 (NRF−2)b tests to obtain the solution to (50). For example, if N RF = 6 and b = 6, we need totally 2 24 tests, which has prohibitively high computation. In this context, sub-optimal search methods are usually adopted to find an appropriate solution to (50). Now we propose a fast search (FS) method for the design of F RF based on f BB . The detailed steps are summarized in Algorithm 1. At step 8, we initialize θ 3 , . . . , θ NRF to be θ 0 3 , . . . , θ 0 NRF , where the superscript "0" represents the number of iterations. In fact, θ 0 3 , . . . , θ 0 NRF can be set as the corresponding entries of the last computed F RF to guarantee the objective of (31) is always decreasing.
At the t(t ≥ 1)th iteration, we determine the value of θ p (p = 3, . . . N RF ) as follows, where Note that (51) essentially guarantees that the N RF −2 variables are computed cyclically. We keep all the entries except θ (t) p to be the same as those in the (t − 1)th iteration, which can be expressed as Then given these N RF −3 entries, we test all entries from Φ b to determine θ (t) p . For each test, given an entry from Φ b , denoted asθ p ∈ Φ b , we obtainθ 1 andθ 2 via (48) and then compute E(θ 1 ,θ 2 , θ   t ← t + 1.
The solution to (53) is denoted as θ (t) p . We iteratively perform these steps until the stop condition expressed as is satisfied. In fact, (54) means the exactly same routine of the iterations is repeated again, which indicates the results thereafter will keep the same. Once is (54) satisfied, we obtain Then the n(n = 1, 2, . . . , N t )th row of the designed F RF is F RF as [ F RF ] n,: = e j θ1 , e j θ2 , . . . , e j θ N RF .
Finally, we output F RF .

D. Design of practical codeword
Now we propose the FS-AltMin algorithm for practical codeword design. Note that the purpose to introduce the name of practical codeword is to be consistent with the ideal codeword in concept. Algorithm 2 summarizes the Subsection IV-A, Subsection IV-B and Subsection IV-C. We iteratively run the algorithms in Section IV-B and Section IV-C to obtain f BB and F RF until the stop condition is satisfied. We may set the stop condition as that a predefined maximum number of iterations T max is achieved or the entries in f BB do not change any more.
We denote the obtained F RF and f BB by the FS-AltMin algorithm as F RF and f BB , respectively. Note that in (31) we have temporarily ignored the power normalization constraint to simplify the practical codeword design. If the power normalization constraint in (9b) is considered, we set Finally, the designed practical codeword is Obtainf BB via (34). 6: ObtainF RF via Algorithm 1. 7: end while 8: Obtain v p via (58). 9: Output: v p .

E. Complexity Analysis
It can be observed that the FS-AltMin algorithm needs at most T max iterations. During each iteration, N t subproblems expressed in (38) need to be solved. For each subproblem, we consider two cases. If N RF = 2, we can get a solution directly via (45) without any iterations. If N RF > 2, we denote the number of iterations to achieve the convergence in (54) as N iter , where we need to compute (49) for 2 b times in each iteration. Therefore, the computational complexity in solving

V. SIMULATION RESULTS
Now we evaluate the performance of the proposed twostep codeword design approach for mmWave massive MIMO systems with quantized phase shifters. The ideal codewords are designed with K = 128 and R max = 2000. Fig. 3 compares the beam patterns of ideal codewords designed by PS-ICD, BMW-SS [17] and LS-ICD [15] with N t = 32 and I v = [−1, 0]. From the figure, PS-ICD is better than BMW-SS and LS-ICD since the codeword designed by PS-ICD is flatter in main lobe and has larger attenuation in side lobe. Table I compares the main lobe variation for different ideal codewords design methods by computing meansquared errors (MSE) between the designed codewords and the objective in (8). C v = √ 2 is set to guarantee that the power of codewords is normalized, which can be obtained from Lemma 1 of [11]. From the table, for different N t , PS-ICD has the smallest variation among the three methods. Fig. 4 extends our work to design more general beamforming vectors such as triangular beam and step beam with N t = 32. Since BMW-SS can not be used to design general beamforming vectors, we compare the beam patterns generated by PS-ICD and LS-ICD. Given the objective beam pattern, e.g., triangular beam or step beam, PS-ICD can better approach the objective beam than LS-ICD. Note that the triangular beam or step beam can be used for beam training by exploiting the overlapped beam patterns of neighbouring beams [21]. Fig. 5 compares the beam patterns of practical codewords designed by FS-AltMin, OMP [11] and OMP [15]. To highlight the difference, we only illustrate the main lobe of codewords in Fig. 5. Since PS-ICD performs best among the ideal codeword design methods, we first generate ideal codewords using PS-ICD, where we set the parameters the
Note that compared to FS-AltMin, OMP [15] employs almost four times of the number of RF chains, which implies that FS-AltMin can save large hardware resource aside of generating better beam pattern. As shown in Fig. 6, we compare the deviation between the designed practical codewords and the ideal codeword with different numbers of RF chains. Since PS-ICD has the best performance for ideal codeword design, an ideal codeword v is generated using PS-ICD, where we set the parameters the same as those of Fig. 3, i.e., N t = 32 and I v = [−1, 0]. Then we design a practical codeword v p with FS-AltMin, OMP [11] and OMP [15]. We define to indicate the deviation between the ideal codeword v and the practical codeword v p . We set b = 6 the same for FS-AltMin, OMP [11] and OMP [15]. In addition, we set T max = 50 for FS-AltMin. From Fig. 6, it is seen that FS-AltMin performs much better than OMP [11] and OMP [15], which means with the same number of RF chains, the practical codeword designed by FS-AltMin has much smaller deviation than that designed by OMP [11] or OMP [15]. Fig. 7 compares the success rates of beam training using the hierarchical codebooks, where the codewords in these codebooks are designed by three methods. The first two methods are all based on two-step codewords design, where PS-ICD and LS-ICD marked in the parenthesis in Fig. 7 are used to design the ideal codewords. PS-ICD uses FS-AltMin to design the practical codewords with N RF = 4 while LS-ICD uses OMP [15] to design the practical codewords with N RF = 12. The last method is BMW-SS, which is designed using the overlapped adding of beams formed by sub-arrays and only considers the design of codewords. We set N r = 32, M = 2 and L = 1 and perform the beam training algorithm based on the hierarchical codebooks proposed in [15]. The definition of success rate is given in (5) and (6). In fact, the success rate in Fig. 7 is determined by the ideal codewords as well as the practical codeword design methods, while the   beam pattern in Fig. 5 is only determined by the practical codeword design methods. From Fig. 7, it is seen that the proposed two-step codeword design method outperforms the existing methods. At signal-to-nose ratio (SNR) of 0dB, the proposed method has nearly 15% improvement over BMW-SS. Note that the proposed method can be used to design codewords with arbitrary width of main lobe, which is different from BMW-SS.

VI. CONCLUSION
In this paper, we have investigated the codeword design for mmWave massive MIMO. A two-step codeword design approach has been developed. In the first step, additional phase is introduced to the beam gain to provide additional degree of freedom and the PS-ICD method has been proposed. To determine the additional phase, an alternative minimization method has been used, where each iteration of the method is based on a closed-form solution. The proposed PS-ICD can also be extended to design more general beamforming vectors with different beam patterns. Based on the ideal codewords designed in the first step, in the second step we have proposed a FS-AltMin algorithm that alternatively designs the analog precoder and digital precoder. In our future work, we will try incorporating some good merits of the FIR filter design, e.g. [27], into the beam design in mmWave massive MIMO.