Reputation: 331
I'm writing a simple D-flip-flop in Verilog and looking at what it synthesizes to. Here's what I have:
module d_flip_flop(
input d,
input clr,
input clk,
input ce,
output reg q
);
always @(posedge clk) begin: d_flip_flop
if (clr) begin
q <= 1'b0;
end else if (ce) begin
q <= d;
end
end
endmodule
However, making this change to the code and adding CE to the sensitivity list:
module d_flip_flop(
input d,
input clr,
input clk,
input ce,
output reg q
);
always @(posedge clk or posedge ce) begin: d_flip_flop
if (clr) begin
q <= 1'b0;
end else if (ce) begin
q <= d;
end
end
endmodule
What is going on? Why would adding CE to the sensitivity list make this synthesize to a buffer?
Thanks!
Upvotes: 1
Views: 570
Reputation: 911
You're probably confusing the synthesis tool with that construct because it's not a normal thing to do. (There's nothing in the FPGA that directly supports that and I doubt it's even synthesizable at all.)
On the other hand, if you changed ce
to clr
in the sensitivity list, you should get a register with clr
as an asynchronous reset, as that's the normal way to code that up for Xilinx.
I tried synthesizing it with Vivado and got a strange warning that didn't make sense. It's probably close enough to an async reset template that it doesn't directly error out, but ultimately not synthesizable so ends up with the output connected to GND
.
Upvotes: 3