Logic - Output (T) F (Logic - Inputs (T) )
Logic - Output (T) F (Logic - Inputs (T) )
Combinational
logic_inputs(t) logic_outputs(t)
Logic
Rules
Avoid technology dependent modeling; i.e. implement
functionality, not timing.
The combinational logic must not have feedback.
Specify the output of a combinational behavior for all
possible cases of its inputs.
Logic that is not combinational will be synthesized as
sequential.
Styles for Synthesizable Combinational Logic
General Steps:
Logic gates are translated to Boolean equations.
The Boolean equations are optimized.
Optimized Boolean equations are covered by library gates.
Complex behavior that is modeled by gates is not mapped
to complex library cells (e.g. adder, multiplier)
The user interface allows gate-level models to be preserved
in synthesis.
Synthesis of Combinational Logic – Continuous Assignments
Example:
module or_nand_2 (enable, x1, x2, x3, x4, y);
input enable, x1, x2, x3, x4;
output y;
assign y = !(enable & (x1 | x2) & (x3 | x4));
endmodule
Synthesis of Combinational Logic – Behavioral Style
Example:
module or_nand_3 (enable, x1, x2, x3, x4, y);
input enable, x1, x2, x3, x4;
output y;
reg y;
always @ (enable or x1 or x2 or x3 or x4)
if (enable)
y = !((x1 | x2) & (x3 | x4));
else
y = 1; // operand is a constant.
endmodule
Example:
module or_nand_4 (enable, x1, x2, x3, x4, y);
input enable, x1, x2, x3, x4;
output y;
assign y = or_nand(enable, x1, x2, x3, x4);
function or_nand;
input enable, x1, x2, x3, x4;
begin
or_nand = ~(enable & (x1 | x2) & (x3 | x4));
end
endfunction
endmodule
Synthesis of Combinational Logic – Tasks
Example:
module or_nand_5 (enable, x1, x2, x3, x4, y);
input enable, x1, x2, x3, x4;
output y;
reg y;
always @ (enable or x1 or x2 or x3 or x4)
or_nand (enable, x1, x2, x3c, x4);
task or_nand;
input enable, x1, x2, x3, x4;
output y;
begin
y = !(enable & (x1 | x2) & (x3 | x4));
end
endtask
endmodule
Construct to Avoid for Combinational Synthesis
Conditional Operator
CASE Statement
module mux_4bits (y, a, b, c, d, sel);
input [3:0] a, b, c, d;
input [1:0] sel
output [3:0] y; a[3:0]
reg [3:0] y;
b[3:0]
always @ (a or b or c or d or sel) y[3:0]
case (sel) c[3:0]
0: y = a; d[3:0]
1: y = b;
2: y = c;
3: y = d;
default: y = 4'bx; sel[1:0]
endcase
endmodule
Synthesis of Multiplexors (cont.)
if .. else Statement
module mux_4bits (y, a, b, c, d, sel);
input [3:0] a, b, c, d;
input [1:0] sel
output [3:0] y; a[3:0]
reg [3:0] y;
b[3:0]
always @ (a or b or c or d or sel) y[3:0]
if (sel == 0) y = a; else c[3:0]
if (sel == 1) y = b; else d[3:0]
if (sel == 2) y = c; else
if (sel == 3) y = d;
else y = 4'bx;
endmodule sel[1:0]
Functional Specs.
Load counter with Data_in when load = 1
Counter counts when counter_on = 1
counts-up when count_up = 1
Counts-down when count_up = 0
Verilog Up/Down Counter (cont.)