Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| learn:software:tutorials:verilog-project-1:start [2022/09/12 15:38] – changed forum.digilentinc.com to forum.digilent.com jeff.greenberg_ni.com | learn:software:tutorials:verilog-project-1:start [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | [[learn/ | ||
| + | ====== Verilog® HDL: Project 1 ====== | ||
| + | ===== Learning relevant keywords and concepts ===== | ||
| + | |||
| + | ===== Project Overview ===== | ||
| + | The goal of this project is to learn about the components inside of a Verilog project (but not program an FPGA quite yet, that's the next project). If you have not already installed Vivado, you can find a guide to do so [[learn/ | ||
| + | |||
| + | A list of the all of the Verilog projects can be found [[learn/ | ||
| + | |||
| + | //Remember that we won't be adding any files or creating a bitstream for this first project; that' | ||
| + | |||
| + | ===== What is a Verilog® Module? ===== | ||
| + | A Verilog® module of a circuit encapsulates a description of its functionality as a structural or behavioral view of its input-output relationship. A structural view could be as simple as a netlist of gates or as complex as a high level architectural partition of the circuit into major functional blocks, such as an arithmetic and logic unit (ALU). A behavioral view could be a simple Boolean equation model, a register transfer level (RTL), or an algorithm. This tutorial will look at the basics of a Verilog file. | ||
| + | |||
| + | ===== A Simple Example ===== | ||
| + | The general format for a Verilog® circuit is shown in the code in the picture below. Major keywords have been shown in blue, comments in green, Verilog requirements in pick, and key text strings the user must supply are shown in bolded italics. We will then go through each of the lines in detail to learn about what they do. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ==== Timescale ==== | ||
| + | This timescale is required for all Verilog projects to synthesize correctly. If you had multiple types of delays, multiple timescales may be listed. | ||
| + | |||
| + | ==== Module ==== | ||
| + | In a schematic capture environment, | ||
| + | |||
| + | The module block (as shown in the image) gives the circuit a name (" | ||
| + | |||
| + | In terms of syntax, the inputs and outputs of the named module are enclosed by a set of parenthesis '' | ||
| + | < | ||
| + | module inputOutput( | ||
| + | input inputExample, | ||
| + | output outputExample, | ||
| + | input [2:0] 3inputs, | ||
| + | output [7:0] 7outputs | ||
| + | ); | ||
| + | endmodule | ||
| + | </ | ||
| + | If a set of inputs/ | ||
| + | |||
| + | ==== Input, Output, and Bus ==== | ||
| + | Whenever you are writing a Verilog module, the first thing to do is to define the input and output signals. In the example in Fig. 1, there is one input signal “sw” coming from the onboard switch SW0, and one output signal “led” connected to LED0. How did we choose the names " | ||
| + | They came from the [[programmable-logic: | ||
| + | |||
| + | Note, however, that input and output can be a group of wires as well. We call these groupings a bus. To declare the input or output as a bus, we need to provide the CAD tools with the index of the most significant bit (MSB) of the bus and the index of the least significant bit (LSB) of the bus. For example, the following code defines an 8-bit wide bus “sw”, where the left-most bit (MSB) has the index 7 and the right-most bit (LSB) has the index 0, with a colon '':'' | ||
| + | |||
| + | < | ||
| + | |||
| + | Indexing a bus in Verilog is similar to indexing an array in the C language. For example, if we want to index the second bit of sw bus declared above, we will use sw[1]. No semicolon is used while listing the various inputs and outputs that are used. | ||
| + | |||
| + | ==== Assign ==== | ||
| + | The '' | ||
| + | |||
| + | An '' | ||
| + | |||
| + | < | ||
| + | module led_sw( | ||
| + | output [7:0] led, | ||
| + | input [7:0] sw | ||
| + | ); | ||
| + | assign led[3] = sw[1]; | ||
| + | ... | ||
| + | endmodule | ||
| + | </ | ||
| + | |||
| + | At the end of each assign statement (can be more than one line long), a semicolon '';'' | ||
| + | ==== Constants ==== | ||
| + | You can also assign a constant number to a signal or a bus to tie them to either logic ' | ||
| + | |||
| + | <Width in bits>'< | ||
| + | |||
| + | Some examples: | ||
| + | |||
| + | ^ Constant in Verilog | ||
| + | | 12' | ||
| + | | 20' | ||
| + | | 4' | ||
| + | |||
| + | |||
| + | ===== Important Takeaways from Project 1 ===== | ||
| + | * Module in Verilog HDL acts like the bounding box in circuit schematic. | ||
| + | * Bus is a group of signals (wires). | ||
| + | * Assign statement passes the value of a signal/bus to another signal/bus. | ||
| + | * Constant in Verilog HDL is presented in form of <Width in bits>'< | ||
| + | * A desire to check out [[learn/ | ||
| + | |||
| + | |||
| + | tags to be added via the tag> and double curly braces around everything\\ | ||
| + | learn programmable-logic software tutorial vivado | ||

