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

Subversion Repositories sigma_delta_dac_dual_loop

[/] [sigma_delta_dac_dual_loop/] [trunk/] [dsm3/] [dac_dsm3_top.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : DAC_DSM2 - sigma-delta DAC converter with double loop
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : dac_dsm2.vhd
6
-- Author     : Wojciech M. Zabolotny ( wzab[at]ise.pw.edu.pl )
7
-- Company    : 
8
-- Created    : 2009-04-28
9
-- Last update: 2012-10-16
10
-- Platform   : 
11
-- Standard   : VHDL'93c
12
-------------------------------------------------------------------------------
13
-- Description: Top entity - contains DAC and output circuit
14
--              generating the 3-bit sequences
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2009  - THIS IS PUBLIC DOMAIN CODE!!!
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 2009-04-28  1.0      wzab    Created
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.numeric_std.all;
26
 
27
entity dac_dsm3_top is
28
    generic (
29
      nbits : integer);
30
  port (
31
    din   : in  signed(15 downto 0);
32
    dout  : out std_logic;
33
    clk   : in  std_logic;
34
    n_rst : in  std_logic);
35
 
36
end dac_dsm3_top;
37
 
38
architecture beh1 of dac_dsm3_top is
39
 
40
  component dac_dsm3
41
    generic (
42
      nbits : integer);
43
    port (
44
      din     : in  signed((nbits-1) downto 0);
45
      dout    : out std_logic;
46
      clk     : in  std_logic;
47
      clk_ena : in  std_logic;
48
      n_rst   : in  std_logic);
49
  end component;
50
 
51
  signal clk_cnt  : integer range 0 to 2 := 0;
52
  signal clk_ena  : std_logic            := '0';
53
  signal dac_dout : std_logic            := '0';
54
 
55
begin
56
  -- The clock cycle counter
57
  clken1 : process (clk, n_rst)
58
  begin  -- process
59
    if n_rst = '0' then                 -- asynchronous reset (active low)
60
      clk_cnt <= 0;
61
    elsif clk'event and clk = '1' then  -- rising clock edge
62
      -- Update the cycle counter
63
      if clk_cnt < 2 then
64
        clk_cnt <= clk_cnt + 1;
65
      else
66
        clk_cnt <= 0;
67
      end if;
68
      -- Generate the clk_ena only in the first cycle
69
      if clk_cnt = 2 then
70
        clk_ena <= '1';
71
      else
72
        clk_ena <= '0';
73
      end if;
74
      -- Generate the narrow (if dac_dout='0') or wide (if dac_output='1')
75
      -- output pulse
76
      if clk_cnt = 0 then
77
        dout <= '1';  -- always the rising slope after the first
78
                      -- clock cycle
79
      elsif (clk_cnt = 1) and (dac_dout = '0') then
80
        dout <= '0';                    -- short dout pulse when dac_dout = '0'
81
      elsif clk_cnt = 2 then
82
        dout <= '0';                    -- always the falling slope after the
83
                                        -- third cycle
84
      end if;
85
    end if;
86
  end process clken1;
87
 
88
  dac_dsm3_1 : dac_dsm3
89
    generic map (
90
      nbits => 16)
91
    port map (
92
      din     => din,
93
      dout    => dout,
94
      clk     => clk,
95
      clk_ena => clk_ena,
96
      n_rst   => n_rst);
97
end beh1;

powered by: WebSVN 2.1.0

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