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

Subversion Repositories bpsk_spread_spectrum_modulator_demodulator

[/] [bpsk_spread_spectrum_modulator_demodulator/] [trunk/] [spread_bpsk.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 aTomek1328
-------------------------------------------------------------------------------
2
-- Title      : Spread using spreading sequence based on BPSK constelation.
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : spread_bpsk.vhd
6
-- Author     : Tomasz Turek  <tomasz.turek@gmail.com>
7
-- Company    : SzuWar INC
8
-- Created    : 21:37:13 20-03-2010
9
-- Last update: 09:03:26 11-05-2010
10
-- Platform   : Xilinx ISE 10.1.03
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: 
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2010 SzuWar INC
16
-------------------------------------------------------------------------------
17
-- Revisions  :
18
-- Date                  Version  Author  Description
19
-- 21:37:13 20-03-2010   1.0      szuwarek  Created
20
-------------------------------------------------------------------------------
21
 
22
library IEEE;
23
use IEEE.STD_LOGIC_1164.ALL;
24
use ieee.std_logic_arith.all;
25
use IEEE.STD_LOGIC_UNSIGNED.all;
26
 
27
Library UNISIM;
28
use UNISIM.vcomponents.all;
29
 
30
entity spread_bpsk is
31
 
32
   generic (
33
         iDataWidith        : integer range 1 to 16  := 2;
34
         iSingleValueSpread : integer range 2 to 255 := 17;
35
         iTrigerType        : integer range 0 to 2   := 2
36
         );
37
 
38
   port (
39
         CLK_I             : in  std_logic;
40
         RESET_I           : in  std_logic;
41
         DATA_I            : in  std_logic_vector(iDataWidith - 1 downto 0);
42
         DATA_VALID_I      : in  std_logic;
43
         TRIGER_I          : in  std_logic;
44
         SPREAD_SEQUENCE_I : in  std_logic_vector(iSingleValueSpread - 1 downto 0);
45
         DATA_O            : out std_logic_vector(iDataWidith - 1 downto 0);
46
         DATA_VALID_O      : out std_logic;
47
         READY_FOR_DATA_O  : out std_logic
48
         );
49
 
50
end entity spread_bpsk;
51
 
52
architecture rtl of spread_bpsk is
53
 
54
-------------------------------------------------------------------------------
55
-- signals --
56
-------------------------------------------------------------------------------
57
   signal fifo_ce               : std_logic;
58
   signal fifo_read             : std_logic;
59
   signal FF_fifo_read          : std_logic;
60
   signal fifo_empty            : std_logic;
61
   signal rfd                   : std_logic;
62
   signal data_processing       : std_logic;
63
   signal v_data_processing     : std_logic_vector(1 downto 0);
64
   signal spread_triger         : std_logic;
65
   signal v_fifo_data           : std_logic_vector(iDataWidith - 1 downto 0);
66
   signal v_data_in             : std_logic_vector(iDataWidith - 1 downto 0);
67
   signal v_fifo_data_spread    : std_logic_vector(iDataWidith - 1 downto 0);
68
   signal v_spread_count        : std_logic_vector(7 downto 0);
69
   signal v_delay_counter       : std_logic_vector(3 downto 0) := x"0";
70
   signal i_delay_counter       : integer range 0 to 16 := 0;
71
 
72
begin  -- architecture rtl
73
 
74
-------------------------------------------------------------------------------
75
-- FIFO IN --
76
-------------------------------------------------------------------------------
77
 
78
   rfd                  <= '1' when v_delay_counter < x"f" else '0';
79
   READY_FOR_DATA_O     <= rfd;
80
   fifo_empty           <= '1' when i_delay_counter = 0 else '0';
81
   fifo_ce              <= '1' when (DATA_VALID_I = '1') and (fifo_read = '1') else
82
                           DATA_VALID_I and rfd ;
83
 
84
   DATA_VALID_O         <= v_data_processing(0);
85
   v_data_in            <= DATA_I when fifo_ce = '1' else
86
                           (others => 'Z');
87
 
88
   G0: for i in 0 to (iDataWidith - 1) generate
89
 
90
      FIFO_IN :
91
         SRLC16E
92
            port map
93
            (
94
                  Q => v_fifo_data(i), -- SRL data output
95
                  A0 => v_delay_counter(0), -- Select[0] input
96
                  A1 => v_delay_counter(1), -- Select[1] input
97
                  A2 => v_delay_counter(2), -- Select[2] input
98
                  A3 => v_delay_counter(3), -- Select[3] input
99
                  CE => fifo_ce, -- Clock enable input
100
                  CLK => CLK_I, -- Clock input
101
                  D => v_data_in(i) -- SRL data input
102
                  );
103
 
104
   end generate G0;
105
 
106
   P0: process (CLK_I) is
107
   begin  -- process P0
108
 
109
      if rising_edge(CLK_I) then
110
 
111
         if RESET_I = '1' then
112
 
113
            i_delay_counter <= 0;
114
            v_delay_counter <= x"0";
115
 
116
         else
117
 
118
            if (DATA_VALID_I = '1') and (fifo_read = '0') and (rfd = '1') then
119
 
120
               if i_delay_counter < 1 then
121
 
122
                  i_delay_counter <= i_delay_counter + 1;
123
                  v_delay_counter <= x"0";
124
 
125
               else
126
 
127
                  i_delay_counter <= i_delay_counter + 1;
128
                  v_delay_counter <= v_delay_counter + 1;
129
 
130
               end if;
131
 
132
            elsif (DATA_VALID_I = '0') and (fifo_read = '1') and (fifo_empty = '0') then
133
 
134
               if ((i_delay_counter < 2) and (i_delay_counter > 0)) then
135
 
136
                  i_delay_counter <= i_delay_counter - 1;
137
                  v_delay_counter <= x"0";
138
 
139
               else
140
 
141
                  i_delay_counter <= i_delay_counter - 1;
142
                  v_delay_counter <= v_delay_counter - 1;
143
 
144
               end if;
145
 
146
            else
147
 
148
               i_delay_counter <= i_delay_counter;
149
               v_delay_counter <= v_delay_counter;
150
 
151
            end if;
152
 
153
         end if;
154
 
155
      end if;
156
 
157
   end process P0;
158
 
159
-------------------------------------------------------------------------------
160
-- FIFO IN --
161
-------------------------------------------------------------------------------
162
 
163
-------------------------------------------------------------------------------
164
-- Triger --
165
-------------------------------------------------------------------------------
166
   P1: process (CLK_I) is
167
   begin  -- process P1
168
 
169
      if rising_edge(CLK_I) then
170
 
171
         if RESET_I = '1' then
172
 
173
 
174
         else
175
 
176
            if iTrigerType = 0 then     -- ce
177
 
178
               triger <= TRIGER_I;
179
 
180
            end if;
181
 
182
 
183
         end if;
184
 
185
      end if;
186
 
187
   end process P1;
188
 
189
-------------------------------------------------------------------------------
190
-- Triger --
191
-------------------------------------------------------------------------------
192
 
193
-------------------------------------------------------------------------------
194
-- SPREAD --
195
-------------------------------------------------------------------------------
196
   P2: process (CLK_I) is
197
   begin  -- process P2
198
 
199
      if rising_edge(CLK_I) then
200
 
201
         if RESET_I = '1' then
202
 
203
            data_processing     <= '0';
204
            v_data_processing   <= "00";
205
            fifo_read           <= '0';
206
            FF_fifo_read        <= '0';
207
            DATA_O              <= (others => '0');
208
            v_spread_count      <= (others => '0');
209
            v_fifo_data_spread  <= (others => '0');
210
 
211
         else
212
 
213
            v_data_processing           <= v_data_processing(0) & data_processing;
214
            FF_fifo_read                <= fifo_read;
215
 
216
            if ((fifo_empty = '0') and (data_processing = '0')) then
217
 
218
               data_processing          <= '1';
219
               fifo_read                <= '1';
220
               v_spread_count           <= (others => '0');
221
               v_fifo_data_spread       <= v_fifo_data;
222
 
223
            else
224
 
225
               if v_spread_count = conv_std_logic_vector(iSingleValueSpread - 1 , 8) then
226
 
227
                  v_spread_count        <= v_spread_count;
228
 
229
                  data_procesing        <= '0';
230
 
231
               else
232
 
233
                  v_spread_count        <= v_spread_count + 1;
234
 
235
               end if;
236
 
237
               fifo_read                <= '0';
238
 
239
               for i in 0 to iDataWidith - 1 loop
240
 
241
                  if v_fifo_data_spread(i) = '1' then
242
 
243
                     DATA_O(i)          <= SPREAD_SEQUENCE_I(conv_integer(v_spread_count));
244
 
245
                  elsif v_fifo_data_spread(i) = '0' then
246
 
247
                     DATA_O(i)          <= not SPREAD_SEQUENCE_I(conv_integer(v_spread_count));
248
 
249
                  end if;
250
 
251
               end loop;  -- i
252
 
253
            end if;
254
 
255
         end if;
256
 
257
      end if;
258
 
259
   end process P2;
260
 
261
-------------------------------------------------------------------------------
262
-- SPREAD --
263
-------------------------------------------------------------------------------
264
 
265
end architecture rtl;

powered by: WebSVN 2.1.0

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