From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id BAD22BBA7 for ; Sun, 5 Feb 2006 15:18:11 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k15EIB9Y022472 for ; Sun, 5 Feb 2006 15:18:11 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12562 for ; Sun, 5 Feb 2006 15:18:10 +0100 (MET) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k15EIAm2022469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 5 Feb 2006 15:18:10 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178049075.adsl.alicedsl.de [85.178.49.75]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id k15EI9I0015084 for ; Sun, 5 Feb 2006 15:18:09 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id A415B20FC2F; Sun, 5 Feb 2006 15:17:26 +0100 (CET) Date: Sun, 5 Feb 2006 15:17:26 +0100 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code... Message-ID: <20060205141726.GA491@first.in-berlin.de> References: <20060204211943.GA590@first.in-berlin.de> <1139106546.8453.87.camel@rosella> <20060205041600.GA5936@first.in-berlin.de> <1139118167.8453.254.camel@rosella> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1139118167.8453.254.camel@rosella> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at nez-perce with ID 43E60923.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43E60922.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 recursive:01 recursive:01 ocaml-code:01 bandel:01 recursion:01 clocked:01 clocked:01 non-trivial:01 notation:01 non-trivial:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Sun, Feb 05, 2006 at 04:42:47PM +1100, skaller wrote: > 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. OK, a clocked circuit. But in the non-trivial machine example, not all operators are clocked. The hint with the clock is good, HvF has not expplicitly mentioned, which thing is cloecked in the block diagram. But I think it is funcion_C (the "C" in the picture), because it is round and the other operators are in square. And this is the only part, which can be critical, because of the feedback. Maybe this (a cirlce) is american (and maybe old) notation of a clocked thingy? When looking at circuits I would have seen different symbols than squares and cirlces. I programmed a version with a record-type and got different results than I found in a paper about the non-trivial machine (NTM). So there may be a problem of wrong timing, so that my program does not the same as it was meant by the block diagram of the circuit. [...] > 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. Well... IMHO the problem here is, when which function get's which value. If it is time n -1, n or n+1 ?! > The functions get very complicated -- otherwise circuit > designers wouldn't have a job :) Well, I doubt that for the simple NTM the functions will get too complicated. Here follows my implementation of the NTM, but it creates different results than I saw in examples in papers, so it seems the initial state is not there at the correct time. So I have to rewrite the code. Or I should use explicit timing, using specialized functions or so...?! (* ============================================================= *) type state_t = { st_e: int option; st_u: int option } let function_A x1 x2 = x1 + x2 let rec function_B x e = x + e let function_C u = u + 3 let initialize() = 0 (* initial value, could also be a ransom value... :) *) let initial_state () = { st_e = None; st_u = None } let get_e state = match state.st_e with Some x -> x | _ -> initialize() let get_u state = match state.st_u with Some x -> x | _ -> initialize() let _ = let rec calc state = let inval = int_of_string (read_line()) in let u = function_B inval (get_e state) and e = function_C (get_u state) and outval = function_A inval (get_e state) in Printf.printf "%d => %d \t e: %d u: %d \n" inval outval e u; calc { st_u = Some u; st_e = Some e } in calc (initial_state2()) (* yes, I like this recursive style: I can set starting state here. :) *) (* ============================================================= *) Ciao, Oliver