WEBVTT

1
00:00:00.000 --> 00:00:04.580
In lesson one, each sensor reported
whether it was too hot.

2
00:00:05.200 --> 00:00:07.560
One bit could answer that question.

3
00:00:08.480 --> 00:00:11.620
Now the display needs a measurement value.

4
00:00:12.440 --> 00:00:17.580
The interface carries eight bits, and the
selector must pass the whole group.

5
00:00:18.520 --> 00:00:24.520
The rule stays the same: select zero
chooses A, and select one chooses B.

6
00:00:25.540 --> 00:00:31.320
This lesson follows those bits from their
declaration to the value a receiver reads.

7
00:00:31.755 --> 00:00:37.975
The range seven down to zero includes both
ends, giving eight positions.

8
00:00:38.635 --> 00:00:42.015
Bit zero is on the right and bit seven is
on the left.

9
00:00:42.895 --> 00:00:47.475
A thick line in the drawing represents the
whole group, often called a bus.

10
00:00:48.555 --> 00:00:50.835
The range does not add memory.

11
00:00:51.255 --> 00:00:53.655
This is still a combinational selector.

12
00:00:54.315 --> 00:00:57.935
Its output follows the chosen input, with
physical

13
00:00:57.935 --> 00:01:00.695
propagation delay determined by the
implementation.

14
00:01:01.340 --> 00:01:05.240
Split the eight bits into two groups of
four.

15
00:01:06.080 --> 00:01:11.100
The group one one one one is the
hexadecimal digit F.

16
00:01:11.960 --> 00:01:16.440
The group zero zero zero zero is the digit
zero.

17
00:01:17.320 --> 00:01:20.240
Together they form F zero.

18
00:01:21.840 --> 00:01:25.860
Hexadecimal gives us a shorter way to
record the pattern.

19
00:01:26.620 --> 00:01:31.120
Changing the notation does not change a
single bit on the interface.

20
00:01:31.720 --> 00:01:37.100
In the literal on screen, the leading
eight specifies the width.

21
00:01:37.920 --> 00:01:42.220
The h after the apostrophe selects
hexadecimal,

22
00:01:42.560 --> 00:01:45.100
and F zero supplies the pattern.

23
00:01:45.960 --> 00:01:49.960
A based literal without the signed marker
is unsigned.

24
00:01:50.720 --> 00:01:54.580
An ordinary decimal integer has different
signedness rules.

25
00:01:55.380 --> 00:02:00.220
For circuit data, this course writes the
intended width explicitly

26
00:02:00.220 --> 00:02:04.920
so the person reading the design can see
how many bits are involved.

27
00:02:05.490 --> 00:02:08.150
Now the source carries nine bits.

28
00:02:08.810 --> 00:02:14.330
A leading one followed by the previous
eight bits gives hexadecimal

29
00:02:14.330 --> 00:02:20.950
one F zero, or four hundred and ninety-six
as an unsigned value.

30
00:02:21.850 --> 00:02:24.190
The destination has only eight positions.

31
00:02:25.070 --> 00:02:30.210
The assignment keeps the low eight bits
and discards the highest bit.

32
00:02:31.030 --> 00:02:35.130
The remaining pattern is F zero, which
reads

33
00:02:35.130 --> 00:02:37.710
as two hundred and forty when unsigned.

34
00:02:38.110 --> 00:02:42.910
A receiver that sees only F zero cannot
tell

35
00:02:42.910 --> 00:02:47.270
whether the source was zero F zero or one
F zero.

36
00:02:47.830 --> 00:02:50.310
Both leave the same low eight bits.

37
00:02:51.210 --> 00:02:56.050
Truncation is intentional when the
interface asks for those low bits.

38
00:02:56.630 --> 00:03:01.070
If the full measurement matters, the
destination needs more

39
00:03:01.070 --> 00:03:05.310
bits or an explicit policy for values
outside its range.

40
00:03:05.310 --> 00:03:09.870
The interface must say which information
has to survive.

41
00:03:10.500 --> 00:03:13.900
Return to the eight-bit pattern F zero.

42
00:03:14.780 --> 00:03:19.460
In an unsigned reading, every position has
a positive weight.

43
00:03:20.280 --> 00:03:23.216
The four set positions contribute one
hundred

44
00:03:23.216 --> 00:03:27.541
and twenty-eight, sixty-four, thirty-two
and sixteen.

45
00:03:28.700 --> 00:03:30.640
Their sum is two hundred and forty.

46
00:03:32.080 --> 00:03:35.740
Eight unsigned bits can represent every
integer

47
00:03:35.740 --> 00:03:38.420
from zero through two hundred and
fifty-five.

48
00:03:38.930 --> 00:03:43.890
If the sensor interface specifies
eight-bit two's complement,

49
00:03:44.650 --> 00:03:48.570
the highest position has a weight of minus
one hundred and twenty-eight.

50
00:03:49.670 --> 00:03:52.130
The other seven weights stay positive.

51
00:03:53.050 --> 00:03:57.930
Add the four set positions again and the
result is minus sixteen.

52
00:03:58.810 --> 00:04:02.810
No bits were flipped and no extra
minus-sign bit was added.

53
00:04:03.610 --> 00:04:07.330
The pattern is unchanged; the interface
has

54
00:04:07.330 --> 00:04:09.910
defined a different numerical
interpretation.

55
00:04:10.680 --> 00:04:15.520
Eight-bit two's complement still has two
hundred and fifty-six patterns.

56
00:04:16.440 --> 00:04:21.420
The half with a zero high bit represents
zero through one hundred and twenty-seven.

57
00:04:22.700 --> 00:04:25.260
The other half represents minus one

58
00:04:25.260 --> 00:04:27.580
hundred and twenty-eight through minus
one.

59
00:04:28.540 --> 00:04:32.040
Zero uses one position in the nonnegative
half.

60
00:04:32.380 --> 00:04:34.660
That explains the asymmetric endpoints.

61
00:04:34.660 --> 00:04:40.000
With four bits, sixteen patterns cover
minus eight through seven.

62
00:04:40.450 --> 00:04:44.310
Suppose the next interface is sixteen bits
wide.

63
00:04:45.230 --> 00:04:50.190
To preserve the signed value minus
sixteen, sign extension

64
00:04:50.190 --> 00:04:54.230
copies the original high bit into the new
positions.

65
00:04:54.850 --> 00:05:00.530
Eight ones appear on the left, and a
signed reading still gives minus sixteen.

66
00:05:01.730 --> 00:05:07.610
An unsigned source is extended with zeros
instead, preserving two hundred and forty.

67
00:05:08.430 --> 00:05:13.290
The right-hand source expression
determines which extension is used.

68
00:05:13.760 --> 00:05:16.840
The wrong version appears to take all
eight

69
00:05:16.840 --> 00:05:20.400
bits, but it adds an explicit part-select.

70
00:05:21.320 --> 00:05:25.160
Under the language rules, a part-select is
unsigned

71
00:05:25.600 --> 00:05:28.360
even when it covers the entire signed
vector.

72
00:05:29.060 --> 00:05:32.840
Widening that expression adds zeros,
turning

73
00:05:32.840 --> 00:05:36.200
the intended minus sixteen into two
hundred and forty.

74
00:05:37.520 --> 00:05:41.160
The repair uses the original signed source
directly,

75
00:05:41.160 --> 00:05:44.140
allowing the assignment to preserve its
value.

76
00:05:44.725 --> 00:05:48.585
The signal description must also identify
its driver.

77
00:05:49.325 --> 00:05:54.565
Lesson one declared a wire net and used a
continuous assignment to drive it.

78
00:05:55.105 --> 00:06:00.405
SystemVerilog also permits one continuous
assignment to drive a logic variable.

79
00:06:01.265 --> 00:06:05.385
A procedural description assigns to a
variable through its procedure.

80
00:06:05.945 --> 00:06:10.205
Keep the declaration and its driver
together when reading the design.

81
00:06:10.205 --> 00:06:15.025
Later lessons will build more elaborate
decision logic on that foundation.

82
00:06:15.590 --> 00:06:20.190
Older Verilog uses reg for variables
assigned by procedures.

83
00:06:21.070 --> 00:06:24.890
In this example, every selection branch
assigns

84
00:06:24.890 --> 00:06:27.890
an output, so the description is
combinational.

85
00:06:28.710 --> 00:06:33.850
The actual synthesis result is an
eight-bit mux with no register cells.

86
00:06:34.830 --> 00:06:38.750
Whether a circuit retains data follows
from its behavior,

87
00:06:39.130 --> 00:06:41.110
not the spelling of its variable type.

88
00:06:41.110 --> 00:06:44.430
Clocked storage will be introduced in
lesson seven.

89
00:06:45.055 --> 00:06:49.235
Four-state simulation can show unknown

90
00:06:49.235 --> 00:06:52.995
and high-impedance states as well as zero
and one.

91
00:06:53.755 --> 00:06:56.755
In this experiment, an uninitialized logic

92
00:06:56.755 --> 00:07:00.855
variable shows X, and an undriven wire
shows Z.

93
00:07:01.495 --> 00:07:05.375
X says the simulator cannot determine a
logic value;

94
00:07:05.795 --> 00:07:08.395
it is not an extra fixed voltage on a
chip.

95
00:07:09.015 --> 00:07:11.975
Z models a high-impedance driver state.

96
00:07:11.975 --> 00:07:17.195
Start debugging by checking
initialization, drivers and connections.

97
00:07:17.750 --> 00:07:22.890
The download interprets all two hundred
and fifty-six eight-bit patterns

98
00:07:22.890 --> 00:07:28.170
and checks truncation for all five hundred
and twelve nine-bit inputs.

99
00:07:29.270 --> 00:07:31.410
The correct widening design passes.

100
00:07:32.430 --> 00:07:36.763
The deliberately unsigned slice fails for
one hundred

101
00:07:36.763 --> 00:07:40.710
and twenty-eight inputs, the half whose
high bit is one.

102
00:07:41.570 --> 00:07:43.750
These are actual simulation results.

103
00:07:43.750 --> 00:07:47.410
The browser inspector explains the
relationships;

104
00:07:48.150 --> 00:07:51.270
rerunning the source checks what the tools
really do.

105
00:07:51.655 --> 00:07:55.335
A useful interface contract records the
signal

106
00:07:55.335 --> 00:07:58.955
name, width, numerical format and driver.

107
00:07:59.775 --> 00:08:04.315
If high bits are discarded, it also says
whether that loss is intentional.

108
00:08:05.375 --> 00:08:09.055
Return to the inspector, toggle the
highest bit

109
00:08:09.355 --> 00:08:12.115
and compare the two readings of the same
pattern.

110
00:08:13.025 --> 00:08:15.695
Then repeat the reasoning with four bits.

111
00:08:15.695 --> 00:08:19.615
The next lesson uses these values in
conditions

112
00:08:19.615 --> 00:08:22.815
so a circuit can decide which data to
accept.

