From: Skybuck Flying on
Hi,

First I would like to program a simple CPU and Memory chip in pascal/delphi.

(Maybe a better word for memory chip would be memory controller ?)

The CPU and Memory chip communicatie in serial bits with each other.

These serial bits could be commands/addressess which the memory chip can
understand.

I would like to program the cpu's microcode with blocking
routines/functions.

For example:

ReadBit( A ); // block until a bit has been read.
ReadBit( A ); // block until the next bit has been read.
ReadBit( A ); // block until the next bit has been read.

WriteBit( B ); // block until a bit has been written.
WriteBit( B ); // block until the next bit has been written.
WriteBit( B ); // block until the next bit has been written.

For simulation purposes the implementation of these routines could be really
simply to fake communication with the memory chip.

The question is if these two functions can be implemented two BLOCK in a
realworld microcode cpu enviroment (cpu's usually work with clocks which
keep on ticking... ) ?

Bye,
Skybuck.


From: Jonathan Bromley on
On Thu, 4 Aug 2005 11:23:23 +0200, "Skybuck Flying"
<nospam(a)hotmail.com> wrote:

>First I would like to program a simple CPU and Memory chip in pascal/delphi.
[...]

You're asking all the right questions, but as someone else has said,
you are asking them in lots of little pieces and you will therefore
get fragmentary answers and fragmentary understanding.

You seem to be trying to build an understanding of digital
electronics, simulation and modelling almost from scratch.
This is admirable but doomed. PLEASE, PLEASE find out about
what others have achieved (it's a great deal) in this area.
Because you have tried to invent the concepts for yourself,
you will be receptive to the ideas and you will learn very
quickly, and then you can go on to do creative new stuff.

Try for these search terms...

SystemC
Transaction level modelling
Untimed functional models
Bus functional models
Finite state machines
Handshake protocols
Wait states

Go to www.systemc.org and find what's there. The SystemC
reference simulator is free, so you can see how its kernel
is built and how it helps you build interesting simulations.
SystemC has a highly developed set of ideas about the
relationship between transaction-level modelling (your
"read" and "write" actions on a memory are transactions)
and the behaviour of hardware that works clock by clock,
"cycle-accurate" modelling. Take a look at the SystemC
part of our website and see if any of the examples are
helpful.

Right now, you are frantically trying to re-invent a
wheel that's taken five decades to build. It's
a great way to prepare for learning, but a lousy way
to get anything useful done.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:jonathan.bromley(a)doulos.com
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

From: Bob Monsen on
Skybuck Flying wrote:
> Hi,
>
> First I would like to program a simple CPU and Memory chip in pascal/delphi.
>
> (Maybe a better word for memory chip would be memory controller ?)
>
> The CPU and Memory chip communicatie in serial bits with each other.
>
> These serial bits could be commands/addressess which the memory chip can
> understand.
>
> I would like to program the cpu's microcode with blocking
> routines/functions.
>
> For example:
>
> ReadBit( A ); // block until a bit has been read.
> ReadBit( A ); // block until the next bit has been read.
> ReadBit( A ); // block until the next bit has been read.
>
> WriteBit( B ); // block until a bit has been written.
> WriteBit( B ); // block until the next bit has been written.
> WriteBit( B ); // block until the next bit has been written.
>
> For simulation purposes the implementation of these routines could be really
> simply to fake communication with the memory chip.
>
> The question is if these two functions can be implemented two BLOCK in a
> realworld microcode cpu enviroment (cpu's usually work with clocks which
> keep on ticking... ) ?
>
> Bye,
> Skybuck.
>
>

Two protocols you may wish to become familiar with are SPI and I2C. They
are both serial protocols, which are designed to communicate with
peripherals. There are memory devices that use both of these (and many
others...). Many microcontrollers have built-in support of them, meaning
you can do a 'write' or a 'read', and the microcontroller will handle
the gory details.

Now, Pascal is simply a computer language. It can run in a variety of
environments. However, access to the hardware is generally controlled by
the operating system. If you are programming on the 'bare metal' as they
say, then you can do whatever the hell you want. Your "ReadBit" routine
can simply loop, waiting for the hardware to respond. It can block, and
let other processes or threads do work while it waits. It can shut off
the CPU, and wait for an interrupt.

On the other hand, if you are programming through an OS, which is
controlling access to the ports, you must use whatever facilities are
provided by the OS in your "ReadBit()" routine.

This particular question may be better answered in the embedded software
newsgroups.

--
Regards,
Bob Monsen

If a little knowledge is dangerous, where is the man who has
so much as to be out of danger?
Thomas Henry Huxley, 1877
From: Skybuck Flying on
> the operating system. If you are programming on the 'bare metal' as they
> say, then you can do whatever the hell you want. Your "ReadBit" routine
> can simply loop, waiting for the hardware to respond. It can block, and
> let other processes or threads do work while it waits. It can shut off
> the CPU, and wait for an interrupt.

Where can I find an example of this concept on the internet, if any ?

I don't know how complex this technique is... but if it's not too complex I
would like
to see a drawing of the gates required etc, as to get a better understanding
of
how it works together with the clock signal etc.

Bye,
Skybuck.


From: Bob Monsen on
Skybuck Flying wrote:
>>the operating system. If you are programming on the 'bare metal' as they
>>say, then you can do whatever the hell you want. Your "ReadBit" routine
>>can simply loop, waiting for the hardware to respond. It can block, and
>>let other processes or threads do work while it waits. It can shut off
>>the CPU, and wait for an interrupt.
>
>
> Where can I find an example of this concept on the internet, if any ?
>
> I don't know how complex this technique is... but if it's not too complex I
> would like
> to see a drawing of the gates required etc, as to get a better understanding
> of
> how it works together with the clock signal etc.
>
> Bye,
> Skybuck.
>
>

There are lots of examples of PIC code which drives I2C or SPI devices.
Google for "PIC I2C SPI". I got 35,000 hits.

--
Regards,
Bob Monsen

If a little knowledge is dangerous, where is the man who has
so much as to be out of danger?
Thomas Henry Huxley, 1877