Skip to content

Commit

Permalink
Create gui.py
Browse files Browse the repository at this point in the history
gui.py

This module provides the graphical user interface (GUI) for the Verilog module generator. It utilizes the Tkinter library to create an interactive window where users can specify parameters for generating Verilog code. Key components include:

Main Application Window: The primary Tkinter window where users enter details for Verilog module generation. It includes fields for specifying the file name, clock type, reset type, and ports.

Dropdown Menus: Options for selecting the clock type (posedge or negedge), reset type (rst or rstn), and machine type (Mealy or Moore).

Port Entries: Entry fields for defining input ports, output ports, wire ports, and register ports, formatted as name:size.

State Machine Encoding: Radio buttons allowing users to choose between automatic and manual state machine encoding.

Create Verilog Module Button: A button that triggers the Verilog module creation process. It collects input from various fields and passes it to the create_verilog_module function for generating the Verilog code.

Custom Dialogs: Includes custom dialogs for selecting encoding styles and managing state machine outputs. These dialogs use dropdowns and input fields to collect user preferences and parameters.

State Transition Handling: Features prompts for defining state transitions and their conditions, ensuring that all conditions are valid Verilog expressions and providing a visual representation of the state machine using Graphviz.

This module integrates various GUI elements to facilitate the creation of Verilog modules, making it user-friendly and efficient for users to design and generate their Verilog code.
  • Loading branch information
shahed22 authored Jul 31, 2024
1 parent 7e7a153 commit 2aec105
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# gui.py
import tkinter as tk
from tkinter import ttk, simpledialog, messagebox
from utils import get_encoding_style, parse_ports, get_state_machine_states
from verilog_generator import create_verilog_module

def create_gui(root):
tk.Label(root, text="Enter File Name:").grid(row=0, column=0)
file_name_entry = tk.Entry(root)
file_name_entry.grid(row=0, column=1)

# Clock Type Dropdown
tk.Label(root, text="Clock Type:").grid(row=1, column=0, padx=10, pady=5)
clock_type_var = tk.StringVar(value="posedge")
clock_type_dropdown = ttk.Combobox(root, textvariable=clock_type_var, values=["posedge", "negedge"])
clock_type_dropdown.grid(row=1, column=1, padx=10, pady=5)

# Reset Type Dropdown
tk.Label(root, text="Reset Type:").grid(row=2, column=0, padx=10, pady=5)
reset_type_var = tk.StringVar(value="rst")
reset_type_dropdown = ttk.Combobox(root, textvariable=reset_type_var, values=["rst", "rstn"])
reset_type_dropdown.grid(row=2, column=1, padx=10, pady=5)

tk.Label(root, text="Input Ports (name:size, separated by commas):").grid(row=3, column=0)
input_ports_entry = tk.Entry(root)
input_ports_entry.grid(row=3, column=1)

tk.Label(root, text="Output Ports (name:size, separated by commas):").grid(row=4, column=0)
output_ports_entry = tk.Entry(root)
output_ports_entry.grid(row=4, column=1)

tk.Label(root, text="Wire Ports (name:size, separated by commas):").grid(row=5, column=0)
wire_ports_entry = tk.Entry(root)
wire_ports_entry.grid(row=5, column=1)

tk.Label(root, text="Register Ports (name:size, separated by commas):").grid(row=6, column=0)
reg_ports_entry = tk.Entry(root)
reg_ports_entry.grid(row=6, column=1)

# Machine Type Dropdown
tk.Label(root, text="Machine Type:").grid(row=8, column=0, padx=10, pady=5)
machine_type_var = tk.StringVar(value="Mealy")
machine_type_dropdown = ttk.Combobox(root, textvariable=machine_type_var, values=["Mealy", "Moore"])
machine_type_dropdown.grid(row=8, column=1, padx=10, pady=5)

state_machine_seq = tk.IntVar()
state_machine_seq.set(1)
tk.Label(root, text="State Machine Encoding:").grid(row=7, column=0)
tk.Radiobutton(root, text="Automatic", variable=state_machine_seq, value=1).grid(row=7, column=1)
tk.Radiobutton(root, text="Manual", variable=state_machine_seq, value=0).grid(row=7, column=2)

tk.Button(root, text="Create Verilog Module",
command=lambda: create_verilog_module(
root, get_file_name(file_name_entry), clock_type_var.get(),
reset_type_var.get(), parse_ports(input_ports_entry.get()),
parse_ports(output_ports_entry.get()), parse_ports(wire_ports_entry.get()),
parse_ports(reg_ports_entry.get()), get_state_machine_states(
root, int(simpledialog.askstring("Number of States", "Enter number of states:", parent=root)),
state_machine_seq.get()), machine_type_var.get())
).grid(row=10, column=0, columnspan=3)

0 comments on commit 2aec105

Please sign in to comment.