Skip to content

Commit c00db34

Browse files
committed
xilinx: added archs and configuration code
1 parent d393be1 commit c00db34

21 files changed

+1568
-300
lines changed

fpga/xilinx/BUILD

Lines changed: 97 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,38 @@ cc_test(
5454
)
5555

5656
cc_library(
57-
name = "configuration-packet",
57+
name = "arch-xc7-frame",
58+
srcs = [
59+
"arch-xc7-frame.cc",
60+
],
5861
hdrs = [
59-
"configuration-packet.h",
62+
"arch-xc7-frame.h",
6063
],
6164
deps = [
62-
"@abseil-cpp//absl/types:optional",
63-
"@abseil-cpp//absl/types:span",
65+
":bit-ops",
6466
],
6567
)
6668

67-
cc_library(
68-
name = "arch-xc7-defs",
69+
cc_test(
70+
name = "arch-xc7-frame_test",
6971
srcs = [
70-
"arch-xc7-defs.cc",
72+
"arch-xc7-frame_test.cc",
73+
],
74+
deps = [
75+
":arch-xc7-frame",
76+
"@googletest//:gtest",
77+
"@googletest//:gtest_main",
7178
],
79+
)
80+
81+
cc_library(
82+
name = "configuration-packet",
7283
hdrs = [
73-
"arch-xc7-defs.h",
84+
"configuration-packet.h",
85+
],
86+
deps = [
87+
"@abseil-cpp//absl/types:optional",
88+
"@abseil-cpp//absl/types:span",
7489
],
7590
)
7691

@@ -83,7 +98,7 @@ cc_library(
8398
"arch-xc7-configuration-packet.h",
8499
],
85100
deps = [
86-
":arch-xc7-defs",
101+
":arch-xc7-frame",
87102
":bit-ops",
88103
":configuration-packet",
89104
"@abseil-cpp//absl/types:span",
@@ -97,7 +112,7 @@ cc_test(
97112
],
98113
deps = [
99114
":arch-xc7-configuration-packet",
100-
":arch-xc7-defs",
115+
":arch-xc7-frame",
101116
":bit-ops",
102117
"@abseil-cpp//absl/types:span",
103118
"@googletest//:gtest",
@@ -106,42 +121,99 @@ cc_test(
106121
)
107122

108123
cc_library(
109-
name = "arch-xc7-frame-address",
124+
name = "arch-xc7-part",
110125
srcs = [
111-
"arch-xc7-frame-address.cc",
126+
"arch-xc7-part.cc",
112127
],
113128
hdrs = [
114-
"arch-xc7-frame-address.h",
129+
"arch-xc7-part.h",
115130
],
116131
deps = [
117-
":arch-xc7-defs",
118-
":bit-ops",
132+
":arch-xc7-frame",
133+
],
134+
)
135+
136+
cc_test(
137+
name = "arch-xc7-part_test",
138+
srcs = [
139+
"arch-xc7-part_test.cc",
140+
],
141+
deps = [
142+
":arch-xc7-frame",
143+
":arch-xc7-part",
144+
"@googletest//:gtest",
145+
"@googletest//:gtest_main",
119146
],
120147
)
121148

122149
cc_library(
123-
name = "arch-xc7-part",
150+
name = "arch-types",
151+
hdrs = [
152+
"arch-types.h",
153+
],
154+
deps = [
155+
":arch-xc7-configuration-packet",
156+
":arch-xc7-frame",
157+
":arch-xc7-part",
158+
],
159+
)
160+
161+
cc_library(
162+
name = "frames",
163+
hdrs = [
164+
"frames.h",
165+
],
166+
deps = [
167+
":arch-types",
168+
],
169+
)
170+
171+
cc_test(
172+
name = "frames-xc7_test",
124173
srcs = [
125-
"arch-xc7-part.cc",
174+
"frames-xc7_test.cc",
175+
],
176+
deps = [
177+
":arch-types",
178+
":arch-xc7-frame",
179+
":frames",
180+
"@googletest//:gtest",
181+
"@googletest//:gtest_main",
182+
],
183+
)
184+
185+
cc_library(
186+
name = "configuration",
187+
srcs = [
188+
"configuration.cc",
126189
],
127190
hdrs = [
128-
"arch-xc7-part.h",
191+
"configuration.h",
129192
],
130193
deps = [
131-
":arch-xc7-defs",
132-
":arch-xc7-frame-address",
194+
":arch-types",
195+
":arch-xc7-configuration-packet",
196+
":bit-ops",
197+
":configuration-packet",
198+
"@abseil-cpp//absl/log:check",
199+
"@abseil-cpp//absl/types:optional",
200+
"@abseil-cpp//absl/types:span",
133201
],
134202
)
135203

136204
cc_test(
137-
name = "arch-xc7-part_test",
205+
name = "configuration-xc7_test",
138206
srcs = [
139-
"arch-xc7-part_test.cc",
207+
"configuration-xc7_test.cc",
140208
],
141209
deps = [
142-
":arch-xc7-defs",
143-
":arch-xc7-frame-address",
144-
":arch-xc7-part",
210+
":arch-types",
211+
":arch-xc7-frame",
212+
":configuration",
213+
":configuration-packet",
214+
":frames",
215+
"@abseil-cpp//absl/types:optional",
216+
"@abseil-cpp//absl/types:span",
145217
"@googletest//:gtest",
146218
"@googletest//:gtest_main",
147219
],

fpga/xilinx/arch-types.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (C) 2017-2020 The Project X-Ray Authors.
3+
*
4+
* Use of this source code is governed by a ISC-style
5+
* license that can be found in the LICENSE file or at
6+
* https://opensource.org/licenses/ISC
7+
*
8+
* SPDX-License-Identifier: ISC
9+
*/
10+
#ifndef FPGA_XILINX_ARCH_H
11+
#define FPGA_XILINX_ARCH_H
12+
13+
#include <memory>
14+
#include <vector>
15+
16+
#include "fpga/xilinx/arch-xc7-configuration-packet.h"
17+
#include "fpga/xilinx/arch-xc7-frame.h"
18+
#include "fpga/xilinx/arch-xc7-part.h"
19+
20+
namespace fpga {
21+
namespace xilinx {
22+
enum class Architecture {
23+
kXC7,
24+
kXC7UltraScale,
25+
kXC7UltraScalePlus,
26+
};
27+
28+
template <Architecture Arch>
29+
struct ArchitectureTraits;
30+
31+
template <xc7::Architecture Arch>
32+
struct ArchitectureXC7Base {
33+
using Part = xc7::Part;
34+
using ConfigurationPacket = xc7::ConfigurationPacket;
35+
using ConfigurationPackage =
36+
std::vector<std::unique_ptr<ConfigurationPacket>>;
37+
using ConfigurationRegister = ConfigurationPacket::ConfRegType;
38+
using FrameAddress = xc7::FrameAddress;
39+
using FrameWords = xc7::FrameWords<Arch>;
40+
};
41+
42+
template <>
43+
struct ArchitectureTraits<Architecture::kXC7> {
44+
using type = ArchitectureXC7Base<xc7::Architecture::kBase>;
45+
};
46+
47+
template <>
48+
struct ArchitectureTraits<Architecture::kXC7UltraScale> {
49+
using type = ArchitectureXC7Base<xc7::Architecture::kUltraScale>;
50+
};
51+
52+
template <>
53+
struct ArchitectureTraits<Architecture::kXC7UltraScalePlus> {
54+
using type = ArchitectureXC7Base<xc7::Architecture::kUltraScalePlus>;
55+
};
56+
57+
template <Architecture Arch>
58+
using ArchitectureType = ArchitectureTraits<Arch>::type;
59+
} // namespace xilinx
60+
} // namespace fpga
61+
#endif // FPGA_XILINX_ARCH_H

fpga/xilinx/arch-xc7-configuration-packet.cc

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,45 @@
22

33
#include <cstdint>
44
#include <optional>
5+
#include <ostream>
56

67
#include "absl/types/span.h"
7-
#include "fpga/xilinx/arch-xc7-defs.h"
8+
#include "fpga/xilinx/arch-xc7-frame.h"
89
#include "fpga/xilinx/bit-ops.h"
910
#include "fpga/xilinx/configuration-packet.h"
1011

1112
namespace fpga {
1213
namespace xilinx {
1314
namespace xc7 {
15+
std::ostream &operator<<(std::ostream &o, const ConfigurationRegister &value) {
16+
switch (value) {
17+
case ConfigurationRegister::kCRC: return o << "CRC";
18+
case ConfigurationRegister::kFAR: return o << "Frame Address";
19+
case ConfigurationRegister::kFDRI: return o << "Frame Data Input";
20+
case ConfigurationRegister::kFDRO: return o << "Frame Data Output";
21+
case ConfigurationRegister::kCMD: return o << "Command";
22+
case ConfigurationRegister::kCTL0: return o << "Control 0";
23+
case ConfigurationRegister::kMASK: return o << "Mask for CTL0 and CTL1";
24+
case ConfigurationRegister::kSTAT: return o << "Status";
25+
case ConfigurationRegister::kLOUT: return o << "Legacy Output";
26+
case ConfigurationRegister::kCOR0: return o << "Configuration Option 0";
27+
case ConfigurationRegister::kMFWR: return o << "Multiple Frame Write";
28+
case ConfigurationRegister::kCBC: return o << "Initial CBC Value";
29+
case ConfigurationRegister::kIDCODE: return o << "Device ID";
30+
case ConfigurationRegister::kAXSS: return o << "User Access";
31+
case ConfigurationRegister::kCOR1: return o << "Configuration Option 1";
32+
case ConfigurationRegister::kWBSTAR: return o << "Warm Boot Start Address";
33+
case ConfigurationRegister::kTIMER: return o << "Watchdog Timer";
34+
case ConfigurationRegister::kBOOTSTS: return o << "Boot History Status";
35+
case ConfigurationRegister::kCTL1: return o << "Control 1";
36+
case ConfigurationRegister::kBSPI:
37+
return o << "BPI/SPI Configuration Options";
38+
default: return o << "Unknown";
39+
}
40+
}
41+
1442
ConfigurationPacket::ParseResult ConfigurationPacket::InitWithWordsImpl(
15-
absl::Span<uint32_t> words, const ConfigurationPacket *previous_packet) {
43+
absl::Span<FrameWord> words, const ConfigurationPacket *previous_packet) {
1644
using ConfigurationRegister = ConfigurationRegister;
1745
// Need at least one 32-bit word to have a valid packet header.
1846
if (words.empty()) {

0 commit comments

Comments
 (0)