> For the complete documentation index, see [llms.txt](https://eeman.gitbook.io/twinbuilder-applications/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eeman.gitbook.io/twinbuilder-applications/vhdl-ams/architecture.md).

# Architecture

在VHDL-AMS中，Architecture是對Entity的具體實現進行描述的部分。Entity聲明了一個元件的接口和行為，而Architecture定義了這個元件的內部實現。

一個Entity可以有多個Architecture，每個Architecture描述了一種不同的實現方式。VHDL-AMS中的Architecture主要包括以下幾個方面：

1. 內部信號的聲明：在Architecture中聲明的信號可以被Entity中所有Process和Subprogram所使用。
2. 內部變量的聲明：變量只在Process和Subprogram中可見，且在Process和Subprogram執行完成時自動被刪除。
3. Process：Process是一個併發的控制結構，其中的行為描述了系統的時間行為。Process的主體中可以使用信號、變量、函式等元素，並可以使用wait語句等待特定的事件發生。
4. Subprogram：Subprogram是一個可以被調用的程序或函式，可以在Process或其他Subprogram中使用。Subprogram可以具有輸入參數和返回值，可以用來實現複雜的計算和邏輯操作。
5. Configuration：Configuration是用來描述Entity與Architecture之間的映射關係，可以將多個Architecture映射到同一個Entity上，也可以在不同的Architecture之間建立連接關係。

總的來說，VHDL-AMS中的Architecture描述了一個元件的內部實現，並定義了元件的功能和行為。在設計複雜系統時，合理地使用Architecture可以使系統的設計更加模塊化和可維護。

例如：

```
// 加法器
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.math_real.all;

entity adder is
    port (
        in1 : in real;
        in2 : in real;
        out1 : out real
    );
end entity adder;

architecture behavioral of adder is
begin
    out1 <= in1 + in2;
end architecture behavioral;
```

這個範例中的Entity是一個加法器，具有兩個輸入端口in1和in2，一個輸出端口out1。其中，in1、in2和out1的類型都是real。

這個Entity只有一個Architecture，即behavioral。在behavioral Architecture中，使用了一個簡單的賦值語句，將in1和in2的和賦值給out1。這個Architecture的作用是實現Entity的加法功能。

在使用這個加法器時，只需要將in1和in2的值輸入到Entity的端口中，out1的值就會自動計算出來。這個範例演示了如何使用VHDL-AMS的Entity和Architecture描述一個簡單的電路功能。

## *<mark style="color:blue;">**2023/06 updated.**</mark>*
