Académique Documents
Professionnel Documents
Culture Documents
Programmable Logic
Teaching Scheme
out = b;
end sel
sel_b
sel
sel_n
out
sel_a
a
Design at Different Level:
Structural
Structural: Logic is described in
terms of Verilog gate primitives
Example: b
not n1(sel_n, sel); sel n1
a1
sel_b
sel_n
and a1(sel_b, b, sel_b); o1 out
a
and a2(sel_a, a, sel); a2 sel_a
output [3:0] q;
input clk, reset;
//4 instances of the module TFF are
created.
TFF tff0(q[0],clk, reset);
TFF tff1(q[1],q[0], reset);
TFF tff2(q[2],q[1], reset);
TFF tff3(q[3],q[2], reset);
endmodule
T flip-flop
module TFF(q,clk,reset);
output q;
input clk, reset;
wire d;
DFF dff0(q,d,clk,reset);
not n1(d, q); // not is a Verilog provided primitive.
endmodule
D flip-flop
// module DFF with asynchronous reset
module DFF(q, d, clk, reset);
output q;
input d, clk, reset;
reg q;
endmodule
Exercise (Half Adder)
module HalfAdder(A,B,Sum,Carry);
input A,B;
output Sum,Carry;
assign Sum = A ^ B;
//^ denotes XOR
endmodule
Lexical Conventions
Number Specifications
<Size><Base format><Number>
Comments
// Single line comment
/* Another single line comment */
/* Begins multi-line (block) comment
All text within is ignored
Line below ends multi-line comment
*/ This is an illegal comment
/* end with this is also illegal
Data Types
Value set
Verilog supports 4 values and 8
strengths to model the functionality of
real hardware
Value Level Condition in Hardware Circuits
wire [3:0] a;
a 0011
<module internals>
endmodule
Connecting Port to
external Signal
Connecting Ports by name