Page 1

Lava 2

Hardware Description and Verification

Thomas Hallgren

2009-04-28

Page 2

Today

Examples covering these topics

Page 3

Yesterday

Look back for a quick reminder.

Page 4

Functions in Haskell

Two ways to handle multiple arguments

Page 5

Function types in Haskell

The two ways to handle multiple arguments is reflected in the types

Page 6

Composition of circuits

Serial composition

Page 7

Serial composition of circuits

Page 8

Composition of circuits

Parallel composition

Page 9

Parallel composition of circuits

From the Lava library

Page 10

Composition of circuits

We have also seen

Page 11

Feedback and sequential circuits

First example

Page 12

Delay in VHDL

Page 13

Delay in Lava

Page 14

Feedback and sequential circuits

Second example

Page 15

Creating longer sequences for simulations

Sequences are lists, so we can use any list function in Haskell

Page 16

List functions

We have seen

Page 17
List functions

But all lists are built from two basic operators on lists

Page 18

Creating lists from scratch

How does replicate 3 low work?

replicate 3 low = low : replicate 2 low
                = low : low : replicate 1 low
                = low : low : low : replicate 0 low
                = low : low : low : []
                = [low,low,low]

Page 19
Creating lists from scratch

How is replicate defined?

replicate 0 x = []
replicate n x = x : replicate (n-1) x

Page 20

Consuming lists

Page 21
Consuming lists

How is sum defined?

sum [] = 0
sum (x : xs) = x + sum xs

Page 22

Consuming lists 2

Page 23
Consuming lists 2

How is minimum defined?

minimum [] = error "minimum of empty list"
minimum [x] = x
minimum (x:xs) = min2(x,minimum xs)

Page 24

Exercise

Zero detection