Dff
Create a single D flip-flop.
module top_module (
input clk, // Clocks are used in sequential circuits
input d,
output reg q );//
always @(posedge clk)
q <= d;
// Use a clocked always block
// copy d to q at every positive edge of clk
// Clocked always blocks should use non-blocking assignments
endmodule
Dff8
Create 8 D flip-flops. All DFFs should be triggered by the positive edge of clk.
module top_module (
input clk,
input [7:0] d,
output [7:0] q
);
always @(posedge clk)
q <= d;
endmodule
Dff8r
Create 8 D flip-flops with active high synchronous reset. All DFFs should be triggered by the positive edge of clk.
module top_module (
input clk,
input reset, // Synchronous reset
input [7:0] d,
output [7:0] q
);
always @(posedge clk)begin
if(!reset)
q <= d;
else
q <= 0;
end
endmodule
Dff8p
Create 8 D flip-flops with active high synchronous reset. The flip-flops must be reset to 0x34 rather than zero. All DFFs should be triggered by the negative edge of clk.
module top_module (
input clk,
input reset,
input [7:0] d,
output [7:0] q
);
always @(negedge clk)begin
if(!reset)
q <= d;
else
q <= 8'h34;
end
endmodule