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_tx/] [optic_transmitter.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 chipmaker7
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    04:53:24 12/11/2013 
6
-- Design Name: 
7
-- Module Name:    optic_transmitter - 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
 
21
library IEEE;
22
use IEEE.STD_LOGIC_1164.ALL;
23
use IEEE.STD_LOGIC_ARITH.ALL;
24
use IEEE.std_logic_unsigned.all;
25
 
26
 
27
-- Uncomment the following library declaration if using
28
-- arithmetic functions with Signed or Unsigned values
29
--use IEEE.NUMERIC_STD.ALL;
30
 
31
-- Uncomment the following library declaration if instantiating
32
-- any Xilinx primitives in this code.
33
--library UNISIM;
34
--use UNISIM.VComponents.all;
35
 
36
 
37
--each frame of 12bit take 12x4 period + 4 + 2 period  * 4; speed@50Mhz 230Khz
38
 
39
entity optic_transmitter is
40
    Port (
41
         iCLK : in  STD_LOGIC;
42
         s : in  STD_LOGIC_VECTOR (11 downto 0);
43
    optic_out : out  STD_LOGIC);
44
end optic_transmitter;
45
 
46
architecture Behavioral of optic_transmitter is
47
 
48
--output flip-flop
49
signal optic_flop:STD_LOGIC;
50
signal s_reg:STD_LOGIC_VECTOR(13 downto 0);
51
signal optic_cnt:STD_LOGIC_VECTOR(5 downto 0);
52
signal optic_sub_cnt:STD_LOGIC_VECTOR(1 downto 0);
53
 
54
 
55
 
56
begin
57
 
58
optic_out<=optic_flop;  --output (fiber optic)
59
 
60
optic_stage:process (iCLK)
61
begin
62
        if (iCLK'event and iCLK = '1') then
63
                optic_sub_cnt<=optic_sub_cnt+1;
64
                if(optic_sub_cnt=0) then
65
                        if(optic_cnt=0)then
66
                                s_reg<=(13=>'0')&s(11 downto 0)&(0=>'1');  --0xxxxxxxx1 where the last 1 is halved
67
                        elsif(optic_cnt(1 downto 0)="00")then
68
                                s_reg<=s_reg(12 downto 0)&'0';
69
                        end if;
70
 
71
                        if(optic_cnt(0)=optic_cnt(1)) then       --00 and 11
72
                                optic_flop<=not optic_cnt(0);
73
                        else                                                                                    --01 and 10
74
                                optic_flop<=optic_cnt(0) xor s_reg(13);
75
                        end if;
76
 
77
                        if(optic_cnt=('1','1','0','1','0','1'))then       --53 because 13x4+2 value
78
                                optic_cnt<=(others=>'0');
79
                        else
80
                                optic_cnt<=optic_cnt+1;
81
                        end if;
82
                end if;--optic_sub_cnt divide iCLK
83
        end if;--iCLK event
84
 
85
end process;
86
 
87
end Behavioral;
88
 

powered by: WebSVN 2.1.0

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