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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use super::{
check, history,
reference_case::*,
reference_inputs::cases,
row::{self, Row},
};
use std::io::{BufWriter, Write};
pub fn run() -> Result {
let mut writer = BufWriter::new(std::io::stdout().lock());
writeln!(writer, "{}", row::HEADER)?;
let mut errors = Vec::new();
for case in cases() {
for width in LAYOUTS {
let batch = match build(case, width) {
Ok(batch) => {
if case.binding != "success" {
errors.push(format!("{}: binding unexpectedly succeeds", case.id));
}
batch
}
Err(error) => {
if let Err(error) = check_error(&error, case.binding, case.binding_element) {
errors.push(error.to_string());
}
for lane in 0..width {
let antecedent = case.antecedent.map(|input| sample(input, lane));
row::write(
&mut writer,
Row {
case,
width,
lane,
phase: "bind",
decision_index: None,
status: category(&error),
element: error.element(),
start: case.start,
end: case.end,
accepted_time: None,
accepted_steps: None,
left: None,
right: None,
state: None,
receipt: None,
sample: antecedent.as_ref(),
},
)?;
}
continue;
}
};
if case.family == "cadence" {
for lane in 0..width {
let antecedent = case.antecedent.map(|input| sample(input, lane));
row::write(
&mut writer,
Row {
case,
width,
lane,
phase: "bind",
decision_index: None,
status: "success".into(),
element: None,
start: case.start,
end: case.end,
accepted_time: None,
accepted_steps: None,
left: None,
right: None,
state: None,
receipt: None,
sample: antecedent.as_ref(),
},
)?;
}
continue;
}
let commands = batch.commands()?;
let states = batch.states()?;
if commands.len() != width || states.len() != width {
return Err("Initial control projection shape differs".into());
}
if batch.time().to_bits() != case.start.to_bits() || batch.accepted_steps() != 0 {
errors.push(format!("{}: initial time or step count differs", case.id));
}
for (lane, (command, state)) in commands.iter().zip(&states).enumerate() {
if let Err(error) = check::command(case, command, case.start, lane) {
errors.push(error.to_string());
}
if state.controller_id != controller(lane)
|| state.latch != case.initial_latch
|| state.pending != case.initial_pending
|| state.last_sample != case.antecedent.map(|input| sample(input, lane))
|| state.transition_count != 0
|| state.last_transition_at_s != case.initial_transition
|| state.last_transition.is_some()
{
errors.push(format!(
"{} lane={lane}: initial declaration differs",
case.id
));
}
row::write(
&mut writer,
Row {
case,
width,
lane,
phase: "initial",
decision_index: None,
status: "success".into(),
element: Some(command.element),
start: case.start,
end: case.start,
accepted_time: Some(batch.time()),
accepted_steps: Some(batch.accepted_steps()),
left: Some(command),
right: Some(command),
state: Some(state),
receipt: None,
sample: None,
},
)?;
}
errors.extend(history::run(&mut writer, case, width, batch)?);
}
}
writer.flush()?;
if !errors.is_empty() {
return Err(errors.join("\n").into());
}
Ok(())
}