Also bin ich ein Neuling in Verilog und versuche, einen Zähler mit strukturellen Verilog zu machen. Der Zähler besteht aus 4 D-Flip-Flops.
Die Funktionalität der Flip-Flops wurde verifiziert, so dass das nicht das Problem ist.Structural Verilog Counter Initialisierung
Das Problem, das ich finde, ist, dass zu Beginn der Simulation der Draht l1 (Verknüpfung von d zu q_bar) undefiniert ist.
Dies kann gelöst werden, indem das Flipflop zurückgesetzt wird und q_bar ein definierter Wert zugewiesen wird.
Wenn es jedoch zu FF1 kommt, funktioniert das Zurücksetzen nicht, da es ein synchrones Zurücksetzen ist und es keine steigende Taktflanke gibt, wenn das Zurücksetzen hoch ist.
Also meine Frage ist,
Wie kann ich die Flip-Flops zurückzusetzen, oder noch besser ist es eine Möglichkeit, die Ausgabe des Flip-Flops der Initialisierung?
Dies ist mein Code:
module sr_latch(q, q_bar, r, s);
output q;
output q_bar;
input s;
input r;
nor #1(q_bar, s, q);
nor #1(q, r, q_bar);
endmodule
module d_latch(clk,q,q_bar,d);
output q, q_bar;
input clk,d;
wire d_bar,r,s;
sr_latch A(q, q_bar, r, s);
not (d_bar, d);
and (s, d, clk);
and (r, d_bar, clk);
endmodule
module d_type_ff (clk, d, q, q_bar);
output q, q_bar;
input clk, d;
wire d1, d2, clk_bar;
d_latch Master(clk_bar, d1, d2, d);
d_latch Slave(clk, q, q_bar, d1);
not(clk_bar, clk);
endmodule
module d_type_ff_rst (clk, d, q, q_bar, reset);
output q;
output q_bar;
input clk, d, reset;
wire d_in, rst_bar;
d_type_ff A(clk, d_in, q, q_bar);
not(rst_bar, reset);
and(d_in, rst_bar, d);
endmodule
module counter_S (clk, reset, enable, count);
input clk, reset, enable;
output [3:0] count; //MSB count[3]
//LSB count[0]
wire l1, l2, l3, l4;
d_type_ff_rst FF0 (clk, l1, count[0], l1, reset);
d_type_ff_rst FF1 (l1, l2, count[1], l2, reset);
d_type_ff_rst FF2 (l2, l3, count[2], l3, reset);
d_type_ff_rst FF3 (l3, l4, count[3], l4, reset);
endmodule
Und die Testbank
module counter_tm();
wire [3:0] count;
reg clk, reset, enable;
counter_S DUT(clk, reset, enable, count);
always #10 clk <= ~clk;
initial
begin
clk <= 1'b0;
reset = 1'b1;
enable = 1'b1;
#10
reset = 1'b0;
end
endmodule
Ich habe versucht, aber wenn reset für eine längere Zeit gehalten wird, hält es q_bar niedrig, was bedeutet, dass die Uhr nicht wellig durch, daher gibt es keine steigende Flanke der Uhr für das nächste Flip-Flop auf zurückgesetzt. –