HW3 Tutorial 2015
HW3 Tutorial 2015
Tutorial of HW3
Hung-Chi Kuo
Advisor: Tzi-Dar Chiueh
2015/11/27
Outline
Introduction to Verilog
Module
Value & Number
Data Type
Flow Chart
4bits>>>4circuits
Paper Works
Truth
Table
K-map: Design
each bit of
output
lib.v
Verilog code:
build circuit
Test:
testbench
ncverilog
lib.v
Truth
Table
K-map: Design
each bit of
output
Verilog code:
build circuit
Introduction to Verilog
Module
Value & Number
Data Type
Test:
testbench
ncverilog
C/C++/Matlab
NC-Verilog
Design Vision
(DV)
NC-Verilog
Astro/
SE
Back-End
Cadence
HSPICE/Nanosim
What is Verilog ?
Verilog is a Hardware Description Language
Describe digital electronic system at multiple
levels of abstraction
Model the timing
Express the concurrency of the system operation
Test the system
Levels of Abstraction
System
concept
Algorithm
Increasing
behavioral
abstraction
Behavior Level
Increasing
detailed
realization &
complexity
Transistor Level
7
High
Verilog Syntax
Create an Verilog file *.v
Edit with text editors such as WordPad or Notepad++
Verilog Module
Basic building blocks .
Begin with module, end with endmodule
module <module name> (<port lists>);
//module description
endmodule
Module Ports
Modules communicate through ports
Input port
Output port
module FD2 (Q, D, CLK, RESET);
output
input
Q;
D, CLK, RESET;
endmodule
11
1
one, true, high
Z
high impedance, floating
X
unknown, occurs at un-initialized storage elements or
un-resolvable logic conflicts
12
Radix
b (binary), o (octal), d (decimal), h (hexadecimal)
Default radix is decimal
Value
Any legal number in selected radix
13
// 4-bit binary
// 5-bit decimal
// 12-bit hexadecimal
// 32-bit decimal
underline usage
16b0001_0101_0001_1111
32h12ab_f001
14
Wire Assignment
assign , output port
wire a;
wire b;
assign b = 1b0;
NOT n0(a, b);
18
Net Concatenations
Representation
{b[3:0],c[2:0]}
Meaning
{b[3] ,b[2] ,b[1] ,b[0], c[2] ,c[1] ,c[0]}
{w,w,w,w}
{b,{3{a,b}}}
{b,a,b,a,b,a,b}
Ex.
wire [1:0] a;
wire [1:0] b;
wire [5:0] c;
assign c = {2{a[1]}, a, b}; // c = {a[1],a[1],a[1],a[0],b[1],b[0]}
19
Q;
D, CLK, RESET;
Call by Order
Call by Name
20
Example : Adder
module ADDER (out, in1, in2);
output [2:0] out;
input [1:0] in1, in2;
wire c;
IC
Des
// netlist
and g1(Z,A,B,C);
// specify block, declare local
// timing constant
specify
// delay parameters
specparam Tp_A_Z = 0.275;
specparam Tp_B_Z = 0.275;
specparam Tp_C_Z = 0.275;
// path delay (full connection)
( A *> Z ) = ( Tp_A_Z );
( B *> Z ) = ( Tp_B_Z );
( C *> Z ) = ( Tp_C_Z );
endspecify
endmodule
22
IV
AN3
AN4
AN2
EN
EN3
EO
EO3
FA1
FD1
FD2
// not
//and
// xnor
// xor
// full adder
// DFF
ND2
ND3
ND4
NR2
NR3
OR2
OR3
OR4
HA1
MUX21H
// nand
// nor
// or
// half adder
// 2-to-1 MUX
23
IC
Des
Notification of HW3!!
In this HW, all the logic operation MUST consist
of standard cell (defined in lib.v). You can NOT
use logic operators(&,|,^,~) or arithmetic
operators(+,-,*,/) or behavioral statement(if, else).
24
IC
Des
Notification of HW3!!
Do NOT change any module name and port name
in ADC_EADC.v, just modifiy the module
description, otherwise you cant pass testbench.
Dont Change
25
lib.v
Truth
Table
K-map: Design
each bit of
output
Verilog code:
build circuit
Test:
testbench
ncverilog
*.v
Test
patterns
*.vcd / out.dat
Output
response
27
Testbench
Put input into circuit you design in ADC_EADC.v
Check if the output is the same as golden output
28
NC-Verilog Simulation
Put all files in the same directory on Workstation
ADC_EADC.v, tb_ADC.v, tb_EADC.v, lib.v, in.dat, out.dat
run.f
source /usr/cadence/cshrc
source /usr/spring_soft/CIC/verdi.cshrc
Test ADC
ncverilog tb_ADC.v ADC_EADC.v lib.v +access+r
Test EADC
ncverilog tb_EADC.v ADC_EADC.v lib.v +access+r
29
Errors
30
Execute nWave
nWave &
31
(2)
*.vcd
(3)
(1)
(4)
32
33
Reminder
If theres any workstation account/password
problem, please directly contact workstation
administrator
- [email protected]
34