0% found this document useful (0 votes)
14 views11 pages

Lab 5 VXL

The document provides a detailed guide on designing various types of flip-flops and latches using SystemVerilog, including D flip-flops, resettable flip-flops, and JK flip-flops. It includes truth tables, code examples using always_ff and always_latch statements, and simulation instructions for testing on the STEP MAX10 board. Additionally, it covers common programming constructs like loops and conditional statements used in the design process.

Uploaded by

QV C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

Lab 5 VXL

The document provides a detailed guide on designing various types of flip-flops and latches using SystemVerilog, including D flip-flops, resettable flip-flops, and JK flip-flops. It includes truth tables, code examples using always_ff and always_latch statements, and simulation instructions for testing on the STEP MAX10 board. Additionally, it covers common programming constructs like loops and conditional statements used in the design process.

Uploaded by

QV C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Lab 5: Design sequential

circuit
D flipflop
D flipflop truth table

clk d q

1 1

0 0

other values x previous value

- Design D flip flop using always_ff and non-blocking assignment.


- Using always_ff statement to model the behavior of sequential logic elements such as flip-flops,
registers,…..
- It ensures that the enclosed code block is executed only when there is a change on the clock signa
Ex: always_ff @(posedge clock) begin
// Your sequential logic here
end
- Using non-blocking assignment.
D- flipflop
d_flipflop.sv d_flipflop_tb.sv
module d_flipflop(input logic clk, d, module d_flipflop_tb();
output logic q);
always_ff@(posedge clk) logic clk, d, q;
begin d_flipflop dut(clk, d, q);
q <= d;
end //Clock signal generation
always begin
clk = ~ clk; #5;
endmodule end

initial begin
clk = 0;
d = 0;

for (int i = 0; i < 20; i++)


begin
d = ~ d; #3;
end

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

other values x x previous value


Resettable enable flipflop
Ex2: Design an resettable enable flipflop having following truth table using in SystemVerilog,
simulate on ModelSim and test on STEP MAX10 board.

clk reset enable d q

1 x x 0

0 1 1 1

0 1 0 0

0 0 x previous value

other values x x x previous value


JK flipflop
Ex3: Design an JK flipflop having following truth table using in SystemVerilog, simulate on
ModelSim and test on STEP MAX10 board.
D latch
Ex4: Design an JK flipflop having following truth table using in SystemVerilog, simulate on
ModelSim and test on STEP MAX10 board.

clk d q

1 1 1

1 0 0

0 x previous value

Using always_latch statement, which is used for design a latch in SystemVerilog


always_latch is equivalent to always@(clk, d).
always_latch always@(clk, d)
begin begin
//your code here //your code here
end end

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy