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

Subversion Repositories i2sparalell

[/] [i2sparalell/] [trunk/] [AnalogBus.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 franksdeve
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
 
6
--  Uncomment the following lines to use the declarations that are
7
--  provided for instantiating Xilinx primitive components.
8
--library UNISIM;
9
--use UNISIM.VComponents.all;
10
 
11
entity AnalogBusPorts is
12
        port (
13
                SClk : in std_logic;     --this whole schebang runs of the analog serial bus clock
14
                LRClk : in std_logic;    --which channel at the moment?
15
                AdcData : in std_logic;  --data coming in from adc
16
                DacData : out std_logic;         --
17
                SampleStrobe : out std_logic;                                            --dump the contents of FifoData into the fifo on next clock
18
                nSampleStrobe : out std_logic;                                           --dump the contents of FifoData into the fifo on next clock
19
                LastAdcSample : out std_logic_vector(23 downto 0);    --buffer for fifo data                
20
                NextDacSample : in std_logic_vector(23 downto 0)--;    --buffer for fifo data               
21
        );
22
end AnalogBusPorts;
23
 
24
architecture AnalogBus of AnalogBusPorts is
25
 
26
        signal LastLRClk  : std_logic;  --to keep track of edges
27
 
28
        --sample buffers
29
        signal CurrentAdcSample : std_logic_vector(23 downto 0);
30
        signal CurrentDacSample : std_logic_vector(23 downto 0);
31
        signal AdcBitIndex  : std_logic_vector(5 downto 0);
32
        signal DacBitIndex  : std_logic_vector(5 downto 0);
33
 
34
begin
35
 
36
 
37
        process (SClk)
38
                begin
39
 
40
                if (SClk'event and SClk = '1') then
41
 
42
                        --move to next bit on each clock of the serial
43
                        AdcBitIndex <= AdcBitIndex + "000001";
44
                        DacBitIndex <= DacBitIndex + "000001";
45
 
46
                        --Just moved to the MSB of the other channel
47
                        if ( LRClk = (not(LastLRClk)) ) then
48
                                LastLRClk <= LRClk; --reset for next edge
49
                                if (LRClk = '1') then
50
                                        AdcBitIndex <= "000000"; --reset at MSB of sample
51
                                        DacBitIndex <= "000001"; --reset at MSB of sample
52
                                end if;
53
                        end if;
54
 
55
                end if;
56
 
57
 
58
                if (SClk'event and SClk = '0') then
59
 
60
                        --if we just finished a sample, better stick it in the adc fifo
61
 
62
                        --Left ADC Channel
63
                        if ( (AdcBitIndex = "111100") ) then --idx=60, which is in the middle of the 8 unused clocks for the R channel.
64
                                LastAdcSample <= CurrentAdcSample(23 downto 0);
65
                                CurrentDacSample(23 downto 0) <= NextDacSample;
66
                        end if;
67
 
68
                        --Right ADC Channel
69
                        if ( (AdcBitIndex = "011100") ) then --idx=28, which is in the middle of the 8 unused clocks for the L channel.
70
                                LastAdcSample <= CurrentAdcSample(23 downto 0);
71
                                CurrentDacSample(23 downto 0) <= NextDacSample;
72
                        end if;
73
 
74
                        if ( (AdcBitIndex = "000000") ) then
75
                                SampleStrobe <= '1';
76
                                nSampleStrobe <= '0';
77
                        end if;
78
 
79
                        if ( (AdcBitIndex = "100000") ) then
80
                                SampleStrobe <= '0'; --50% duty approx
81
                                nSampleStrobe <= '1';
82
                        end if;
83
 
84
                        --put each bit into/from the appropriate location in the sample buffer
85
 
86
                        if (AdcBitIndex(4 downto 0) < "11000") then --ignore the top 8 MSB's (24 bits of data in 32 bit transaction)
87
 
88
                                CurrentAdcSample(Conv_INTEGER(AdcBitIndex(4 downto 0))) <= AdcData;
89
 
90
                        end if;
91
 
92
                        if (DacBitIndex(4 downto 0) < "11000") then --ignore the top 8 MSB's (24 bits of data in 32 bit transaction)
93
 
94
                                DacData <= CurrentDacSample(Conv_INTEGER(DacBitIndex(4 downto 0)));
95
 
96
                        end if;
97
 
98
                end if; --if (SClk'event and SClk = '1') then
99
 
100
        end process; --process (SClk)
101
 
102
end AnalogBus;

powered by: WebSVN 2.1.0

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