-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_undriven_checker.cpp
More file actions
76 lines (66 loc) · 3.16 KB
/
Copy pathtest_undriven_checker.cpp
File metadata and controls
76 lines (66 loc) · 3.16 KB
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
#include <catch2/catch_test_macros.hpp>
#include "UndrivenChecker.h"
#include "TestUtils.h"
using namespace connect;
using slang::ast::ArgumentDirection;
using testutils::makePort;
TEST_CASE("UndrivenChecker: driven input produces no issues") {
ConnectionGraph graph;
auto outPort = makePort("top.u_a", "o_data", ArgumentDirection::Out);
auto inPort = makePort("top.u_b", "i_data", ArgumentDirection::In);
graph.allPorts.push_back(outPort);
graph.allPorts.push_back(inPort);
graph.connections.push_back({outPort, inPort});
UndrivenChecker checker;
REQUIRE(checker.check(graph).empty());
}
TEST_CASE("UndrivenChecker: undriven input is ERROR") {
ConnectionGraph graph;
graph.allPorts.push_back(makePort("top.u_b", "i_config", ArgumentDirection::In));
UndrivenChecker checker;
auto issues = checker.check(graph);
REQUIRE(issues.size() == 1);
CHECK(issues[0].type == Issue::Type::UNDRIVEN_INPUT);
CHECK(issues[0].severity == Issue::Severity::ERROR);
CHECK(issues[0].port.portName == "i_config");
}
TEST_CASE("UndrivenChecker: output ports are ignored") {
ConnectionGraph graph;
graph.allPorts.push_back(makePort("top.u_a", "o_data", ArgumentDirection::Out));
UndrivenChecker checker;
REQUIRE(checker.check(graph).empty());
}
TEST_CASE("UndrivenChecker: optional exists_* inputs are suppressed when exists_req_i is tied low") {
ConnectionGraph graph;
graph.allPorts.push_back(makePort("top.u_q", "exists_req_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_q", "exists_data_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_q", "exists_mask_i", ArgumentDirection::In));
graph.connectedPorts.insert("top.u_q.exists_req_i");
graph.constantZeroTieOffPorts.insert("top.u_q.exists_req_i");
UndrivenChecker checker;
auto issues = checker.check(graph);
CHECK(issues.empty());
}
TEST_CASE("UndrivenChecker: optional exists_* inputs still error when disable companion is not tied low") {
ConnectionGraph graph;
graph.allPorts.push_back(makePort("top.u_q", "exists_req_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_q", "exists_data_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_q", "exists_mask_i", ArgumentDirection::In));
graph.connectedPorts.insert("top.u_q.exists_req_i");
UndrivenChecker checker;
auto issues = checker.check(graph);
REQUIRE(issues.size() == 2);
}
TEST_CASE("UndrivenChecker: optional exists_* suppression is limited to same instance scope") {
ConnectionGraph graph;
graph.allPorts.push_back(makePort("top.u_a", "exists_req_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_b", "exists_data_i", ArgumentDirection::In));
graph.allPorts.push_back(makePort("top.u_b", "exists_mask_i", ArgumentDirection::In));
graph.connectedPorts.insert("top.u_a.exists_req_i");
graph.constantZeroTieOffPorts.insert("top.u_a.exists_req_i");
UndrivenChecker checker;
auto issues = checker.check(graph);
REQUIRE(issues.size() == 2);
CHECK(issues[0].type == Issue::Type::UNDRIVEN_INPUT);
CHECK(issues[1].type == Issue::Type::UNDRIVEN_INPUT);
}