Complete the code to declare a gated clock signal named clk_gated.
wire clk_gated = [1] & enable;The gated clock is generated by ANDing the original clock clk with the enable signal.
Complete the code to instantiate a latch for clock gating control.
always @([1] or enable) begin if (!enable) latch_out <= 0; else latch_out <= 1; end
The latch is controlled on the negative edge of the clock to hold the enable signal stable for gating.
Fix the error in the clock gating module declaration.
module clock_gating(
input wire clk,
input wire enable,
output wire [1]
);The output clock signal is commonly named gated_clk to clearly indicate it is the gated version of the clock.
Fill both blanks to complete the clock gating logic with latch and gated clock output.
reg latch_out; always @([1] or enable) begin if (!enable) latch_out <= 0; else latch_out <= 1; end assign [2] = clk & latch_out;
The latch triggers on the negative edge of the clock, and the gated clock output is assigned by ANDing the clock with the latch output.
Fill all three blanks to complete a clock gating module with input clock, enable, and gated clock output.
module clock_gating( input wire [1], input wire [2], output wire [3] ); reg latch_out; always @(negedge [1] or [2]) begin if (![2]) latch_out <= 0; else latch_out <= 1; end assign [3] = [1] & latch_out; endmodule
The module inputs are the clock clk and enable signal enable. The output is the gated clock clk_gated.
