Page 1

Lava 2

Hardware Description and Verification

Thomas Hallgren

2010-05-03

Page 2

Today

Examples covering these topics

Page 3

Last week

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

Higher order functions

Page 7

Composition of circuits

Serial composition

Page 8

Serial composition of circuits

Page 9

Composition of circuits

Parallel composition

Page 10

Parallel composition of circuits

From the Lava library

Page 11

Composition of circuits

We have also seen

Page 12

Feedback and sequential circuits

First example

Page 13

Delay in VHDL

Page 14

Delay in Lava

Page 15

Feedback and sequential circuits

Second example

Page 16

Creating longer sequences for simulations

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

Page 17

List functions

We have seen

Page 18
List functions

But all lists are built from two basic operators on lists

Page 19

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 20
Creating lists from scratch

How is replicate defined?

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

Page 21

Consuming lists

Page 22
Consuming lists

How is sum defined?

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

Page 23

Consuming lists 2

Page 24
Consuming lists 2

How is minimum defined?

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

Page 25

Exercise

Zero detection