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

Subversion Repositories astron_sim_transceiver

[/] [astron_sim_transceiver/] [trunk/] [sim_transceiver_deserializer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright 2020
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18
--
19
-------------------------------------------------------------------------------
20
 
21
-- Author:
22
-- . Daniel van der Schuur
23
-- Purpose:
24
--   Basic deserializer model for fast transceiver simulation
25
-- Description:
26
--   See sim_transceiver_serializer.vhd 
27
-- Remarks:
28
 
29
 
30
LIBRARY IEEE, common_pkg_lib;
31
USE IEEE.std_logic_1164.ALL;
32
USE common_pkg_lib.common_pkg.ALL;
33
 
34
ENTITY sim_transceiver_deserializer IS
35
  GENERIC(
36
    g_data_w         : NATURAL := 32;
37
    g_tr_clk_period  : TIME := 6.4 ns
38
  );
39
  PORT(
40
    tb_end        : IN  STD_LOGIC := '0';
41
 
42
    tr_clk        : IN  STD_LOGIC;
43
    tr_rst        : IN  STD_LOGIC;
44
 
45
    rx_out_data   : OUT STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
46
    rx_out_ctrl   : OUT STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
47
    rx_out_sop    : OUT STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
48
    rx_out_eop    : OUT STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
49
 
50
    rx_serial_in  : IN  STD_LOGIC
51
  );
52
 
53
END sim_transceiver_deserializer;
54
 
55
 
56
ARCHITECTURE beh OF sim_transceiver_deserializer IS
57
 
58
  CONSTANT c_line_clk_period    : TIME    := g_tr_clk_period * 8 / 10 / g_data_w;
59
  CONSTANT c_nof_bytes_per_data : NATURAL := g_data_w/c_byte_w;
60
 
61
BEGIN
62
 
63
  p_deserialize: PROCESS
64
    VARIABLE v_rx_out_data : STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
65
    VARIABLE v_rx_out_ctrl : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
66
    VARIABLE v_rx_out_sop  : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
67
    VARIABLE v_rx_out_eop  : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
68
  BEGIN
69
    --rx_out_data <= (OTHERS=>'0');
70
    rx_out_ctrl <= (OTHERS=>'0');
71
    rx_out_sop  <= (OTHERS=>'0');
72
    rx_out_eop  <= (OTHERS=>'0');
73
 
74
    WAIT UNTIL tr_rst='0' ;
75
 
76
    -- Align to tr_clk
77
    WAIT UNTIL rising_edge(tr_clk);
78
 
79
    WHILE tb_end='0' LOOP
80
      -- Wait for half of a serial clk period so data is stable when sampling
81
      WAIT FOR c_line_clk_period/2;
82
 
83
      -- Data word deserialization cycle
84
      FOR byte IN 0 TO c_nof_bytes_per_data-1 LOOP
85
        -- Deserialize each data byte using 10 bits per byte from the line
86
        FOR bit IN 0 TO c_byte_w-1 LOOP
87
          v_rx_out_data(byte*c_byte_w+bit) := rx_serial_in;  -- Get the 8 data bits of the data byte from the line
88
          WAIT FOR c_line_clk_period;
89
        END LOOP;
90
        v_rx_out_ctrl(byte) := rx_serial_in;                 -- Get the 1 control bit from the line for each byte
91
        WAIT FOR c_line_clk_period;
92
        v_rx_out_sop(byte) := '0';                           -- Get the SOP/EOP (tenth) bit from the line
93
        v_rx_out_eop(byte) := '0';
94
        IF rx_serial_in='1' THEN
95
          v_rx_out_sop(byte) := '1';
96
        ELSIF rx_serial_in = 'U' THEN
97
          v_rx_out_eop(byte) := '1';
98
        END IF;
99
        IF byte<c_nof_bytes_per_data-1 THEN
100
          WAIT FOR c_line_clk_period;  -- exit loop in last half line clock cycle
101
        END IF;
102
      END LOOP;
103
 
104
      -- Realign to tr_clk rising edge
105
      WAIT UNTIL rising_edge(tr_clk);
106
 
107
      -- End of this deserialization cycle: the rx data word has been assembled.
108
      rx_out_data <= v_rx_out_data;
109
      rx_out_ctrl <= v_rx_out_ctrl;
110
      rx_out_sop  <= v_rx_out_sop;
111
      rx_out_eop  <= v_rx_out_eop;
112
    END LOOP;
113
 
114
  END PROCESS;
115
 
116
END beh;

powered by: WebSVN 2.1.0

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