|
| 1 | +# Verilog support in CircuitVerse |
| 2 | + |
| 3 | +CircuitVerse together with providing a graphical interface for designing circuits, it also supports Verilog which is a popular hardware description languages which allows the users to simulate hardware and test them. CircuitVerse provides two types of verilog features: |
| 4 | + |
| 5 | + - [Circuit to Verilog code](#Circuit-to-Verilog-code) |
| 6 | + - [Steps to Convert Circuit to Verilog Code](#Steps-to-Convert-Circuit-to-Verilog-Code) |
| 7 | + - [Features and Verilog construct provided by Circuitverse](#Features-and-Verilog-construct-provided-by-Circuitverse) |
| 8 | + - [Example](#Example) |
| 9 | + - [Verilog code to Circuit](verilogtocircuit.md) |
| 10 | + |
| 11 | +## Circuit to Verilog code |
| 12 | +CircuitVerse allows users to convert graphical circuits into Verilog code and export them to be run by different verilog simulators like EDA playground and reconfigurable integrated circuits like FPGAs (NOTE: CV doesn't generate bitstreams for hardware). |
| 13 | + |
| 14 | +## Steps to Convert Circuit to Verilog Code |
| 15 | + |
| 16 | +1. **Design Your Circuit**: Create your digital circuit using the CircuitVerse online simulator. Ensure that your circuit is complete and functions as expected. |
| 17 | + |
| 18 | +2. **Access the Verilog Conversion Tool**: |
| 19 | + - Once your circuit is ready, click on the **"Tools"** menu located at the top of the CircuitVerse interface. |
| 20 | + - Select the **"Export Verilog"** option from the dropdown menu. Refer Figure 8.1. |
| 21 | + |
| 22 | +  |
| 23 | + |
| 24 | + <div align="center"><em>Figure 8.1</em></div> |
| 25 | + |
| 26 | +3. **Give labels to your input and output elements**: |
| 27 | + - You can give your input, output and elements labels to name them respectively in generated verilog code. This also helps in debugging the code. |
| 28 | + |
| 29 | +4. **Generate Verilog Code**: |
| 30 | + - A new window will appear displaying the Verilog code and testbench(commented) generated from your circuit. |
| 31 | + - Review the generated code to ensure it accurately represents your circuit design. Refer Figure 8.2. |
| 32 | + |
| 33 | +  |
| 34 | + |
| 35 | + <div align="center"><em>Figure 8.2</em></div> |
| 36 | + |
| 37 | + > NOTE: Verilog support is an experimental feature in CV so, in some cases it can generate wrong verilog code. |
| 38 | +
|
| 39 | +5. **Download or Copy the Code**: |
| 40 | + - You can either download the Verilog code as a `.v` file or copy the code directly from the window. |
| 41 | + - Use the downloaded or copied code in your preferred Verilog simulator or integrate it into your existing Verilog projects. |
| 42 | + - EDA playground is suggested as simulator to run the generated verilog module (Icarus verilog is the supported version). |
| 43 | + |
| 44 | +6. **Testbench code generated**: |
| 45 | + - The verilog window also contains testbench for the generated verilog module generated but is commented out, it is not filled with the sample values and the user need to enter it manually. |
| 46 | + |
| 47 | +## Features and Verilog construct provided by Circuitverse |
| 48 | +CircuitVerse supports a variety of Verilog constructs, including: |
| 49 | + |
| 50 | +- **Primitive Gates**: Basic logic gates like AND, OR, NOT, NAND, NOR, XOR, and XNOR can be defined using Verilog. |
| 51 | +- **Sequential elements**: Sequential elements like flip-flops, latches, RAM, ROM, ALU etc can be defined using Verilog. |
| 52 | +- **Gate-Level and Behavioral Code**: CV supports generating Verilog code at both gate and behavioral levels, depending on circuit complexity . |
| 53 | +- **Verilog Module Instantiations and Subcircuits**: Each subcircuit in CircuitVerse is converted into a separate Verilog module which is then instantiated in the main module. |
| 54 | + |
| 55 | +## Example |
| 56 | + |
| 57 | +Here is a simple example of a AND Gate circuit and its corresponding Verilog code: |
| 58 | + |
| 59 | +### Circuit Design |
| 60 | + |
| 61 | +<iframe src="https://circuitverse.org/simulator/embed/andvk?theme=&display_title=false&clock_time=true&fullscreen=true&zoom_in_out=true" style="border-width:; border-style: ; border-color:;" name="myiframe" id="projectPreview" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="500" width="500" allowFullScreen></iframe> |
| 62 | + |
| 63 | +### Generated Verilog Code |
| 64 | + |
| 65 | +```verilog |
| 66 | +module Main(out1, inp1, inp2); |
| 67 | + output out1; |
| 68 | + input inp1, inp2; |
| 69 | + wire and_0_out; |
| 70 | + assign and_0_out = inp1 & inp2; |
| 71 | + assign out1 = and_0_out; |
| 72 | +endmodule |
| 73 | +``` |
| 74 | + |
| 75 | + |
| 76 | +> TIP: By following these steps, you can efficiently convert your CircuitVerse designs into Verilog code, integrate it into your verilog project and do further simulation and integration into your digital design workflow. The generated verilog code can be also used in reconfigured circuit boards like FPGAs to simulate the hardware. |
0 commit comments