summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/cat702.h
blob: 72185d03185fa8078afa660c1c1489ab4a4ae941 (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
58
59
60
61
62
63
// license:BSD-3-Clause
// copyright-holders:smf
/*  CAT702 security chip */

#ifndef MAME_MACHINE_CAT702_H
#define MAME_MACHINE_CAT702_H

#pragma once


DECLARE_DEVICE_TYPE(CAT702, cat702_device)
DECLARE_DEVICE_TYPE(CAT702_PIU, cat702_piu_device)

class cat702_device_base : public device_t
{
public:
	// configuration helpers
	auto dataout_handler() { return m_dataout_handler.bind(); }

	void write_datain(int state);

protected:
	cat702_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	virtual void device_start() override ATTR_COLD;

	void apply_bit_sbox(int sel);
	void apply_sbox(const uint8_t *sbox);

	int m_select;
	int m_clock;
	int m_datain;
	uint8_t m_state;
	uint8_t m_bit;

	devcb_write_line m_dataout_handler;

private:
	uint8_t compute_sbox_coef(int sel, int bit);

	optional_memory_region m_region;
	uint8_t m_transform[8];
};

class cat702_device : public cat702_device_base
{
public:
	cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void write_select(int state);
	void write_clock(int state);
};

class cat702_piu_device : public cat702_device_base
{
public:
	cat702_piu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void write_select(int state);
	void write_clock(int state);
};

#endif // MAME_MACHINE_CAT702_H