Académique Documents
Professionnel Documents
Culture Documents
based on textbook
Contemporary Logic Design, 2nd Edition
by R. H. Katz and G. Borriello
COMMONWEALTH OF AUSTRALIA
Copyright Regulations 1969
WARNING
This material has been reproduced and communicated to you by or on behalf of
Monash University pursuant to Part VB of the Copyright Act 1968 (the Act).
The material in this communication may be subject to copyright under the Act. Any
further reproduction or communication of this material by you may be the subject of
copyright protection under the Act.
Do not remove this notice.
Behavioral/functional description
Simulation semantics
HDLs
Verilog
Behavioral
out
Structural model
a
out
b
module xor_gate (out, a, b);
input
a, b;
output
out;
wire
abar, bbar, t1, t2;
inverter
inverter
and_gate
and_gate
or_gate
endmodule
always block:
module xor_gate
input
output
reg
out
b
(out, a, b);
a, b;
out;
out;
module xor_gate
input
output
reg
(out, a, b);
a, b;
out;
out;
assign #6 out = a ^ b;
endmodule
2-bit vector
assign x = cnt[1];
assign y = cnt[0];
endmodule
III - Working with
Combinational Logic
directive to stop
simulation
Complete simulation
test-bench
x
y
10
Comparator example
11
(n0, n1, n2, n3, n4, n5, n6, n7, self, out);
n0, n1, n2, n3, n4, n5, n6, n7, self;
out;
out;
neighbors;
count;
i;
assign neighbors = {n7, n6, n5, n4, n3, n2, n1, n0};
always @(neighbors or self) begin
count = 0;
for (i = 0; i < 8; i = i+1) count = count + neighbors[i];
out = (count == 3);
out = out | ((self == 1) & (count == 2));
end
endmodule
III - Working with
Combinational Logic
12
Program structure
Assignment
Data structures
Parallelism
13
14
15