1 |
2 |
zguig52 |
-------------------------------
|
2 |
|
|
---- Project: EurySPACE CCSDS RX/TX with wishbone interface
|
3 |
|
|
---- Design Name: ccsds_rxtx_oversampler
|
4 |
|
|
---- Version: 1.0.0
|
5 |
|
|
---- Description:
|
6 |
|
|
---- Insert OSR-1 '0' between symbols
|
7 |
|
|
-------------------------------
|
8 |
|
|
---- Author(s):
|
9 |
|
|
---- Guillaume REMBERT
|
10 |
|
|
-------------------------------
|
11 |
|
|
---- Licence:
|
12 |
|
|
---- MIT
|
13 |
|
|
-------------------------------
|
14 |
|
|
---- Changes list:
|
15 |
|
|
---- 2016/11/06: initial release
|
16 |
|
|
-------------------------------
|
17 |
|
|
|
18 |
|
|
-- libraries used
|
19 |
|
|
library ieee;
|
20 |
|
|
use ieee.std_logic_1164.all;
|
21 |
|
|
|
22 |
|
|
--=============================================================================
|
23 |
|
|
-- Entity declaration for ccsds_tx / unitary rxtx oversampler inputs and outputs
|
24 |
|
|
--=============================================================================
|
25 |
|
|
entity ccsds_rxtx_oversampler is
|
26 |
|
|
generic(
|
27 |
|
|
constant CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO: integer := 4;
|
28 |
|
|
constant CCSDS_RXTX_OVERSAMPLER_SYMBOL_DEPHASING: boolean := false;
|
29 |
|
|
constant CCSDS_RXTX_OVERSAMPLER_SIG_QUANT_DEPTH: integer
|
30 |
|
|
);
|
31 |
|
|
port(
|
32 |
|
|
-- inputs
|
33 |
|
|
clk_i: in std_logic;
|
34 |
|
|
rst_i: in std_logic;
|
35 |
|
|
sam_i: in std_logic_vector(CCSDS_RXTX_OVERSAMPLER_SIG_QUANT_DEPTH-1 downto 0);
|
36 |
|
|
sam_val_i: in std_logic;
|
37 |
|
|
-- outputs
|
38 |
|
|
sam_o: out std_logic_vector(CCSDS_RXTX_OVERSAMPLER_SIG_QUANT_DEPTH-1 downto 0);
|
39 |
|
|
sam_val_o: out std_logic
|
40 |
|
|
);
|
41 |
|
|
end ccsds_rxtx_oversampler;
|
42 |
|
|
|
43 |
|
|
--=============================================================================
|
44 |
|
|
-- architecture declaration / internal components and connections
|
45 |
|
|
--=============================================================================
|
46 |
|
|
architecture structure of ccsds_rxtx_oversampler is
|
47 |
|
|
-- internal constants
|
48 |
|
|
-- internal variable signals
|
49 |
|
|
-- components instanciation and mapping
|
50 |
|
|
begin
|
51 |
|
|
-- presynthesis checks
|
52 |
|
|
CHKOVERSAMPLERP0 : if (CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO mod 2 /= 0) generate
|
53 |
|
|
process
|
54 |
|
|
begin
|
55 |
|
|
report "ERROR: OVERSAMPLING RATIO HAS TO BE A MULTIPLE OF 2" severity failure;
|
56 |
|
|
wait;
|
57 |
|
|
end process;
|
58 |
|
|
end generate CHKOVERSAMPLERP0;
|
59 |
|
|
CHKOVERSAMPLERP1 : if (CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO = 0) generate
|
60 |
|
|
process
|
61 |
|
|
begin
|
62 |
|
|
report "ERROR: OVERSAMPLING RATIO CANNOT BE 0" severity failure;
|
63 |
|
|
wait;
|
64 |
|
|
end process;
|
65 |
|
|
end generate CHKOVERSAMPLERP1;
|
66 |
|
|
-- internal processing
|
67 |
|
|
--=============================================================================
|
68 |
|
|
-- Begin of osrp
|
69 |
|
|
-- Insert all 0 samples
|
70 |
|
|
--=============================================================================
|
71 |
|
|
-- read: rst_i, sam_i
|
72 |
|
|
-- write: sam_o
|
73 |
|
|
-- r/w:
|
74 |
|
|
OSRP: process (clk_i)
|
75 |
|
|
variable samples_counter: integer range 0 to CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO-1 := CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO-1;
|
76 |
|
|
begin
|
77 |
|
|
-- on each clock rising edge
|
78 |
|
|
if rising_edge(clk_i) then
|
79 |
|
|
-- reset signal received
|
80 |
|
|
if (rst_i = '1') then
|
81 |
|
|
sam_o <= (others => '0');
|
82 |
|
|
samples_counter := CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO-1;
|
83 |
|
|
else
|
84 |
|
|
if (sam_val_i = '1') then
|
85 |
|
|
sam_val_o <= '1';
|
86 |
|
|
if (CCSDS_RXTX_OVERSAMPLER_SYMBOL_DEPHASING = true) then
|
87 |
|
|
if (samples_counter <= 0) then
|
88 |
|
|
sam_o <= (others => '0');
|
89 |
|
|
samples_counter := CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO-1;
|
90 |
|
|
else
|
91 |
|
|
if (samples_counter = CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO/2) then
|
92 |
|
|
sam_o <= sam_i;
|
93 |
|
|
else
|
94 |
|
|
sam_o <= (others => '0');
|
95 |
|
|
end if;
|
96 |
|
|
samples_counter := samples_counter - 1;
|
97 |
|
|
end if;
|
98 |
|
|
else
|
99 |
|
|
if (samples_counter <= 0) then
|
100 |
|
|
sam_o <= sam_i;
|
101 |
|
|
samples_counter := CCSDS_RXTX_OVERSAMPLER_OVERSAMPLING_RATIO-1;
|
102 |
|
|
else
|
103 |
|
|
sam_o <= (others => '0');
|
104 |
|
|
samples_counter := samples_counter - 1;
|
105 |
|
|
end if;
|
106 |
|
|
end if;
|
107 |
|
|
else
|
108 |
|
|
sam_val_o <= '0';
|
109 |
|
|
end if;
|
110 |
|
|
end if;
|
111 |
|
|
end if;
|
112 |
|
|
end process;
|
113 |
|
|
end structure;
|