National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
Digital Design
Lecture 2
Tooba Javed
Spring 2017
Department of Electrical Engineering, FASTNU
HDL (Hardware Description Language)
HDL is a language used to describe a digital system e.g., a
computer or a component of a computer.
Most popular HDLs are
National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
Digital Design
Lecture 4
Tooba Javed
Spring 2017
Department of Electrical Engineering, FASTNU
DATA TYPES (CONTD.)
Reference: Circuit Design with VHDL, Pedroni : Chapter 3
User defined data types
User may define his/her own data type
Two categories of u
National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
Digital Design
Spring 2017
Department of Electrical Engineering,
FASTNU
Tooba Javed
(CHAPTER 6 contd.)
LOOP
It is used to instantiate a piece of code several
times
It is intended exclusively for sequential code
FOR/LOOP
Repeated a fixed number of times
National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
Digital Design
Spring 2017
Department of Electrical Engineering, FASTNU
Tooba Javed
Lecture 5
DATA TYPES (CONTD.)
Reference: Circuit Design with VHDL, Pedroni : Chapter 3
Data Conversion
Vhdl does not allow direct operations between data of different
National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
Digital Design
Lecture 3
Tooba Javed
Spring 2017
Department of Electrical Engineering, FASTNU
Example 2.1: DFF with asynchronous reset
Example 2.2: DFF plus NAND Gate
Exercise
Write VHDL code to implement following circuit
DATA TYPES
Reference: Circuit
National University of Computer and Emerging Sciences, Lahore
sos
COMPUTER S 1010

Spring 2017
DIGITAL DESIGN
CH6 CONTD. + CH 7
Spring 2017
Example: RAM
Declaring
1Dx1D array
Exercise Write VHDL code for the following JK Flipflop 74LS112D
Operating
mode
Inputs
outputs
P
R J
K
Q
Q
SET
L
H X
X
H
L
RESET
H
L
X
X
L
H
UNDERTERMIN
ED
L
L
X
X
H
H
TOGGLE
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
Structs (User Define Data Type)
There are many instances in programming where we need more than one variable in
order to represent an object. For example, to represent yourself, you might want to
store your name, your birthday, your height, your weight, o
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
118
5 Generating Functions
We now turn our attention to rational functions and their decomposition into partial
fractions. A rational function is a function of the form f (x) = p(x)/q(x), where p(x)
and q(x) are polynomials such that q(x) = 0. If the degr
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
3.7 Application: Cryptosystems and the Enigma
93
Fig. 3.5 The rotor assembly
Example 3.7.4 Suppose that the wiring of the rotors and the reflector are unknown.
Further suppose that it is unknown how many plugboard cables are being used.
Determine the numb
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
140
5 Generating Functions
Thus the required generating function is given by:
F (x, y, z) = (1 + xyz2 + x 2 y 2 z4 + ) (1 + xy 2 z3 + x 2 y 4 z6 + )
!
"#
$ !
"#
$
x1
3 5
6 10 2
x2
2
3
4 2 6
(1 + x y z + x y z + ) (1 + x yz + x y z + )
!
"#
$ !
"#
$
x3
=
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.3 Single Variable Generating Functions
131
Subject to:
0 x1 10;
0 x2 5;
4 x3 7;
2 x4 8.
Solution First we derive the generating function. The exponent of x in the ith factor
gives the value of xi in the sum. Thus the exponents of xi must satisfy the abo
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.1 Review of Factoring and Partial Fractions
117
Alternately, if we can manipulate the standard factoring in algebra to achieve
the desired form. Namely,
f (x) = 3x 2 9x + 6 = 3(x 2 3x + 2) = 3(x 2)(x 1)
!
"
!
"
1
1
= 3( 2) 1 x (1)(1 x) = 6 1 x (1 x).
2
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.3 Single Variable Generating Functions
133
linear equation subject to a set of constraints. We begin by finding the appropriate
generating function.
Since the number of gumdrops that Edward receives is dependant on the number of
gumdrops Alice receives,
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.3 Partition Numbers and Stirling Numbers of the Second Kind
107
Table 4.4 The number of partitions of n
n
0
1
2
3
4
5
6
7
8
9
10
11
12
13
p(n)
1
1
2
3
5
7
11
15
22
30
42
56
77
101
+ p(n 15) p(n 22)
where the sum is taken over all p(n k) where k = 21 i(
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
110
4 Distribution Problems
Now, distribute the unlabeled white balls. The number of distributions of the white
balls can be counted in n2 + 1 disjoint, exhaustive sets. The j th set is the set of all
distributions in which j white balls are placed in the
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
99
Fig. 4.1 A distribution of 15
unlabeled balls into 6 labeled
urns
In some cases, it is desirable to look at distributions in which each urn receives a
specified number of balls. This will be considered
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
128
5 Generating Functions
Normally, we would simplify this as
1 + x + xn + .
However, in our initial exhibition, we prefer the expanded form. In this expanded
form, the first exponent of one gives the value of penny and the second exponent of
n gives the
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
3.7 Application: Cryptosystems and the Enigma
91
Solution The length of the message key can be at most the length of the message
itself. Thus even if the keyword is four letters, say MATH and n = 10, then the
message key would be MATHMATHMA. Hence there a
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
103
integer solutions to x1 + x2 + x3 + x4 = 20, where x1 7, x2 10, x3 6, and
x4 13. Unfortunately, the machinery necessary to solve this problem has not been
developed at this time. We will revisit this p
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.3 Partition Numbers and Stirling Numbers of the Second Kind
109
Table 4.6 Summary of results for n balls into k urns
Unlabeled balls
Unlabeled urns
Unlabeled balls
Labeled urns
Labeled balls
Unlabeled urns
Labeled balls
Labeled urns
No restriction
!k
i=
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
102
4 Distribution Problems
However, some distributions may be in both A and B. Note that A B is the set of
all distributions in which every urn receives at least one ball. In this case, we can
simply ignore the colors. Hence, this is a distribution of n
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.1 Review of Factoring and Partial Fractions
119
Choosing two distinct values of x will yield a system of two equations with two
unknowns, which we can then solve. We make the convenient choices of x = 1 and
x = 2.
x = 1 3 = 3A1 A1 = 1
x = 2 5 = 6A2 A2 =
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
101
Since the Ai are disjoint sets, it follows that the number of distributions is given
by
#"
#
k " #"
!
k n2 1 n 1 + i 1
Ai  =
.
i
i1
k1
i=1
i=1
k
!
!
Note that in the previous example, the roles of th
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
97
A variation on the above example would be to consider the case where we are are
offering the children gumdrops before dinner. Again, the gumdrops can be considered
unlabeled balls and the children can b
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
106
4 Distribution Problems
Similarly, suppose cfw_1 , ., k is a partition of n into k parts. This corresponds
to placing i unlabeled balls into the ith urn. Since the i > 0, no urn will be left
empty.
!
It would be desirable to find a concise formula fo
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
94
3 The Binomial Coefficient
So, by the Addition Principle, the total number of configurations is given by
13
!
k=0
Ak  =
13 "
!
k=0
"
#
#
26!
26!
2
(26!(26! 1)(26! 2)(26 ) 13
2k (26 2k)!k!
2 13!
3 10114 .
One of the key steps in the cryptanalysis of
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
120
5 Generating Functions
Substituting in x = 1 and x = 2 yields:
x = 2 2 = A1,1 and
x = 1 2 = A2,2 /2 A2,2 = 4.
To solve for A2,1 , we can substitute a third value in for x (say x = 0). This yields
2 = 2 + A2,1 4. Hence A2,1 = 4.
Alternately, we can com