1
00:00:01,540 --> 00:00:08,110
So the balancing is an interesting feature of mechanical switches, and it may cause some problems when

2
00:00:08,110 --> 00:00:13,720
we connect the mechanical switch, such as push buttons or light switches to digital circuits.

3
00:00:14,260 --> 00:00:18,580
This lecture will define this phenomenon and you'll explain how to solve that.

4
00:00:21,000 --> 00:00:27,930
A mechanical switch such as a slight switch and a push button that we have on the basis three more toggles,

5
00:00:27,930 --> 00:00:31,930
two metal plates touch each other to create an electrical circuit.

6
00:00:32,850 --> 00:00:36,460
However, this touching process does not happen instantly.

7
00:00:36,960 --> 00:00:42,260
The metal plates touch each other several times before the final stable connection is made.

8
00:00:43,080 --> 00:00:51,060
Although this bouncing phenomenon can last milliseconds, a high logic circuit can detect all the bouncing

9
00:00:51,060 --> 00:00:51,600
values.

10
00:00:54,570 --> 00:00:57,330
To cope with this issue, we should balance the switch.

11
00:00:58,200 --> 00:01:00,810
There are several techniques to implement a switch demands.

12
00:01:02,650 --> 00:01:06,940
Electrical solution, digital solution, software solution.

13
00:01:10,390 --> 00:01:16,420
The goal is describing a digital circuit, then necklace that converts the switch bounces signal outward

14
00:01:16,420 --> 00:01:21,630
into a pulse with clear edges, let's assume the circuit clock and the switch bounces signal.

15
00:01:22,300 --> 00:01:27,250
One of the simple ideas is using a delay after detecting an edge on the switch out.

16
00:01:28,680 --> 00:01:34,800
For this purpose, the circuit samples the switch output on the rising edge of the clock when an age

17
00:01:34,800 --> 00:01:40,490
is detected, it stops sampling for a period of time and then starts sampling again.

18
00:01:42,750 --> 00:01:48,630
If the sampling polls delay is greater than the bouncing period, then the circuit can generate the

19
00:01:48,630 --> 00:01:49,690
desired output.

20
00:01:50,070 --> 00:01:54,270
Note that there are more robust solutions for the Swiftie bounce or circuit.

21
00:01:55,270 --> 00:01:59,860
However, a study, all of these solutions is not the goal of this course.

22
00:02:02,480 --> 00:02:07,930
Kurita White Essentialists project with the name of the bouncer Dasch White Essentialists.

23
00:02:16,440 --> 00:02:19,590
Choose the basis to bought as a target FPGA platform.

24
00:02:28,050 --> 00:02:32,220
Create a new design, Sourcefire and the New Testament, Sourcefire.

25
00:02:46,770 --> 00:02:48,240
Open the design, Sourcefire.

26
00:02:49,640 --> 00:02:55,670
Let's define the delay under escort counter macro for defining a five millisecond delay.

27
00:02:56,870 --> 00:03:04,220
Our demands are circuit has to states transfer and delay in the transfer of state, it connects the

28
00:03:04,220 --> 00:03:05,780
input signal to the output.

29
00:03:06,810 --> 00:03:13,590
The circuit keeps the output unchanged in the delay state and waits for bounces on the input to expire.

30
00:03:15,520 --> 00:03:20,230
The design top function has two arguments, an input and an output.

31
00:03:20,980 --> 00:03:26,500
Let's define two static variables, one for the circuit, the state and another for saving the delay

32
00:03:26,500 --> 00:03:26,980
counter.

33
00:03:28,800 --> 00:03:34,980
We also need another static variable to keep the previous value on the input signal to detect an edge

34
00:03:34,980 --> 00:03:35,400
on the.

35
00:03:39,280 --> 00:03:44,470
Please know that these are static variables will be synthesized into registers in hardware.

36
00:03:45,310 --> 00:03:52,090
Now let's define the temporary variables corresponding to two estate and countless static variables.

37
00:03:55,060 --> 00:04:01,360
As we won't change the content of the previous underscore S.W. static variable in our Suchiate statement,

38
00:04:01,660 --> 00:04:04,040
we don't need a temporary variable for that.

39
00:04:04,840 --> 00:04:08,770
We also need a temporary variable corresponding to the output signal.

40
00:04:09,340 --> 00:04:12,160
Now, let's define our state machine between states.

41
00:04:12,640 --> 00:04:15,430
For this purpose, we use a switch case statement.

42
00:04:16,150 --> 00:04:20,160
When the circuit is in the transfer state, it goes to the delay state.

43
00:04:20,260 --> 00:04:27,610
If the current and previous values on this stability input are different, which means there is an edge

44
00:04:27,790 --> 00:04:36,220
on this subject, otherwise it stays in the transfer state and the instability input is connected to

45
00:04:36,220 --> 00:04:36,830
the output.

46
00:04:37,720 --> 00:04:41,920
Also next, kountouris delay underscore counter macro.

47
00:04:43,350 --> 00:04:49,290
In the DeLay state, the circuit recommends the counter on each clock, and when the counter gets to

48
00:04:49,290 --> 00:04:52,560
zero, the state machine goes to transfer state.

49
00:04:53,910 --> 00:04:57,630
In the delay state, the output signal keeps its previous value.

50
00:04:58,460 --> 00:05:03,440
Finally, we should update the static variables and function output signal.

51
00:05:06,520 --> 00:05:13,980
Now, let's try the test code, simulating the code for five hundred thousand clock cycles is not comfortable.

52
00:05:14,830 --> 00:05:19,030
Let's reduce a delay only for simulation purposes and define the delay.

53
00:05:19,030 --> 00:05:23,140
Underscore counter macro again for only 500 clock cycles.

54
00:05:27,940 --> 00:05:34,630
Please open the test page Sourcefire include the iList three, Mahadev five and the design top function

55
00:05:34,630 --> 00:05:35,210
prototype.

56
00:05:35,800 --> 00:05:37,750
Now let's define the main function.

57
00:05:39,390 --> 00:05:46,140
As usual, we should define the status valuable that returns the design correctness a status we need

58
00:05:46,140 --> 00:05:49,860
to variables representing the design, input and output arguments.

59
00:05:50,190 --> 00:05:56,130
Now, let's call the design for 5000 times while to establish an input signal, Izell.

60
00:05:57,090 --> 00:06:03,810
And use a for loop with 250 iterations to generate a synthetic bouncing on this.

61
00:06:06,120 --> 00:06:14,440
Then keep the S.W. input stable on the high logic level, using a 5000 iteration for now, let's insert

62
00:06:14,440 --> 00:06:17,250
the artificial bouncer's on the input switch again.

63
00:06:19,030 --> 00:06:22,730
Finally, keep the input signal stable on the low logic level.

64
00:06:32,310 --> 00:06:36,690
Let's do the simulation to find possible syntax on some hunting arrows.

65
00:06:39,300 --> 00:06:46,530
Here, I haven't printed any signal values on the screen that is not so readable, but you can do so

66
00:06:46,530 --> 00:06:52,440
if you are interested now perform the synthesis and artillery simulation after that.

67
00:06:53,700 --> 00:06:58,860
Don't forget to dump all signal values for inspecting their signal waveforms.

68
00:08:16,650 --> 00:08:23,490
Now, let's click on the waveform viewer I come all the way from viewer will be opened shot design and

69
00:08:23,490 --> 00:08:29,010
put an end to the signals and inspect the output signal, which is a clear pulse, even though there

70
00:08:29,010 --> 00:08:30,630
are lots of bounces on the.

71
00:09:35,490 --> 00:09:41,140
How can we design a digital counter in the next lecture will cope with this question.

72
00:09:42,630 --> 00:09:44,270
These are our takeaway messages.

73
00:09:44,730 --> 00:09:47,680
Mechanical switches suffer from bouncing phenomena.

74
00:09:48,510 --> 00:09:54,090
If we are going to use the output of a mechanical switch as an input to a digital circuit, we should

75
00:09:54,090 --> 00:09:54,650
utilize it.

76
00:09:54,660 --> 00:09:55,800
The balancing mechanism.

77
00:09:57,780 --> 00:10:03,000
There are several developing mechanisms available categorized into hardware and software solutions.

78
00:10:03,930 --> 00:10:09,510
As the sweet bouncing is a low level physical phenomenon, low level solutions are usually more efficient

79
00:10:09,510 --> 00:10:11,850
than high level software based solutions.

80
00:10:14,090 --> 00:10:20,750
Now, the quiz question, calculate the delay in the code in terms of millisecond when DeLay underscore

81
00:10:20,750 --> 00:10:24,920
Kountouris 500 and 500000.
