# mohammad-ismael/cas_cycle_accurate_simulator architecture

> Architecture diagram of the GitHub repository mohammad-ismael/cas_cycle_accurate_simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohammad-ismael/cas_cycle_accurate_simulator
- Repository: https://github.com/mohammad-ismael/cas_cycle_accurate_simulator

## Overview

CAS is a SystemVerilog RTL simulator with an integrated verification IDE. The principal workflow accepts design sources and simulation options, parses them into an AST, elaborates the design, runs discrete-event simulation, and produces waveform and profiling outputs. The graph also includes documented IDE, diagnostics, and waveform-viewer capabilities. Some web wiring and unsampled runtime internals are not shown in the excerpts, so those relationships are omitted or marked unverified.

Main entry points: [`CAS/src/engine.cpp`](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/engine.cpp) (Engine), [`CAS/src/main.cpp`](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/main.cpp) (CLI Runner), [`server.py`](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/server.py) (Studio Server), [`CAS/src/frontend/lexer.cpp`](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/frontend/lexer.cpp) (Lexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Simulator Entry"]
  node_cli["CLI Runner<br/>[main.cpp]"]
end

subgraph group_frontend["Language Frontend"]
  node_lexer["Lexer<br/>[lexer.cpp]"]
  node_parser["SystemVerilog Parser<br/>[parser.cpp]"]
  node_ast["Design AST<br/>[ast_module.hpp]"]
end

subgraph group_kernel["Simulation Kernel"]
  node_engine["Engine<br/>[engine.cpp]"]
  node_elaborator["Design Elaboration<br/>[elaborator.cpp]"]
  node_scheduler["Event Scheduler<br/>[scheduler.cpp]"]
  node_evaluator["Expression Evaluation<br/>[expr_evaluator.cpp]"]
  node_logic["Four-State Logic<br/>[logic_val.hpp]"]
end

subgraph group_outputs["Simulation Outputs"]
  node_vcd["VCD Dumper<br/>[vcd_dumper.cpp]"]
  node_profiler["Hardware Profiler<br/>[profiler.cpp]"]
end

subgraph group_studio["Studio Environment"]
  node_server["Studio Server<br/>[server.py]"]
  node_ide["Multi-file IDE<br/>[app.js]"]
  node_editor["Source Editor<br/>[editor.js]"]
  node_console["Diagnostic Console<br/>[console.js]"]
  node_waveviewer["Waveform Viewer<br/>[wave_app.js]"]
  node_vcdparser["VCD Parser<br/>[vcd_parser.js]"]
end

node_user(("Engineer"))

node_user -->|"supplies sources"| node_cli
node_cli -->|"starts parsing"| node_lexer
node_lexer -.->|"tokenizes input"| node_parser
node_parser -->|"builds AST"| node_ast
node_ast -->|"design input"| node_engine
node_engine -->|"elaborates design"| node_elaborator
node_engine -->|"runs simulation"| node_scheduler
node_engine -->|"evaluates design"| node_evaluator
node_evaluator -.->|"uses logic values"| node_logic
node_cli -->|"runs engine"| node_engine
node_engine -->|"emits waveforms"| node_vcd
node_engine -->|"collects profiling"| node_profiler
node_user -->|"edits designs"| node_ide
node_ide -.->|"uses environment"| node_server
node_server -.->|"serves diagnostics"| node_console
node_server -.->|"serves viewer"| node_waveviewer
node_waveviewer -.->|"parses waveform"| node_vcdparser

click node_cli "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/main.cpp"
click node_lexer "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/frontend/lexer.cpp"
click node_parser "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/frontend/parser.cpp"
click node_ast "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/include/frontend/ast_module.hpp"
click node_engine "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/engine.cpp"
click node_elaborator "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/elaborator.cpp"
click node_scheduler "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/scheduler.cpp"
click node_evaluator "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/expr_evaluator.cpp"
click node_logic "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/include/common/logic_val.hpp"
click node_vcd "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/tracer/vcd_dumper.cpp"
click node_profiler "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/profiler/profiler.cpp"
click node_server "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/server.py"
click node_ide "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/app.js"
click node_editor "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/editor.js"
click node_console "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/console.js"
click node_waveviewer "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/waveviewer/js/wave_app.js"
click node_vcdparser "https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/waveviewer/js/vcd_parser.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli toneBlue
class node_lexer,node_parser,node_ast toneAmber
class node_engine,node_elaborator,node_scheduler,node_evaluator,node_logic toneMint
class node_vcd,node_profiler toneRose
class node_server,node_ide,node_editor,node_console,node_waveviewer,node_vcdparser,node_user toneIndigo
```

## Components

### Simulator Entry

- [CLI Runner](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/main.cpp): `CAS/src/main.cpp`

### Language Frontend

- [Lexer](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/frontend/lexer.cpp): `CAS/src/frontend/lexer.cpp`
- [SystemVerilog Parser](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/frontend/parser.cpp): `CAS/src/frontend/parser.cpp`
- [Design AST](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/include/frontend/ast_module.hpp): `CAS/include/frontend/ast_module.hpp`

### Simulation Kernel

- [Engine](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/engine.cpp): `CAS/src/engine.cpp`
- [Design Elaboration](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/elaborator.cpp): `CAS/src/kernel/elaborator.cpp`
- [Event Scheduler](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/scheduler.cpp): `CAS/src/kernel/scheduler.cpp`
- [Expression Evaluation](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/kernel/expr_evaluator.cpp): `CAS/src/kernel/expr_evaluator.cpp`
- [Four-State Logic](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/include/common/logic_val.hpp): `CAS/include/common/logic_val.hpp`

### Simulation Outputs

- [VCD Dumper](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/tracer/vcd_dumper.cpp): `CAS/src/tracer/vcd_dumper.cpp`
- [Hardware Profiler](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/CAS/src/profiler/profiler.cpp): `CAS/src/profiler/profiler.cpp`

### Studio Environment

- [Studio Server](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/server.py): `server.py`
- [Multi-file IDE](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/app.js): `static/js/app.js`
- [Source Editor](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/editor.js): `static/js/editor.js`
- [Diagnostic Console](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/js/console.js): `static/js/console.js`
- [Waveform Viewer](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/waveviewer/js/wave_app.js): `static/waveviewer/js/wave_app.js`
- [VCD Parser](https://github.com/mohammad-ismael/cas_cycle_accurate_simulator/blob/main/static/waveviewer/js/vcd_parser.js): `static/waveviewer/js/vcd_parser.js`

### Other components

- **Engineer**

## Connections

- Engineer → CLI Runner: supplies sources
- CLI Runner → Lexer: starts parsing (evidence: `CAS/src/main.cpp`)
- Lexer → SystemVerilog Parser: tokenizes input
- SystemVerilog Parser → Design AST: builds AST
- Design AST → Engine: design input
- Engine → Design Elaboration: elaborates design
- Engine → Event Scheduler: runs simulation
- Engine → Expression Evaluation: evaluates design
- Expression Evaluation → Four-State Logic: uses logic values
- CLI Runner → Engine: runs engine (evidence: `CAS/src/main.cpp`)
- Engine → VCD Dumper: emits waveforms
- Engine → Hardware Profiler: collects profiling
- Engineer → Multi-file IDE: edits designs
- Multi-file IDE → Studio Server: uses environment
- Studio Server → Diagnostic Console: serves diagnostics
- Studio Server → Waveform Viewer: serves viewer
- Waveform Viewer → VCD Parser: parses waveform
