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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! The SCDC hook: a test's quirk on top of the built-in SCDC sink.
use crateEnv;
/// A test's change to how the built-in SCDC sink takes a byte the source writes, or answers
/// a read: a vendor quirk on top of the standard sink, which keeps its offset, bursts, lock,
/// HPD resets and records. Set with
/// [`BenchBuilder::scdc_hook`](crate::BenchBuilder::scdc_hook); one per bench, kept across a
/// [`plug`](crate::Bench::plug). Presets do not pass through it: they are the test's own. Like
/// a target, it runs with the bench locked and sees it through [`Env`] only.
///
/// ```
/// use maquette::{Bench, DdcBus, Env, HookWrite, ScdcHook, ScdcRegisters};
///
/// /// A sink that ignores writes to Config_0.
/// struct NoConfig0;
///
/// impl ScdcHook for NoConfig0 {
/// fn write(&mut self, reg: u8, value: u8, _: &ScdcRegisters<'_>, _: &mut Env<'_>) -> HookWrite {
/// if reg == 0x30 { HookWrite::Drop } else { HookWrite::Store(value) }
/// }
/// }
///
/// let mut hook = NoConfig0;
/// let bench = Bench::builder(&[]).scdc_hook(&mut hook).build().unwrap();
/// bench.ddc().write(0x54, &[0x30, 0x02, 0x35]).unwrap();
/// assert_eq!(bench.sink().config_0(), Some(0));
/// assert_eq!(bench.sink().config_1(), Some(0x35));
/// ```
/// What the sink does with a byte the source writes, as an [`ScdcHook`] decides.
/// A read-only view of the SCDC registers, as the sink holds them.