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

Subversion Repositories hdlc

[/] [hdlc/] [trunk/] [CODE/] [RX/] [CORE/] [Zero_detect.vhd] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 khatib
-------------------------------------------------------------------------------
2
-- Title      :  Zero Detection
3
-- Project    :  HDLC controller
4
-------------------------------------------------------------------------------
5
-- File        : zero_detect.vhd
6
-- Author      : Jamil Khatib  (khatib@ieee.org)
7
-- Organization: OpenIPCore Project
8
-- Created     : 2000/12/28
9 9 khatib
-- Last update: 2001/04/27
10 2 khatib
-- Platform    : 
11
-- Simulators  : Modelsim 5.3XE/Windows98
12
-- Synthesizers: FPGA express 3
13
-- Target      : 
14
-- Dependency  : ieee.std_logic_1164
15
--
16
-------------------------------------------------------------------------------
17
-- Description:  Zero Detection
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            :   28 Dec 2000
31
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
32
-- Desccription    :   Created
33
-- ToOptimize      :   Needs large external buffer (1 byte internal buffer)
34
--                     for low speed backend interface 
35
--                     (flow control is used to manage this problem)
36
-------------------------------------------------------------------------------
37 5 khatib
-- Revisions  :
38
-- Revision Number :   2
39
-- Version         :   0.2
40
-- Date            :   12 Jan 2001
41
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
42
-- Desccription    :   Enable bug fixed
43
-- ToOptimize      :   Needs large external buffer (1 byte internal buffer)
44
--                     for low speed backend interface 
45
--                     (flow control is used to manage this problem)
46
-------------------------------------------------------------------------------
47 9 khatib
-- Revisions  :
48
-- Revision Number :   3
49
-- Version         :   0.3
50
-- Date            :   27 April 2001
51
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
52
-- Desccription    :   Available and enable bugs fixed
53
-- ToOptimize      :  
54
-------------------------------------------------------------------------------
55 2 khatib
library ieee;
56
use ieee.std_logic_1164.all;
57
 
58
entity ZeroDetect_ent is
59
 
60
  port (
61 9 khatib
    ValidFrame : in  std_logic;         -- Valid Frame strobe
62
    Readbyte   : in  std_logic;         -- Back end read byte
63
    aval       : out std_logic;         -- can get more data (connected to flow
64 2 khatib
                                        -- controller
65 9 khatib
    enable     : in  std_logic;         -- enable (Driven by flow controller)
66 2 khatib
 
67
    rdy          : out std_logic;                      -- data ready
68
    rst          : in  std_logic;                      -- system reset
69
    StartofFrame : in  std_logic;                      -- start of Frame
70
    RxClk        : in  std_logic;                      -- RX clock
71
    RxD          : in  std_logic;                      -- RX data
72
    RxData       : out std_logic_vector(7 downto 0));  -- Receive Data bus
73
 
74
end ZeroDetect_ent;
75
 
76
architecture ZeroDetect_beh of ZeroDetect_ent is
77
  signal DataRegister : std_logic_vector(7 downto 0);
78
                                        -- Data register
79
  signal flag         : std_logic;      -- 8 Bits data ready
80
 
81
begin  -- ZeroDetect_beh
82
 
83
-- purpose: Detect zero
84
-- type   : sequential
85
-- inputs : RxClk, rst
86
-- outputs: 
87
  detect_proc : process (RxClk, rst)
88
 
89
    variable ZeroDetected : std_logic;                     -- Zero Detected
90
    variable tempRegister : std_logic_vector(7 downto 0);  -- Data Register
91
    variable counter      : integer range 0 to 7;          -- Counter
92
 
93
    variable checkreg : std_logic_vector(5 downto 0);  -- Check register
94
 
95
  begin  -- process detect
96
    if rst = '0' then                   -- asynchronous reset (active low)
97
 
98
      counter      := 0;
99
      tempRegister := (others => '0');
100
 
101
      DataRegister <= (others => '0');
102
 
103
      flag         <= '0';
104
      ZeroDetected := '0';
105
 
106
      checkreg := (others => '0');
107
 
108
    elsif RxClk'event and RxClk = '1' then  -- rising clock edge
109
      if enable = '1' then                  -- No overflow on the backend
110
 
111
        -- add new bit to the register
112
--        tempRegister(counter) := RxD;
113
 
114
        if StartofFrame = '0' then
115
 
116
          -- add new bit to the check register
117 5 khatib
          checkreg              := RxD & checkreg(5 downto 1);
118
          tempRegister(counter) := RxD;
119 2 khatib
        else
120
          -- reset the check register
121 5 khatib
          checkreg              := (RxD, others => '0');
122
          counter               := 0;
123 2 khatib
          tempRegister(counter) := RxD;
124
        end if;
125
 
126
        -- check if we got 5 ones
127
        ZeroDetected := not checkreg(5) and checkreg(4) and checkreg(3) and checkreg(2) and checkreg(1) and checkreg(0);
128
 
129
 
130
        if ZeroDetected = '1' then
131
 
132
          flag <= '0';
133
 
134
        else
135
 
136
          if counter = 7 then
137
 
138
            DataRegister <= tempRegister;
139
 
140
            counter := 0;
141
 
142
            flag <= '1';
143
 
144
 
145
          else
146
 
147
            counter := counter + 1;
148
 
149
            flag <= '0';
150
 
151
          end if;
152
 
153
        end if;
154
 
155
      end if;
156
 
157
    end if;
158
  end process detect_proc;
159
-------------------------------------------------------------------------------
160
  -- purpose: Backend process
161
  -- type   : sequential
162
  -- inputs : Rxclk, rst
163
  -- outputs: 
164
  backend_proc : process (Rxclk, rst)
165
 
166
    variable status  : std_logic;       -- Status
167
    variable rdy_var : std_logic;       -- temp variable for Rdy
168
 
169
  begin  -- process backend_proc
170
    if rst = '0' then                   -- asynchronous reset (active low)
171
 
172
 
173
      RxData <= (others => '0');
174
 
175
      status := '0';
176
      aval   <= '1';
177
 
178
      rdy_var := '0';
179
 
180
      rdy <= '0';
181
 
182
    elsif Rxclk'event and Rxclk = '1' then  -- rising clock edge
183 5 khatib
      if enable = '1' then
184 2 khatib
 
185 5 khatib
        if flag = '1' then
186 2 khatib
 
187 5 khatib
          status := '1';                -- Can not take more
188 2 khatib
 
189 5 khatib
          RxData  <= DataRegister;
190
          rdy_var := '1';
191 2 khatib
 
192 5 khatib
        end if;  -- flag
193 2 khatib
 
194 5 khatib
      end if;  -- enable
195 2 khatib
      if readbyte = '1' then
196
 
197
        status := '0';                  -- can take more data
198
 
199
        rdy_var := '0';
200
 
201 5 khatib
      end if;  -- readbyte
202 2 khatib
 
203 9 khatib
      rdy <= rdy_var;
204
 
205
      if ValidFrame = '0' then
206
        aval <= '1';
207
      else
208
 
209
        aval <= not status;
210
      end if;
211
 
212
 
213 5 khatib
    end if;  -- clk
214 2 khatib
 
215
 
216
  end process backend_proc;
217
 
218
-------------------------------------------------------------------------------
219
 
220
end ZeroDetect_beh;

powered by: WebSVN 2.1.0

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