Skybuck Flying wrote:
> I read a PDF about the possibility of computers without a clock.
>
> http://www.sun.com/processors/throug...Am_Reprint.pdf
>
> Since I am not really used to programming with clocks and stuff like that...
> an async system might be much easier
> to program for an application programmer like me
No - the opposite is valid: It is quite easy to model a synchronous system.
And let me add: Forget "programming". Hardware has to modelled.
Programming VHDL is o.k. for non-synthesizable testbenches, but for real
hardware VHDL is more a textual CAD software than and programming language.
> Anyway my question is: Can VHDL be used to program such a async device ?
AFAIK yes - I've heard about it, but did never such heavy stuff.
> The document itself says that most tools are far behind etc... so I wouldn't
> be too surprised if VHDL and Verilog don't support it.
It is not the language itself, that makes this difficult but also the
nessecary hardware for totally asynchronous devices.
>>---
>>count_up: process (clock)
>>variable count_value : natural := 0;
>>begin
>>if rising_edge(clock) then
>>-- ... and so on
>>end if;
>>end process count_up;
>>---
>
> Rising_edge is that a predefined function ?
Yes. It is almost the same as
if (clock'event and clock='1') then
but it is recommended to use rising_edge. Furthermore it makes the code
easy to read.
[quoting repaired]
> count_up: process (clock)
> variable count_value : natural := 0;
> begin
> if clock = '1' then
> count_value := (count_value + 1) mod 4;
> q0 <= bit'val(count_value mod 2) after prop_delay;
> q1 <= bit'val(count_value / 2) after prop_delay;
> end if;
> end process count_up;
> end behaviour;
....
> Since in the original code at first glance there is no loop ?
Yes - for simulation. But a synthesis tool does not find an 'event
attribute and therefore assumes, that this process describes a latch.
(Well .. I guess so. I have no synthesis tool at hand at the moment,
because I am at home.)
>>A second pitfall is the type bit or bit_vector, that is used by
>>Ashenden. Because bit is only '1' or '0', no unknown values can be
>>represented. Use std_ulogic(_vector), std_logic(_vector), signed or
>>unsinged instead.
>
>
> The code example uses "natural" for the count_value.
I was talking about Ashendens Cookbook in general. He uses bit(_vector)
in general.
> Are the mod 4, mod 2 and /2 statements/operations allowed ?
Yes.
> I see you have defined
>
> variable count_value : unsigned(1 downto 0);
>
> Does this mean "natural" is bad for synthesis ?
No - but using an unsigned vector is more handy for this example.
* The range definition makes it clear, how many flipflops will be
inferred. This helps me reading the code and the synthesis tool gets
an easier job.
* Overflow is handled automatically.
- Natural is a subtype of integer beeing 0 or any other positive
value. Usually integer is a 32 bit data type. The unused bits have
to be removed by the synthesis tool.
- To make it clear, that only the range 0 to 3 is desired, you could
declare count_value to be "natural range 0 to 3". But then, if 3 is
reached, adding a 1 would result in a range violation and therefore
you have to add manually a statement like
if (count_value=3) then
count_value:=0;
else count_value:=count_value+1;
end if;
Using the unsigned vector, this extra statement can be saved, wich
makes the code more readable.
* Because q0 and q1 have to be derived from count_value, your could use
the modulo approach like in Ashendens example or you could convert the
natural to unsigned. Both is not well readable. From the unsigned
vector the desired bits can be derived very easy as I have shown in my
example.
Note that everything, that was mentioned are just reasons for nice
readable code. Synthesis results using natural or unsigned will be the
same - except for synthesis time maybe.
> I do realize the pdf/cookbook is pretty old (from 1990).
This is not a reason pro or contra this Cookbook. There are only a few
points, that have changed during the years. (e.g. the recommendation for
std_(u)logic_(vector) and for the library IEEE.numeric_std)
Unfortunately Ashendens Cookbook is a really nice example how to
_program_ with VHDL. And as I told you: Forget programming if you aim
for synthesizable code.
> Can you recommand any VHDL programmer's references or tutorial which are
> good for "synthesis" ?
I've learned VHDL with "HDL chip design" from Douglas J. Smith, Doone
Publications. I teaches both VHDL and Verilog, which makes it great, if
you (unfortunately

) have to learn Verilog later.
And let me add a general hint: There are 3 things in a HDL you need:
combinational logic, flipflops and (if you want) latches. Almost
everything synthesizable can be described with this.
Ralf