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

Subversion Repositories tdm

[/] [tdm/] [trunk/] [code/] [tdm_cont/] [core/] [TxTDMBuff.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 khatib
-------------------------------------------------------------------------------
2
-- Title      : TDM controller Tx Buffer
3
-- Project    : TDM controller
4
-------------------------------------------------------------------------------
5
-- File       : TxTDMBuff.vhd
6
-- Author     : Jamil Khatib  <khatib@ieee.org>
7
-- Organization:  OpenCores.org
8
-- Created    : 2001/05/14
9
-- Last update:2001/05/22
10
-- Platform   : 
11
-- Simulators  : NC-sim/linux, Modelsim XE/windows98
12
-- Synthesizers: Leonardo
13
-- Target      : 
14
-- Dependency  : ieee.std_logic_1164,ieee.std_logic_unsigned
15
--               memLib.mem_pkg
16
-------------------------------------------------------------------------------
17
-- Description:  Transmit Buffer that uses internal Sram
18
-------------------------------------------------------------------------------
19
-- Copyright (c) 2001  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
-- Revisions  :
27
-- Revision Number :   1
28
-- Version         :   0.1
29
-- Date            :  2001/05/15
30
-- Modifier        :  Jamil Khatib  <khatib@ieee.org>
31
-- Desccription    :  Created
32
-- ToOptimize      :
33
-- Known Bugs      : 
34
-------------------------------------------------------------------------------
35
-- $Log: not supported by cvs2svn $
36
-- Revision 1.1  2001/05/24 22:48:56  jamil
37
-- TDM Initial release
38
--
39
-------------------------------------------------------------------------------
40
 
41
LIBRARY ieee;
42
USE ieee.std_logic_1164.ALL;
43
USE ieee.std_logic_unsigned.ALL;
44
 
45
LIBRARY memLib;
46
USE memLib.mem_pkg.ALL;
47
 
48
ENTITY TxTDMBuff IS
49
 
50
  PORT (
51
    CLK_I       : IN  STD_LOGIC;                     -- System Clock
52
    rst_n       : IN  STD_LOGIC;                     -- System reset
53
    TxD         : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Tx output data
54
    TxValidData : OUT STD_LOGIC;                     -- Tx Valid Data
55
    TxWrite     : OUT STD_LOGIC;                     -- Write byte
56
    TxRdy       : IN  STD_LOGIC;                     -- Ready to send data
57
 
58
    WrBuff       : IN  STD_LOGIC;       -- Write to buffer
59
    TxData       : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Tx Byte output from buffer
60
    NoChannels   : IN  STD_LOGIC_VECTOR(4 DOWNTO 0);  -- No of channels
61
    DropChannels : IN  STD_LOGIC_VECTOR(4 DOWNTO 0);  -- No of channels to be dropped
62
    TxDone       : OUT STD_LOGIC;       -- Transmission completed
63
    TxOverflow   : OUT STD_LOGIC        -- Tx buffer overflow
64
 
65
    );
66
 
67
END TxTDMBuff;
68
 
69
ARCHITECTURE TxTDMBuff_rtl OF TxTDMBuff IS
70
 
71
  TYPE States_type IS (IDLE_st, READ_st, WAITREAD_st, WRITE_st);  -- Buffer states
72
 
73
  SIGNAL Address : STD_LOGIC_VECTOR(4 DOWNTO 0);  -- memory address
74
 
75
  SIGNAL cs : STD_LOGIC := '1';         -- dummy signal
76
 
77
  SIGNAL wr_i    : STD_LOGIC;                     -- Read/Write signal
78
  SIGNAL Data_In : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Memory Data in
79
 
80
  SIGNAL Data_Out : STD_LOGIC_VECTOR(7 DOWNTO 0);  -- Memory Data out
81
 
82
  SIGNAL TotalChannels : STD_LOGIC_VECTOR(4 DOWNTO 0);  -- Totoal Channels
83
 
84
BEGIN  -- TxTDMBuff_rtl
85
 
86
-------------------------------------------------------------------------------
87
  TxD           <= Data_Out;
88
  TotalChannels <= NoChannels - DropChannels;
89
 
90
-------------------------------------------------------------------------------
91
-- purpose: FSM process
92
-- type   : sequential
93
-- inputs : CLK_I, rst_n
94
-- outputs: 
95
  fsm : PROCESS (CLK_I, rst_n)
96
 
97
    VARIABLE state   : States_type;                   -- internal state
98
    VARIABLE counter : STD_LOGIC_VECTOR(4 DOWNTO 0);  -- Internal Counter
99
--    VARIABLE TxwriteDelayed : STD_LOGIC;            -- Delayed TxWrite
100
 
101
  BEGIN  -- PROCESS fsm
102
 
103
    IF rst_n = '0' THEN                 -- asynchronous reset (active low)
104
      state       := IDLE_st;
105
      TxWrite     <= '0';
106
      Counter     := "00000";
107
      TxValidData <= '0';
108
 
109
      TxOverflow <= '0';
110
 
111
      address <= (OTHERS => '0');
112
      Data_In <= (OTHERS => '0');
113
 
114
      TxDone <= '0';
115
      wr_i   <= '1';
116
 
117
    ELSIF CLK_I'event AND CLK_I = '1' THEN  -- rising clock edge
118
 
119
 
120
      CASE state IS
121
        WHEN IDLE_st =>
122
          TxValidData <= '0';
123
          TxOverflow  <= '0';
124
 
125
          Counter := "00000";
126
          address <= Counter;
127
          Data_In <= TxData;
128
 
129
          Txwrite <= '0';
130
          TxDone  <= '1';
131
 
132
          IF (WrBuff = '1') THEN
133
 
134
            state   := WRITE_st;
135
            Counter := Counter +1;
136
 
137
          END IF;
138
 
139
          wr_i <= NOT WrBuff;
140
 
141
          TxOverflow <= '0';
142
 
143
        WHEN READ_st =>
144
          TxValidData <= '1';
145
          TxDone      <= '0';
146
          TxOverflow  <= '0';
147
 
148
          wr_i    <= '1';
149
          Txwrite <= '0';
150
 
151
          address <= Counter;
152
 
153
          IF (TxRdy = '1') THEN
154
 
155
            state := WAITREAD_st;
156
 
157
          END IF;
158
 
159
        WHEN WAITREAD_st =>
160
          TxDone      <= '0';
161
          TxValidData <= '1';
162
          Txwrite     <= '1';
163
          TxOverflow  <= '0';
164
 
165
          address <= counter;
166
 
167
          wr_i <= '1';
168
 
169
          IF (TxRdy = '0') THEN
170
            IF (counter = TotalChannels) THEN
171
 
172
              counter := (OTHERS => '0');
173
              state := IDLE_st;
174
 
175
              else
176
                counter := counter +1;
177
                state := READ_st;
178
            END IF;
179
 
180
          END IF;
181
 
182
        WHEN WRITE_st =>
183
          TxDone <= '0';
184
 
185
          TxValidData <= '0';
186
 
187
          TxOverflow <= '0';
188
 
189
          Txwrite <= '0';
190
 
191
          wr_i <= NOT WrBuff;
192
 
193
          address <= Counter;
194
          Data_In <= TxData;
195
 
196
          IF (counter = TotalChannels) THEN
197
 
198
            counter := "00000";
199
            state   := READ_st;
200
 
201
          ELSIF (WrBuff = '1') THEN
202
            counter := counter + 1;
203
          END IF;
204
 
205
 
206
        WHEN OTHERS => NULL;
207
      END CASE;
208
    END IF;
209
 
210
  END PROCESS fsm;
211
------------------------------------------------------------------------------
212
 
213
  Buff : Spmem_ent
214
    GENERIC MAP (
215
      USE_RESET   => FALSE,
216
      USE_CS      => FALSE,
217
      DEFAULT_OUT => '1',
218
      OPTION      => 0,
219
      ADD_WIDTH   => 5,
220
      WIDTH       => 8)
221
    PORT MAP (
222
      cs          => cs,
223
      clk         => clk_I,
224
      reset       => rst_n,
225
      add         => Address,
226
      Data_In     => Data_In,
227
      Data_Out    => Data_Out,
228
      WR          => WR_i);
229
 
230
END TxTDMBuff_rtl;
231
 
232
 
233
 

powered by: WebSVN 2.1.0

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