OpenCores
URL https://opencores.org/ocsvn/dqpskmap/dqpskmap/trunk

Subversion Repositories dqpskmap

[/] [dqpskmap/] [trunk/] [rtl/] [diffPhaseEncoder.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
 
2
-- Copyright (c) 2013 Antonio de la Piedra
3
 
4
-- This program is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
 
9
-- This program is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
library IEEE;
18
use IEEE.STD_LOGIC_1164.ALL;
19
use IEEE.STD_LOGIC_ARITH.ALL;
20
use IEEE.STD_LOGIC_UNSIGNED.ALL;
21
 
22
entity diffPhaseEncoder is
23
        port(clk_18_KHz: in std_logic;
24
                  rst: in std_logic;
25
                  en: in std_logic;
26
                  a_k : in std_logic;
27
                  b_k : in std_logic;
28
                  i_k : out std_logic_vector(7 downto 0);
29
                  q_k : out std_logic_vector(7 downto 0));
30
end diffPhaseEncoder;
31
 
32
architecture Behavioral of diffPhaseEncoder is
33
 
34
                -- constellation values arranged as fixed point 8-bit, 6-bit fractional.
35
 
36
        constant c_minus_0_7 : std_logic_vector(7 downto 0) := "10100101";
37
        constant c_plus_0_7  : std_logic_vector(7 downto 0) := "01011011";
38
        constant c_plus_1    : std_logic_vector(7 downto 0) := "01111111";
39
        constant c_minus_1   : std_logic_vector(7 downto 0) := "10000000";
40
        constant c_plus_0      : std_logic_vector(7 downto 0) := "00000000";
41
 
42
        type state is (plus_0_plus_1,
43
                                   plus_0_7_plus_0_7,
44
                                        plus_1_plus_0,
45
                                        plus_0_7_minus_0_7,
46
                                        plus_0_minus_1,
47
                                        minus_0_7_minus_0_7,
48
                                        minus_1_plus_0,
49
                                        minus_0_7_plus_0_7);
50
 
51
        signal pr_state : state;
52
        signal nx_state : state;
53
 
54
begin
55
 
56
        fsm_seq: process(clk_18_KHz, rst)
57
        begin
58
 
59
                if falling_edge(clk_18_KHz)  then
60
                        if  rst = '1' then
61
                                pr_state <= plus_1_plus_0;
62
                        else
63
                                pr_state <= nx_state;
64
                        end if;
65
                end if;
66
        end process;
67
 
68
 
69
        fsm_comb: process(pr_state, a_k, b_k, en)
70
        begin
71
                case pr_state is
72
                        when plus_0_plus_1 =>
73
                                i_k <= c_plus_0;
74
                                q_k <= c_plus_1;
75
 
76
                                if en = '1' then
77
                                        if (a_k = '0' and b_k = '0') then
78
                                                nx_state <= minus_0_7_plus_0_7;
79
                                        elsif (a_k = '0' and b_k = '1') then
80
                                                nx_state <= minus_0_7_minus_0_7;
81
                                        elsif (a_k = '1' and b_k = '0') then
82
                                                nx_state <= plus_0_7_plus_0_7;
83
                                        else -- 1, 1
84
                                                nx_state <= plus_0_7_minus_0_7;
85
                                        end if;
86
                                else
87
                                        nx_state <= plus_0_plus_1;
88
                                end if;
89
 
90
                   when plus_0_7_plus_0_7 =>
91
                                i_k <= c_plus_0_7;
92
                                q_k <= c_plus_0_7;
93
 
94
                                if en = '1' then
95
                                        if (a_k = '0' and b_k = '0') then
96
                                                nx_state <= plus_0_plus_1;
97
                                        elsif (a_k = '0' and b_k = '1') then
98
                                                nx_state <= minus_1_plus_0;
99
                                        elsif (a_k = '1' and b_k = '0') then
100
                                                nx_state <= plus_1_plus_0;
101
                                        else -- 1, 1
102
                                                nx_state <= plus_0_minus_1;
103
                                        end if;
104
                                else
105
                                        nx_state <= plus_0_7_plus_0_7;
106
                                end if;
107
 
108
                   when plus_1_plus_0 =>
109
                                i_k <= c_plus_1;
110
                                q_k <= c_plus_0;
111
 
112
                                if en = '1' then
113
                                        if (a_k = '0' and b_k = '0') then
114
                                                nx_state <= plus_0_7_plus_0_7;
115
                                        elsif (a_k = '0' and b_k = '1') then
116
                                                nx_state <= minus_0_7_plus_0_7;
117
                                        elsif (a_k = '1' and b_k = '0') then
118
                                                nx_state <= plus_0_7_minus_0_7;
119
                                        else -- 1, 1
120
                                                nx_state <= minus_0_7_minus_0_7;
121
                                        end if;
122
                                else
123
                                        nx_state <= plus_1_plus_0;
124
                                end if;
125
 
126
                   when plus_0_7_minus_0_7 =>
127
                                i_k <= c_plus_0_7;
128
                                q_k <= c_minus_0_7;
129
 
130
                                if en = '1' then
131
                                        if (a_k = '0' and b_k = '0') then
132
                                                nx_state <= plus_1_plus_0;
133
                                        elsif (a_k = '0' and b_k = '1') then
134
                                                nx_state <= plus_0_plus_1;
135
                                        elsif (a_k = '1' and b_k = '0') then
136
                                                nx_state <= plus_0_minus_1;
137
                                        else -- 1, 1
138
                                                nx_state <= minus_1_plus_0;
139
                                        end if;
140
                                else
141
                                        nx_state <= plus_0_7_minus_0_7;
142
                                end if;
143
 
144
                        when plus_0_minus_1 =>
145
                                i_k <= c_plus_0;
146
                                q_k <= c_minus_1;
147
 
148
                                if en = '1' then
149
                                        if (a_k = '0' and b_k = '0') then
150
                                                nx_state <= plus_0_7_minus_0_7;
151
                                        elsif (a_k = '0' and b_k = '1') then
152
                                                nx_state <= plus_0_7_plus_0_7;
153
                                        elsif (a_k = '1' and b_k = '0') then
154
                                                nx_state <= minus_0_7_minus_0_7;
155
                                        else -- 1, 1
156
                                                nx_state <= minus_0_7_plus_0_7;
157
                                        end if;
158
                                else
159
                                        nx_state <= plus_0_minus_1;
160
                                end if;
161
 
162
                        when minus_0_7_minus_0_7 =>
163
                                i_k <= c_minus_0_7;
164
                                q_k <= c_minus_0_7;
165
 
166
                                if en = '1' then
167
                                        if (a_k = '0' and b_k = '0') then
168
                                                nx_state <= plus_0_minus_1;
169
                                        elsif (a_k = '0' and b_k = '1') then
170
                                                nx_state <= plus_1_plus_0;
171
                                        elsif (a_k = '1' and b_k = '0') then
172
                                                nx_state <= minus_1_plus_0;
173
                                        else -- 1, 1
174
                                                nx_state <= plus_0_plus_1;
175
                                        end if;
176
                                else
177
                                        nx_state <= minus_0_7_minus_0_7;
178
                                end if;
179
 
180
                        when minus_1_plus_0 =>
181
                                i_k <= c_minus_1;
182
                                q_k <= c_plus_0;
183
 
184
                                if en = '1' then
185
                                        if (a_k = '0' and b_k = '0') then
186
                                                nx_state <= minus_0_7_minus_0_7;
187
                                        elsif (a_k = '0' and b_k = '1') then
188
                                                nx_state <= plus_0_7_minus_0_7;
189
                                        elsif (a_k = '1' and b_k = '0') then
190
                                                nx_state <= minus_0_7_plus_0_7;
191
                                        else -- 1, 1
192
                                                nx_state <= plus_0_7_plus_0_7;
193
                                        end if;
194
                                else
195
                                        nx_state <= minus_1_plus_0;
196
                                end if;
197
 
198
                        when minus_0_7_plus_0_7 =>
199
                                i_k <= c_minus_0_7;
200
                                q_k <= c_plus_0_7;
201
 
202
                                if en = '1' then
203
                                        if (a_k = '0' and b_k = '0') then
204
                                                nx_state <= minus_1_plus_0;
205
                                        elsif (a_k = '0' and b_k = '1') then
206
                                                nx_state <= plus_0_minus_1;
207
                                        elsif (a_k = '1' and b_k = '0') then
208
                                                nx_state <= plus_0_plus_1;
209
                                        else -- 1, 1
210
                                                nx_state <= plus_1_plus_0;
211
                                        end if;
212
                                else
213
                                        nx_state <= minus_0_7_plus_0_7;
214
                                end if;
215
 
216
                end case;
217
        end process;
218
 
219
 
220
end Behavioral;
221
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.