summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/netlist/devices/nld_r2r_dac.c
blob: 91b2bf4d8205b49fa9e6836b27f64de60d83459c (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
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
 * nld_R2R_dac.c
 *
 */

#include "nld_r2r_dac.h"

NETLIB_START(r2r_dac)
{
	NETLIB_NAME(twoterm)::start();
	register_terminal("VOUT", m_P);
	register_terminal("VGND", m_N);
	register_param("R", m_R, 1.0);
	register_param("VIN", m_VIN, 1.0);
	register_param("N", m_num, 1);
	register_param("VAL", m_val, 1);
}

NETLIB_RESET(r2r_dac)
{
	NETLIB_NAME(twoterm)::reset();
}

NETLIB_UPDATE(r2r_dac)
{
	NETLIB_NAME(twoterm)::update();
}

NETLIB_UPDATE_PARAM(r2r_dac)
{
	//printf("updating %s to %f\n", name().cstr(), m_R.Value());

	update_dev();

	nl_double V = m_VIN.Value() / (double) (1 << m_num.Value()) * (double) m_val.Value();

	this->set(1.0 / m_R.Value(), V, 0.0);
}