VERILOG: Synthesis - Combinational Logic Combination Logic Function Can Be Expressed As
VERILOG: Synthesis - Combinational Logic Combination Logic Function Can Be Expressed As
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 Synthesizable combinational can have following styles
Netlist of gate instances and Verilog primitives (Fully structural) Combinational UDP (Some tools) Functions
Continuous Assignments
Behavioral statements Tasks without event or delay control Interconnected modules of the above
Synthesis of Combinational Logic Gate Netlist Synthesis tools further optimize a gate netlist specified in terms of Verilog primitives Example:
module or_nand_1 (enable, x1, x2, x3, x4, y); input enable, x1, x2, x3, x4; output y; wire w1, w2, w3; or (w1, x1, x2); or (w2, x3, x4); or (w3, x3, x4); // redundant nand (y, w1, w2, w3, enable); endmodule
Note: Inputs to the behavior must be included in the event control expression, otherwise a latch will be inferred.
task or_nand; input enable, x1, x2, x3, x4; output y; begin y = !(enable & (x1 | x2) & (x3 | x4)); end endtask endmodule
wait statements
External disable statements Procedural loops with timing Data dependent loops Tasks with timing controls Sequential UDPs
sel[1:0]
sel[1:0]
sel[1:0]
Note: CASE statement and if/else statements are more preferred and recommended styles for inferring MUX
Unwanted Latches Unintentional latches generally result from incomplete case statement or conditional branch Example: case statement
always @ (sel_a or sel_b or data_a or data_b) case ({sel_a, sel_b}) 2'b10: y_out = data_a; 2'b01: y_out = data_b; endcase
The latch is enabled by the "event or" of the cases under which assignment is explicitly made. e.g. ({sel_a, sel_b} == 2'b10) or ({sel_a, sel_b} == 2'b01)
Priority Logic
When the branching of a conditional (if) is not mutually exclusive, or when the branches of a case statement are not mutually exclusive, the synthesis tool will create a priority structure. Example:
module mux_4pri (y, a, b, c, d, sel_a, sel_b, sel_c); input a, b, c, d, sel_a, sel_b, sel_c; output y; reg y; always @ (sel_a or sel_b or sel_c or a or b or c or d) begin if (sel_a == 1) y = a; else if (sel_b == 0) y = b; else if (sel_c == 1) y = c; else y = d; end endmodule
Registered Combinational Logic Combinational logic that is included in a synchronous behavior will be synthesized with registered output. Example:
module mux_reg (a, b, c, d, y, select, clock); input [7:0] a, b, c, d; output [7:0] y; input [1:0] select; reg [7:0] y; always @ (posedge clock) case (select) 0: y <= a; // non-blocking 1: y <= b; // same result with = 2: y <= c; 3: y <= d; default y <= 8'bx; endcase endmodule
Synthesis Result
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