﻿1
00:00:12,140 --> 00:00:18,500
Welcome to when else statements with select When statement lecture and this lecture I'm going to talk

2
00:00:18,500 --> 00:00:25,990
about the when else with select and with select when statements in the VHDL language.

3
00:00:26,000 --> 00:00:31,910
So first let's talk about the when else statement A Well statement allows a signal to be assigned a

4
00:00:31,910 --> 00:00:34,890
value based on a set of conditions.

5
00:00:34,970 --> 00:00:38,810
The statement is considered a concurrent signal assignment.

6
00:00:38,810 --> 00:00:44,690
This is directly placed into your architecture and it is when all statements are very similar to a case

7
00:00:44,690 --> 00:00:45,640
statement.

8
00:00:45,710 --> 00:00:53,120
However a case statement when you create them you must place them inside a process and your micel design

9
00:00:53,510 --> 00:00:58,640
where when else statement does not need to happen inside of a process.

10
00:00:58,940 --> 00:01:03,870
So an example of a one else statement we have two signals A and B.

11
00:01:03,980 --> 00:01:09,250
They're both standard logic vectors or signal B is from 3 and 0.

12
00:01:09,260 --> 00:01:17,690
So it's 4 bits wide or signal A is from 1 down to zero so two bits wide and we'll use or when else statement

13
00:01:18,160 --> 00:01:26,630
and or when a statement is going to assign a value to B when depending upon the value of a sort of value

14
00:01:26,630 --> 00:01:27,230
of b.

15
00:01:27,260 --> 00:01:31,790
For example the first line will be equal to 1 000.

16
00:01:31,790 --> 00:01:34,280
When a is equal to zero zero.

17
00:01:34,550 --> 00:01:43,410
Otherwise B will be equal to 0 1 0 0 when they is equal to 0 1 and just on down the line or B will be

18
00:01:43,410 --> 00:01:45,200
equal to 0 0 1 0.

19
00:01:45,200 --> 00:01:53,090
When a is equal to 1 0 and also be equal to 0 0 0 1 when a is equal to one one.

20
00:01:53,090 --> 00:01:58,040
Now you'll know if you look at this statement you could say hey I can implement this in a case statement

21
00:01:58,460 --> 00:02:01,210
and me personally I would do that.

22
00:02:01,220 --> 00:02:06,470
These are just kind of it's more of a personal preference in VHDL as the lot of other languages you

23
00:02:06,470 --> 00:02:12,980
can do a lot of the same things just using different coding style structures or different statements.

24
00:02:12,980 --> 00:02:18,500
So in this case if you wanted something to put it directly in the architecture and you want it to happen

25
00:02:18,500 --> 00:02:21,990
before clock edge you would use a When statement.

26
00:02:22,010 --> 00:02:28,190
However if you need it to happen on the rising or falling edge of a clock or in Iowa every time a signal

27
00:02:28,220 --> 00:02:32,520
changes state you would want to use a case statement and place in a process.

28
00:02:32,600 --> 00:02:38,000
And so it's more like a personal preference or depending upon the specific design application.

29
00:02:39,110 --> 00:02:45,740
Now if we have a with select When statement This allows one of several possible values to be assigned

30
00:02:46,130 --> 00:02:52,940
to a signal based on a select expression the choice is slight and must be determined when being compiled.

31
00:02:53,210 --> 00:02:55,160
This is similar to a case statement as well.

32
00:02:55,160 --> 00:03:01,040
So you'll notice that with the select statement as well as the with select When statement.

33
00:03:01,100 --> 00:03:03,830
They're very similar they do the same exact thing.

34
00:03:03,850 --> 00:03:06,310
It's once again just kind of a preference.

35
00:03:06,350 --> 00:03:11,280
I've been doing this for multiple years and I almost always go with a case statement.

36
00:03:11,300 --> 00:03:15,860
I just think they look cleaner nicer and it's easier for me to understand but it's a personal preference

37
00:03:15,860 --> 00:03:16,390
thing.

38
00:03:17,730 --> 00:03:23,020
When when you're working with with Slyke When statement we have an example.

39
00:03:23,050 --> 00:03:35,770
So we have our with a select Y is equal to zero when 000 or C 1 when 0 0 1 and a comma.

40
00:03:36,070 --> 00:03:39,550
And we keep going down line like are C to when 0 1 0.

41
00:03:39,580 --> 00:03:45,150
Or C 3 when 0 1 1 and then we have our zero win others.

42
00:03:45,330 --> 00:03:50,960
And so it's a slight difference from the with select statement or with statement.

43
00:03:51,040 --> 00:03:55,180
This is kind of a a little difference but once again like I said it's just kind of a personal preference

44
00:03:55,180 --> 00:03:59,400
whichever you prefer on what looks cleaner to you what's easier for you remember.

45
00:03:59,590 --> 00:04:05,100
And so you kind of just make that decision now that we have covered all the different statements and

46
00:04:05,100 --> 00:04:05,610
loops.

47
00:04:05,610 --> 00:04:10,110
Next we're going to discuss the HGL processes and concurrent statements.

