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

Subversion Repositories hdlc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 khatib
-------------------------------------------------------------------------------
2
-- Title      :  Top Tx test bench
3
-- Project    :  HDLC controller
4
-------------------------------------------------------------------------------
5
-- File        : Txtop_tb.vhd
6
-- Author      : Jamil Khatib  (khatib@ieee.org)
7
-- Organization: OpenIPCore Project
8
-- Created     :2001/03/15
9
-- Last update: 2001/03/19
10
-- Platform    : 
11
-- Simulators  : Modelsim 5.3XE/Windows98,NC-SIM/Linux
12
-- Synthesizers: 
13
-- Target      : 
14
-- Dependency  : ieee.std_logic_1164
15
-------------------------------------------------------------------------------
16
-- Description:  Top Tx test bench
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2000 Jamil Khatib
19
-- 
20
-- This VHDL design file is an open design; you can redistribute it and/or
21
-- modify it and/or implement it after contacting the author
22
-- You can check the draft license at
23
-- http://www.opencores.org/OIPC/license.shtml
24
 
25
-------------------------------------------------------------------------------
26
-- Revisions  :
27
-- Revision Number :   1
28
-- Version         :   0.1
29
-- Date            :   15 March 2001
30
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
31
-- Desccription    :   Created
32
-- ToOptimize      :
33
-- Bugs            :
34
-------------------------------------------------------------------------------
35
-- Revision Number :   2
36
-- Version         :   0.11
37
-- Date            :   21 March 2001
38
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
39
-- Desccription    :   Test ack signal effect
40
-- ToOptimize      :
41
-- Bugs            :   
42
-------------------------------------------------------------------------------
43
-- $Log: not supported by cvs2svn $
44
-- Revision 1.2  2001/03/21 22:47:42  jamil
45
-- ACK signal test added
46
--
47
-- Revision 1.1  2001/03/20 19:29:33  jamil
48
-- Test Bench of Tx FCS and Buffer created
49
--
50
-------------------------------------------------------------------------------
51
 
52
LIBRARY ieee;
53
USE ieee.std_logic_1164.ALL;
54
USE ieee.std_logic_unsigned.ALL;
55
 
56
-------------------------------------------------------------------------------
57
 
58
ENTITY TxTop_ent_tb IS
59
 
60
END TxTop_ent_tb;
61
 
62
-------------------------------------------------------------------------------
63
 
64
ARCHITECTURE TxTop_beh_tb OF TxTop_ent_tb IS
65
 
66
  COMPONENT Txfcs_ent
67
    PORT (
68
      TxClk       : IN  STD_LOGIC;
69
      rst_n       : IN  STD_LOGIC;
70
      ValidFrame  : OUT STD_LOGIC;
71
      WriteByte   : OUT STD_LOGIC;
72
      rdy         : IN  STD_LOGIC;
73
      ack         : IN  STD_LOGIC;
74
      TxData      : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
75
      TxDataAvail : IN  STD_LOGIC;
76
      RdBuff      : OUT STD_LOGIC;
77
      TxDataBuff  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0));
78
  END COMPONENT;
79
 
80
  COMPONENT TxBuff_ent
81
    GENERIC (
82
      ADD_WIDTH     :     INTEGER);
83
    PORT (
84
      TxClk         : IN  STD_LOGIC;
85
      rst_n         : IN  STD_LOGIC;
86
      RdBuff        : IN  STD_LOGIC;
87
      Wr            : IN  STD_LOGIC;
88
      TxDataAvail   : OUT STD_LOGIC;
89
      TxEnable      : IN  STD_LOGIC;
90
      TxDone        : OUT STD_LOGIC;
91
      TxDataOutBuff : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
92
      TxDataInBuff  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
93
      Full          : OUT STD_LOGIC);
94
  END COMPONENT;
95
 
96
  SIGNAL ack           : STD_LOGIC := '0';
97
  SIGNAL TxClk         : STD_LOGIC := '0';
98
  SIGNAL rst_n         : STD_LOGIC := '0';
99
  SIGNAL ValidFrame_i  : STD_LOGIC;
100
  SIGNAL WriteByte_i   : STD_LOGIC;
101
  SIGNAL rdy_i         : STD_LOGIC;
102
  SIGNAL TxData_i      : STD_LOGIC_VECTOR(7 DOWNTO 0);
103
  SIGNAL TxDataAvail_i : STD_LOGIC;
104
  SIGNAL RdBuff_i      : STD_LOGIC;
105
  SIGNAL TxDataBuff_i  : STD_LOGIC_VECTOR(7 DOWNTO 0);
106
 
107
  SIGNAL Wr_i           : STD_LOGIC;
108
  SIGNAL TxEnable_i     : STD_LOGIC;
109
--  signal TxDataOutBuff_i : std_logic_vector(7 downto 0);
110
  SIGNAL TxDataInBuff_i : STD_LOGIC_VECTOR(7 DOWNTO 0);
111
  SIGNAL Full_i         : STD_LOGIC;
112
  SIGNAL TxDone_i       : STD_LOGIC;
113
 
114
BEGIN  -- Txfcs_beh_tb
115
 
116
  TxClk <= NOT TxClk AFTER 50 NS;
117
  rst_n <= '1'       AFTER 120 NS;
118
 
119
  write_proc      : PROCESS (TxClk, rst_n)
120
    VARIABLE flag : STD_LOGIC;          -- Internal flag
121
  BEGIN  -- process write_proc
122
    IF rst_n = '0' THEN                 -- asynchronous reset (active low)
123
      flag           := '1';
124
      Wr_i           <= '0';
125
      TxDataInBuff_i <= (OTHERS => '0');
126
      TxEnable_i     <= '0';
127
 
128
    ELSIF TxClk'event AND TxClk = '0' THEN  -- rising clock edge
129
 
130
      IF TxDone_i'event AND TxDone_i = '1' THEN
131
        flag := '1';
132
      END IF;
133
 
134
      IF flag = '1' THEN
135
 
136
        IF TxDataInBuff_i = "0001000" THEN
137
          TxDataInBuff_i <= (OTHERS => '0');
138
          TxEnable_i     <= '1';
139
          Wr_i           <= '0';
140
 
141
          flag           := '0';
142
        ELSE
143
          Wr_i           <= '1';
144
          TxDataInBuff_i <= TxDataInBuff_i + 1;
145
          TxEnable_i     <= '0';
146
 
147
 
148
        END IF;
149
 
150
      ELSE
151
        Wr_i           <= '0';
152
        TxDataInBuff_i <= (OTHERS => '0');
153
        TxEnable_i     <= '0';
154
      END IF;
155
 
156
    END IF;
157
  END PROCESS write_proc;
158
 
159
 
160
  hdlc_IF_proc       : PROCESS (TxClk, rst_n)
161
    VARIABLE counter : INTEGER := 0;
162
 
163
  BEGIN  -- process hdlc_IF_proc
164
    IF rst_n = '0' THEN                     -- asynchronous reset (active low)
165
      counter   := 0;
166
    ELSIF TxClk'event AND TxClk = '0' THEN  -- rising clock edge
167
      IF WriteByte_i = '1' THEN
168
        -- after 100 ns must be fixed to check two clocks
169
        ack     <= '1' AFTER 100 NS;
170
        rdy_i   <= '0' AFTER 100 NS;
171
        counter := 0;
172
 
173
      ELSIF (counter MOD 8) = 0 THEN
174
        rdy_i <= '1';
175
        ack   <= '0';
176
      END IF;
177
 
178
      counter := counter +1;
179
 
180
    END IF;
181
  END PROCESS hdlc_IF_proc;
182
 
183
 
184
  DUT : Txfcs_ent
185
    PORT MAP (
186
      TxClk       => TxClk,
187
      rst_n       => rst_n,
188
      ValidFrame  => ValidFrame_i,
189
      WriteByte   => WriteByte_i,
190
      rdy         => rdy_i,
191
      ack         => ack,
192
      TxData      => TxData_i,
193
      TxDataAvail => TxDataAvail_i,
194
      RdBuff      => RdBuff_i,
195
      TxDataBuff  => TxDataBuff_i);
196
 
197
 
198
  DUT2 : TxBuff_ent
199
    GENERIC MAP (
200
      ADD_WIDTH     => 7)
201
    PORT MAP (
202
      TxClk         => TxClk,
203
      rst_n         => rst_n,
204
      RdBuff        => RdBuff_i,
205
      Wr            => Wr_i,
206
      TxDataAvail   => TxDataAvail_i,
207
      TxEnable      => TxEnable_i,
208
      TxDone        => TxDone_i,
209
      TxDataOutBuff => TxDataBuff_i,
210
      TxDataInBuff  => TxDataInBuff_i,
211
      Full          => Full_i);
212
 
213
END TxTop_beh_tb;
214
 
215
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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