Re: [quirks-uvm-devel] query on quirks examples
Status: Pre-Alpha
Brought to you by:
teodor
|
From: Bhavani M. <bha...@ya...> - 2002-03-29 21:15:39
|
Hi,
Thanks for the answers. Now I am able to write
some thing. Here is my first program which does
Conversion of temperature. please let me know your
comments.
below is CtoF.ua file.
-------------------------------------------------------
--Procedure to convert temperature in Centigrade to
Fahrenheit and Vice Versa
--Temperature in Fahrenheit = 1.8*C + 32
-- fp[0] = starting C value = 0
-- fp[1] = Max C = 100
-- ct[0] = 18, ct[1] = 10 divide these two values to
get 1.8, ct[2] = 32 which is from the formula
procedure :CtoF is
-- Make two 32 bit local registers.
-- Each register is both writeable and readable.
lv is <int32/inout int32/in int32/in int32/inout
int32/inout int32/inout int32/in stu>;
declare map
auCmp is <int32/in int32/in int32/out stu>;
map is
(auCmp[1], lv[4])
(auCmp[0], fp[1])
(auCmp[2], lv[0])
end map;
declare map
-- Get access to two registers of
incrementer/decrementer
auInc is <int32/in int32/out stu>;
-- Three ports of multiplier
auMul is <int32/out int32/in int32/in stu>;
au2Mul is <int32/in int32/in int32/out stu>;
auSum is <int32/in int32/in int32/out
stu>;
map is
(auInc[0], fp[0]) --Starting value of C
(auMul[1], lv[1]) (auMul[2], lv[2]) (auMul[0],
lv[3]) -- calculate 18/10 = 1.8
(auInc[0], lv[4]) -- C
(au2Mul[0],lv[4])
(au2Mul[1],lv[3])
(au2Mul[2}, lv[5])
(auSum[0], lv[5])
(auSum[1], lv[6])
(auSum[2], lv[5]) -- done with conversion
of C to F
(auInc[1], lv[4]) -- Increment C
end map;
begin
lv[1] <- ct[0] -- value 18
lv[2] <- ct[1] -- value 10
lv[6] <- ct[2] -- value 32
@Loop: loop
* auCmp;
exit @Loop when lv[0];
* auSum;
end loop;
fp[2] <- lv[5];
end :CtoF
below is CtoF.efg file.
-------------------------------------------------------
ct:
<int32/in int32/in int32/in stu>
18
10
32
--------------
below is CtoF.uvmd file.
-------------------------------------------------------
load "CtoFconversion.ru"
load environment "CtoFconversion.efg"
select module 1
select environment 1
set fp = <int32/inout int32/inout int32/inout stu>
fp[0] = 0
fp[1] = 100
make instance of :CtoF
;show #CtoF
run #CtoF
print fp[2]
quit
__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/
|