group all xilinx annotations together
All checks were successful
/ test (pull_request) Successful in 4m23s
All checks were successful
/ test (pull_request) Successful in 4m23s
This commit is contained in:
parent
a565be1b09
commit
def406ab52
7 changed files with 71 additions and 34 deletions
|
@ -145,52 +145,73 @@ pub struct DocStringAnnotation {
|
|||
|
||||
macro_rules! make_annotation_enum {
|
||||
(
|
||||
#[$non_exhaustive:ident]
|
||||
$(#[$meta:meta])*
|
||||
$vis:vis enum $Annotation:ident {
|
||||
$vis:vis enum $AnnotationEnum:ident {
|
||||
$($Variant:ident($T:ty),)*
|
||||
}
|
||||
) => {
|
||||
crate::annotations::make_annotation_enum!(@require_non_exhaustive $non_exhaustive);
|
||||
|
||||
#[$non_exhaustive]
|
||||
$(#[$meta])*
|
||||
$vis enum $Annotation {
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
$vis enum $AnnotationEnum {
|
||||
$($Variant($T),)*
|
||||
}
|
||||
|
||||
$(impl IntoAnnotations for $T {
|
||||
type IntoAnnotations = [$Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[$Annotation::$Variant(self)]
|
||||
impl std::fmt::Debug for $AnnotationEnum {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
$(Self::$Variant(v) => v.fmt(f),)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoAnnotations for &'_ $T {
|
||||
type IntoAnnotations = [$Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[$Annotation::$Variant(*self)]
|
||||
$(impl From<$T> for crate::annotations::Annotation {
|
||||
fn from(v: $T) -> Self {
|
||||
$AnnotationEnum::$Variant(v).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoAnnotations for &'_ mut $T {
|
||||
type IntoAnnotations = [$Annotation; 1];
|
||||
impl crate::annotations::IntoAnnotations for $T {
|
||||
type IntoAnnotations = [crate::annotations::Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[$Annotation::$Variant(*self)]
|
||||
[self.into()]
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoAnnotations for Box<$T> {
|
||||
type IntoAnnotations = [$Annotation; 1];
|
||||
impl crate::annotations::IntoAnnotations for &'_ $T {
|
||||
type IntoAnnotations = [crate::annotations::Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[$Annotation::$Variant(*self)]
|
||||
[crate::annotations::Annotation::from(self.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::annotations::IntoAnnotations for &'_ mut $T {
|
||||
type IntoAnnotations = [crate::annotations::Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[crate::annotations::Annotation::from(self.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::annotations::IntoAnnotations for Box<$T> {
|
||||
type IntoAnnotations = [crate::annotations::Annotation; 1];
|
||||
|
||||
fn into_annotations(self) -> Self::IntoAnnotations {
|
||||
[crate::annotations::Annotation::from(*self)]
|
||||
}
|
||||
})*
|
||||
};
|
||||
(@require_non_exhaustive non_exhaustive) => {};
|
||||
}
|
||||
|
||||
pub(crate) use make_annotation_enum;
|
||||
|
||||
make_annotation_enum! {
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum Annotation {
|
||||
DontTouch(DontTouchAnnotation),
|
||||
|
@ -199,8 +220,7 @@ make_annotation_enum! {
|
|||
BlackBoxPath(BlackBoxPathAnnotation),
|
||||
DocString(DocStringAnnotation),
|
||||
CustomFirrtl(CustomFirrtlAnnotation),
|
||||
XdcLocation(crate::build::vendor::xilinx::XdcLocationAnnotation),
|
||||
XdcIOStandard(crate::build::vendor::xilinx::XdcIOStandardAnnotation),
|
||||
Xilinx(crate::build::vendor::xilinx::XilinxAnnotation),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
crates/fayalite/src/build/vendor/xilinx.rs
vendored
10
crates/fayalite/src/build/vendor/xilinx.rs
vendored
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// See Notices.txt for copyright information
|
||||
|
||||
use crate::intern::Interned;
|
||||
use crate::{annotations::make_annotation_enum, intern::Interned};
|
||||
|
||||
pub mod yosys_nextpnr_prjxray;
|
||||
|
||||
|
@ -15,6 +15,14 @@ pub struct XdcLocationAnnotation {
|
|||
pub location: Interned<str>,
|
||||
}
|
||||
|
||||
make_annotation_enum! {
|
||||
#[non_exhaustive]
|
||||
pub enum XilinxAnnotation {
|
||||
XdcIOStandard(XdcIOStandardAnnotation),
|
||||
XdcLocation(XdcLocationAnnotation),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn built_in_job_kinds() -> impl IntoIterator<Item = crate::build::DynJobKind> {
|
||||
yosys_nextpnr_prjxray::built_in_job_kinds()
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
external::{
|
||||
ExternalCommand, ExternalCommandJob, ExternalCommandJobKind, ExternalProgramTrait,
|
||||
},
|
||||
vendor::xilinx::{XdcIOStandardAnnotation, XdcLocationAnnotation},
|
||||
vendor::xilinx::{XdcIOStandardAnnotation, XdcLocationAnnotation, XilinxAnnotation},
|
||||
verilog::{UnadjustedVerilog, VerilogDialect, VerilogJob, VerilogJobKind},
|
||||
},
|
||||
bundle::Bundle,
|
||||
|
@ -377,13 +377,17 @@ impl YosysNextpnrXrayWriteXdcFile {
|
|||
| Annotation::BlackBoxPath(_)
|
||||
| Annotation::DocString(_)
|
||||
| Annotation::CustomFirrtl(_) => {}
|
||||
Annotation::XdcLocation(XdcLocationAnnotation { location }) => writeln!(
|
||||
Annotation::Xilinx(XilinxAnnotation::XdcLocation(XdcLocationAnnotation {
|
||||
location,
|
||||
})) => writeln!(
|
||||
output,
|
||||
"set_property LOC {} [get_ports {}]",
|
||||
tcl_escape(location),
|
||||
tcl_escape(port.scalarized_name())
|
||||
)?,
|
||||
Annotation::XdcIOStandard(XdcIOStandardAnnotation { value }) => writeln!(
|
||||
Annotation::Xilinx(XilinxAnnotation::XdcIOStandard(XdcIOStandardAnnotation {
|
||||
value,
|
||||
})) => writeln!(
|
||||
output,
|
||||
"set_property IOSTANDARD {} [get_ports {}]",
|
||||
tcl_escape(value),
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
DocStringAnnotation, DontTouchAnnotation, SVAttributeAnnotation, TargetedAnnotation,
|
||||
},
|
||||
array::Array,
|
||||
build::{ToArgs, WriteArgs},
|
||||
build::{ToArgs, WriteArgs, vendor::xilinx::XilinxAnnotation},
|
||||
bundle::{Bundle, BundleField, BundleType},
|
||||
clock::Clock,
|
||||
enum_::{Enum, EnumType, EnumVariant},
|
||||
|
@ -1905,7 +1905,8 @@ impl<'a> Exporter<'a> {
|
|||
class: str::to_string(class),
|
||||
additional_fields: (*additional_fields).into(),
|
||||
},
|
||||
Annotation::XdcLocation(_) | Annotation::XdcIOStandard(_) => return,
|
||||
Annotation::Xilinx(XilinxAnnotation::XdcLocation(_))
|
||||
| Annotation::Xilinx(XilinxAnnotation::XdcIOStandard(_)) => return,
|
||||
};
|
||||
self.annotations.push(FirrtlAnnotation {
|
||||
data,
|
||||
|
|
|
@ -1802,6 +1802,7 @@ impl_run_pass_clone!([] ExternModuleParameter);
|
|||
impl_run_pass_clone!([] SIntValue);
|
||||
impl_run_pass_clone!([] std::ops::Range<usize>);
|
||||
impl_run_pass_clone!([] UIntValue);
|
||||
impl_run_pass_clone!([] crate::build::vendor::xilinx::XilinxAnnotation);
|
||||
impl_run_pass_copy!([] BlackBoxInlineAnnotation);
|
||||
impl_run_pass_copy!([] BlackBoxPathAnnotation);
|
||||
impl_run_pass_copy!([] bool);
|
||||
|
@ -1817,8 +1818,6 @@ impl_run_pass_copy!([] UInt);
|
|||
impl_run_pass_copy!([] usize);
|
||||
impl_run_pass_copy!([] FormalKind);
|
||||
impl_run_pass_copy!([] PhantomConst);
|
||||
impl_run_pass_copy!([] crate::build::vendor::xilinx::XdcIOStandardAnnotation);
|
||||
impl_run_pass_copy!([] crate::build::vendor::xilinx::XdcLocationAnnotation);
|
||||
|
||||
macro_rules! impl_run_pass_for_struct {
|
||||
(
|
||||
|
@ -2219,8 +2218,7 @@ impl_run_pass_for_enum! {
|
|||
BlackBoxPath(v),
|
||||
DocString(v),
|
||||
CustomFirrtl(v),
|
||||
XdcLocation(v),
|
||||
XdcIOStandard(v),
|
||||
Xilinx(v),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
DocStringAnnotation, DontTouchAnnotation, SVAttributeAnnotation, TargetedAnnotation,
|
||||
},
|
||||
array::ArrayType,
|
||||
build::vendor::xilinx::{XdcIOStandardAnnotation, XdcLocationAnnotation},
|
||||
build::vendor::xilinx::{XdcIOStandardAnnotation, XdcLocationAnnotation, XilinxAnnotation},
|
||||
bundle::{Bundle, BundleField, BundleType},
|
||||
clock::Clock,
|
||||
enum_::{Enum, EnumType, EnumVariant},
|
||||
|
|
|
@ -1177,8 +1177,7 @@
|
|||
"BlackBoxPath": "Visible",
|
||||
"DocString": "Visible",
|
||||
"CustomFirrtl": "Visible",
|
||||
"XdcLocation": "Visible",
|
||||
"XdcIOStandard": "Visible"
|
||||
"Xilinx": "Visible"
|
||||
}
|
||||
},
|
||||
"DontTouchAnnotation": {
|
||||
|
@ -1216,6 +1215,13 @@
|
|||
"$kind": "Opaque"
|
||||
}
|
||||
},
|
||||
"XilinxAnnotation": {
|
||||
"data": {
|
||||
"$kind": "Enum",
|
||||
"XdcLocation": "Visible",
|
||||
"XdcIOStandard": "Visible"
|
||||
}
|
||||
},
|
||||
"XdcLocationAnnotation": {
|
||||
"data": {
|
||||
"$kind": "Opaque"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue