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_dsm3v.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : DAC_DSM3 - 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: Implementation with use of variables inside of process
14
--            : and with one rising and falling slope for each output cycle
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_dsm3v is
28
 
29
  generic (
30
    nbits : integer := 16);
31
 
32
  port (
33
    din     : in  signed((nbits-1) downto 0);
34
    dout    : out std_logic;
35
    clk     : in  std_logic;
36
    clk_ena : in  std_logic;
37
    n_rst   : in  std_logic);
38
 
39
end dac_dsm3v;
40
 
41
architecture beh1 of dac_dsm3v is
42
 
43
  signal del1, del2, d_q : signed(nbits+2 downto 0) := (others => '0');
44
  constant c1            : signed(nbits+2 downto 0) := to_signed(1, nbits+3);
45
  constant c_1           : signed(nbits+2 downto 0) := to_signed(-1, nbits+3);
46
begin  -- beh1
47
 
48
  process (clk, n_rst)
49
    variable v1, v2 : signed(nbits+2 downto 0) := (others => '0');
50
  begin  -- process
51
    if n_rst = '0' then                 -- asynchronous reset (active low)
52
      del1 <= (others => '0');
53
      del2 <= (others => '0');
54
      dout <= '0';
55
    elsif clk'event and clk = '1' then  -- rising clock edge
56
      if clk_ena = '1' then
57
        v1 := din - d_q + del1;
58
        v2 := v1 - d_q + del2;
59
        if v2 > 0 then
60
          d_q  <= shift_left(c1, nbits);
61
          dout <= '1';
62
        else
63
          d_q  <= shift_left(c_1, nbits);
64
          dout <= '0';
65
        end if;
66
        del1 <= v1;
67
        del2 <= v2;
68
      end if;
69
    end if;
70
  end process;
71
 
72
 
73
end beh1;

powered by: WebSVN 2.1.0

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