With FPGA I absolutely will design in verilog—no reason to do it in schematics.
Bill
Code: Select all
module Bug
(
output reg signal,
input wire CLK
);
reg currentState;
reg signalChangePending;
always @(posedge CLK) begin
if (signalChangePending) begin
signal <= ~signal;
signalChangePending <= 0;
end
end
always @(negedge CLK) begin
if (currentState == 1) begin
signalChangePending <= 1;
currentState <= 0;
end
else begin
currentState <= 1;
end
end
endmodule
// Pin assignment for the experimental Yosys FLoow
//
//PIN: CHIP "Bug" ASSIGNED TO AN PLCC84
//PIN: signal : 74
//PIN: CLK : 83Code: Select all
Checking module Bug...
Warning: multiple conflicting drivers for Bug.\signalChangePending:
port Q[0] of cell $procdff$16 ($dff)
port Q[0] of cell $procdff$18 ($dff)
Found and reported 1 problems.
Code: Select all
module Bug
(
output reg signal,
input wire CLK
);
reg currentState = 0;
reg signalChangePending = 0;
always @(posedge CLK) begin
if (signalChangePending) begin
signal <= ~signal;
end
end
always @(negedge CLK) begin
if (signalChangePending) begin
signalChangePending <= 0;
end
else if (currentState == 1) begin
signalChangePending <= 1;
currentState <= 0;
end
else begin
currentState <= 1;
end
end
endmodule
// Pin assignment for the experimental Yosys FLoow
//
//PIN: CHIP "Bug" ASSIGNED TO AN PLCC84
//PIN: signal : 74
//PIN: CLK : 83