summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/74148.cpp
blob: 216d98a05d13eb1cbc1e05c45dc405842bfd6a55 (plain) (blame)
1
2
3
4
5
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
//
// asio_ssl.cpp
// ~~~~~~~~~~~~
//
// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include "asio/ssl/impl/src.hpp"
196 197
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/*****************************************************************************

  74148 8-line-to-3-line priority encoder


  Pin layout and functions to access pins:

  input_line_w(4)  [1] /IN4   VCC [16]
  input_line_w(5)  [2] /IN5   /EO [15]  enable_output_r
  input_line_w(6)  [3] /IN6   /GS [14]  output_valid_r
  input_line_w(7)  [4] /IN7  /IN3 [13]  input_line_w(3)
  enable_input_w   [5] /EI   /IN2 [12]  input_line_w(2)
  output_r         [6] /A2   /IN1 [11]  input_line_w(1)
  output_r         [7] /A1   /IN0 [10]  input_line_w(0)
                   [8] GND   /A0  [9]   output_r


  Truth table (all logic levels indicate the actual voltage on the line):

              INPUTS            |     OUTPUTS
                                |
    EI  I0 I1 I2 I3 I4 I5 I6 I7 | A2 A1 A0 | GS EO
    ----------------------------+----------+------
 1  H   X  X  X  X  X  X  X  X  | H  H  H  | H  H
 2  L   H  H  H  H  H  H  H  H  | H  H  H  | H  L
 3  L   X  X  X  X  X  X  X  L  | L  L  L  | L  H
 4  L   X  X  X  X  X  X  L  H  | L  L  H  | L  H
 5  L   X  X  X  X  X  L  H  H  | L  H  L  | L  H
 6  L   X  X  X  X  L  H  H  H  | L  H  H  | L  H
 7  L   X  X  X  L  H  H  H  H  | H  L  L  | L  H
 8  L   X  X  L  H  H  H  H  H  | H  L  H  | L  H
 9  L   X  L  H  H  H  H  H  H  | H  H  L  | L  H
 10 L   L  H  H  H  H  H  H  H  | H  H  H  | L  H
    ----------------------------+----------+------
    L   = lo (0)
    H   = hi (1)
    X   = any state

*****************************************************************************/

#include "emu.h"
#include "74148.h"


DEFINE_DEVICE_TYPE(TTL74148, ttl74148_device, "74148", "74148 TTL")


ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, TTL74148, tag, owner, clock)
	, m_output_cb(*this)
	, m_enable_input(0)
	, m_output(0)
	, m_output_valid(0)
	, m_enable_output(0)
	, m_last_output(0)
	, m_last_output_valid(0)
	, m_last_enable_output(0)
{
	for (auto &elem : m_input_lines)
		elem = 0;
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void ttl74148_device::device_start()
{
	save_item(NAME(m_input_lines));
	save_item(NAME(m_enable_input));
	save_item(NAME(m_output));
	save_item(NAME(m_output_valid));
	save_item(NAME(m_enable_output));
	save_item(NAME(m_last_output));
	save_item(NAME(m_last_output_valid));
	save_item(NAME(m_last_enable_output));
}

//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void ttl74148_device::device_reset()
{
	m_enable_input = 1;
	m_input_lines[0] = 1;
	m_input_lines[1] = 1;
	m_input_lines[2] = 1;
	m_input_lines[3] = 1;
	m_input_lines[4] = 1;
	m_input_lines[5] = 1;
	m_input_lines[6] = 1;
	m_input_lines[7] = 1;

	m_last_output = -1;
	m_last_output_valid = -1;
	m_last_enable_output = -1;
}


void ttl74148_device::update()
{
	if (m_enable_input)
	{
		// row 1 in truth table
		m_output = 0x07;
		m_output_valid = 1;
		m_enable_output = 1;
	}
	else
	{
		int bit0, bit1, bit2;

		/* this comes straight off the data sheet schematics */
		bit0 = !(((!m_input_lines[1]) &
					m_input_lines[2] &
					m_input_lines[4] &
					m_input_lines[6])  |
					((!m_input_lines[3]) &
					m_input_lines[4] &
					m_input_lines[6])  |
					((!m_input_lines[5]) &
					m_input_lines[6])  |
					(!m_input_lines[7]));

		bit1 = !(((!m_input_lines[2]) &
					m_input_lines[4] &
					m_input_lines[5])  |
					((!m_input_lines[3]) &
					m_input_lines[4] &
					m_input_lines[5])  |
					(!m_input_lines[6])  |
					(!m_input_lines[7]));

		bit2 = !((!m_input_lines[4])  |
					(!m_input_lines[5])  |
					(!m_input_lines[6])  |
					(!m_input_lines[7]));

		m_output = (bit2 << 2) | (bit1 << 1) | bit0;

		m_output_valid = (m_input_lines[0] &
										m_input_lines[1] &
										m_input_lines[2] &
										m_input_lines[3] &
										m_input_lines[4] &
										m_input_lines[5] &
										m_input_lines[6] &
										m_input_lines[7]);

		m_enable_output = !m_output_valid;
	}


	/* call callback if any of the outputs changed */
	if ((m_output != m_last_output) ||
			(m_output_valid != m_last_output_valid) || (m_enable_output != m_last_enable_output))
	{
		m_last_output = m_output;
		m_last_output_valid = m_output_valid;
		m_last_enable_output = m_enable_output;

		m_output_cb(m_output);
	}
}


void ttl74148_device::input_line_w(int input_line, int data)
{
	m_input_lines[input_line] = data ? 1 : 0;
}


void ttl74148_device::enable_input_w(int data)
{
	m_enable_input = data ? 1 : 0;
}


int ttl74148_device::output_r()
{
	return m_output;
}


int ttl74148_device::output_valid_r()
{
	return m_output_valid;
}


int ttl74148_device::enable_output_r()
{
	return m_enable_output;
}