IEEE ASUSB Session 1
IEEE ASUSB Session 1
Sign off
Sign off
Even after the circuit has been designed and implemented, FPGAs
can still be modified, updated, and completely change its
functionality to perform a completely different task than before which
make it different from ASIC design.
FPGA
Introduction to FPGA
• LE ( Logic Elements ) :
• the basic repeating logic resource on an FPGA
A0
• Ex : Two input AND gate A1
A1 A0 F 0
0 0 0 0
F
0 1 0
0
1 0 0
1
1 1 1
FPGA
What is Verilog ?
Verilog
Hint : MUX function is to choose between two inputs using selection line.
\
• “X” is used by the simulators when the wires are not initialized to known value like 1 or 0
Verilog Basics
Operators
~a NOT
Bitwise operators: a&b AND
• Performs bit by bit evaluation between two operands a|b OR
• 2’b01 & 2’b11 = {0&1,1&1} a^ b XOR
• !(2’b01) = 0 a || b OR
a == b If X or Z in bits returns
• “==” tests logical equality for ‘1’ and ‘0’ only all other will result in ‘X’ a != b X
• “===” tests 4-state logical equality (1,0,Z,X)
a === b Return 0 or 1 only
a !== b based on bit-by-bit
comparison
Verilog Basics
Operators &a AND
~&a NAND
Arithmetic operators :
• To perform arithmetic operation (- , + , * , / , %)
Arithmetic shift Logical shift
>>> , <<< >> , <<
Shift operators:
• Shift the first operand by the number specified by the second operand 3’b110 >>> 1 = 3’b111 3’b110 >> 1 = 3’b011
Relational operators:
• to compare between two operands
( == , != , < , > , <= , >= )
Verilog Basics
Verilog Essentials for
Combinational Logic
Design
Module
• Module is the basic block in Verilog consist of :
Port list
Find the
Error
Keyword endmodule
Verilog Basics
Wires
• Wire represent a real and physical wire inside the module
• By default wires are 1-bit size and all inputs and outputs are wires
• We don’t declare the wires in port list as they are internal signals
Verilog Basics
Modeling styles
• Gate-level modeling
• The module is implemented using the built-in logic gates and the interconnection
between them
Verilog Basics
Modeling styles
• Data flow modeling
• Designer must know how the data flow within the design
• endmodule
Verilog Basics
Modeling styles
• Structural modeling
• The same as gate level modeling but doesn’t use built-in logic gates
• It include declaration and instantiation previously defined.
We need to instantiate the previous full adder to make 4-bit adder
um
module four_bit- adder (input [3:0] A , B , input cin , output [3:0]S , output Cout); // declaration of top module
• full_adder DUT (C,A,B) ;
• endmodule
Verilog Basics
Modeling styles
• Structural modeling
module full_adder (input in1, in2, Cin, output Cout,S);
• assign {Cout,S} = in1+in2+Cin;
• endmodule
um
module add_4bit (input [3:0] A , B ,input Cin , output [3:0]S , output Cout );
• wire C1 , C2 , C3 ;
• full_adder add1(.in1(A[0]) , .in2(B[0]) , .Cin (Cin) , .Cout(C1) , .S(S[0]));
• full_adder add2 (.in1(A[1]) , .in2(B[1]) , .Cin (C1) , .Cout(C2) , .S(S[1]));
• full_adder add3 (.in1(A[2]) , .in2(B[2]) , .Cin (C2) , .Cout(C3) , .S(S[2]));
• full_adder add4 (.in1(A[3]) , .in2(B[3]) , .Cin (C3) , .Cout(Cout) , .S(S[3]));
• endmodule Verilog Basics
Modeling styles
• module mux2 (input A, B, switch, output out); Quiz
• wire S1, S2, S3;
• and (S1 ,A, switch);
• nor (S2 ,switch);
• and (S3 ,S2,B);
• or (out ,S1 , S3);
• endmodule um