Lab 5 VXL
Lab 5 VXL
circuit
D flipflop
D flipflop truth table
clk d q
1 1
0 0
initial begin
clk = 0;
d = 0;
end
endmodule
D- flipflop simulation result
Test D-flipflop on STEP-MAX10
board
d_flipflop.sv clock_devider.sv top_module.sv
module d_flipflop(input logic clk, module clock_divider ( module top_module (
d, input logic clk_in, // 12 input logic clk_12mhz, // 12
output logic q); MHz input clock MHz input clock
always_ff@(posedge clk) output logic clk_out // 1 Hz input logic d, // D
begin output clock input for D flip-flop
q <= d; ); output logic q // Q
end output of D flip-flop
logic [23:0] counter = 24'd0; // );
24-bit counter
// 1 Hz clock signal
endmodule always_ff @(posedge clk_in) begin logic clk_1hz;
if (counter == 24'd6000000)
begin // Instantiate clock divider
counter <= 24'd0; clock_divider
clk_out <= ~clk_out; // clock_divider_instance (clk_12mhz,
Toggle output clock clk_1hz);
end
else // Instantiate D flip-flop
counter <= counter + 1; d_flipflop d_flipflop_instance
end (clk_1hz, d, q);
endmodule endmodule
Pin assignment
Common used statement
for case
for (initialization; condition; increment) begin case (expression)
// Loop body value1: begin
end // Code for when expression matches value1
end
value2: begin
// Code for when expression matches value2
end
// More value cases...
default: begin
// Code for when no value case matches the
expression
end
endcase
if – else while
if (condition) begin while (condition) begin
// Statements to execute when the condition is true // Statements to execute while the condition is
end true
else begin end
// Statements to execute when the condition is false
end
Resettable flipflop
Ex1: Design an resettable flipflop having following truth table using in SystemVerilog and simulate
on ModelSim and test on STEP MAX10 board.
clk reset d q
1 x 0
0 1 1
0 0 0
1 x x 0
0 1 1 1
0 1 0 0
0 0 x previous value
clk d q
1 1 1
1 0 0
0 x previous value