summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/devices/nld_r2r_dac.h
blob: 18e5bddc05374c63f3fee62049434e4d47bc541f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
 * nld_R2R_DAC.h
 *
 *  DMR2R_DAC: R-2R DAC
 *
 *  Generic R-2R DAC ... This is fast.
 *                 2R
 *  Bit n    >----RRR----+---------> Vout
 *                       |
 *                       R
 *                       R R
 *                       R
 *                       |
 *                       .
 *                       .
 *                 2R    |
 *  Bit 2    >----RRR----+
 *                       |
 *                       R
 *                       R R
 *                       R
 *                       |
 *                 2R    |
 *  Bit 1    >----RRR----+
 *                       |
 *                       R
 *                       R 2R
 *                       R
 *                       |
 *                      V0
 *
 * Using Thevenin's Theorem, this can be written as
 *
 *          +---RRR-----------> Vout
 *          |
 *          V
 *          V  V = VAL / 2^n * Vin
 *          V
 *          |
 *          V0
 *
 */

#ifndef NLD_R2R_DAC_H_
#define NLD_R2R_DAC_H_

#include "../nl_setup.h"

#define R2R_DAC(name, p_VIN, p_R, p_N)                                          \
		NET_REGISTER_DEV(R2R_DAC, name)                                         \
		NETDEV_PARAMI(name, VIN, p_VIN)                                         \
		NETDEV_PARAMI(name, R,   p_R)                                           \
		NETDEV_PARAMI(name, N,   p_N)

#endif /* NLD_R2R_DAC_H_ */