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

Subversion Repositories astron_sim_transceiver

[/] [astron_sim_transceiver/] [trunk/] [sim_transceiver_serializer.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 serializer model for fast transceiver simulation
25
-- Description:
26
--   The model serializes parallel data using 10 serial bits per byte. The two 
27
--   extra bits are used to transfer control (valid, SOP/EOP).
28
--   The model can represent any real transceiver encoding scheme (10b/8b, 66b/64b) 
29
--   because the modelled line rate does not have to be the same as the true line rate.
30
--   The key feature that the model provides is that the parallel data gets
31
--   transported via a single 1-bit lane. This allows fast simulation of the 
32
--   link using the true port widths.
33
--   The most straightforward is to mimic 10/8 encoding for as far as data rates
34
--   and clock ratios are concerned (not the encoding itself):
35
--   * User data rate = (8/10)*line data rate
36
--   * User clock frequency = User data rate / user data width
37
--   * Serial data block size = 10 bits [9..0] LSb sent first
38
--     *  [9] = SOP/EOP; '1'=SOP;'U'=EOP.
39
--     *  [8] = Control bit.
40
--     *  [7..0] = Data
41
--   * Word/byte alignment is not required because reference clk and rst are
42
--     global in simulation: what gets transmitted first is received first.
43
--   
44
--  The following diagram shows the serialization of the 32-bit word 0x2. The
45
--  grid of dots indicates the bit resolution. Note the 1 serial cycle of delay
46
--  before the first bit is put on the line.
47
--
48
--               . _______________________________________ . . . . . . . . . . . . . . . . . . . . .
49
-- tr_clk        _|. . . . . . . . . . . . . . . . . . . .|_________________________________________
50
--               _ . . _ . . . . . . _ . . . . . . . . . _ . . . . . . . . . _ . . . . . . . . . _ .        
51
-- tx_serial_out .|___|.|___________|.|_________________|.|_________________|.|_________________|.|_
52
--              
53
--               c P 0 1 2 3 4 5 6 7 c P 0 1 2 3 4 5 6 7 c P 0 1 2 3 4 5 6 7 c P 0 1 2 3 4 5 6 7 c P
54
--                  |<----- Byte 0 ---->|<----- Byte 1 ---->|<----- Byte 2 ---->|<----- Byte 3 ---->|
55
--
56
-- Remarks:
57
-- . All serializers in the simualation should be simultaneously released from 
58
--   reset and have to share the same transceiver reference clock.
59
-- . The number of line clock cycles to transmit one data word fits within 1
60
--   tr_clk period. After every data word the data is realigned to the tr_clk.
61
 
62
 
63
LIBRARY IEEE, common_pkg_lib;
64
USE IEEE.std_logic_1164.ALL;
65
USE common_pkg_lib.common_pkg.ALL;
66
 
67
ENTITY sim_transceiver_serializer IS
68
  GENERIC(
69
    g_data_w         : NATURAL := 32;
70
    g_tr_clk_period  : TIME := 6.4 ns
71
  );
72
  PORT(
73
    tb_end        : IN  STD_LOGIC := '0';
74
 
75
    tr_clk        : IN  STD_LOGIC;
76
    tr_rst        : IN  STD_LOGIC;
77
 
78
    tx_in_data    : IN  STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
79
    tx_in_ctrl    : IN  STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0); -- 1 valid bit per byte
80
    tx_in_sop     : IN  STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0) := (OTHERS=>'0'); -- 1 SOP   bit per byte
81
    tx_in_eop     : IN  STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0) := (OTHERS=>'0'); -- 1 EOP   bit per byte
82
 
83
    tx_serial_out : OUT STD_LOGIC
84
  );
85
 
86
END sim_transceiver_serializer;
87
 
88
 
89
ARCHITECTURE beh OF sim_transceiver_serializer IS
90
 
91
  CONSTANT c_line_clk_period   : TIME    := g_tr_clk_period * 8 / 10 / g_data_w;
92
  CONSTANT c_tr_clk_period_sim : TIME    := c_line_clk_period * g_data_w * 10 / 8;
93
 
94
  CONSTANT c_nof_bytes_per_data : NATURAL := g_data_w / c_byte_w;
95
 
96
BEGIN
97
 
98
  p_serialize: PROCESS
99
    VARIABLE v_tx_in_data : STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
100
    VARIABLE v_tx_in_ctrl : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
101
    VARIABLE v_tx_in_sop  : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
102
    VARIABLE v_tx_in_eop  : STD_LOGIC_VECTOR(g_data_w/c_byte_w-1 DOWNTO 0);
103
  BEGIN
104
    tx_serial_out <= '0';
105
    WAIT UNTIL tr_rst='0';
106
 
107
    -- Align to tr_clk
108
    WAIT UNTIL rising_edge(tr_clk);
109
    v_tx_in_data := tx_in_data;
110
    v_tx_in_ctrl := tx_in_ctrl;
111
    v_tx_in_sop  := tx_in_sop;
112
    v_tx_in_eop  := tx_in_eop;
113
 
114
    WHILE tb_end='0' LOOP
115
      -- Data word serialization cycle
116
      FOR byte IN 0 TO c_nof_bytes_per_data-1 LOOP
117
        -- Serialize each data byte using 10 bits per byte on the line
118
        FOR bit IN 0 TO c_byte_w-1 LOOP
119
          tx_serial_out <= v_tx_in_data(byte*c_byte_w+bit);   -- Put the 8 data bits of the data byte on the line
120
          WAIT FOR c_line_clk_period;
121
        END LOOP;
122
        tx_serial_out <= v_tx_in_ctrl(byte);                  -- Put the valid bit on the line for each byte
123
        WAIT FOR c_line_clk_period;
124
        tx_serial_out <= '0';                                 -- Put the SOP/EOP indicator bit on the line. '1'=SOP; 'U'=EOP.
125
        IF v_tx_in_sop(byte) = '1' THEN
126
          tx_serial_out <= '1';
127
        ELSIF v_tx_in_eop(byte)='1' THEN
128
          tx_serial_out <= 'U';
129
        END IF;
130
        IF byte<c_nof_bytes_per_data-1 THEN
131
          WAIT FOR c_line_clk_period;  -- exit loop in last line clock cycle
132
        END IF;
133
      END LOOP;
134
 
135
      -- Realign to tr_clk rising edge if necessary
136
      WAIT UNTIL rising_edge(tr_clk);
137
 
138
      v_tx_in_data := tx_in_data;
139
      v_tx_in_ctrl := tx_in_ctrl;
140
      v_tx_in_sop  := tx_in_sop;
141
      v_tx_in_eop  := tx_in_eop;
142
 
143
    END LOOP;
144
 
145
  END PROCESS;
146
 
147
END beh;

powered by: WebSVN 2.1.0

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