Skip to content

Commit 1e821ff

Browse files
authored
added docs for verilog feature in CV (#401)
* added docs for verilog feature in CV
1 parent 97ebd53 commit 1e821ff

21 files changed

Lines changed: 181 additions & 13 deletions

docs/_sidebar.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
* [CircuitVerse Design Process](/chapter7/1cvdesignprocess.md)
3232
* [Building Circuit Simulations within CircuitVerse Simulator](/chapter7/2buildwithcv.md)
3333
* [Testing Circuits](/chapter7/3testcircuits.md)
34-
* Chapter 8: Support Resources
35-
* [Online Forums](/chapter8/1onlineforums.md)
36-
* [FAQ](/chapter8/2cvfaq.md)
37-
* [Understanding Error Messages](/chapter8/3cverrormessages.md)
38-
* [Keyboard Shortcuts](/chapter8/4shortcuts.md)
34+
* Chapter 8: Verilog in Circuitverse
35+
* [Export Verilog for your Circuits](/chapter8/1circuittoverilog.md)
36+
* [Insert subcircuits using Verilog module](/chapter8/2verilogtocircuit.md)
37+
* Chapter 9: Support Resources
38+
* [Online Forums](/chapter9/1onlineforums.md)
39+
* [FAQ](/chapter9/2cvfaq.md)
40+
* [Understanding Error Messages](/chapter9/3cverrormessages.md)
41+
* [Keyboard Shortcuts](/chapter9/4shortcuts.md)

docs/chapter8/1circuittoverilog.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
![export verilog](../images/img_chapter8/8.1.png)
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+
![sample verilog code generated](../images/img_chapter8/8.2.png)
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.

docs/chapter8/2verilogtocircuit.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Verilog Code to Circuit
2+
3+
CircuitVerse allows you to convert Verilog code into a circuit. This feature is useful for those who prefer writing hardware descriptions in Verilog and want to visualize the corresponding circuit by simulating it in CircuitVerse Simulator.
4+
5+
## Steps to Convert Verilog Code to Circuit
6+
7+
1. **Access the Verilog Editor**:
8+
Navigate to **Circuit** drop-down menu to select **New Verilog Module** from the drop down menu. As shown in Figure 8.3, the **Enter circuit name** pop up window is displayed.
9+
10+
![drawing](../images/img_chapter8/8.3.png)
11+
12+
<div align="center"><em>Figure 8.3</em></div>
13+
14+
2. Enter a circuit tab name in the text field. Refer Figure 8.3.
15+
16+
3. Click **OK **to launch the Verilog code interface window as shown in Figure 8.4.
17+
18+
![drawing](../images/img_chapter8/8.4.png)
19+
20+
<div align="center"><em>Figure 8.4</em></div>
21+
22+
4. **Write or Paste Verilog Code**:
23+
Enter the desired Verilog code in the module interface. Refer Figure 8.5.
24+
25+
![drawing](../images/img_chapter8/8.5.png)
26+
27+
<div align="center"><em>Figure 8.5</em></div>
28+
29+
5. Click on the **Save Code** button to receive the message that the code has been saved successfully. Refer Figure 8.6.
30+
31+
![drawing](../images/img_chapter8/8.6.png)
32+
33+
<div align="center"><em>Figure 8.6</em></div>
34+
35+
6. Navigate to Simulator back from the Verilog code editor: Refer Figure 8.10
36+
![navigate to simulator back](../images/img_chapter8/8.10.gif)
37+
38+
<div align="center"><em>Figure 8.10</em></div>
39+
40+
7. Navigate to **Circuit** drop-down menu to select **Insert SubCircuit** from the drop down menu. As shown in Figure 8.7, the **Insert SubCircuit** pop up window is displayed. Select your Verilog-module name and click on **Insert SubCircuit** button.
41+
42+
![drawing](../images/img_chapter8/8.7.png)
43+
44+
<div align="center"><em>Figure 8.7</em></div>
45+
46+
8. The Verilog module will be inserted as box with name of Verilog module and defined input and output ports in the simulator. Refer Figure 8.8.
47+
48+
![drawing](../images/img_chapter8/8.8.png)
49+
50+
<div align="center"><em>Figure 8.8</em></div>
51+
52+
9. **Verify and Simulate**:
53+
- Verify the generated circuit by checking the connections and components.
54+
- Use the simulation tools in CircuitVerse to test the functionality of the circuit.
55+
56+
## Example
57+
58+
Here is a simple example of Verilog code for a 2-input AND gate:
59+
60+
```verilog
61+
module ANDGate (
62+
input A,
63+
input B,
64+
output Y
65+
);
66+
assign Y = A & B;
67+
endmodule
68+
```
69+
70+
After compiling and generating the circuit, you should see a circuit with two inputs (A and B) and one output (Y) representing the AND gate. Add the input and output to the circuit as shown above in figure 8.9 above.
71+
72+
![drawing](../images/img_chapter8/8.9.png)
73+
74+
<div align="center"><em>Figure 8.9</em></div>
75+
76+
## Tips and Warning
77+
78+
- The V2C Generator does not support all the Verilog Constructs, so it might fail to generate circuit for some verilog code.
79+
- Ensure that your Verilog code is well-commented to make it easier to understand and debug.
80+
- Use meaningful names for inputs, outputs, and internal signals and use proper data-types to avoid mistakes.
81+
- Avoid using verilog constructs like file I/O.
82+
83+
By following these steps, you can easily convert Verilog code into a digital circuit using CircuitVerse, allowing for better visualization and testing of your hardware designs.
File renamed without changes.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@
3838

3939
7. How can I move a wire while laying out complex designs on the Canvas?
4040

41-
You can easily move a wire on the Canvas by selecting both the nodes of the wire as shown in Figure 8.1.
41+
You can easily move a wire on the Canvas by selecting both the nodes of the wire as shown in Figure 9.1.
4242

43-
![drawing](../images/img_chapter8/8.1.png)
43+
![drawing](../images/img_chapter9/9.1.png)
4444

45-
<div align="center"><em>Figure 8.1</em></div>
45+
<div align="center"><em>Figure 9.1</em></div>
4646

4747
8. I'm getting lots of problems with the new UI now. Is the old CircuitVerse simulator interface still accessible?
4848

49-
While we encourage our users to use the new UI, the old user interface can be accessed from the **Project** drop-down menu in the menu bar. Refer Figure 8.2 for more details.
49+
While we encourage our users to use the new UI, the old user interface can be accessed from the **Project** drop-down menu in the menu bar. Refer Figure 9.2 for more details.
5050

51-
![drawing](../images/img_chapter8/8.2.png)
51+
![drawing](../images/img_chapter9/9.2.png)
5252

53-
<div align="center"><em>Figure 8.2</em></div>
53+
<div align="center"><em>Figure 9.2</em></div>
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99

1010
**Resolution**: Cyclic paths cause an infinite loop and the circuit never reaches a stable state. Sometimes contention in wires presents itself as a cyclic path. Revise your circuit design for circuit nodes that sometimes behave as inputs and sometimes behave as outputs. Alternatively, troubleshoot and resolve the bug in the circuit.
1111

12-
2. **Contention Error 1 and 0**: When the circuit is driven by two or more outputs of both HIGH and LOW, the simulator may display this error.
12+
2. **Contention Error 1 and 0**: When the circuit is driven by two or more outputs of both HIGH and LOW, the simulator may display this error.Refer figure 9.3 and 9.4.
1313

14-
![Contention Error 1 and 0](https://i.stack.imgur.com/xW0lC.gif)
14+
![drawing](../images/img_chapter9/9.3.gif)
15+
16+
<div align="center"><em>Figure 9.3</em></div>
17+
18+
![drawing](../images/img_chapter8/9.4.gif)
19+
20+
<div align="center"><em>Figure 9.4</em></div>
1521

1622
**Resolution:** Logic contention errors indicate a circuit design problem leading to large amounts of power to flow across circuit elements. Revisit your design for some wiring errors or for active multiple output enable lines that are driving a bus or circuit node simultaneously.
File renamed without changes.

docs/images/img_chapter8/8.1.png

45.7 KB
Loading

docs/images/img_chapter8/8.10.gif

282 KB
Loading

docs/images/img_chapter8/8.2.png

104 KB
Loading

0 commit comments

Comments
 (0)