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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [sigdel.vhd] - Blame information for rev 29

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 martin
--
2
--      sigdel.vhd
3
--
4
--      sigma delta AD converter
5
--      
6
--      without external comperator:
7
--              input threshhold of Acex is used as comperator
8
--              (not very exact but only 3 external components)
9
--
10
--
11
--            100k
12
--            ___
13
--    sdo o--|___|--+
14
--                  |
15
--            100k  |
16
--            ___   |
17
--    uin o--|___|--o----------o sdi
18
--                  |
19
--                 ---
20
--                 ---  100n
21
--                  |
22
--                  |
23
--                 ---
24
--                  -
25
--
26
--              
27
--      Author: Martin Schoeberl        martin@jopdesign.com
28
--
29
--
30
--      resources on ACEX1K30-3
31
--
32
--              xx LCs, max xx MHz
33
--
34
--
35
--      todo:
36
--              use clk_freq, make it configurable
37
--              use a 'real' LP
38
--
39
--
40
--      2002-02-23      first working version
41
--      2002-08-08      free running 16 bit counter -> 16 bit ADC
42
--      2003-09-23      new IO standard
43
--      2005-12-28      just a simple data port
44
--
45
 
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
use ieee.numeric_std.all;
50
 
51
entity sigdel is
52
 
53
generic (clk_freq : integer);
54
port (
55
        clk             : in std_logic;
56
        reset   : in std_logic;
57
        dout    : out std_logic_vector(15 downto 0);
58
 
59
        sdi             : in std_logic;
60
        sdo             : out std_logic
61
);
62
end sigdel ;
63
 
64
architecture rtl of sigdel is
65
 
66
        signal clksd            : unsigned(4 downto 0);
67
 
68
        signal clkint           : unsigned(15 downto 0);
69
        signal val                      : unsigned(15 downto 0);
70
        signal sd_dout          : std_logic_vector(15 downto 0);
71
 
72
        signal rx_d                     : std_logic;
73
        signal serdata          : std_logic;
74
 
75
        signal spike            : std_logic_vector(2 downto 0);  -- sync in, filter
76
 
77
begin
78
 
79
        sdo <= serdata;
80
        dout <= sd_dout;
81
 
82
--
83
--      sigma delta converter
84
--
85
process(clk, reset)
86
 
87
begin
88
        if (reset='1') then
89
                clksd <= "00000";
90
                spike <= "000";
91
                sd_dout <= (others => '0');
92
                val <= (others => '0');
93
                clkint <= (others => '0');
94
                serdata <= '0';
95
 
96
        elsif rising_edge(clk) then
97
 
98
                clksd <= clksd+1;
99
 
100
                if clksd="00000" then           -- with 20 MHz => 625 kHz
101
 
102
--
103
--      delay
104
--
105
                        spike(0) <= sdi;
106
                        spike(2 downto 1) <= spike(1 downto 0);
107
                        serdata <= rx_d;                -- no inverter, using an invert. comperator
108
--                      serdata <= not rx_d;    -- without comperator
109
 
110
--
111
--      integrate
112
--
113
 
114
                        if serdata='0' then              -- 'invert' value
115
                                val <= val+1;
116
                        end if;
117
 
118
                        if clkint=0 then         -- some time... (9.5 Hz)
119
                                sd_dout <= std_logic_vector(val);
120
                                val <= (others => '0');
121
                        end if;
122
 
123
                        clkint <= clkint+1;             -- free running counter
124
 
125
                end if;
126
        end if;
127
 
128
end process;
129
 
130
 
131
--
132
--      filter input
133
--
134
        with spike select
135
                rx_d <= '0' when "000",
136
                                '0' when "001",
137
                                '0' when "010",
138
                                '1' when "011",
139
                                '0' when "100",
140
                                '1' when "101",
141
                                '1' when "110",
142
                                '1' when "111",
143
                                'X' when others;
144
 
145
 
146
end rtl;

powered by: WebSVN 2.1.0

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