Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2006-02-05 (05:42)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code...
On Sun, 2006-02-05 at 05:16 +0100, Oliver Bandel wrote:

> But I'm not clear about how to write this function "f",
> because it needs mutual recursion...

No it doesn't, not even with feedback, because your
system is CLOCKED.

A simple model is: you have a collection of
chips with inputs and outputs. In phase one,
calculate the ouputs from the inputs.

In phase 2, you have a circuit board, representing
the wiring, this is a function that copies the outputs
of all the chip to their inputs, following the
wiring diagram. That's where the feedback comes in.

If you want to know how to make a subcircuit
do the feedback *internally* on one clock,
there is a simple answer and a hard one.

The simple answer is YOU CANT. Circuits are

The hard answer is .. you can have multiple
clocks, synchronised by a master clock. 
The implementation is simple .. a clock is
just a counter that writes TRUE when it is zero
and FALSE otherwise.

Then you invent a thing called a LATCH, which
is like wire, except it holds the output
stable and ignores the input UNLESS a special
ENABLE input is True. That's connected to your counter.

Basically .. you're asking hard questions about how
to design synchronous circuits. Don't expect a clocked
circuit to just be a simple composition of functions.
The functions get very complicated -- otherwise circuit
designers wouldn't have a job :)

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: