﻿1
00:00:13,690 --> 00:00:19,630
Welcome to the unsigned and signed data types lecture and this lecture I'm going to explain VHDL unsigned

2
00:00:19,710 --> 00:00:27,160
and signed data types what is an unsigned data type and unsigned type is declared in the package numeric

3
00:00:27,160 --> 00:00:34,600
standard and one unsigned data type is there's an array of standard logic which we know a standard logic

4
00:00:34,690 --> 00:00:41,710
is an individual one or a zero a specific bit and a type unsigned is interpreted as a standard logic

5
00:00:41,710 --> 00:00:45,050
vector where we have a group of standard logic.

6
00:00:45,190 --> 00:00:50,440
But the difference is we have different operators available with a of logic vector we have.

7
00:00:50,440 --> 00:00:57,580
We can actually do addition or subtraction Hovell with the unsigned data type we can if we have to unsigned

8
00:00:57,690 --> 00:01:01,970
data types we can take and subtract them or add them to each other.

9
00:01:02,170 --> 00:01:06,910
And also we can manipulate the individual bits which is a major advantage.

10
00:01:06,910 --> 00:01:09,040
We can only with an unsigned type.

11
00:01:09,030 --> 00:01:11,590
We can only represent positive numbers.

12
00:01:11,590 --> 00:01:13,540
We can't represent a negative number.

13
00:01:13,660 --> 00:01:19,580
So once we get down to zero if we subtract one will still say zero we can't go to a negative one.

14
00:01:19,760 --> 00:01:28,240
And in the unsigned data type the leftmost bit is the NSB or the most significant bit.

15
00:01:28,270 --> 00:01:31,460
Let's take a look at an unsigned data type example.

16
00:01:31,480 --> 00:01:38,040
We have the data class which is a signal we have the signal name which is count.

17
00:01:38,050 --> 00:01:45,830
Then we have the colon and the data type which in this case is unsigned and HDL is denoted by just unsigned

18
00:01:46,480 --> 00:01:49,640
and we have the size of the unsigned data type.

19
00:01:49,780 --> 00:01:53,630
So here we have a data with minus one down to zero.

20
00:01:53,740 --> 00:02:00,490
So whenever either data with this if our data is a size of 8 we would take 8 minus one so B 7 down to

21
00:02:00,490 --> 00:02:05,150
zero which would give us a total of 8 bits in our unsigned data type.

22
00:02:05,440 --> 00:02:07,440
And then we have our.

23
00:02:07,750 --> 00:02:13,540
So my coin equals to give us our initial value which we have the other is keyword telling us that all

24
00:02:13,540 --> 00:02:17,960
these bits are set to zero no matter what size.

25
00:02:17,980 --> 00:02:23,740
For example if we want to have a signal a with an unsigned data type we'll make it three down to zero

26
00:02:23,800 --> 00:02:29,860
which gives us 4 bits wide and we want to set that value to 13 which would be the binary value of 1

27
00:02:29,860 --> 00:02:35,860
1 0 1 with your leftmost bit being less inefficient that we Abdus up.

28
00:02:35,860 --> 00:02:37,970
That gives a value of 13.

29
00:02:38,440 --> 00:02:40,930
And if we take another signal we'll call signal B.

30
00:02:41,000 --> 00:02:47,780
I give it an unsigned data type with 3 down to zero which also is an 0 4 bits of one set that night

31
00:02:47,780 --> 00:02:53,350
of 5 and 0 1 0 1 leftmost bit is the most significant bit.

32
00:02:53,410 --> 00:03:01,860
And so that is how you would set the initial value of b to 5 now talk about our signed data types these

33
00:03:01,950 --> 00:03:03,480
are also declared in the package.

34
00:03:03,510 --> 00:03:10,110
Numeric standard just like the unsigned data types are and as well these are an array of stand who logic

35
00:03:10,410 --> 00:03:11,940
just like the unsigned data type.

36
00:03:11,940 --> 00:03:19,860
However the difference between the unsigned versus the signed is that you're signed data types can represent

37
00:03:19,920 --> 00:03:21,400
negative numbers.

38
00:03:21,540 --> 00:03:24,990
And the way they're stored are in twos complement form.

39
00:03:25,020 --> 00:03:30,660
So if you want to represent a negative five depending on the number of bits you specified for your data

40
00:03:30,660 --> 00:03:37,200
type you'll want to take negative five and the two's complement form and store it inside in the leftmost

41
00:03:37,200 --> 00:03:42,790
bit just like the unsigned data type is the MSP or the most significant bit.

42
00:03:42,830 --> 00:03:47,510
Well let's take a look at what a signed data type example looks like.

43
00:03:47,610 --> 00:03:50,460
We have our data class which is a signal.

44
00:03:50,490 --> 00:03:58,170
We have our signal name calling count and data type we're specifying assigned and then the size of that

45
00:03:58,170 --> 00:03:59,040
sign data type.

46
00:03:59,040 --> 00:04:01,580
How many bits is that signed data type.

47
00:04:01,680 --> 00:04:05,450
In this case we're saying data wit minus one down to zero.

48
00:04:05,490 --> 00:04:13,110
So our data with this if we have 8 bits we subtract one gives a 7 down to zero which are give us 8 bit

49
00:04:13,110 --> 00:04:19,100
number for Assigned data type and then the initial value which we are specifying them all to be zeros

50
00:04:19,950 --> 00:04:23,560
which is what the others keyword specifies.

51
00:04:23,610 --> 00:04:29,600
So let's say we have a signal a which is assigned to type signal we'll call it from 3 down to zero.

52
00:04:29,610 --> 00:04:34,910
So that gives us four bits and we want to have a negative three value.

53
00:04:35,070 --> 00:04:37,230
So we have to store this in twos complement.

54
00:04:37,440 --> 00:04:40,500
So that's where we have a 1 1 0 1.

55
00:04:40,500 --> 00:04:43,930
The leftmost bit is used to signify that it's negative.

56
00:04:44,070 --> 00:04:47,760
So we know that's a negative 3 and two's complement form.

57
00:04:47,760 --> 00:04:50,270
Now we want to have a positive five.

58
00:04:50,340 --> 00:04:53,950
We have our signal B which is assigned to type as well.

59
00:04:53,970 --> 00:05:01,650
Three down to zero gives us our four bits and we would specify or initial value is 0 1 0 1 and that's

60
00:05:01,650 --> 00:05:05,280
how you would set assign data type to a value of 5.

61
00:05:06,540 --> 00:05:09,290
And that is the signed unsigned datatypes lecture.

