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

Subversion Repositories hdlc

[/] [hdlc/] [trunk/] [CODE/] [TOP/] [tb/] [RxTop_tb.vhd] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 khatib
-------------------------------------------------------------------------------
2
-- Title      :  Top Rx test bench
3
-- Project    :  HDLC controller
4
-------------------------------------------------------------------------------
5
-- File        : Rxtop_tb.vhd
6
-- Author      : Jamil Khatib  (khatib@ieee.org)
7
-- Organization: OpenIPCore Project
8
-- Created     :2001/04/10
9
-- Last update: 2001/04/12
10
-- Platform    : 
11
-- Simulators  : Modelsim 5.3XE/Windows98,NC-SIM/Linux
12
-- Synthesizers: 
13
-- Target      : 
14
-- Dependency  : ieee.std_logic_1164,
15
--               hdlc.hdlc_components_pkg
16
-------------------------------------------------------------------------------
17
-- Description:  Top Rx test bench
18
-------------------------------------------------------------------------------
19
-- Copyright (c) 2000 Jamil Khatib
20
-- 
21
-- This VHDL design file is an open design; you can redistribute it and/or
22
-- modify it and/or implement it after contacting the author
23
-- You can check the draft license at
24
-- http://www.opencores.org/OIPC/license.shtml
25
 
26
-------------------------------------------------------------------------------
27
-- Revisions  :
28
-- Revision Number :   1
29
-- Version         :   0.1
30
-- Date            :   10 April 2001
31
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
32
-- Desccription    :   Created
33
-- ToOptimize      :
34
-- Bugs            :
35
-------------------------------------------------------------------------------
36
library ieee;
37
use ieee.std_logic_1164.all;
38
use ieee.std_logic_unsigned.all;
39
 
40
library hdlc;
41
use hdlc.hdlc_components_pkg.all;
42
-------------------------------------------------------------------------------
43
 
44
entity RxTop_ent_tb is
45
 
46
end RxTop_ent_tb;
47
 
48
-------------------------------------------------------------------------------
49
architecture Rxtop_beh_tb of RxTop_ent_tb is
50
  constant ADD_WIDTH     : integer   := 7;
51
  signal   Clk           : std_logic := '0';
52
  signal   rst_n         : std_logic := '0';
53
  signal   DataBuff      : std_logic_vector(7 downto 0);
54
  signal   EOF           : std_logic;
55
  signal   WrBuff        : std_logic;
56
  signal   FrameSize     : std_logic_vector(ADD_WIDTH-1 downto 0);
57
  signal   RxRdy         : std_logic;
58
  signal   RxDataBuffOut : std_logic_vector(7 downto 0);
59
  signal   Overflow      : std_logic;
60
  signal   Rd            : std_logic;
61
 
62
 
63
  signal RxD        : std_logic_vector(7 downto 0);
64
  signal ValidFrame : std_logic := '0';
65
  signal rdy        : std_logic;
66
  signal Readbyte   : std_logic;
67
  signal FCSen      : std_logic := '1';
68
  signal FCSerr     : std_logic;
69
 
70
begin  -- Rxtop_beh_tb
71
  Clk   <= not Clk after 50 ns;
72
  rst_n <= '1'     after 120 ns;
73
 
74
  -- purpose: data generation
75
  -- type   : sequential
76
  -- inputs : Clk, rst_n
77
  -- outputs: 
78
  process (Clk, rst_n)
79
  begin  -- PROCESS
80
 
81
    if rst_n = '0' then                 -- asynchronous reset (active low)
82
      RxD <= (others => '0');
83
    elsif Clk'event and Clk = '1' then  -- rising clock edge
84
      RxD <= RxD + 1;
85
    end if;
86
 
87
  end process;
88
 
89
-- purpose: serial interface EBM
90
-- type   : combinational
91
-- inputs : 
92
-- outputs: 
93
  process
94
    variable counter    : integer := 0;
95
    variable FrameCount : integer := 0;  -- Frame Counter
96
  begin  -- PROCESS
97
 
98
    rdy <= '0';
99
 
100
    -- Wait three clocks
101
    wait until Clk = '0';
102
    wait until Clk = '0';
103
    wait until Clk = '0';
104
 
105
    ValidFrame <= '1';
106
 
107
    wait until Clk = '0';
108
    wait until Clk = '0';
109
    wait until Clk = '0';
110
 
111
 
112
    while (true) loop
113
 
114
      wait until clk = '0';
115
      counter := counter +1;
116
 
117
      if (counter = 8) then
118
        FrameCount := FrameCount +1;
119
        rdy        <= '1';
120
        wait until clk = '0';
121
      end if;
122
 
123
      if (Readbyte = '1') then
124
        WAIT UNTIL clk = '1';
125
        rdy <= '0';
126
        counter := 0;
127
      end if;
128
 
129
      if (FrameCount = 15 ) then
130
        ValidFrame <= '0';
131
      end if;
132
    end loop;
133
 
134
  end process;
135
 
136
-- purpose: Backend EBM
137
-- type   : combinational
138
-- inputs : 
139
-- outputs: 
140
  Backend_EBM        : process
141
    variable flag    : std_logic := '0';  -- tatus flag
142
    variable counter : integer   := 0;    -- counter
143
  begin  -- PROCESS Backend_EBM
144
    rd                           <= '0';
145
 
146
    wait until RxRdy = '1';
147
 
148
    while counter /= conv_integer(FrameSize) loop
149
 
150
      wait until clk = '0';
151
      counter := counter +1;
152
      Rd      <= '1';
153
 
154
    end loop;
155
 
156
    counter := 0;
157
    Rd      <= '0';
158
 
159
  end process Backend_EBM;
160
 
161
  DUT1 : RxBuff_ent
162
    generic map (
163
      FCS_TYPE => 2,
164
      ADD_WIDTH     => ADD_WIDTH)
165
    port map (
166
      Clk           => Clk,
167
      rst_n         => rst_n,
168
      DataBuff      => DataBuff,
169
      EOF           => EOF,
170
      WrBuff        => WrBuff,
171
      FrameSize     => FrameSize,
172
      RxRdy         => RxRdy,
173
      RxDataBuffOut => RxDataBuffOut,
174
      Overflow      => Overflow,
175
      Rd            => Rd);
176
 
177
 
178
  DUT2 : RxFCS_ent
179
    GENERIC MAP (
180
      FCS_TYPE => 2)
181
    port map (
182
      clk        => clk,
183
      rst_n      => rst_n,
184
      RxD        => RxD,
185
      ValidFrame => ValidFrame,
186
      rdy        => rdy,
187
      Readbyte   => Readbyte,
188
      DataBuff   => DataBuff,
189
      WrBuff     => WrBuff,
190
      EOF        => EOF,
191
      FCSen      => FCSen,
192
      FCSerr     => FCSerr);
193
 
194
end Rxtop_beh_tb;

powered by: WebSVN 2.1.0

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