WEBVTT

00:13.690 --> 00:19.630
Welcome to the unsigned and signed data types lecture and this lecture I'm going to explain VHDL unsigned

00:19.710 --> 00:27.160
and signed data types what is an unsigned data type and unsigned type is declared in the package numeric

00:27.160 --> 00:34.600
standard and one unsigned data type is there's an array of standard logic which we know a standard logic

00:34.690 --> 00:41.710
is an individual one or a zero a specific bit and a type unsigned is interpreted as a standard logic

00:41.710 --> 00:45.050
vector where we have a group of standard logic.

00:45.190 --> 00:50.440
But the difference is we have different operators available with a of logic vector we have.

00:50.440 --> 00:57.580
We can actually do addition or subtraction Hovell with the unsigned data type we can if we have to unsigned

00:57.690 --> 01:01.970
data types we can take and subtract them or add them to each other.

01:02.170 --> 01:06.910
And also we can manipulate the individual bits which is a major advantage.

01:06.910 --> 01:09.040
We can only with an unsigned type.

01:09.030 --> 01:11.590
We can only represent positive numbers.

01:11.590 --> 01:13.540
We can't represent a negative number.

01:13.660 --> 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.

01:19.760 --> 01:28.240
And in the unsigned data type the leftmost bit is the NSB or the most significant bit.

01:28.270 --> 01:31.460
Let's take a look at an unsigned data type example.

01:31.480 --> 01:38.040
We have the data class which is a signal we have the signal name which is count.

01:38.050 --> 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

01:46.480 --> 01:49.640
and we have the size of the unsigned data type.

01:49.780 --> 01:53.630
So here we have a data with minus one down to zero.

01:53.740 --> 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

02:00.490 --> 02:05.150
zero which would give us a total of 8 bits in our unsigned data type.

02:05.440 --> 02:07.440
And then we have our.

02:07.750 --> 02:13.540
So my coin equals to give us our initial value which we have the other is keyword telling us that all

02:13.540 --> 02:17.960
these bits are set to zero no matter what size.

02:17.980 --> 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

02:23.800 --> 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

02:29.860 --> 02:35.860
1 0 1 with your leftmost bit being less inefficient that we Abdus up.

02:35.860 --> 02:37.970
That gives a value of 13.

02:38.440 --> 02:40.930
And if we take another signal we'll call signal B.

02:41.000 --> 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

02:47.780 --> 02:53.350
of 5 and 0 1 0 1 leftmost bit is the most significant bit.

02:53.410 --> 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

03:01.950 --> 03:03.480
are also declared in the package.

03:03.510 --> 03:10.110
Numeric standard just like the unsigned data types are and as well these are an array of stand who logic

03:10.410 --> 03:11.940
just like the unsigned data type.

03:11.940 --> 03:19.860
However the difference between the unsigned versus the signed is that you're signed data types can represent

03:19.920 --> 03:21.400
negative numbers.

03:21.540 --> 03:24.990
And the way they're stored are in twos complement form.

03:25.020 --> 03:30.660
So if you want to represent a negative five depending on the number of bits you specified for your data

03:30.660 --> 03:37.200
type you'll want to take negative five and the two's complement form and store it inside in the leftmost

03:37.200 --> 03:42.790
bit just like the unsigned data type is the MSP or the most significant bit.

03:42.830 --> 03:47.510
Well let's take a look at what a signed data type example looks like.

03:47.610 --> 03:50.460
We have our data class which is a signal.

03:50.490 --> 03:58.170
We have our signal name calling count and data type we're specifying assigned and then the size of that

03:58.170 --> 03:59.040
sign data type.

03:59.040 --> 04:01.580
How many bits is that signed data type.

04:01.680 --> 04:05.450
In this case we're saying data wit minus one down to zero.

04:05.490 --> 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

04:13.110 --> 04:19.100
number for Assigned data type and then the initial value which we are specifying them all to be zeros

04:19.950 --> 04:23.560
which is what the others keyword specifies.

04:23.610 --> 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.

04:29.610 --> 04:34.910
So that gives us four bits and we want to have a negative three value.

04:35.070 --> 04:37.230
So we have to store this in twos complement.

04:37.440 --> 04:40.500
So that's where we have a 1 1 0 1.

04:40.500 --> 04:43.930
The leftmost bit is used to signify that it's negative.

04:44.070 --> 04:47.760
So we know that's a negative 3 and two's complement form.

04:47.760 --> 04:50.270
Now we want to have a positive five.

04:50.340 --> 04:53.950
We have our signal B which is assigned to type as well.

04:53.970 --> 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

05:01.650 --> 05:05.280
how you would set assign data type to a value of 5.

05:06.540 --> 05:09.290
And that is the signed unsigned datatypes lecture.
