Lecture 1: Introduction: Ucsd Ece 111 Prof. Bill Lin Winter 2019
Lecture 1: Introduction: Ucsd Ece 111 Prof. Bill Lin Winter 2019
• Lectures:
– Section A00: MW 2:00-3:20p, EBU1-2315
– Section B00: MW 3:30p-4:50p, EBU1-2315
• Teaching Assistants:
– Jianling Liu Justin Law, Dylan Vizcarra, Yu Huang
and Ping Yin
– Office hours: TBD
– Note: You may get help from any TA during their
office hours.
2
Course Information
• Course webpage
http://cwcserv.ucsd.edu/~billlin/classes/ECE111/index.php
http://www.ece.ucsd.edu/courses
http://piazza.com/ucsd/winter2019/ece111
3
Course Information
• Course webpage
http://cwcserv.ucsd.edu/~billlin/classes/ECE111/index.php
http://www.ece.ucsd.edu/courses
• Lectures:
– Section A00: MW 2:00-3:20p, EBU1-2315
– Section B00: MW 3:30p-4:50p, EBU1-2315
4
Introduction
• Goal: Learn Verilog-based chip design
5
Why Learn Verilog/SystemVerilog
• Most EE jobs are Verilog/SystemVerilog based chip designs
ASIC
Design
FPGA
Design
6
Why Learn Verilog/SystemVerilog
• Example modern Systems-on-Chip (SoC)
Qualcomm Snapdragon 845 Mobile Processor
7
Why Learn Verilog/SystemVerilog
• Emergence of the FPGA Cloud
Example: Microsoft’s Catapult Project deployed worldwide
10
FPGA Cloud Applications
• Bing search engine implemented in
Microsoft’s FPGA cloud
• Machine learning/AI
11
Class Project
• Final project on Bitcoin mining
• Great deal of interest in cryptocurrencies
12
Class Project
• Blockchain is the underlying technology for
cryptocurrencies, which provides authenticated
global ledger (tamper-proof global transaction
record)
13
Class Project
• Bitcoin mining “target” = 00xxxx…xxx
32
“nounce”
512 256
SHA256 < found?
+
“msg” “hash”
“block”
512
• Every “msg” will produce different 256-bit hash. Changing
“nounce” will change “msg” and produce different 256-bit hash.
17
More Information
• Recommended textbook
– Digital Design and Computer Architecture,
Second Edition, by David Harris and Sarah
Harris
– We will only be using Chapter 4 of this
book, which provides a good overview of
SystemVerilog with good examples.
– Make sure you get the 2nd Edition since the
1st Edition uses Verilog instead of
SystemVerilog
– Book recommended, but not required.
18
Honor Code
• The UCSD Student Conduct Code
https://
students.ucsd.edu/sponsor/student-conduct/
regulations/22.00.html
19
Let’s Get Started with
SystemVerilog
Synthesis vs. Simulation
• Extremely important to understand that
SystemVerilog is BOTH a “Synthesis” language and a
“Simulation” language
– Small subset of the language is “synthesizable”,
meaning that it can be translated to logic gates and
flip-flops.
– SystemVerilog also includes many features for
“simulation” or “verification”, features that have no
meaning in hardware!
Module Abstraction:
a
Verilog
b y
Module
c
Slide derived from slides by Harris & Harris from their book 22
HDL Synthesis
SystemVerilog:
module example(input logic a, b, c,
output logic y);
assign y = ~a & ~b & ~c | a & ~b & ~c | a & ~b & c;
endmodule
un8_y
Slide derived from slides by Harris & Harris from their book 23
SystemVerilog Syntax
• Case sensitive
– Example: reset and Reset are not the same signal.
• No names that start with numbers
– Example: 2mux is an invalid name
• Whitespace ignored
• Comments:
– // single line comment
– /* multiline
comment */
Slide derived from slides by Harris & Harris from their book 24
Structural Modeling - Hierarchy
module and3(input logic a, b, c,
output logic y);
assign y = a & b & c;
endmodule
Slide derived from slides by Harris & Harris from their book 25
Bitwise Operators
module gates(input logic [3:0] a, b,
output logic [3:0] y1, y2, y3, y4, y5);
/* Five different two-input logic
gates acting on 4 bit busses */
assign y1 = a & b; // AND
assign y2 = a | b; // OR
assign y3 = a ^ b; // XOR
assign y4 = ~(a & b); // NAND
assign y5 = ~(a | b); // NOR
endmodule
Slide derived from slides by Harris & Harris from their book 26
Reduction Operators
module and8(input logic [7:0] a,
output logic y);
assign y = &a;
// &a is much easier to write than
// assign y = a[7] & a[6] & a[5] & a[4] &
// a[3] & a[2] & a[1] & a[0];
endmodule
Slide derived from slides by Harris & Harris from their book 27
Conditional Assignment
module mux2(input logic [3:0] d0, d1,
input logic s,
output logic [3:0] y);
assign y = s ? d1 : d0;
endmodule
Slide derived from slides by Harris & Harris from their book 28
Precedence
Order of operations
Highest ~ NOT
*, /, % mult, div, mod
+, - add,sub
<<, >> shift
<<<, >>> arithmetic shift
<, <=, >, >= comparison
==, != equal, not equal
&, ~& AND, NAND
^, ~^ XOR, XNOR
|, ~| OR, NOR
Lowest ?: ternary operator
Slide derived from slides by Harris & Harris from their book 29