Basic Syntax of FPGA

Input and Output Signals

The input signals of the input module, such as input rst.

The output signals of the output module, such as output en.

The bidirectional signals of the inout module.

Signal Types

wire signal, generally used in assign statements.

reg register, generally used in always blocks.

Module Structure

The content of each module is embedded between the module and endmodule statements. A module consists of two parts: one part describes the interface, and the other part describes the logical functionality.

module block (
    // Input interface
    input wire a,
    input wire b,
    // Output interface
    output wire c
 );

 // Logical functionality
 assign c = a & b ;

endmodule

Data Types and Their Constants, Variables

(1) Common data types include: reg type, wire type, integer type, parameter type.

(2) Constants

(3) Parameter (Parameter) type

parameter param_name1 = expression, param_name2 = expression, …, param_name_n = expression;

localparam param_name1 = expression, param_name2 = expression, …, param_name_n = expression;

(4) Variables

reg type defined as: reg [n-1:0] data_name1, data_name2, … data_name_i;

memory type defined: reg [n-1:0] memory_name[m-1:0]; indicates creating m registers of n-bit width.

(5) Operators and Expressions

1) Arithmetic operators (+, −, ×, /, %)

2) Assignment operators (=, <=)

3) Relational operators (>, <, >=, <=)

4) Logical operators (&&, ||, !)

5) Conditional operator (?:)

6) Bitwise operators (~, |, ^, &, ^~)

7) Shift operators (<<, >>)

8) Concatenation operator ({ })

Assignment Statements

(1) Non-blocking assignment, such as b <= a;

(2) Blocking assignment, such as b = a

Block Statements

Commonly, begin indicates the start, and end indicates the end

Conditional Statements

(1) if_else statements, which have priority.

A. if (expression) statement

B. if (expression) statement1

else statement2

C. if (expression1) statement1;

else if (expression2) statement2;

else if (expression3) statement3;

Loop Statements

(1) forever statement

forever begin multiple statements end

(2) repeat statement

repeat (expression) begin multiple statements end

Summary

This article mainly shares some introductory knowledge about FPGA. FPGA stands for Field Programmable Gate Array, which is a type of digital integrated circuit chip. FPGA is one of the physical implementations of digital circuits. Compared to another important implementation method of digital circuits, ASIC (Application Specific Integrated Circuit), a key feature of FPGA is its programmability, allowing users to specify the FPGA to implement a specific digital circuit through programming.

Leave a Comment