Version française
Home     About     Download     Resources     Contact us    
Browse thread
From a recursive circuit to a functional/recursive OCaml-code...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code...
On Sun, 2006-02-05 at 15:17 +0100, Oliver Bandel wrote:

Looking at 

http://www.belug.org/~ob/struktur-grafisch.jpg

the bottom diagram, I would do this:

type state = { e:t; u:t }

for some type t I don't know about, possibly the types
are different, but this will do for exposition.

You also have arrows

	a: t * t -> t
	b: t * t -> t
	c: t -> t

So the clock function is simply

	let step (s:state) x =
	{ s with 
		e = c s.u;
		u = b (x, s.e)
	} 
	in s, a (x, s.e)

This function accepts the state and a new input x,
and returns the state and the output y. 

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net