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/] [dsm2/] [dac_dsm2v.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: 2009-04-29
10
-- Platform   : 
11
-- Standard   : VHDL'93c
12
-------------------------------------------------------------------------------
13
-- Description: Implementation with use of variables inside of process
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2009  - THIS IS PUBLIC DOMAIN CODE!!!
16
-------------------------------------------------------------------------------
17
-- Revisions  :
18
-- Date        Version  Author  Description
19
-- 2009-04-28  1.0      wzab    Created
20
-------------------------------------------------------------------------------
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
use ieee.numeric_std.all;
25
 
26
entity dac_dsm2v is
27
 
28
  generic (
29
    nbits : integer := 16);
30
 
31
  port (
32
    din   : in  signed((nbits-1) downto 0);
33
    dout  : out std_logic;
34
    clk   : in  std_logic;
35
    n_rst : in  std_logic);
36
 
37
end dac_dsm2v;
38
 
39
architecture beh1 of dac_dsm2v is
40
 
41
  signal del1, del2, d_q : signed(nbits+2 downto 0) := (others => '0');
42
  constant c1            : signed(nbits+2 downto 0) := to_signed(1, nbits+3);
43
  constant c_1           : signed(nbits+2 downto 0) := to_signed(-1, nbits+3);
44
begin  -- beh1
45
 
46
  process (clk, n_rst)
47
    variable v1, v2 : signed(nbits+2 downto 0) := (others => '0');
48
  begin  -- process
49
    if n_rst = '0' then                 -- asynchronous reset (active low)
50
      del1 <= (others => '0');
51
      del2 <= (others => '0');
52
      dout <= '0';
53
    elsif clk'event and clk = '1' then  -- rising clock edge
54
      v1 := din - d_q + del1;
55
      v2 := v1 - d_q + del2;
56
      if v2 > 0 then
57
        d_q  <= shift_left(c1, nbits);
58
        dout <= '1';
59
      else
60
        d_q  <= shift_left(c_1, nbits);
61
        dout <= '0';
62
      end if;
63
      del1 <= v1;
64
      del2 <= v2;
65
    end if;
66
  end process;
67
 
68
 
69
end beh1;

powered by: WebSVN 2.1.0

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