Skip to content

Commit 97a2a67

Browse files
cdlearycopybara-github
authored andcommitted
[cleanup] Move all ice40 oriented code to contrib directory.
We were targeting small FPGAs in early experiments but our primary focus is ASIC and we can use open PDKs for that in OSS (e.g. ASAP7, SKY130). PiperOrigin-RevId: 610799670
1 parent e4d3071 commit 97a2a67

40 files changed

+271
-245
lines changed

xls/contrib/ice40/BUILD

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Copyright 2024 The XLS Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
package(
16+
default_applicable_licenses = ["//:license"],
17+
default_visibility = ["//xls:xls_internal"],
18+
licenses = ["notice"], # Apache 2.0
19+
)
20+
21+
cc_library(
22+
name = "wrap_io",
23+
srcs = ["wrap_io.cc"],
24+
hdrs = ["wrap_io.h"],
25+
deps = [
26+
":io_strategy",
27+
"//xls/codegen:finite_state_machine",
28+
"//xls/codegen:module_signature",
29+
"//xls/codegen:vast",
30+
"//xls/common:math_util",
31+
"//xls/common/status:ret_check",
32+
"//xls/common/status:status_macros",
33+
"//xls/ir:source_location",
34+
"@com_google_absl//absl/status",
35+
"@com_google_absl//absl/status:statusor",
36+
],
37+
)
38+
39+
cc_test(
40+
name = "wrap_io_test",
41+
srcs = ["wrap_io_test.cc"],
42+
data = glob(["testdata/wrap_io_test_*.vtxt"]),
43+
deps = [
44+
":ice40_io_strategy",
45+
":null_io_strategy",
46+
":wrap_io",
47+
"//xls/codegen:module_signature",
48+
"//xls/codegen:vast",
49+
"//xls/common:xls_gunit",
50+
"//xls/common:xls_gunit_main",
51+
"//xls/common/logging",
52+
"//xls/common/status:matchers",
53+
"//xls/ir:source_location",
54+
"//xls/simulation:module_testbench",
55+
"//xls/simulation:module_testbench_thread",
56+
"//xls/simulation:verilog_test_base",
57+
],
58+
)
59+
60+
cc_library(
61+
name = "ice40_io_strategy",
62+
srcs = ["ice40_io_strategy.cc"],
63+
hdrs = ["ice40_io_strategy.h"],
64+
data = ["//xls/contrib/ice40/uncore_rtl/ice40:iceprog_includes"],
65+
deps = [
66+
":io_strategy",
67+
"//xls/codegen:vast",
68+
"//xls/common/file:filesystem",
69+
"//xls/common/file:get_runfile_path",
70+
"//xls/common/status:status_macros",
71+
"//xls/tools:verilog_include",
72+
"@com_google_absl//absl/status",
73+
"@com_google_absl//absl/status:statusor",
74+
],
75+
)
76+
77+
cc_binary(
78+
name = "wrap_io_main",
79+
srcs = ["wrap_io_main.cc"],
80+
deps = [
81+
":ice40_io_strategy_registry",
82+
":io_strategy",
83+
":io_strategy_factory",
84+
":wrap_io",
85+
"//xls/codegen:module_signature",
86+
"//xls/common:exit_status",
87+
"//xls/common:init_xls",
88+
"//xls/common/file:filesystem",
89+
"//xls/common/logging",
90+
"@com_google_absl//absl/flags:flag",
91+
"@com_google_absl//absl/status",
92+
"@com_google_absl//absl/status:statusor",
93+
],
94+
)
95+
96+
cc_library(
97+
name = "ice40_io_strategy_registry",
98+
srcs = ["ice40_io_strategy_registry.cc"],
99+
deps = [
100+
":ice40_io_strategy",
101+
":io_strategy_factory",
102+
"//xls/common:module_initializer",
103+
],
104+
alwayslink = True,
105+
)
106+
107+
cc_binary(
108+
name = "drpc_main",
109+
srcs = ["drpc_main.cc"],
110+
deps = [
111+
":device_rpc_strategy",
112+
":device_rpc_strategy_factory",
113+
":ice40_device_rpc_strategy_registry",
114+
"//xls/common:exit_status",
115+
"//xls/common:init_xls",
116+
"//xls/common/logging",
117+
"//xls/ir:format_preference",
118+
"//xls/ir:ir_parser",
119+
"@com_google_absl//absl/flags:flag",
120+
"@com_google_absl//absl/status:statusor",
121+
"@com_google_absl//absl/types:span",
122+
],
123+
)
124+
125+
cc_library(
126+
name = "ice40_device_rpc_strategy",
127+
srcs = ["ice40_device_rpc_strategy.cc"],
128+
hdrs = ["ice40_device_rpc_strategy.h"],
129+
deps = [
130+
":device_rpc_strategy",
131+
"//xls/common:math_util",
132+
"//xls/common:strerror",
133+
"//xls/common/file:filesystem",
134+
"//xls/common/logging",
135+
"//xls/common/status:ret_check",
136+
"//xls/common/status:status_macros",
137+
"@com_google_absl//absl/status:statusor",
138+
"@com_google_absl//absl/strings",
139+
"@com_google_absl//absl/strings:str_format",
140+
],
141+
)
142+
143+
cc_library(
144+
name = "ice40_device_rpc_strategy_registry",
145+
srcs = ["ice40_device_rpc_strategy_registry.cc"],
146+
deps = [
147+
":device_rpc_strategy_factory",
148+
":ice40_device_rpc_strategy",
149+
"//xls/common:module_initializer",
150+
],
151+
alwayslink = True,
152+
)
153+
154+
cc_library(
155+
name = "null_io_strategy",
156+
srcs = ["null_io_strategy.cc"],
157+
hdrs = ["null_io_strategy.h"],
158+
deps = [
159+
":io_strategy",
160+
"//xls/codegen:vast",
161+
"@com_google_absl//absl/status",
162+
"@com_google_absl//absl/status:statusor",
163+
],
164+
)
165+
166+
cc_library(
167+
name = "device_rpc_strategy",
168+
hdrs = ["device_rpc_strategy.h"],
169+
deps = [
170+
"//xls/ir:type",
171+
"//xls/ir:value",
172+
"@com_google_absl//absl/status",
173+
"@com_google_absl//absl/status:statusor",
174+
"@com_google_absl//absl/types:span",
175+
],
176+
)
177+
178+
cc_library(
179+
name = "device_rpc_strategy_factory",
180+
srcs = ["device_rpc_strategy_factory.cc"],
181+
hdrs = ["device_rpc_strategy_factory.h"],
182+
deps = [
183+
":device_rpc_strategy",
184+
"@com_google_absl//absl/base:no_destructor",
185+
"@com_google_absl//absl/container:flat_hash_map",
186+
"@com_google_absl//absl/status",
187+
"@com_google_absl//absl/status:statusor",
188+
"@com_google_absl//absl/strings:str_format",
189+
],
190+
)
191+
192+
cc_library(
193+
name = "io_strategy",
194+
hdrs = ["io_strategy.h"],
195+
deps = [
196+
"//xls/codegen:vast",
197+
"//xls/tools:verilog_include",
198+
"@com_google_absl//absl/status",
199+
"@com_google_absl//absl/status:statusor",
200+
],
201+
)
202+
203+
cc_library(
204+
name = "io_strategy_factory",
205+
srcs = ["io_strategy_factory.cc"],
206+
hdrs = ["io_strategy_factory.h"],
207+
deps = [
208+
":io_strategy",
209+
"@com_google_absl//absl/base:no_destructor",
210+
"@com_google_absl//absl/container:flat_hash_map",
211+
"@com_google_absl//absl/status:statusor",
212+
],
213+
)

xls/contrib/ice40/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Utilities for working with designs placed onto the ICE40 FPGA; e.g. via yosys.

xls/tools/device_rpc_strategy_factory.cc renamed to xls/contrib/ice40/device_rpc_strategy_factory.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "xls/tools/device_rpc_strategy_factory.h"
15+
#include "xls/contrib/ice40/device_rpc_strategy_factory.h"
1616

1717
#include <memory>
1818
#include <string_view>

xls/tools/device_rpc_strategy_factory.h renamed to xls/contrib/ice40/device_rpc_strategy_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "absl/base/no_destructor.h"
2525
#include "absl/container/flat_hash_map.h"
2626
#include "absl/status/statusor.h"
27-
#include "xls/tools/device_rpc_strategy.h"
27+
#include "xls/contrib/ice40/device_rpc_strategy.h"
2828

2929
namespace xls {
3030

xls/tools/drpc_main.cc renamed to xls/contrib/ice40/drpc_main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
#include "xls/common/exit_status.h"
3333
#include "xls/common/init_xls.h"
3434
#include "xls/common/logging/logging.h"
35+
#include "xls/contrib/ice40/device_rpc_strategy.h"
36+
#include "xls/contrib/ice40/device_rpc_strategy_factory.h"
3537
#include "xls/ir/format_preference.h"
3638
#include "xls/ir/ir_parser.h"
37-
#include "xls/tools/device_rpc_strategy.h"
38-
#include "xls/tools/device_rpc_strategy_factory.h"
3939

4040
ABSL_FLAG(std::string, target_device, "",
4141
"Target (category of) device for DRPC targeting; e.g. ice40.");

xls/tools/ice40_device_rpc_strategy.cc renamed to xls/contrib/ice40/ice40_device_rpc_strategy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "xls/tools/ice40_device_rpc_strategy.h"
15+
#include "xls/contrib/ice40/ice40_device_rpc_strategy.h"
1616

1717
#include <fcntl.h>
1818
#include <sys/stat.h>

xls/tools/ice40_device_rpc_strategy.h renamed to xls/contrib/ice40/ice40_device_rpc_strategy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <optional>
1919

2020
#include "absl/status/statusor.h"
21-
#include "xls/tools/device_rpc_strategy.h"
21+
#include "xls/contrib/ice40/device_rpc_strategy.h"
2222

2323
namespace xls {
2424

xls/tools/ice40_device_rpc_strategy_registry.cc renamed to xls/contrib/ice40/ice40_device_rpc_strategy_registry.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// limitations under the License.
1414

1515
#include "xls/common/module_initializer.h"
16-
#include "xls/tools/device_rpc_strategy_factory.h"
17-
#include "xls/tools/ice40_device_rpc_strategy.h"
16+
#include "xls/contrib/ice40/device_rpc_strategy_factory.h"
17+
#include "xls/contrib/ice40/ice40_device_rpc_strategy.h"
1818

1919
XLS_REGISTER_MODULE_INITIALIZER(xls_tools_ice40_device_rpc_strategy_registry, {
2020
xls::DeviceRpcStrategyFactory::GetSingleton().Add("ice40", []() {

xls/tools/ice40_io_strategy.cc renamed to xls/contrib/ice40/ice40_io_strategy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "xls/tools/ice40_io_strategy.h"
15+
#include "xls/contrib/ice40/ice40_io_strategy.h"
1616

1717
#include <filesystem>
1818
#include <utility>

xls/tools/ice40_io_strategy.h renamed to xls/contrib/ice40/ice40_io_strategy.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#include "absl/status/status.h"
2121
#include "absl/status/statusor.h"
2222
#include "xls/codegen/vast.h"
23-
#include "xls/tools/wrap_io.h"
23+
#include "xls/contrib/ice40/io_strategy.h"
24+
#include "xls/tools/verilog_include.h"
2425

2526
namespace xls {
2627
namespace verilog {
@@ -40,9 +41,8 @@ class Ice40IoStrategy : public IOStrategy {
4041
private:
4142
// The files tick-included by the IO strategy.
4243
constexpr static const char* kIncludes[] = {
43-
"xls/uncore_rtl/ice40/uart_receiver.v",
44-
"xls/uncore_rtl/ice40/uart_transmitter.v"
45-
};
44+
"xls/contrib/ice40/uncore_rtl/ice40/uart_receiver.v",
45+
"xls/contrib/ice40/uncore_rtl/ice40/uart_transmitter.v"};
4646

4747
VerilogFile* f_;
4848

xls/tools/ice40_io_strategy_registry.cc renamed to xls/contrib/ice40/ice40_io_strategy_registry.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// limitations under the License.
1414

1515
#include "xls/common/module_initializer.h"
16-
#include "xls/tools/ice40_io_strategy.h"
17-
#include "xls/tools/io_strategy_factory.h"
16+
#include "xls/contrib/ice40/ice40_io_strategy.h"
17+
#include "xls/contrib/ice40/io_strategy_factory.h"
1818

1919
XLS_REGISTER_MODULE_INITIALIZER(xls_tools_ice40_strategy_registry, {
2020
xls::verilog::IOStrategyFactory::GetSingleton().Add(
File renamed without changes.

xls/tools/io_strategy_factory.cc renamed to xls/contrib/ice40/io_strategy_factory.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "xls/tools/io_strategy_factory.h"
15+
#include "xls/contrib/ice40/io_strategy_factory.h"
1616

1717
#include <memory>
1818
#include <string_view>

xls/tools/io_strategy_factory.h renamed to xls/contrib/ice40/io_strategy_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "absl/base/no_destructor.h"
2525
#include "absl/container/flat_hash_map.h"
2626
#include "absl/status/statusor.h"
27-
#include "xls/tools/io_strategy.h"
27+
#include "xls/contrib/ice40/io_strategy.h"
2828

2929
namespace xls {
3030
namespace verilog {

xls/tools/null_io_strategy.cc renamed to xls/contrib/ice40/null_io_strategy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "xls/tools/null_io_strategy.h"
15+
#include "xls/contrib/ice40/null_io_strategy.h"
1616

1717
namespace xls {
1818
namespace verilog {

xls/tools/null_io_strategy.h renamed to xls/contrib/ice40/null_io_strategy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "absl/status/status.h"
2121
#include "absl/status/statusor.h"
2222
#include "xls/codegen/vast.h"
23-
#include "xls/tools/io_strategy.h"
23+
#include "xls/contrib/ice40/io_strategy.h"
2424

2525
namespace xls {
2626
namespace verilog {

xls/tools/testdata/wrap_io_test_Ice40WrapIOIdentity32b.vtxt renamed to xls/contrib/ice40/testdata/wrap_io_test_Ice40WrapIOIdentity32b.vtxt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module device_to_wrap(
44
);
55
assign out = in;
66
endmodule
7-
`include "xls/uncore_rtl/ice40/uart_receiver.v"
8-
`include "xls/uncore_rtl/ice40/uart_transmitter.v"
7+
`include "xls/contrib/ice40/uncore_rtl/ice40/uart_receiver.v"
8+
`include "xls/contrib/ice40/uncore_rtl/ice40/uart_transmitter.v"
99
module input_resetter(
1010
input wire clk,
1111
input wire [7:0] byte_in,

0 commit comments

Comments
 (0)