-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenPDK] Make synthesis targets for find_index for investigation of #23
The following command works for sample `bazel_rules_hdl` based synthesis (yosys, sky130): ``` bazel build -c opt //xls/examples:find_index_5000ps_model_unit_verilog_synth ``` Introduces `rules_pkg` dependency to XLS Bazel WORKSPACE which is required for `bazel_rules_hdl` to produce this target output. PiperOrigin-RevId: 447582850
- Loading branch information
1 parent
ecca7a8
commit b08f89e
Showing
5 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2022 The XLS Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import std | ||
|
||
fn find_index(x: u4[4], target: u4) -> (bool, u2) { | ||
let (found, index) = std::find_index(x, target); | ||
(found, index as u2) | ||
} | ||
|
||
#![test] | ||
fn test_sample_values() { | ||
let _ = assert_eq(find_index(u4[4]:[1, 2, 3, 4], u4:1), (true, u2:0)); | ||
let _ = assert_eq(find_index(u4[4]:[1, 2, 3, 4], u4:3), (true, u2:2)); | ||
let _ = assert_eq(find_index(u4[4]:[1, 2, 3, 4], u4:5), (false, u2:0)); | ||
() | ||
} |