VHDL数据类型(Data Types)

数据类型(Data Types)

数据类型用来指示该点多使用的类型。VHDL中共有4类类型:
A data type appears in a declaration to identify the type used at that point. There are four classes of types in VHDL:

  • 标量类型:表示一个单独的数字值,枚举类型。标准类型有:
    • 枚举类型
    • 浮点型
    • 整型
    • 物理类型
  • Scalar types: represent a single numeric value, or in the case of
    enumerated types, an enumeration value. The standard types that fall
    into this class are:
    • Enumeration
    • Floating Point
    • Integer
    • Physical
  • 复合类型:表示数值的集合。其标准类型有以下几种:
    • 数组
    • 记录
  • Composite types: represent a collection of values. The standard types
    that fall into this call are:
    • Array
    • Record
  • 访问类型提供对象的访问入口,类似于一些软件编程语言的指针。
  • Access type provide access to objects, equivalent to pointers in
    software programming languages.
    -文件类型表示对象(典型的如硬盘文件)包含一系列值。
    File type reference objects (typically disk files) that contain a
    sequence of values.
    你可以基于上述类型的基础上自定义自己的类型,或者使用subtype关键字来约束已存在的类型。
    You can define your own type based on one of the classes mentioned above, or constrain an existing type with the subtype keyword.

枚举类型(Enumeration Type)

枚举类型是一组具有明确值的集合。枚举中的值是一个命名项或者一个字符。
The enumeration type is a type whose values are defined by listing all possible values explicitly. Each value is either a name or a character.

语法(Syntax)

type 枚举名 is ( 枚举元素, 枚举元素, ... );
type new_name is ( type_element, type_element, ... );

说明(Description)

枚举类型是一个有序值的集合,也称为枚举文字,连续的标识符或字符文字。相同值不允许出现在同一类型中,但是可以出现在不同的枚举类型中。这种情况被称为重载。
The enumeration type is a type with an ordered set of values, called enumeration literals, and consisting of identifiers and character literals. The same value cannot appear twice in the same type, but may appear in two (or more) different enumeration types. This is called overloading.
所有的枚举值都是有序的,并且有一个数字(整数)与之对应。数字值指示该枚举值在列表中的位置。枚举类型中第一个值的位置值为0,后面的值依次加一。
All enumerated values are ordered and each of them has a numeric (integer) value assigned to it. This number indicates the position of the value in the list. The first value in the definition has position number zero and each subsequent has the number increased by one from its predecessor.

例程(Example)

type FSM_States is (idle, start, stop, clear); 
type std_ulogic is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-');

注释(Notes)

  • 定义有范围的枚举类型是不合法的。
  • It is illegal to define an enumeration type with a range.
  • 列表中的字符值是可打印字符,且用单引号包围。
  • A character in the list of values is a printable charter enclosed in
    single quotes!
    标准库中声明了一些预先定义的枚举类型。
  • The package Standard contains declarations of several predefined
    enumeration types.

浮点类型(Floating Point)

浮点类型提供实数的近似值。
A floating point type provides an approximation to the real numbers.

语法(Syntax)

type 浮点名 is 实数最大值 downto 实属最小值;    -- 降序 
type 浮点名 is 实属最小值 to 实属最大值;        -- 升序
type new_name is range real_number_left_bound downto real_number_right_bound;    -- descending 
type new_name is range real_number_left_bound to real_number_right_bound;        -- ascending

说明(Description)

浮点类型是由实数组成的数字类型,它的值具有特定的范围。
A floating point type is a numeric type consisting of real numbers which values are constrained by a specified range.
目前仅有一种浮点类型:real。实数类型值的范围取决于实现工具,但是它的范围必须在标准范围-1.0E38到+1.0E38之间。
There exists only one predefined floating point type: Real. The range of the values for the type Real are implementation-dependent, but it is required by the standard that it covers the values from -1.0E38 to +1.0E38.
用户定义的浮点类型建立于预定义实数类型的基础上,通过约束其范围来创建。用户定义浮点类型的范围边界必须是静态的浮点类型表达式。
A user-defined floating point type can be constructed on the basis of the predefined Real type by constraining its range. The bounds of the range of a user-defined floating point type must be static floating point type expressions.
所有浮点类型(包括用户定义的)具有相同的算术运算符集,即:加、减、乘、除、取绝对值和幂运算。
All floating point types (including user-defined) have the same set of arithmetic operators, namely: addition, subtraction, multiplication, division, absolute function and exponentiation.

例程(Example)

type InputLevel is range -6.55 to +12.35; 
type Int64K is range -65536.00 to 65535.00;

注释(Note)
- 浮点类型不能被综合。浮点类型被用于高层次的仿真。
- The floating point types are not synthesizeable. The floating point
type is used for high level simulations.

整型(Integer)
整型是包含指定范围整数的数量集。
The integer type is a scalar whose set of values includes integer numbers of the specified range.

语法(Syntax)

type 整型名 is 整数最小值 to 整数最大值; 
type 整型名 is 整数最大值 downto 整数最小值; 
type type_name is integer_left_bound to integer_right_bound; 
type type_name is integer_left_bound downto integer_right_bound; 

说明(Description)

整型是由一定范围的整数组成的数字类型。只有一种预定义的整型,其大小范围为+/-(2E31 - 1)。
An integer type is a numeric type which consists of integer numbers within the specified range. There is only one predefined Integer type, and that is type Integer which range depends on the implementation, but must cover at least the range +/-(2E31 - 1).

用户定义的整型可以通过约束其范围,基于预定义的整型来构建。
A user-defined integer type can be constructed on the basis of the predefined Integer type by constraining its range.
所有整型(包括用户定义的)都具有相同的在标准包中定义的算术运算集,即加、减、乘、除、取模和取余。在所以情况下,操作符和结果都是整型。
All integer types (including user-defined) have the same set of arithmetic operators, defined in the package Standard, namely: addition, subtraction, multiplication, division, modulus, and remainder. In all cases both operands and the result are of the integer type.
整型的关系运算符有:等、不等、大于、大于等于、小于等于。关系运算的结构是布尔型(boolean type)。
Relations can be checked on integer operands: equal, unequal, greater than, less than, greater or equal than, and less or equal than. In all cases, the result is of the Boolean type.

例程(Example)

type Level is range 0 to 7; 
type Int_64K is range -65536 to 65535; 
type WORDS is range 31 downto 0;

注释(Note)

  • 给整型赋的值超过其范围则导致错误。
  • It is an error to assign to an integer object a value which is from
    outside its range.

物理类型(Physical Type)

物理类型表示具有物理单位的整数值。
A physical type represents an integer value together with a physical unit.

语法(Syntax)

type 物理类型名 is 左边界 to 右边界
units
    主单位名;
    次级单位名 = 量级值 主单位名;
    ...
end units [物理类型名]

type 物理类型名 is 左边界 downto 右边界
units
    主单位名;
    次级单位名 = 量级值 主单位名;
    ...
end units [物理类型名]
type new_name is range left_bound to right_bound 
units 
  primary_unit_name;
  secondary_unit_name = number primary_unit_name;
  ...
end units [ new_name ]; 
type new_name is range left_bound downto right_bound 
units 
  primary_unit_name;
  secondary_unit_name = number primary_unit_name;
  ...
end units [ new_name ];

说明(Description)
物理类型允许给一些物理量定义测量单位,如长度、时间、压强,电容等。
A physical type allows to define measurement units for some physical quantity, like length, time, pressure, capacity, etc.
物理类型的声明以定义一个主单位开始,后面可以选择有一个或多个次级单位。主单位一般表示该指定类型的主单位。次级单位被定义为主单位的倍数或者前面定义的次级单位的倍数。他们的声明只能是整型。
A physical type declaration starts with the definition of a primary unit, which is optionally followed by, one or more secondary units. The primary unit serves as the base unit for representing values of the specified type. The secondary units are defined as multiplicity of primary units or previously specified secondary units. Their declarations may contain only integer literals.
每个物理类型的值都有一个相对于主单位的位置编号。所以,同一类型不同单位的值可以进行比较。
Each value of a physical type has a corresponding position number, which is the number of primary units represented by that unit name. This way values specified in different units of the same type can be compared.

例程(Example)

type Capacity is range 0 to integer'high
units
  pF;               -- picofarad 
  nF = 1000 pF;     -- nanofarad 
  uF = 1000 nF;     -- microfarad 
  mF = 1000 uF;     -- milifarad 
  F  = 1000 mF;     -- farad 
end units; 

注释(Notes)

  • 物理类型不可被综合。
  • Physical types are not synthesizeable.
  • 浮点值不允许用于物理类型的声明。例如,如果要实现毫米到英尺(25.4mm = 1in)的转换,则毫米不能用作基本单位。
  • It is not allowed to use floating point values in physical type
    declarations, i.e. if a conversion from millimeters to inches (25.4
    mm = 1 in) would have to be performed, then millimeters could not be
    used as the base unit.
    仅推荐使用的物理类型为时间。
  • The only commonly used physical type is Time.

数组(Array)
数组类型由具有相同基本类型的矢量集或多维集合构成。
A data type which consists of a vector or a multi-dimensional set of values of the same base type.

语法(Syntax)

type 数组名 is array ( 范围, ... ) of 数据类型            -- 有约束条件
type 数据名 is array ( type range <>, ... ) of 数据类型    -- 无约束条件
type array_name is array ( range, ... ) of data_type            -- constrained
type array_name is array ( type range <>, ... ) of data_type    -- unconstrained

说明(Description)
数组是一个复合对象,它的元素都有相同的子类型。每个元素都有一个唯一的索引值。索引值的多少也就是其维度的大小,例如一维数组有一个索引值,二维数组有两个索引值。
An array is a composite object, which elements are of the same subtype. Each element is uniquely distinguished by an index. The number of indices is the number of dimensions, i.e. one-dimensional array has one index, two-dimensional has two indices, etc.

数组可以有约束条件也可以无约束。如果数组的大小被约束则该数组为有约束的数组。数组的大小可以用离散类型标记或者范围来约束。
An array may be either constrained or unconstrained. The array is constrained if the size of the array is constrained. The size of the array can be constrained using a discrete type mark or a range.
如果数组的大小不定则该数组为无约束数组,无约束数组的大小以离散类型名字的形式来声明,其范围时不定的。无约束数字类型的元素个数是不定的。
The array is said to be unconstrained if its size is unconstrained: the size of the unconstrained array is declared in the form of the name of the discrete type, which range is unconstrained. The number of elements of unconstrained array type is unknown.
数组中的值可以通过索引名或者片名来进行读写。
The values within an array can be read or written using an indexed name or a slice name.

例程(Example)

subtype Byte is std_logic_vector(7 downto 0); 
type Mem is array (0 to 63) of Byte; 
variable Memory : Mem; 
... 
if Read then 
  Data <= Memory(to_integer(Address)); 
elsif Write then 
  Memory(to_integer(Address) := Data; 
end if;

注释(Notes)

-大部分综合工具不支持多维数组(“vectors of vectors“形式的二维数外 )
- Most synthesis tools do not support multidimensional arrays (one
exception to this is two-dimensional “vectors of vectors”).

记录(Record)

由已命名元素构成的复合类型。
A composite type whose values consist of named elements.

语法(Syntax)

type 记录名 is record 
  元素名, ... : 数据类型;
  ...
end record [ 记录名 ]; 
type record_name is record 
  element_name, ... : data_type;
  ...
end record [ record_name ]; 

说明(Description)

记录表示不同类型值的集合。他和数组最大的区别在于数组的值必须是相同类型。记录的所有元素都有其各自的名字。每个记录中元素的名字必须是唯一的,相同的元素名可在不同的记录中使用。
The record represents a set of values of different types. This is the main difference from arrays, which must have all elements of the same type. All elements are declared with individual names. The names of elements in each record must be distinct. However, the same element name can be used in different records.
记录类型对象的值是一个复合值,由其元素的值构成。给记录类型赋值可以对整个记录类型赋值,也可以是对独立的元素赋值(通过名字来选取)。
The value of an object of type record is a composite value, consisting of the values of its elements. The assignment of a value to an object of the type record can be realized either through an aggregate or through individual assignments to elements (selected names).
当给记录类型的元素赋值时,使用记录名加点加上元素名来选取该元素。
When individual assignment to elements is used then each element is referenced by the record name followed by a dot and element’s name.

例程(Example)

type Person is record 
  FirstName: string (1 to 20); 
  Married: boolean;
  Children: natural;
end record;

variable V1, V2: Person;
V1.Children:= 1;
V2:= ("John", false, 0);

注释(Note)

  • 文件不允许作为记录的元素。
  • Files are not allowed as elements of records.

访问(Access)
访问类型允许动态的内存分配。访问类型值有内存分配算符返回(等同于C或者Pascal里的指针)。
A type that allows dynamic memory allocation. An access value is returned by an allocator (equivalent to pointers in C or Pascal)

语法(Syntax)

type type_name is access data_type;

type incomplete_type_name;

说明(Description)

访问类型可以灵活地处理数据,在事先不知道其确切大小的前提下,在仿真时动态地创建。任何对访问类型的引用都通过分配运算符来实现,其工作机制类似于编程语言中的指针。
Access type allows to manipulate data, which are created dynamically during simulation and which exact size is not known in advance. Any reference to them is performed via allocators, which work in a similar way as pointers in programming languages.

只有变量类型的对象允许是访问类型。
The only objects allowed to be of the access type are variables.
访问类型的默认值为空(null)。
The default value of an access type is null.

对于每个不完全类型的声明都必须对应一个相同名字的完全类型声明。而且两者必须在同一个地方声明。在完全类型没有声明完成前,定义的访问类型不能被使用。
For each incomplete type declaration there must be a corresponding full type declaration with the same name. The complete declaration must appear in the same declarative part. A type declared as incomplete may not be used for any other purposes than to define an access type before the complete type definition is accomplished.

例程(Example)

--declaration of record
type DataRecord is record
   Data: std_logic_vector(15 downto 0);
   NextData: Link;
end record;

-- declaration of the access type
type Link is access DataRecord; 

variable StartOfRecords, Ptr: Link;

文件(File)

文件声明表示一个特定的文件类型。
A file declaration declares a file of the specified type.

语法(Syntax)

type 新文件名 is file of 类型名;

file 新文件名: 数据类型 [ [ open 打开方式 ] is 文件名 ];
打开方式 = 只读 | 只写 | 追加 
file 新文件名: 数据类型 is [ 打开模式 ] 文件名;       -- 仅VHDL'87  
打开模式 = 输入 | 输出                             -- 仅VHDL'87 

文件名 = 字符串表达式
type new_name is file of type_name;

file new_name: data_type [ [ open file_kind ] is file_name ];
file_kind = read_mode | write_mode | append_mode 
file new_name: data_type is [ mode ] file_name;                -- VHDL'87 only 
mode = in | out                                                -- VHDL'87 only

file_name = string_expression

说明(Description)

文件声明创建一个或多个指定类型的文件对象。文件声明可以在任何对象可创建的地方进行,如结构体主体、进程、块、包或子程序中。
The file declaration creates one or more file objects of the specified type. Such a declaration can be included in any declarative part in which the objects can be created, that is within architecture bodies, processes, blocks, packages or subprograms.

可选择参数打开模式(file_kind)可以允许指定如何访问打开的文件。打开模式的值必须是在标准包中预定义的值(file_open_kind)。
The optional open file_kind allows specifying how the physical file associated with the file object should be opened. The expression must have the predefined type file_open_kind value, which is declared in the Standard package.
文件名(file_name)必须是字符串表达式。文件名将外部主机文件系统中的文件与文件对象相关联。这种关联提供了一种机制,用于在仿真期间把外部文件数据导入到设计中,或者在将生成的数据导出到外部文件。
The file_name must be an expression of predefined type String. The file_name identifies an external file in the host file system that is associated with the file object. This association provides a mechanism for either importing data contained in an external file into the design during simulation or exporting data generated during simulation to an external file.

以下是为所有文件类型定义的子进程和函数:
The following procedures and functions are defined for all file types:

procedure file_open (file F: FT; 
                     external_name: in string; 
                     open_kind: in file_open_kind := read_mode); 
procedure file_open (status: out file_open_status; 
                     file F: FT; 
                     external_name: in string; 
                     open_kind: in file_open_kind := read_mode); 
procedure file_close (file F: FT); 
procedure read (file F: FT; value: out TM); 
procedure write (file F: FT; value: in TM); 
function endfile (file F: FT) return BOOLEAN;

例程(Example)

type DataFile is file of string;
file F: DataFile open write_mode is "FileName";   -- VHDL'93 
file F: DataFile is out "filename";               -- VHDL'87 

Notes:

  • 指向同一外部文件的文件对象必须是相同的基础类型。
  • All file objects associated with the same external file should be of
    the same base type.
    VHDL’87和VHDL’93的文件声明方式不同。
  • File declarations are incompatible between VHDL’87 and VHDL’93.
  • 通常使用Textio包来读写文件。
  • Always use package Textio to read or write files.

类型(Type)

数值集或操作符集。
A set of values and a set of operations.

语法(Syntax)

type 类型名 [ is 数据类型 ]; 
type type_name [ is data_type ]; 

说明(Description)

所有的信号、变量、常量(如对象)和表达式都有类型。类型决定了对象或表达式可以取的数值集合。类型同样可以决定对象或表达式可用的操作符集合。
All signals, variables, constants (i.e. objects) and expresssions have a type. The type defines the set of values that the object or expression can have. A type also determines the set of operations which can be performed on an object or expression.

VHDL中有四类类型:
There are four classes of types in VHDL:

  • 标量类型:表示一个单独的数值,或者枚举类型中的枚举值。
  • scalar types: represent a single numeric value, or in the case of
    enumerated types, an enumeration value.
    复合类型:表示一些值的集合。
  • composite types: represent a collection of values.
  • 访问类型:为给定类型的对象提供访问接口。
  • access types: provide access to objects of a given type.
  • 文件:为给定类型的特定序列值对象(典型的如硬盘文件)提供访问接口。
  • files: provide access to objects that contain a sequence of values of
    a given type (typically disk files).

除了预定义的类型外(标准库,std_logic_1164和numeric_std),用户可以定义自己的类型。用户定义的类型可以是上述四类类型的任何一个。
Apart from predefined types (available through the packages Standard, Std_logic_1164 and Numeric_std), the user can define his own types. A user-defined type can be of any of the four classes mentioned above.

不同类型的值不能赋值给不同类型的对象。如果需要给不同类型的对象赋值,则需要强制转换。
A value of one type cannot be assigned to an object of a different type. If a translation from one type to another is required, then type conversion must be applied.

例程(Example)

type State is (TReset, TWait, THold, THalt);

注释(Notes)

  • VHDL是强类型化的语言,即已相同方式定义的两个类型,如果其名字不同,则被认为不同的类型。
  • VHDL is a strongly typed language which causes that two types defined
    in exactly the same way (i.e. lexically identical) but differing only
    by names will be considered different.
    对象的初始值为该类型的左最值。例如枚举类最左边的值。
  • The initial value of an object is the left most value of the type,
    i.e. the value on the left of the base enumeration.

子类型(Subtype)

有约束的类型。
A type together with a constraint.

语法(Syntax)

subtype subtype_name is data_type;

说明(Description)

子类型与其基本类型相兼容,且共享相同的操作符。
A subtype is compatible with its base type and shares the same operations.

指定类型的子类型值是在约束条件范围内的类型值。类型也是其自身的自类型。这种自类型被称为无约束的,因为他们满足不限制的条件。
A value belongs to a subtype of a given type if it belongs to the type and satisfies the constraint. A type is a subtype of itself. Such a subtype is said to be unconstrained because it corresponds to a condition that imposes no restriction.
在标准库中有两个预定义的自类型:Natural和Positive。两者都是整型的自类型。Std_logic_1164同样也有子类型的声明,包括std_logic的子类型。
There are two predefined subtypes specified in the package Standard: Natural and Positive. Both are subtypes of the type Integer. The package Std_logic_1164 also contains declarations of subtypes, which are constrained subtypes of the std_logic.

例程(Example)

subtype Digits is integer range 0 to 9; 
subtype MyBit is std_logic range '0' to '1'; 
subtype MyVector is std_logic_vector(2 downto 0);

注释(Notes)

  • 子类型声明并不产生新类型。
  • A subtype declaration does not define a new type.
  • 在仿真工具为仿真寄存器设置一个数值时,强烈建议使用枚举和整型的自类型。
  • Using subtypes of enumerated and integer types for synthesis is
    strongly recommended as synthesis tools infer an appropriate number
    of bits in synthesized registers, depending on the range.

预定义类型(Predefined Types)

VHDL LRM在标准库中定义了一些数据类型,如布尔型(boolean),位(bit),位向量(bit_vector)和字符串(string)。
The VHDL LRM defines a few data types in the Standard pacakage such as Boolean, Bit, Bit_vector and String.

布尔型(Boolean)

布尔类型在标准库中的定义为枚举数据类型,有两个可能的值:假(false)和真(ture)。
The boolean type is predefined in the Standard package as an enumerated data type with two possible values: false and true.

语法(Syntax)

type boolean is (false, true); 

说明(Description)

布尔类型用于条件运算。布尔对象可用于任何关系运算符,如<,>,<=,>=,= 或者/=。
The boolean type is used for conditional operations. Boolean objects can be used with any of the relational operators <, >, <=, >=, = or /=.
任何布尔类型对象的默认值为假(false)。
The default value of any object of the boolean type is false.

例程(Example)

signal Condition: boolean; 
Condition <= true;
if Condition then ...  {is equivalent to: if Condition = true then ...}

注释(Note)

  • 布尔值(假和真)不同于逻辑0和1.在VHDL中,逻辑0和1是位类型。
  • Boolean values (false and true) are not identical to logical 0 and 1,
    respectively. In VHDL, the logical 0 and 1 are of the bit type.

位(Bit)

在标准包中位类型的定义也是一个枚举数据类型,有两个允许值:‘0’和‘1’。
The bit type is predefined in the Standard package as an enumerated data type with only two allowable values: ‘0’ and ‘1’.

语法(Syntax)

type bit is ('0','1'); 

说明(Description)

位类型是用于表示逻辑值的基本类型。值得注意的是位类型只有两个已定义的值。不能用户高阻态和其他非平常值,如未知,弱阻性等。
The bit type is the basic type to represent logical values. Note that there are only two values defined for the bit type and it is not possible to use it for high impedance and other non-trivial values such as Unknown, Resistive Weak, etc. (see Std_logic).

位类型对象的默认值为‘0’。
The default value of any object of the bit type is ‘0’.

例程(Example)

signal A, B: bit; 
... 
A <= '1'; 
B <= not A;

注释(Notes)

  • 位类型的值‘0’和‘1’不等同于布尔类型值。
  • Bit type values ‘0’ and ‘1’ are not identical to the Boolean values
    (false and true), respectively.
    位类型对象的逻辑值必须用单引号包围,来区别于整数。
  • Logical values for an object of the bit type must be written in
    quotes to distinguish them from Integer values.

位向量(Bit_Vector)

位向量是由位类型元素组成的一维数组。位向量类型也在标准包中预定义。
The bit_vector is a one-dimensional array type with elements being of type Bit. The bit_vector type is predefined in the Standard package.

语法(Syntax)

type bit_vector is array (natural range <>) of bit; 

说明(Description)

位向量类型是无约束的向量。声明时指定向量的大小。
The bit_vector type is an unconstrained vector. During the declaration the size of a vector is specified.
给位向量赋值方法等同于其他数组的复制方法。
Assignments to a bit_vector can be done in the same way as in case of any arrays (using single element assignments, concatenation, aggregates, slices or any combination of the previous methods).

位向量类型是未决定的类型,因此在结构体中只能有一处赋值的地方。
The bit_vector is an unresolved type and therefore any object of this type can have only one assignment in an architecture.

例程(Example)

signal Bus : bit_vector(7 downto 0); 
Bus(0) <= '1'; 
Bus <= ('1', others => '0'); 
Bus <= Bus(6 downto 0) & Bus(7); 
Bus <= "01110010";

注释(Notes)

  • 位向量类型的逻辑值必须用双引号包围。
  • Logical values for objects of the bit_vector type must be written in
    double quotes.
    位向量中单个元素是位类型,因此所有对单个元素的值必须用单引号包围。
  • Single elements are of the bit type, therefore all values assigned to
    single elements are specified in single quotes.

字符串(String)

在标准包中,字符串类型被预定义为字符类型的一维数组。
The string type is predefined in the package Standard as a standard one-dimensional array type with each element being of the type Character.

语法(Syntax)

type string is array (positive range <>) of character; 

说明(Description)

字符串类型是一个字符类型的无约束向量。声明时,必须指定字符串中字符的数量。字符串的赋值和数组的赋值相同。
The type String is an unconstrained vector of elements of the type Character. The number of characters in a string must be specified during its declaration. Assignments to a String can be done in the same way as in case of any arrays, i.e. using single element assignments, concatenation, aggregates, slices or any combination of them.
字符串可以有表示二进制,十进制或十六进制,的标识。
B“数值” – 二进制
O“数值”– 十进制
X“数值” –十六进制
A String can have an explicit number base for Binary, Octal or Hexadecimal values.
B”value” – binary
O”value” – octal
X”value” – hexadecimal

例程(Example)

"hello world" 
"0000XXXX"
B"0010_1100"

注释(Notes)

  • 字符串的书写形式用双信号包围。单个元素是字符类型,所以用单引号包围。
  • Strings are written in double quotes. Single elements, however, are
    of the type Character, therefore values assigned to single elements
    (referred by the index) are specified in single quotes.
    字符串区分大小写。
  • Strings are case sensitive.

你可能感兴趣的:(HDL)