Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code...
Date: Sun, 5 Feb 2006 15:17:26 +0100	[thread overview]
Message-ID: <20060205141726.GA491@first.in-berlin.de> (raw)
In-Reply-To: <1139118167.8453.254.camel@rosella>

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




  reply	other threads:[~2006-02-05 14:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-04 21:19 Oliver Bandel
2006-02-05  2:29 ` [Caml-list] " skaller
2006-02-05  4:16   ` Oliver Bandel
2006-02-05  5:42     ` skaller
2006-02-05 14:17       ` Oliver Bandel [this message]
2006-02-05 16:05         ` skaller
2006-02-05 18:07           ` Oliver Bandel
2006-02-06 11:52       ` Oliver Bandel
2006-02-06 13:10         ` Oliver Bandel
2006-02-05  5:55     ` Bill Wood
2006-02-05 11:26       ` [Caml-list] From a recursive circuit to a functional/recursiveOCaml-code Frédéric Gava
     [not found]     ` <1139134445.28935.14.camel@localhost>
     [not found]       ` <20060205175014.GA1969@first.in-berlin.de>
     [not found]         ` <1139178136.463.37.camel@localhost>
2006-02-05 23:23           ` [Caml-list] From a recursive circuit to a functional/recursive OCaml-code Oliver Bandel
2006-02-05 23:46             ` Oliver Bandel
2006-02-06  3:39             ` skaller
2006-02-05 11:45 ` Oliver Bandel
2006-02-05 18:19 ` Oliver Bandel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060205141726.GA491@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox