Re: [quirks-uvm-devel] query on quirks examples
Status: Pre-Alpha
Brought to you by:
teodor
From: Sergei L. <se...@mo...> - 2002-03-30 18:38:03
|
Hello Bhavani. Sorry for delay. Thanks for this good example. I found 8 errors (it is normal because it is impossible guess all I think). Correct me if I don't catch something. Let's start. 1. You make iteration from fp[0] to fp[2] and use lv[4] as a variable (counter) of this loop. But you should initialize it: lv[4] <- fp[0] before the loop. (Declarative part before `begin' (I mean maps) do nothing with anything). 2. If you would like to know what is auCmp look at the quirks-uvm/uvm/src/lib/cart/predef_aus.c file. This file defines all arithmetic modules I used. There is a function cmpInt32_iio for the module auCmp <in in out> in this file. It perform such operation: auCmp[2] = auCmp[0] < auCmp[1] But your order of argument is not right. I think you mean: lv[0] = lv[4] < fp[1] but you get: lv[0] = fp[1] < lv[4] The question is `what auCmp means'. In the current cartridge it means "<". I agree, auCmp is not a good name for "<". It seems to me that the exit condition should be `not lv[0]'. 3. The order of selector declaration in a map definition defines the order of actions: auInc auMul au2Mul it is inc, then mul mul. I think mul mul then inc will be better in the context of your loop (or use 2 maps and 2 act commands, but one map runs faster on our interpreter). (When you invoke `act' the according map calls all defined AUs from top to bottom. It is not on principle to which AU from this map you point with act. Ideally we need only one map and an algorithm for finding AUs which involved in operation, but now we use less intellectual scheme). 4. You use lv[1], lv[2] and lv[6] to store constants. You can drop this variables and use ct[0], ct[1] and ct[2] directly (they are "memorized" entities). 5. You can't store 1.8 in lv[3]. It is for integers. I sought you can realize the following approach: 18 * C / 10 + 32. It is better method before that time when we will include floating point types (but really it is very simple task, I mean floating point addition). 6. We can't have more than one register attached to a channel (see the case with auInc[0] in your program). See error 1. 7. We can't write to a registers with `in' mode (you use several in the `lv' selector. It is impossible to map `out' from AU on `in' register). 8. You miss ';' in many places. The good side is that if we try start your program we find a places with bad error reporting. Now it is really weak side - in many cases uvm do "fatal error" without explanation. So, I put one more test template in my money-box :) So, I wait for corrected version. P.S. The list is OK and I hear you. Don't worry about it. > 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 > -- Sergei. |