rewire-backend-2.8: A Haskell-to-Verilog/VHDL compiler, the Hyle backend
Safe HaskellSafe
LanguageHaskell2010

ReWire.VHDL.Syntax

Description

Syntax for the subset of VHDL-2008 emitted by the VHDL backend (ReWire.Hyle.ToVHDL). Everything is typed std_logic_vector; Verilog-style expression semantics (unsigned arithmetic, width rules) are provided by functions in an emitted rw_helpers package.

Synopsis

Documentation

type Name = Text Source #

type Size = Word Source #

type Index = Int Source #

newtype Device Source #

Constructors

Device 

Fields

Instances

Instances details
Show Device Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq Device Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Device -> Device -> Bool #

(/=) :: Device -> Device -> Bool #

Pretty Device Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Device -> Doc ann #

prettyList :: [Device] -> Doc ann

data Unit Source #

An entity/architecture pair with its context clause (use clauses, e.g., ieee.std_logic_1164.all; library clauses are derived).

Constructors

Unit 

Fields

Instances

Instances details
Show Unit Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Unit -> ShowS #

show :: Unit -> String #

showList :: [Unit] -> ShowS #

Eq Unit Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Unit -> Unit -> Bool #

(/=) :: Unit -> Unit -> Bool #

Pretty Unit Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Unit -> Doc ann #

prettyList :: [Unit] -> Doc ann

data Direction Source #

Constructors

In 
Out 

Instances

Instances details
Show Direction Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq Direction Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Pretty Direction Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Direction -> Doc ann #

prettyList :: [Direction] -> Doc ann

data Port Source #

Constructors

Port !Name !Direction !Size 

Instances

Instances details
Show Port Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Port -> ShowS #

show :: Port -> String #

showList :: [Port] -> ShowS #

Eq Port Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Port -> Port -> Bool #

(/=) :: Port -> Port -> Bool #

Pretty Port Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Port -> Doc ann #

prettyList :: [Port] -> Doc ann

data Component Source #

Component declaration: name, integer generic names, ports.

Constructors

Component !Name ![Name] ![Port] 

Instances

Instances details
Show Component Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq Component Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Pretty Component Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Component -> Doc ann #

prettyList :: [Component] -> Doc ann

data Signal Source #

Declarations in the architecture declarative part: signals with an optional initial value, constants, and display-only comment lines.

Instances

Instances details
Show Signal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq Signal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Signal -> Signal -> Bool #

(/=) :: Signal -> Signal -> Bool #

Pretty Signal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Signal -> Doc ann #

prettyList :: [Signal] -> Doc ann

sanitizeComment :: Text -> Text Source #

Newlines in comment text would push the remainder into code position.

data Stmt Source #

Constructors

Assign !LVal !Exp 
SelAssign !Exp !LVal ![(BV, Exp)] !Exp

Selected signal assignment: scrutinee, target, choices, others.

Process ![Name] ![ProcVar] ![SeqStmt]

Sensitivity list (empty: none), variables, body.

Instantiate !Name !Name ![(Name, Integer)] ![(Name, Exp)]

Component, instance label, generic map, port map (empty name: positional).

Comment !Text 

Instances

Instances details
Show Stmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Stmt -> ShowS #

show :: Stmt -> String #

showList :: [Stmt] -> ShowS #

Eq Stmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Stmt -> Stmt -> Bool #

(/=) :: Stmt -> Stmt -> Bool #

Pretty Stmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Stmt -> Doc ann #

prettyList :: [Stmt] -> Doc ann

data ProcVar Source #

Process-local variable declarations.

Constructors

LineVar !Name

variable n : line;

Instances

Instances details
Show ProcVar Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq ProcVar Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: ProcVar -> ProcVar -> Bool #

(/=) :: ProcVar -> ProcVar -> Bool #

Pretty ProcVar Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: ProcVar -> Doc ann #

prettyList :: [ProcVar] -> Doc ann

ppArm :: (BV, Exp) -> Doc an Source #

A selected-assignment choice: the choices are literal bit-strings of exactly the scrutinee's width (never constants or aggregates, for portability).

data SeqStmt Source #

Sequential statements (process bodies).

Constructors

SIf ![(Cond, [SeqStmt])] ![SeqStmt]

if/elsif branches, else branch.

SAssign !LVal !Exp 
SWait !Natural

wait for n ns;

SWriteLn ![Chunk]

write(l, ...); writeline(output, l);

SFinish

std.env.finish;

Instances

Instances details
Show SeqStmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Eq SeqStmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: SeqStmt -> SeqStmt -> Bool #

(/=) :: SeqStmt -> SeqStmt -> Bool #

Pretty SeqStmt Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: SeqStmt -> Doc ann #

prettyList :: [SeqStmt] -> Doc ann

data Chunk Source #

A piece of a line written by SWriteLn: a string literal or the hex-string rendering of an expression.

Constructors

ChunkLit !Text 
ChunkHex !Exp 

Instances

Instances details
Show Chunk Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Chunk -> ShowS #

show :: Chunk -> String #

showList :: [Chunk] -> ShowS #

Eq Chunk Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Chunk -> Chunk -> Bool #

(/=) :: Chunk -> Chunk -> Bool #

Pretty Chunk Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Chunk -> Doc ann #

prettyList :: [Chunk] -> Doc ann

data Cond Source #

Conditions appearing in generated processes.

Constructors

CondEq !Name !BV

name = "bits"

CondRising !Name

rising_edge(name(0))

Instances

Instances details
Show Cond Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Cond -> ShowS #

show :: Cond -> String #

showList :: [Cond] -> ShowS #

Eq Cond Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Cond -> Cond -> Bool #

(/=) :: Cond -> Cond -> Bool #

Pretty Cond Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Cond -> Doc ann #

prettyList :: [Cond] -> Doc ann

data LVal Source #

Constructors

LVName !Name 
LVRange !Name !Index !Index

name(j downto i): low index i, high index j.

LVElem !Name !Index 

Instances

Instances details
Show LVal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> LVal -> ShowS #

show :: LVal -> String #

showList :: [LVal] -> ShowS #

Eq LVal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: LVal -> LVal -> Bool #

(/=) :: LVal -> LVal -> Bool #

Pretty LVal Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: LVal -> Doc ann #

prettyList :: [LVal] -> Doc ann

data Exp Source #

Constructors

Lit !BV 
Var !Name 
Slice !Name !Index !Index

name(j downto i): low index i, high index j.

Elem !Name !Index

name(i downto i): a 1-bit vector.

Cat ![Exp] 
FunCall !Name ![Exp] 
Num !Natural 

Instances

Instances details
Show Exp Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

showsPrec :: Int -> Exp -> ShowS #

show :: Exp -> String #

showList :: [Exp] -> ShowS #

Eq Exp Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

(==) :: Exp -> Exp -> Bool #

(/=) :: Exp -> Exp -> Bool #

Pretty Exp Source # 
Instance details

Defined in ReWire.VHDL.Syntax

Methods

pretty :: Exp -> Doc ann #

prettyList :: [Exp] -> Doc ann

ppLit :: BV -> Doc an Source #

A qualified bit-string literal: hex (std_logic_vector'(X"5a")) when the width is a whole number of hex digits, binary (std_logic_vector'(B"0101")) otherwise.

ppInit :: BV -> Doc an Source #

A literal in signal-initial position: like ppLit, except wide all-zero vectors render as an aggregate.

ppBits :: BV -> Text Source #

The value in binary, exactly the vector's width.

ppHex :: BV -> Text Source #

The value in hex, zero-padded to exactly width/4 digits.

ppName :: Name -> Doc an Source #

Print a name as a VHDL identifier: a basic identifier when valid (and unambiguous: all-lowercase, since basic identifiers are case-insensitive), otherwise a VHDL-2008 extended identifier (\name\).

ppContext :: [Text] -> Doc an Source #

Library clauses are derived from the package names (the work and std libraries are implicit).