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

Subversion Repositories spidac

[/] [spidac/] [trunk/] [DAC_TOP.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 socrates
-----------------------------------------------------------------------------------------
2
-- Engineer: Tomas Daujotas (mailsoc@gmail.com www.scrts.net)
3
-- 
4
-- Create Date: 2010-07-21 
5
-- Design Name: Control of LTC2624 Quad 12 bit DAC on Spartan-3E Starter Kit (32bit mode)
6
-----------------------------------------------------------------------------------------
7
library IEEE;
8
use IEEE.STD_LOGIC_1164.ALL;
9
use IEEE.NUMERIC_STD.ALL;
10
 
11
 
12
entity DAC_TOP is
13
    Port ( CLK : in  STD_LOGIC;
14
           RST : in  STD_LOGIC;
15
           DAC_MOSI : out  STD_LOGIC;
16
           DAC_CLR : out  STD_LOGIC;
17
           DAC_SCK : out  STD_LOGIC;
18
           DAC_CS : out  STD_LOGIC;
19
           SPI_SS_B : out  STD_LOGIC;           -- Serial Flash
20
           AMP_CS : out  STD_LOGIC;                     -- Amplifier for ADC
21
           AD_CONV : out  STD_LOGIC;            -- ADC Conversion start
22
           SF_CE0 : out  STD_LOGIC;                     -- StrataFlash 
23
           FPGA_INIT_B : out  STD_LOGIC);       -- Platform Flash
24
end DAC_TOP;
25
 
26
architecture DAC of DAC_TOP is
27
 
28
signal rdy,daccs,dacsck,dacmosi : std_logic;
29
signal command : std_logic_vector(3 downto 0);
30
signal address : std_logic_vector(3 downto 0);
31
signal dacdata : std_logic_vector(31 downto 0);
32
signal pattern : std_logic_vector(11 downto 0);
33
 
34
component DAC_Control
35
         Port ( CLK : in  STD_LOGIC;
36
           RST : in  STD_LOGIC;
37
                          DAC_DATA : in STD_LOGIC_VECTOR(31 downto 0);
38
           DAC_MOSI : out  STD_LOGIC;
39
           DAC_SCK : out  STD_LOGIC;
40
           DAC_CS : out  STD_LOGIC;
41
           RDY : out  STD_LOGIC);
42
end component;
43
 
44
begin
45
        U1 : DAC_Control
46
        Port map ( CLK => CLK,
47
                                  RST => RST,
48
                                  DAC_MOSI => dacmosi,
49
                                  DAC_SCK => dacsck,
50
                                  DAC_CS => daccs,
51
                                  RDY => RDY,
52
                                  DAC_DATA => dacdata);
53
 
54
process(RST,CLK,daccs,dacsck,dacmosi)
55
        begin
56
                if (RST='1') then
57
                        DAC_MOSI <= '0';
58
                        DAC_CLR <= '0';
59
                        DAC_SCK <= '0';
60
                        DAC_CS <= '1';
61
                elsif rising_edge(CLK) then
62
                        if rdy = '1' then                                       -- Check if first 32 bits is sent and proceed to the next
63
                                command <= "0011";                              -- Set the command register
64
                                address <= "1111";                              -- Set the address register 
65
                                pattern <= "100000000000";              -- 12 bit value (refer to LTC2624 datasheet page 10 for Vout)
66
                                dacdata(31 downto 24) <= (others => '0'); -- Don't care (refer to LTC2624 datasheet page 13)
67
                                dacdata(23 downto 20) <= command;
68
                                dacdata(19 downto 16) <= address;
69
                                dacdata(15 downto 4) <= pattern;
70
                                dacdata(3 downto 0) <= (others => '0');   -- Don't care
71
                        end if;
72
                        DAC_CLR <= '1';
73
                end if;
74
                DAC_CS <= daccs;
75
                DAC_SCK <= dacsck;
76
                DAC_MOSI <= dacmosi;
77
end process;
78
 
79
        ----- Disabling not required devices -----
80
        SPI_SS_B <= '1';
81
        AMP_CS <= '1';
82
        AD_CONV <= '0';
83
        SF_CE0 <= '1';
84
        FPGA_INIT_B <= '1';
85
 
86
end DAC;
87
 

powered by: WebSVN 2.1.0

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