Unit 1 - LP5
Unit 1 - LP5
Unit 1 - LP5
1 2 3 4
nmos, pmos
assign and,or etc.. always Intermediate
Equation Gate level Diagram
Algorithm signal
Types of Modelling
Dataflow D Gate G
Level
Behaviour B
Level
Switch S
Level
Level
Usage :
and (out, i1,i2);
nand (out, i1,i2);
or (out, i1,i2);
nor (out, i1,i2);
xor (out, i1,i2);
xnor (out, i1,i2);
Example Full Adder Using Half Adder
Top Module Sub Module
module fulladder (s, cout,a,b,cin); module halfadder (sum, carry, in0, in1);
output cout,s; output sum, carry;
input a,b,cin ; input in0, in1;
halfadder ha1(s1,c1,a,b); // 2-input XOR gate.
halfadder ha2(s,c2,s1,cin); xor x1 (sum, in0, in1);
or o1(cout,c1,c2); // 2-input AND gate.
endmodule and x2 (carry, in0, in1);
endmodule
c1
s1 c2 Full Adder
What is the Designer want ?
Algorithm
Input & Output Relation
Don't Require Hardware details
Control Statements – If & Case
Syntax similar to C language
Making decisions based upon certain conditions
Conditions are used to decide statement execution
Keyword : if and else
Multiway Branching – Switch Case
Too many alternatives exist
Keyword : case, endcase and default
Conditional Statement (if, else if, else)
if Statement
Syntax:
if (condition) Example:
if (Clk)
Q = 0;
procedural_statemen else
t Q = D;
else if (condition)
Coding Section Example : 2:1 MUX
module mux_2x1(a, b, sel, out); Behaviour of MUX:
input a, b, s;
output out;
reg out;
always @(a or b or s)
begin Sensitivity List
if (s == 1)
out = a;
else out = b;
end
endmodule
Coding Section Example : 4:1 MUX using Case
module MUX (C, D, E, F, S, MUX_OUT); Behaviour of MUX:
input C, D, E, F;
input [1:0] S;
output MUX_OUT;
reg MUX_OUT;
always @(C or D or E or F or S)
begin
case (S)
2'b00 : MUX_OUT = C;
2'b01 : MUX_OUT = D;
2'b10 : MUX_OUT = E;
default : MUX_OUT = F;
endcase
end
endmodule
Mind Map
Thank You!