Pre-Lab2 Digital Design
Pre-Lab2 Digital Design
OBJECTIVES
➢ Getting to know how to describe finite state machine (FSM) using variety styles of System
Verilog code (logic expressions/ behavioral expressions/ shift registers).
➢ Design and implement digital circuits using FSM.
➢ Download the circuit into the FPGA chip and test its functionality.
REFERENCE
1. Intel FPGA training
Figure 1: A state diagram for the FSM Table 1: One-hot codes for the FSM
Instruction:
1. Write System Verilog assignment statements for all flip-flops of the FSM
2. Based on above statements, implement the circuit using flip-flops and logic gates.
Requirement: The state table of a FSM is also described by using a System Verilog CASE
statement in a ALWAYS block and use another ALWAYS block to instantiate the state flip-flops.
The output z can be specified by using a third ALWAYS block or simple assignment statements.
Instruction:
Below is a suggested skeleton of the VHDL code. Write VHDL code which describe the FSM in
exercise 1, which has state code shown in table 2. always_ff
module …( …
/* input and output declaration*/
);
//state declaration and assignment
typedef enum { A,B,C,D,E,F,G,H,I } statecode_;
// or enum bit [3:0] {A=4'b0000, B=4'b0001, …} statecode;
case ( state )
A : if ( w ) next = F ;
else next = B;
B:
…;
.
.
.
endcase
end
. . . assignments for output z and the LEDs
endmodule
Check: Your report has to show VHDL description for the FSM.
Instruction:
Requirement: Write a System Verilog program which create an enable signal that is asserted once
every second.
Instruction:
Requirement: The Morse code uses patterns of short and long pulses to represent a message. Each
letter is represented as a sequence of dots (a short pulse), and dashes (a long pulse). For example,
the first eight letters of the alphabet have the following representation:
A•—
B—•••
C—•—•
D—••
E•
F••—•
G——•
H••••
Design and implement a Morse-code encoder circuit using an FSM.
Instruction:
- When KEY1 is pressed, the system begins to store the Morse code to be sent in a shift register
(data = Morse_code), and its length in a counter (size = Morse_length). Otherwise, the system is
idle. (notes: Morse_code and Morse_length depend on SW2-0 value.)
- After loading data and size, the system starts to send LSB bit of data:
If data(0) = 1, a LEDG will be on for half of a second. After a second, the data is right shifted
and its size decreased by one.
- The process continues to display data on LED using new data and size value until data size equal
1.