\chapter{Basic Principles} \label{chapter:basics} This chapter contains a short introduction to the basic principles of digital circuit synthesis. \section{Levels of Abstraction} Digital circuits can be represented at different levels of abstraction. During the design process a circuit is usually first specified using a higher level abstraction. Implementation can then be understood as finding a functionally equivalent representation at a lower abstraction level. When this is done automatically using software, the term {\it synthesis} is used. So synthesis is the automatic conversion of a high-level representation of a circuit to a functionally equivalent low-level representation of a circuit. Figure~\ref{fig:Basics_abstractions} lists the different levels of abstraction and how they relate to different kinds of synthesis. \begin{figure}[b!] \hfil \begin{tikzpicture} \tikzstyle{lvl} = [draw, fill=green!10, rectangle, minimum height=2em, minimum width=15em] \node[lvl] (sys) {System Level}; \node[lvl] (hl) [below of=sys] {High Level}; \node[lvl] (beh) [below of=hl] {Behavioral Level}; \node[lvl] (rtl) [below of=beh] {Register-Transfer Level (RTL)}; \node[lvl] (lg) [below of=rtl] {Logical Gate Level}; \node[lvl] (pg) [below of=lg] {Physical Gate Level}; \node[lvl] (sw) [below of=pg] {Switch Level}; \draw[dotted] (sys.east) -- ++(1,0) coordinate (sysx); \draw[dotted] (hl.east) -- ++(1,0) coordinate (hlx); \draw[dotted] (beh.east) -- ++(1,0) coordinate (behx); \draw[dotted] (rtl.east) -- ++(1,0) coordinate (rtlx); \draw[dotted] (lg.east) -- ++(1,0) coordinate (lgx); \draw[dotted] (pg.east) -- ++(1,0) coordinate (pgx); \draw[dotted] (sw.east) -- ++(1,0) coordinate (swx); \draw[gray,|->] (sysx) -- node[right] {System Design} (hlx); \draw[|->|] (hlx) -- node[right] {High Level Synthesis (HLS)} (behx); \draw[->|] (behx) -- node[right] {Behavioral Synthesis} (rtlx); \draw[->|] (rtlx) -- node[right] {RTL Synthesis} (lgx); \draw[->|] (lgx) -- node[right] {Logic Synthesis} (pgx); \draw[gray,->|] (pgx) -- node[right] {Cell Library} (swx); \draw[dotted] (behx) -- ++(5,0) coordinate (a); \draw[dotted] (pgx) -- ++(5,0) coordinate (b); \draw[|->|] (a) -- node[right] {Yosys} (b); \end{tikzpicture} \caption{Different levels of abstraction and synthesis.} \label{fig:Basics_abstractions} \end{figure} Regardless of the way a lower level representation of a circuit is obtained (synthesis or manual design), the lower level representation is usually verified by comparing simulation results of the lower level and the higher level representation \footnote{In recent years formal equivalence checking also became an important verification method for validating RTL and lower abstraction representation of the design.}. Therefore even if no synthesis is used, there must still be a simulatable representation of the circuit in all levels to allow for verification of the design. Note: The exact meaning of terminology such as ``High-Level'' is of course not fixed over time. For example the HDL ``ABEL'' was first introduced in 1985 as ``A High-Level Design Language for Programmable Logic Devices'' \cite{ABEL}, but would not be considered a ``High-Level Language'' today. \subsection{System Level} The System Level abstraction of a system only looks at its biggest building blocks like CPUs and computing cores. At this level the circuit is usually described using traditional programming languages like C/C++ or Matlab. Sometimes special software libraries are used that are aimed at simulation circuits on the system level, such as SystemC. Usually no synthesis tools are used to automatically transform a system level representation of a circuit to a lower-level representation. But system level design tools exist that can be used to connect system level building blocks. The IEEE 1685-2009 standard defines the IP-XACT file format that can be used to represent designs on the system level and building blocks that can be used in such system level designs. \cite{IP-XACT} \subsection{High Level} The high-level abstraction of a system (sometimes referred to as {\it algorithmic} level) is also often represented using traditional programming languages, but with a reduced feature set. For example when representing a design at the high level abstraction in C, pointers can only be used to mimic concepts that can be found in hardware, such as memory interfaces. Full featured dynamic memory management is not allowed as it has no corresponding concept in digital circuits. Tools exist to synthesize high level code (usually in the form of C/C++/SystemC code with additional metadata) to behavioural HDL code (usually in the form of Verilog or VHDL code). Aside from the many commercial tools for high level synthesis there are also a number of FOSS tools for high level synthesis \citeweblink{C_to_Verilog} \citeweblink{LegUp}. \subsection{Behavioural Level} At the behavioural abstraction level a language aimed at hardware description such as Verilog or VHDL is used to describe the circuit, but so-ca
-- Semantic analysis.
-- Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold
--
-- GHDL is free software; you can redistribute it and/or modify it under
-- the terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 2, or (at your option) any later
-- version.
--
-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with GHDL; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with Vhdl.Nodes; use Vhdl.Nodes;
with Vhdl.Sem_Expr; use Vhdl.Sem_Expr;
package Vhdl.Sem_Assocs is
-- Rewrite the association chain by changing the kind of assocation
-- corresponding to non-object interfaces. Such an association mustn't be
-- handled an like association for object as the actual is not an
-- expression.
function Extract_Non_Object_Association
(Assoc_Chain : Iir; Inter_Chain : Iir) return Iir;
-- Analyze actuals of ASSOC_CHAIN.
-- Check all named associations are after positionnal one.
-- Return TRUE if no error.
function Sem_Actual_Of_Association_Chain (Assoc_Chain : Iir) return Boolean;
-- Analyze association chain ASSOC_CHAIN with interfaces from
-- INTERFACE_CHAIN.
-- Return the level of compatibility between the two chains in LEVEL.
-- If FINISH is true, then ASSOC_CHAIN may be modifies (individual assoc
-- added), and error messages (if any) are displayed.
-- MISSING control unassociated interfaces.
-- LOC is the association.
-- Sem_Actual_Of_Association_Chain must have been called before.
type Missing_Type is (Missing_Parameter, Missing_Port, Missing_Generic,
Missing_Allowed);
procedure Sem_Association_Chain
(Interface_Chain : Iir;
Assoc_Chain: in out Iir;
Finish: Boolean;
Missing : Missing_Type;
Loc : Iir;
Match : out Compatibility_Level);
-- Do port Sem_Association_Chain checks for subprograms.
procedure Check_Subprogram_Associations
(Inter_Chain : Iir; Assoc_Chain : Iir);
-- Check for restrictions in LRM93 1.1.1.2
-- Return FALSE in case of error.
function Check_Port_Association_Mode_Restrictions
(Formal : Iir_Interface_Signal_Declaration;
Actual : Iir_Interface_Signal_Declaration;
Assoc : Iir)
return Boolean;
-- Check restrictions of LRM02 12.2.4
procedure Check_Port_Association_Bounds_Restrictions
(Formal : Iir; Actual : Iir; Assoc : Iir);
end Vhdl.Sem_Assocs;