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

Subversion Repositories parallel_io_through_fiber

[/] [parallel_io_through_fiber/] [trunk/] [parport_rx/] [optic_receiver.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 chipmaker7
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    05:31:10 12/11/2013 
6
-- Design Name: 
7
-- Module Name:    optic_receiver - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.std_logic_unsigned.all;
24
 
25
-- Uncomment the following library declaration if using
26
-- arithmetic functions with Signed or Unsigned values
27
--use IEEE.NUMERIC_STD.ALL;
28
 
29
-- Uncomment the following library declaration if instantiating
30
-- any Xilinx primitives in this code.
31
--library UNISIM;
32
--use UNISIM.VComponents.all;
33
 
34
entity optic_receiver is
35
    Port ( iCLK : in  STD_LOGIC;
36
           optic_in : in  STD_LOGIC;
37
           s : out  STD_LOGIC_VECTOR (11 downto 0);
38
                          s_prev : out  STD_LOGIC_VECTOR (11 downto 0);
39
                          step_sync : out  STD_LOGIC);
40
end optic_receiver;
41
 
42
architecture Behavioral of optic_receiver is
43
 
44
 
45
signal q1 : STD_LOGIC;
46
signal q2 : STD_LOGIC;
47
signal samp2 : STD_LOGIC;
48
 
49
signal samp : STD_LOGIC;
50
signal cnt : STD_LOGIC_VECTOR(4 downto 0);
51
signal s_reg : STD_LOGIC_VECTOR(11 downto 0);
52
signal N1 : STD_LOGIC;
53
--signal s_prev : STD_LOGIC_VECTOR(2 downto 0);
54
signal s_recv : STD_LOGIC_VECTOR(11 downto 0);
55
signal bit_count: STD_LOGIC_VECTOR(3 downto 0);
56
 
57
 
58
begin
59
 
60
step_sync<='1' when (bit_count>=4 and bit_count<8) else '0';
61
s<=s_recv;
62
 
63
input_low_pass:process (iCLK)
64
begin
65
 
66
if (iCLK'event and iCLK= '1') then
67
 
68
        q1<=q2;
69
        q2<=optic_in;
70
        if(q1=q2)then
71
                samp<=q1;
72
        end if;
73
end if;
74
 
75
end process;
76
 
77
fiber_decoder:process (iCLK)
78
begin
79
 
80
if (iCLK'event and iCLK= '1') then
81
 
82
 
83
        --samp<=optic_in;
84
        --if(samp/=optic_in and samp='0') then
85
        samp2<=samp;
86
        if(samp2/=samp and samp='1') then
87
 
88
                if(cnt>11) then         --12 = 3/4 of a 16 period (ideally 7 or 15)
89
                        if(N1='1')then
90
                                --s<=s_reg(11 downto 3)&(s_reg(2 downto 0) xor s_prev);
91
                                --s<=s_reg(11 downto 0);
92
                                --s_prev<=s_reg(2 downto 0);
93
                                s_prev<=s_recv;
94
                                s_recv<=s_reg;
95
                                bit_count<=(others=>'0');
96
                        else
97
                                s_reg<=s_reg(10 downto 0)&'0';
98
                                bit_count<=bit_count+1;
99
                        end if;
100
                        N1<='0';
101
                else
102
                        if(N1='1')then
103
                                s_reg<=s_reg(10 downto 0)&'1';--shift 1
104
                                bit_count<=bit_count+1;
105
                        end if;
106
                        N1<= not N1;
107
                end if;
108
 
109
                cnt<=(others=>'0');
110
        else
111
                cnt<=cnt+1;
112
        end if;
113
 
114
end if;
115
 
116
end process;
117
 
118
end Behavioral;
119
 

powered by: WebSVN 2.1.0

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