Struct moore_vhdl::ty2::ScalarSubtype [−][src]
Expand description
A subtype of a scalar type.
Scalar types may be subtyped by a range constraint.
Implementations
Create a new enumeration subtype.
Example
use moore_vhdl::ty2::{Type, TypeMark, EnumBasetype, EnumSubtype, Range};
use moore_common::name::get_name_table;
let ty = EnumBasetype::new(vec![
"first".into(),
"second".into(),
'0'.into(),
'1'.into(),
]);
let tm = TypeMark::new(
get_name_table().intern("MY_TYPE", false),
&ty,
);
let subty = EnumSubtype::new(&tm, Range::ascending(1usize, 2usize)).unwrap();
assert_eq!(format!("{}", subty), "MY_TYPE range second to '0'");
Create a new real subtype.
Returns Some(...)
if range
is a subrange of the real, or None
otherwise.
Example
use moore_common::name::get_name_table;
use moore_vhdl::ty2::{Type, TypeMark, FloatingBasetype, FloatingSubtype, Range};
let ty = FloatingBasetype::new(Range::ascending(0.0, 1.0));
let tm = TypeMark::new(
get_name_table().intern("UNIT", false),
&ty,
);
let a = FloatingSubtype::new(&tm, Range::ascending(0.0, 0.5)).unwrap();
let b = FloatingSubtype::new(&tm, Range::descending(0.5, 0.0)).unwrap();
assert_eq!(format!("{}", a), "UNIT range 0 to 0.5");
assert_eq!(format!("{}", b), "UNIT range 0.5 downto 0");
Create a new integer subtype.
Returns Some(...)
if range
is a subrange of the integer, or None
otherwise.
Example
use moore_vhdl::ty2::{Type, TypeMark, IntegerBasetype, IntegerSubtype, Range};
use moore_common::name::get_name_table;
let ty = IntegerBasetype::new(Range::ascending(0usize, 255usize));
let tm = TypeMark::new(
get_name_table().intern("BYTE", false),
&ty,
);
let a = IntegerSubtype::new(&tm, Range::ascending(0usize, 15usize)).unwrap();
let b = IntegerSubtype::new(&tm, Range::descending(15usize, 0usize)).unwrap();
assert_eq!(format!("{}", a), "BYTE range 0 to 15");
assert_eq!(format!("{}", b), "BYTE range 15 downto 0");
Create a new integer subtype.
Returns Some(...)
if range
is a subrange of the integer, or None
otherwise.
Example
use moore_vhdl::ty2::{Type, TypeMark, PhysicalUnit, PhysicalBasetype, PhysicalSubtype, Range};
use moore_common::name::get_name_table;
let ty = PhysicalBasetype::new(Range::ascending(-1000isize, 1000isize), vec![
PhysicalUnit::primary(get_name_table().intern("fs", false), 1),
PhysicalUnit::secondary(get_name_table().intern("ps", false), 1000, 1000, 0),
], 0);
let tm = TypeMark::new(
get_name_table().intern("TIME", false),
&ty,
);
let a = PhysicalSubtype::new(&tm, Range::ascending(0isize, 100isize)).unwrap();
let b = PhysicalSubtype::new(&tm, Range::descending(100isize, 0isize)).unwrap();
assert_eq!(format!("{}", a), "TIME range 0 to 100");
assert_eq!(format!("{}", b), "TIME range 100 downto 0");
Trait Implementations
Allocate a value of type T
.
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn FloatingType + 't, f64>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn FloatingType + 't, f64>> for TypeArena<'t> where
't: 'a,
Allocate a value of type T
.
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn IntegerType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn IntegerType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
Allocate a value of type T
.
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
impl<'a, 't> Alloc<'a, 'a, ScalarSubtype<'t, dyn PhysicalType + 't, BigInt>> for TypeArena<'t> where
't: 'a,
Allocate a value of type T
.
impl<'t, T: PartialEq + Type + ?Sized + 't, C: PartialEq + Clone> PartialEq<ScalarSubtype<'t, T, C>> for ScalarSubtype<'t, T, C>
impl<'t, T: PartialEq + Type + ?Sized + 't, C: PartialEq + Clone> PartialEq<ScalarSubtype<'t, T, C>> for ScalarSubtype<'t, T, C>
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<'t, T, C> !RefUnwindSafe for ScalarSubtype<'t, T, C>
impl<'t, T, C> !Send for ScalarSubtype<'t, T, C>
impl<'t, T, C> !Sync for ScalarSubtype<'t, T, C>
impl<'t, T: ?Sized, C> Unpin for ScalarSubtype<'t, T, C> where
C: Unpin,
impl<'t, T, C> !UnwindSafe for ScalarSubtype<'t, T, C>
Blanket Implementations
Mutably borrows from an owned value. Read more