Monday, November 28, 2011

CS402 Theory of Automata midterm solved past paper fall 26 November 2011

1.       What is difference between S+ and S*.
2.       What are Distinguishable strings and Indistinguishable strings?
3.       Is the moore machine is Distinguishable or Indistinguishable? Is the number of states remained constant if we convert moore machine to mealy machine discuss if any case?
4.       Write the first step to convert a TG into RE?
    Convert the following FAs to NFAs?
        a).



5.   Solution:


        b).S
   Solution:
   



CS501 Advance Computer Architecture solved Mid term past paper fall 28 November 2011

Q.1 consider the following sequence of instruction going through the SRC pipeline  (5)
200: shl r6, r3, 2
204: str r3, 32
208: sub r2, r4, r5
212: add r1. R2, r3
216: ld r7, 48
What hazards can occur executing above instructions and how can be resolved these?
Solution:
There is a data hazard between instruction three and four (208 , 212).
For more detail please consult lecture # 20. topic: SRC hazard detection and correction

 Q.2 arranges the following according to control signal for pipeline stages.
·         Decode and operand read
·         Register Writeback
·         ALU Operation
·         Memory Access
·         Instruction fetch

Solution:
1.       Instruction fetch
2.       Decode and operand read
3.       ALU Operation
4.       Memory Access
5.       Register Writeback

Q.3 write structural RTL for the following instruction. (3)
In ra, c2
Solution:




Q.4 write structural RTL for the following instruction. (3)
Jump [ra+c2]
Solution:
Q.5  write the simple form of the given structural RTL . (2)

Solution:
Sub ra, rb rc

Q.6 what is the difference between latency and throughput?
Solution:

Latency is defined as the time required to process a single instruction, while throughput is
defined as the number of instructions processed per second. Pipelining cannot lower the
latency of a single instruction; however, it does increase the throughput. With respect to
the example discussed earlier, in a non-pipelined machine there would be one instruction
processed after an average of 5 cycles, while in a pipelined machine, instructions are
completed after each and every cycle (in the steady-state, of course!!!). Hence, the overall
time required to execute the program is reduced.

  1. SRC instruction set type B have  --------- instructions.
                                                               i.      2
                                                            ii.      3
                                                            iii.      4
                                                           iv.      5             
  1. ----------- is defined as the time required to process a single instruction
                                                               i.      Latency & throughput
                                                            ii.      Latency
                                                            iii.      Throughput
                                                           iv.      None
  1. A  scalar processor that can issue multiple instructions simultaneously is said to be --------
                                                              i.      Superscalar
                                                            ii.      Multiscalar
                                                          iii.      ---
                                                          iv.      ---
  1. Which memory is faster than Cache?
                                                              i.      RAM
                                                            ii.      Processor Registers
                                                          iii.      Primary memory
                                                          iv.      Secondary memory
  1. In ---------  we discussed that a number of instructions are executed in a staggered fashion.
                                                              i.      Parallel processing
                                                            ii.      Multiprocessing
                                                          iii.      Pipelining
                                                          iv.      Multithreading


Monday, November 21, 2011

CS501 2 Advance Computer Architecture fall 2011 assignment solution

Question No. 1:

Find the execution time for a program that executes 60 million instructions on a processor with an average CPI of 1.0 and a clock period of 33.3 nsec.


Execution time = IC * CPI * T
IC = 60 * 10 6
CPI = 1.0
T = 33.3 nsec  = 33.3 * 10-9

Execution time = 60 * 10 6 * 1.0 * 33.3 * 10-9
= 1.998


Question No. 2:

Consider a program that executes 200 million instructions in 10 seconds. What is the MIPS rating for this program?

MIPS = IC / ( ET * 106 )
IC = 200 millions
ET = 10 sec
MIPS = 200 millions / (10 * 106)
MIPS = 20

Wednesday, November 16, 2011

Assignment Solution CS201 Introduction to Programming no. 2 Fall 2011

Copy the code in Dev C++ and save it as a C++ file and submit it.
Please so changes before submit.



  #include<iostream.h>


void GetAnnualIncome(int[],int);
void CalcIncChange(int[], double[],int);
void CalcChangePercent(int[], double[], float[], int);
void IncDecYears(double[], int);
void MaxIncDecYears(int,int); 

main()
{
      int anlIncm[10];
      double chngInc[10];
      float chngIncPer[10];
     
      cout<<"\t\t     .... ABC Company Income Sheet ....\n"<<endl;
      cout<<"Enter Income for Past 10 Years (in Millions)\n"<<endl;
      GetAnnualIncome(anlIncm,10);
      CalcIncChange(anlIncm, chngInc, 10);
      CalcChangePercent(anlIncm, chngInc,chngIncPer, 10);
      IncDecYears(chngInc, 10);
cout<<endl<<endl;     
system("pause");
}

void GetAnnualIncome(int inc[],int size)
{
     int var;
     for(int i=0;i<size;i++)
     {
             cout<<"Income for Year "<<2000+i<<" :                 ";
             cin>>var;
             if(var < 0)
             {
                    i--;
             }
             else if(var >=0 )
             {
                  inc[i] = var;
             }
     }
}

void CalcIncChange(int inc[], double chg[],int size)
{
     cout<<"\n\n";
 
     chg[0] = inc[0] -1000;
     for(int i=1;i<size;i++)
     {
             chg[i] = inc [i] - inc[i-1];
     }
     for(int i=0;i<size;i++)
     {
             if (chg[i] >= 0)
             {
                        cout<<"Income Increase in Year "<<2000+i<<" :     "<<chg[i]<<" million"<<endl;
             }
             else if (chg[i] < 0)
             {
                        cout<<"Income Decrease in Year "<<2000+i<<" :     "<<chg[i]*-1<<" million"<<endl;
             }
     }
}
void CalcChangePercent(int inc[], double chg[], float per[], int size)
{
     
    
     cout<<"\n\n";
     per[0] = (chg[0]*100 / 1000);
     for(int i=1;i<size;i++)
     {
             per[i] = (chg [i]*100 / inc[i-1]);
     }
     for(int i=0;i<size;i++)
     {
             if (per[i] >= 0)
             {
                        cout<<"Income Increase in Year "<<2000+i<<" :     "<<per[i]<<"%"<<endl;
             }
             else if (per[i] < 0)
             {
                        cout<<"Income Decrease in Year "<<2000+i<<" :     "<<per[i]*-1<<"%"<<endl;
             }
     }
}
 
 
void IncDecYears(double chg[], int size)
{
     int max, min;
     cout<<"\n\nIncome Increased in the following years: "<<endl;
     for(int i=0;i<size;i++)
     {
             max=min=0;
             if (chg[i] >= 0)
             {
                       
                        if(chg[max] < chg[i])
                        {
                               max = i;
                        }                              
                        cout<<2000+i<<", ";
             }
     }
     cout<<"\n\nIncome Decreased in the following years: "<<endl;
     for(int i=0;i<size;i++)
     {
             if (chg[i] < 0)
             {
                        if(chg[min] > chg[i])
                        {
                               min = i;
                        }
                        cout<<2000+i<<", ";
             }
     }
MaxIncDecYears(max+2000,min+2000);
    
}  

void MaxIncDecYears(int max,int min)
{
     cout<<"\n\nYear with maximium income Increase:      "<<max<<endl;
     cout<<"Year with maximium income Decrease:      "<<min<<endl;
}

Monday, November 14, 2011

CS401: Computer Architecture and Assembly Language Programming Assignment No. 02 Semester: Fall 2011

Suppose your roll number is MC432198765. Here we refer 8765 as last four digits of your roll number.

Question No. 1:                                         5 Marks

Write and execute the following Assembly language program on your system and tell what will be the value of BX register at the end of this program?

[org 0x0100]
Mov bx, 0x8765
Ror bx,8
mov ax, 0x4c00
int 0x21

Note: In above program 8765 is used as an example. You have to put last four digits of your roll number there.


Let us suppose the last four digits of your rollno. is 1234 then 

Answer: will     3412

only interchange the last two digit with the first two digits.

example:    abcd   then   cd  will come before  ab  as   cdab


Question No. 2:                                         5 Marks

Modify the above program such that at the end of your program, we shall have 1’s compliment of your roll number’s last four digits in BX register.
[org 0x0100]

Mov bx, 0x8765--------Please enter your roll number’s last four digits here
Not bx
mov ax, 0x4c00
int 0x21


Question No. 3:                                          10 Marks

Write an assembly language program that will calculate the number of 1’s in the binary representation of last four digits of your roll number. For example if the binary representation of last four digits of your roll no. is 1101001100001 then the number of 1’s will be 6. The total number of 1’s should be stored in AX register. In this case, AX will contain 6 at the end of program.


[org 0x0100]


     mov dx, 0x8765--------Please enter your roll number’s last four digits here
     mov cl, 17
     mov ax,0

a:
     shr dx, 1
     dec cl
     jz t
     jnc a

     add ax,1

    
      
     jnz a
t:

     mov ax, 0x4c00
     int 0x21

Saturday, November 12, 2011

ASSIGNMENT 02(MTH401) Differential Equation

Question 1:                                                                                                                             
Solve the initial value problem.
4 dy / dx - 2y = xy5,     y(1) = 3

4 dy / dx - 2y = xy5 --------------------------------(1)

P(x) = -2   , q(x) = x  ,   n=5
Divide the equation (1) with y5 

4y-5 dy/dx -2y-4 =x

Let suppose
w = y-4
dw / dx = -4 y-5 dy / dx ------------------------------------(2)
as we know from the original equation:
dy / dx = (xy5 + 2y) /4
putting the value of dy/dx in eq (2)
dw / dx = - y-5 (xy5 +2y)
dw / dx = - x - 2y-4
dw / dx = - x - 2w
dw / dx + 2w = -x
by taking integral factor
= e f (p(x)dx)
P(x) = 2
u(x) = e f 2dx = e2x

Multiply the whole equation with integrating factor
dw / dx e2x + 2w e2x = -x e2x
f d / dx (w e2x )= f -x e2x
we2x = f -x e2x
we2x = - (x e2x/2 - f  e2x/2dx)
we2x = - (x e2x/2 - e2x/4 + c)
w  = - x /2 + 1/4 - c e-2x
y-4 = - x /2 + 1/4 - c e-2x
(3)-4 = - 1 /2 + 1/4 - c e-2
1/81 = - 1 / 4 - c e-2
C =85e2 / 204
y-4 = - x /2 + 1/4 -  85e2 / 204 e-2x
y = ( - x /2 + 1/4 -  85e2 / 204 e-2x ) -1 / 4

Wednesday, November 9, 2011

Assignment No. 02 CS602 – Computer Graphics Fall 2011

Question                                      20 marks
We have two vectors V1 = (1, 2, 3) and V2 = (4, 5, 6).
Using these vectors evaluate the following.
1.    V1norm =?                                
|V1| = sqrt(12 +22 + 32)
|V1| =sqrt(14)
|V1| = 3.74
V1norm = V1 / |V1| = (1+2+ 3) / 3.74
V1norm = (1 / 3.74, 2 / 3.74, 3 / 3.74)
V1 norm = (0.27, 0.53, 0.80)

2.    V1 + V2 =?   
V1 + V2 = (V1x + V2x, V1y + V2y, V1z + V2z)   
V1 + V2 = (1 + 4, 2 + 5, 3 + 6)
V1+V2 = (5, 7, 9)
                        
3.    V1.V2 =?        
V1.V2=  (V1x V2x ) + (V1y V2y ) + (V1z V2z)
V1 . V2 = (1 * 4) + ( 2 * 5) + ( 3 * 6)
V1.V2 =4 + 10 + 18
V1 . V2 =32
                         

4.    V1 X V2 =?                                  8 marks
V1 X V2 =(V1y V2z – V1z V2y , V1z V2x - V1x V2z , V1xV2y - V1y V2x )
= (2*6) - (3*5) , (3*4)-(1*6) , (1*5)-(2*4)
= 12 -15 , 12 – 6 , 5 – 8
= -3 , 6 , -3                             

Thursday, November 3, 2011

CS609-System Programming Assignment No. 1 Fall 2011

Assignment                                                                 [Total Marks 20]

Q No. 1
Write the C Program that should print the 25 rows of DOS screen with different colors, i.e. your DOS screen should be displayed in such a way that every two consecutive rows should have different colors.  Following is the sample output of your program.

You can print the 25 rows of DOS screen with any colors but the two consecutive rows should have different colors so that we can identify them from each other.

Solution:






#include<BIOS.H>
#include<DOS.H>
#include<conio.h>
unsigned int far *vga=0xb8000000;
void main()
{
int i,j;
clrscr();
j= 0x0020;
for(i=1; i<=2000; i++)
{
(*(vga+i-1))=j;
if(i%80==0)
{
j=j+4096;
}
}
getch();
}

Wednesday, November 2, 2011

Assignment No. 01 CS401: Computer Architecture and Assembly Language Programming Semester: Fall 2011

Question No. 1:

a. Suppose architecture A has 14-bit address bus. What is maximum size of memory that can be accessed in this architecture? (Show the steps for calculating maximum accessible memory) (5 marks)


Memory accessed = 2 no. of bits
214 =16384
16384/1024 = 16KB


b. An architecture B has a maximum limit of 2GB memory. How many address bits are required for this architecture? (Show the steps for calculating required number of address bits) (5 marks)

2GB*1024=2048 MB
2048*1024=2097152 KB
2097152*1024=2147483648 Bytes
No. of bits = log2 (2147483648)
No. of bits = 31 bits


Question No. 2:
What are the first and the last physical memory addresses accessible using the following segment values? (2 mark each)
  1. 0000
First address = 00000 + 00000 =00000
Last  address = 00000 + 0FFFF =0FFFF
  1. FFFF
First address = FFFF0 + 00000 = FFFF0
Last address  = FFFF0 + 0FFFF = 0FFEF


Question No. 3:

Calculate physical address using the following segment offset pairs.
(1 mark each)
  1. ABCD:1234  = ABCD0 + 01234 =   ACF04
  2. 1234:ABCD  = 12340 + 0ABCD =   1CF0D






Question No. 4:

What is effective address generated by the following instructions? Every instruction is independent of others. Initially BX = 0xFF00, SI=0x00FF
(1 mark each)

  1. mov ax, [BX+SI]
   BX+SI =0xFF00 + 0x00FF = 0XFFFF

  = 0XFFFF

  1. mov ax, [BX+1024] (1024 is in decimal)
   BX+1024=0xFF00 + 0X400 = 0x0300

    = 0x0300






Question No. 5:

What are the contents of memory locations 720, 721, 722 and 723 if the word 4321 is stored at offset 720 and the word 8765 is stored at the offset 722 using Big Endean format? (2 marks)


Address
Contents

0x720
43
0x721
21
0x722
87
0x723
65