|
| 1 | +--- |
| 2 | +description: GHDL |
| 3 | +--- |
| 4 | + |
| 5 | +# GHDL |
| 6 | + |
| 7 | +TerosHDL provides comprehensive integration with GHDL (GHDL VHDL compiler and simulator), offering both configuration options and automated tasks for VHDL development. This guide explains how to use GHDL effectively within TerosHDL. |
| 8 | + |
| 9 | +## Table of Contents |
| 10 | + |
| 11 | +- [Overview](#overview) |
| 12 | +- [Getting Started](#getting-started) |
| 13 | +- [Tasks](#tasks) |
| 14 | + - [GHDL Check Syntax](#ghdl-check-syntax) |
| 15 | + - [GHDL Run All](#ghdl-run-all) |
| 16 | + - [Individual Tasks](#individual-tasks) |
| 17 | +- [Understanding the Workflow](#understanding-the-workflow) |
| 18 | +- [Configuration Options](#configuration-options) |
| 19 | +- [Usage Examples](#usage-examples) |
| 20 | +- [Troubleshooting](#troubleshooting) |
| 21 | + |
| 22 | +## Overview |
| 23 | + |
| 24 | +GHDL is a free and open-source VHDL compiler and simulator. TerosHDL integrates GHDL to provide a complete VHDL development environment with: |
| 25 | + |
| 26 | +- **Syntax checking** without code generation |
| 27 | +- **Analysis and compilation** of VHDL files |
| 28 | +- **Elaboration** of designs |
| 29 | +- **Simulation** with automatic waveform generation |
| 30 | +- **Comprehensive configuration** options |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +## Getting Started |
| 35 | + |
| 36 | +1. **Install GHDL** on your system or specify the installation path in TerosHDL settings |
| 37 | +2. **Create or open a VHDL project** in TerosHDL |
| 38 | +3. **Add your VHDL files** to the project |
| 39 | +4. **Specify the top-level entity** for simulation |
| 40 | +5. **Use the tasks** to compile and simulate your design |
| 41 | + |
| 42 | +## Tasks |
| 43 | + |
| 44 | +TerosHDL provides several GHDL tasks accessible through the Tasks panel. These tasks automate the VHDL development workflow from syntax checking to simulation. |
| 45 | + |
| 46 | +### GHDL Check Syntax |
| 47 | + |
| 48 | +**What it does**: Performs fast syntax checking of your VHDL files without generating any code or updating libraries. |
| 49 | + |
| 50 | +**When to use**: |
| 51 | +- Before starting compilation to catch syntax errors early |
| 52 | +- During development to quickly validate code changes |
| 53 | +- When you want to check code without affecting your project libraries |
| 54 | + |
| 55 | +**How it works**: |
| 56 | +- Scans all VHDL files in your project |
| 57 | +- Uses the VHDL standard detected from your files (or forces a specific one if configured) |
| 58 | +- Groups files by their logical libraries |
| 59 | +- Reports syntax errors immediately |
| 60 | +- Does not generate any output files |
| 61 | + |
| 62 | +**Benefits**: |
| 63 | +- **Fast feedback** - much quicker than full compilation |
| 64 | +- **Non-invasive** - doesn't modify your project libraries |
| 65 | +- **Early error detection** - catch problems before simulation |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +### GHDL Run All |
| 70 | + |
| 71 | +**What it does**: Executes the complete VHDL workflow from compilation to simulation in the correct order. |
| 72 | + |
| 73 | +**When to use**: |
| 74 | +- When you want to compile and simulate your complete design |
| 75 | +- For final testing before deployment |
| 76 | +- When you need waveform output for debugging |
| 77 | + |
| 78 | +**The workflow includes three sequential steps**: |
| 79 | + |
| 80 | +#### 1. GHDL Analyze |
| 81 | +**Purpose**: Compiles VHDL files and builds/updates the library database. |
| 82 | + |
| 83 | +**What happens**: |
| 84 | +- Processes files grouped by logical library |
| 85 | +- Compiles each file and checks for errors |
| 86 | +- Updates the library database with compiled entities, architectures, and packages |
| 87 | +- Ensures all dependencies are properly analyzed |
| 88 | + |
| 89 | +#### 2. GHDL Elaborate |
| 90 | +**Purpose**: Links the design and prepares it for simulation. |
| 91 | + |
| 92 | +**What happens**: |
| 93 | +- Takes your top-level entity and traces all its dependencies |
| 94 | +- Resolves all component instantiations and port mappings |
| 95 | +- Creates an executable simulation model |
| 96 | +- Performs binding checks and optimizations |
| 97 | + |
| 98 | +#### 3. GHDL Simulate |
| 99 | +**Purpose**: Runs the actual simulation and generates results. |
| 100 | + |
| 101 | +**What happens**: |
| 102 | +- **Automatically removes old waveform files** (`wave.*`) to ensure clean results |
| 103 | +- Executes the simulation with your configured time limits |
| 104 | +- Generates waveform files in your chosen format (VCD, GHW, or FST) |
| 105 | +- Applies all run-time options and signal tracing |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +### Individual Tasks |
| 110 | + |
| 111 | +You can also run the components of "GHDL Run All" individually: |
| 112 | + |
| 113 | +#### GHDL Analyze (Standalone) |
| 114 | +Run only the analysis/compilation step. Useful when: |
| 115 | +- You want to check compilation without simulation |
| 116 | +- You're working on library packages that other files depend on |
| 117 | +- You need to update libraries after code changes |
| 118 | + |
| 119 | +#### GHDL Elaborate (Standalone) |
| 120 | +Run only the elaboration step. Useful when: |
| 121 | +- Analysis is already complete |
| 122 | +- You want to test design binding without simulation |
| 123 | +- You're debugging elaboration-specific issues |
| 124 | + |
| 125 | +#### GHDL Simulate (Standalone) |
| 126 | +Run only the simulation step. Useful when: |
| 127 | +- Analysis and elaboration are already complete |
| 128 | +- You want to re-run simulation with different parameters |
| 129 | +- You're experimenting with different simulation settings |
| 130 | + |
| 131 | +#### Open Waveform |
| 132 | +**Purpose**: Opens the generated waveform files in your configured viewer. |
| 133 | + |
| 134 | +**What it does**: |
| 135 | +- Searches for waveform files (`.vcd`, `.ghw`, `.fst`) in the project directory |
| 136 | +- Opens the found waveform files using your configured viewer |
| 137 | +- Provides easy access to simulation results |
| 138 | + |
| 139 | +**When to use**: |
| 140 | +- After running a simulation to view waveform results |
| 141 | +- To re-open waveform files from previous simulations |
| 142 | +- When you want to analyze timing and signal behavior |
| 143 | + |
| 144 | +**Supported viewers**: |
| 145 | +- **GTKWave** - External professional waveform viewer |
| 146 | +- **VaporView** - VS Code extension for waveform viewing |
| 147 | +- **Built-in tool viewers** - When available |
| 148 | + |
| 149 | +**Supported formats**: GHW, VCD, FST |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | +## Understanding the Workflow |
| 154 | + |
| 155 | +### The VHDL Development Cycle |
| 156 | + |
| 157 | +``` |
| 158 | +1. Write/Edit VHDL Code |
| 159 | + ↓ |
| 160 | +2. Check Syntax (optional but recommended) |
| 161 | + ↓ |
| 162 | +3. Analyze → Elaborate → Simulate |
| 163 | + ↓ |
| 164 | +4. View Waveforms |
| 165 | + ↓ |
| 166 | +5. Debug and Iterate |
| 167 | +``` |
| 168 | + |
| 169 | +### When to Use Each Task |
| 170 | + |
| 171 | +| Task | Use Case | Speed | Output | |
| 172 | +|------|----------|-------|---------| |
| 173 | +| **Check Syntax** | Quick validation during development | Very Fast | Error reports only | |
| 174 | +| **Analyze** | After code changes, library updates | Fast | Updated libraries | |
| 175 | +| **Elaborate** | Test design binding and connectivity | Fast | Simulation model | |
| 176 | +| **Simulate** | Generate results and waveforms | Moderate | Waveforms, logs | |
| 177 | +| **Run All** | Complete workflow, final testing | Full time | Complete results | |
| 178 | +c |
| 179 | +## Configuration Options |
| 180 | + |
| 181 | +All GHDL settings are accessible through TerosHDL's configuration interface. |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | +### Basic Configuration |
| 186 | + |
| 187 | +**Installation Path**: Specify where GHDL is installed on your system |
| 188 | +- Leave empty to use system PATH |
| 189 | +- Required if GHDL is not in your system PATH |
| 190 | + |
| 191 | +### VHDL Language Settings |
| 192 | + |
| 193 | +**VHDL Standard Version**: Control which VHDL standard to use |
| 194 | +- `Auto-detect from file`: Automatically detect from your VHDL files (recommended) |
| 195 | +- `Force VHDL-87/93/2002/2008/2019`: Override with specific standard |
| 196 | + |
| 197 | +**IEEE Library**: Choose IEEE library implementation |
| 198 | +- `Standard IEEE`: Standard IEEE implementation |
| 199 | +- `Synopsys IEEE`: Synopsys IEEE implementation |
| 200 | + |
| 201 | +**Relaxed Parsing**: Enable more lenient VHDL parsing rules |
| 202 | + |
| 203 | +**Unicode Support**: Allow Unicode identifiers in your VHDL code |
| 204 | + |
| 205 | +**PSL Support**: Enable Property Specification Language features |
| 206 | + |
| 207 | +### Library Management |
| 208 | + |
| 209 | +**Work Library**: Name of the default working library (usually "work") |
| 210 | + |
| 211 | +**Library Paths**: Additional directories to search for VHDL libraries |
| 212 | + |
| 213 | +### Stage-Specific Options |
| 214 | + |
| 215 | +**Check Syntax Options**: Additional flags for syntax checking (`ghdl -s`) |
| 216 | + |
| 217 | +**Analyze Options**: Extra options for compilation (`ghdl -a`) |
| 218 | + |
| 219 | +**Elaborate Options**: Additional flags for elaboration (`ghdl -e`) |
| 220 | + |
| 221 | +**Run Options**: Simulation parameters (`ghdl -r`) |
| 222 | + |
| 223 | +**Synthesis Options**: Options for synthesis (`ghdl --synth`) |
| 224 | + |
| 225 | +### Simulation Settings |
| 226 | + |
| 227 | +**Simulation Time**: Set maximum simulation time (e.g., "1ms", "500ns") |
| 228 | + |
| 229 | +**Resolution Limit**: Set time precision (e.g., "1ps", "1ns") |
| 230 | + |
| 231 | +**Stack Size**: Memory allocation for simulation |
| 232 | + |
| 233 | +**Stop Delta Cycles**: Limit delta cycle iterations |
| 234 | + |
| 235 | +### Waveform Output |
| 236 | + |
| 237 | +**Waveform Enabled**: Enable/disable waveform generation |
| 238 | + |
| 239 | +**Waveform Format**: Choose output format |
| 240 | +- `VCD`: Value Change Dump (widely supported) |
| 241 | +- `GHW`: GHDL native format (most detailed) |
| 242 | +- `FST`: Fast Signal Database (compact) |
| 243 | + |
| 244 | +**Waveform Options**: Additional waveform generation parameters |
| 245 | + |
| 246 | +**Advanced Waveform Settings**: |
| 247 | +- Wave start time recording |
| 248 | +- VCD 4-state format |
| 249 | +- Signal filtering options |
| 250 | +- Custom wave option files |
| 251 | + |
| 252 | +### Debug and Analysis |
| 253 | + |
| 254 | +**Debug Level**: Control amount of debug information |
| 255 | +- `No debug info`: Fastest execution |
| 256 | +- `Minimal debug info`: Basic information |
| 257 | +- `Full debug info`: Detailed debugging |
| 258 | + |
| 259 | +**Verbose Output**: Enable detailed command output |
| 260 | + |
| 261 | +### Error and Warning Handling |
| 262 | + |
| 263 | +**Warnings as Errors**: Treat warnings as compilation errors |
| 264 | + |
| 265 | +**Suppress Warnings**: Specify warning types to ignore |
| 266 | + |
| 267 | +### Assertions and Verification |
| 268 | + |
| 269 | +**Assert Level**: Control assertion sensitivity |
| 270 | +- `Note/Warning/Error/Failure level`: Different sensitivity levels |
| 271 | +- `Disable assertions`: Turn off assertion checking |
| 272 | + |
| 273 | +**Display Options**: Show timing and delta cycle information |
| 274 | + |
| 275 | +**Backtrace Settings**: Control error backtrace generation |
| 276 | + |
| 277 | +### IEEE Standards Compliance |
| 278 | + |
| 279 | +**IEEE Asserts**: Control IEEE assertion handling |
| 280 | + |
| 281 | +**Asserts Policy**: Policy for handling assertions during simulation |
| 282 | + |
| 283 | +### Advanced Features |
| 284 | + |
| 285 | +**File I/O and External Interfaces**: |
| 286 | +- SDF file support for timing annotation |
| 287 | +- VPI/VHPI module loading |
| 288 | +- External trace file generation |
| 289 | +- PSL reporting options |
| 290 | + |
| 291 | +**Display and Hierarchy**: |
| 292 | +- Design hierarchy display options |
| 293 | +- Signal and port visualization |
| 294 | +- Process and instance information |
| 295 | + |
| 296 | +## Usage Examples |
| 297 | + |
| 298 | +### Basic Workflow Example |
| 299 | + |
| 300 | +1. **Setup your project**: |
| 301 | + - Ensure GHDL is installed and configured |
| 302 | + - Add your VHDL files to the project |
| 303 | + - Set the top-level entity |
| 304 | + |
| 305 | +2. **Quick syntax check**: |
| 306 | + - Run "GHDL Check Syntax" to catch any syntax errors |
| 307 | + - Fix any reported issues |
| 308 | + |
| 309 | +3. **Full simulation**: |
| 310 | + - Run "GHDL Run All" to compile and simulate |
| 311 | + - Wait for completion (monitor progress in Tasks panel) |
| 312 | + |
| 313 | +4. **View results**: |
| 314 | + - Click "Open Waveform" to view simulation results |
| 315 | + - Analyze signals and timing in the waveform viewer |
| 316 | + |
| 317 | + |
| 318 | +## Troubleshooting |
| 319 | + |
| 320 | +### Common Issues and Solutions |
| 321 | + |
| 322 | +#### GHDL Not Found |
| 323 | +**Problem**: Error message "ghdl: command not found" |
| 324 | +**Solutions**: |
| 325 | +- Install GHDL on your system |
| 326 | +- Add GHDL to your system PATH |
| 327 | +- Set the correct installation path in TerosHDL configuration |
| 328 | + |
| 329 | +#### No Top-Level Entity |
| 330 | +**Problem**: "No top level entity specified" |
| 331 | +**Solutions**: |
| 332 | +- Specify the top-level entity in your project settings |
| 333 | +- Ensure the entity name exactly matches your VHDL file |
| 334 | +- Check that the entity is properly declared |
| 335 | + |
| 336 | +#### Compilation Errors |
| 337 | +**Problem**: Analysis or elaboration fails |
| 338 | +**Solutions**: |
| 339 | +- Run "GHDL Check Syntax" first to identify syntax issues |
| 340 | +- Verify VHDL standard settings match your code |
| 341 | +- Check library dependencies and include paths |
| 342 | + |
| 343 | +#### No Waveform Generated |
| 344 | +**Problem**: Simulation completes but no waveform file appears |
| 345 | +**Solutions**: |
| 346 | +- Enable "Waveform Enabled" in configuration |
| 347 | +- Check "Run Options" for waveform generation parameters |
| 348 | +- Verify simulation actually ran (check for error messages) |
| 349 | +- Ensure you have write permissions in the project directory |
| 350 | + |
| 351 | +#### Library Issues |
| 352 | +**Problem**: "Library not found" errors |
| 353 | +**Solutions**: |
| 354 | +- Check library path configuration |
| 355 | +- Verify library directory structure |
| 356 | +- Ensure all required libraries are properly compiled |
| 357 | +- Check file library assignments |
| 358 | + |
| 359 | +### Performance Tips |
| 360 | + |
| 361 | +1. **Use syntax checking** during development to catch errors early |
| 362 | +2. **Enable appropriate debug level** (minimal for faster execution) |
| 363 | +3. **Set reasonable simulation time limits** for large designs |
| 364 | +4. **Use efficient waveform formats** (FST for large simulations) |
| 365 | +5. **Organize libraries efficiently** to minimize compilation time |
| 366 | + |
| 367 | +### Getting Help |
| 368 | + |
| 369 | +- **Check the terminal output** for detailed error messages and warnings |
| 370 | +- **Use verbose mode** for more diagnostic information |
| 371 | +- **Start with simple examples** to verify your setup |
| 372 | +- **Check GHDL documentation** for command-line option details |
| 373 | + |
| 374 | +--- |
| 375 | + |
| 376 | +## Additional Resources |
| 377 | + |
| 378 | +- [GHDL Official Documentation](https://ghdl.readthedocs.io/) |
| 379 | +- [GTKWave User Guide](http://gtkwave.sourceforge.net/) |
| 380 | + |
0 commit comments