Project: Web FPGA Signal Propagation Simulator
Version: 1.4
Date: 2025-03-25
Document Revision History
| Version | Date | Author | Summary of Changes |
|---|---|---|---|
| 0.1 | 2025-02-26 | Abderrazaq Makran | Initial structure and outline created |
| 0.2 | 2025-03-01 | Abderrazaq Makran | Added system overview, architecture diagram, and tech stack |
| 0.3 | 2025-03-05 | Abderrazaq Makran | Drafted functional requirements and FPGA visualization model |
| 0.4 | 2025-03-10 | Abderrazaq Makran | Integrated simulation engine specs and interaction flows |
| 1.0 | 2025-03-17 | Abderrazaq Makran | First complete version; added error handling and UI wireframes |
| 1.2 | 2025-03-22 | Abderrazaq Makran | Refactored structure, improved code guidelines and diagrams |
| 1.3 | 2025-03-24 | Abderrazaq Makran | Pre-final version |
| 1.4 | 2025-03-25 | Abderrazaq Makran | Final version with appendices, glossary, and performance details |
- Technical Specification
Understanding signal propagation in FPGAs is inherently complex. This simulator provides an interactive, visual environment that enables users to observe and manipulate FPGA signal behavior in real time without the need for specialized hardware.
Core Question: How can we make the intricate workings of an FPGA accessible and comprehensible to both novice and experienced users?
- Teachers: Responsible for selecting preloaded FPGA examples or uploading custom
.vand.sdffiles, then managing simulation sessions. - Students: Engage with real-time FPGA simulations through a user-friendly web interface.
- Intuitive Navigation: Minimal training required.
- Real-Time Feedback: Immediate visual response to user actions.
- Interactive Learning: Ability to control simulation speed, step through the simulation, and inspect details.
- Self-Guided Exploration: Tools that encourage experimentation with FPGA designs.
- Accessibility: Support across multiple devices and include necessary accessibility features.
The simulator bridges theory and practice by:
- Visualizing abstract FPGA internals.
- Enabling hands-on experimentation without physical hardware.
- Supporting self-paced, interactive learning.
- Connecting theoretical concepts with practical simulation outcomes.
| Term | Definition |
|---|---|
| API | Application Programming Interface; enables communication between different software components. |
| BEL | Basic Element; a fundamental component within an FPGA (e.g., LUT, flip-flop, Block RAM) that will be visualized in the simulation canvas. |
| Canvas | HTML element used for drawing graphics and animations via JavaScript. |
| Docker | Platform for developing, shipping, and running applications in containers. |
| Express.js | Minimal and flexible Node.js web application framework for building APIs. |
| FPGA | Field-Programmable Gate Array; a reconfigurable integrated circuit for custom digital logic. |
| IndexedDB | Low-level JavaScript API for client-side storage of significant amounts of structured data. |
| JSON Model | A structured data format representing FPGA components and signals for visualization purposes. |
| Monaco | Code editor that powers VS Code, used for syntax highlighting and code editing. |
| Netlist | A structural representation of an FPGA design, detailing its components and connections. |
| Node.js | JavaScript runtime built on Chrome's V8 JavaScript engine for server-side execution. |
| P&R | Place and Route; mapping netlist components onto FPGA resources and determining routing paths. |
| React | JavaScript library for building user interfaces with component-based architecture. |
| SDF | Standard Delay Format; a file format containing timing delay information. |
| Simulation | Modeling signal propagation over time to test and validate digital designs. |
| Socket.io | Library enabling real-time, bidirectional communication between web clients and servers. |
| Synthesis | The process of converting Verilog code into a netlist. |
| TailwindCSS | Utility-first CSS framework for rapidly building custom user interfaces. |
| TypeScript | JavaScript superset that adds static typing and other features to enhance code quality. |
| Vercel | Platform for static site deployment and serverless functions with global CDN. |
| Verilog | A hardware description language used to design and simulate digital circuits. |
| Vite | Modern frontend build tool providing faster development experience through native ES modules. |
| Browser | Minimum Version | Notes |
|---|---|---|
| Chrome | 88+ | Recommended for best performance |
| Firefox | 85+ | Full WebGL 2.0 support required |
| Safari | 14+ | Limited canvas performance on iOS |
| Edge (Chromium) | 88+ | Full feature support |
WebGL Requirements:
- WebGL 2.0 support required for canvas rendering
- Hardware acceleration recommended
- Minimum 2GB video memory for large FPGA layouts
| Error Scenario | Recovery Procedure | Data Persistence |
|---|---|---|
| Browser Crash | Auto-save to IndexedDB every 30 seconds | Restore last saved state on reload |
| Network Failure | Queue operations for retry | Cache parsed models locally |
| File Corruption | Maintain backup of last valid state | Version history of last 5 changes |
| Memory Exhaustion | Clear non-essential caches | Persist critical simulation data |
Recovery Features:
- Automatic state saving during simulation
- Manual save points for critical operations
- Background sync for unsaved changes
- Conflict resolution for multi-tab editing
Frontend:
- React + Vite (TypeScript)
- TailwindCSS
- HTML Canvas (for 2D FPGA layout rendering)
Backend:
- Node.js + Express.js (TypeScript)
- File Parsing Libraries (for
.vand.sdffiles)
Deployment:
- Local deployment via Vite (frontend) and Express.js (backend)
- Option for static deployment on Vercel for the frontend
- Optional Docker for containerized testing
┌───────────────────────────────────────────────────────────┐
│ Web Browser UI │
└───────────────────────────────────────┬───────────────────┘
│
▼
┌───────────────────────────────────────────────────────────┐
│ React Application (Vite) │
│ ┌───────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ Code Editor │ │ Simulation │ │ FPGA Canvas │ │
│ │ (Monaco) │ │ Controls │ │ Renderer │ │
│ └───────────────┘ └──────────────┘ └───────────────┘ │
└────────────────────────────┬──────────────────────────────┘
│ HTTP/Fetch API
▼
┌───────────────────────────────────────────────────────────┐
│ Express.js Backend (Node.js) │
│ ┌───────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ File Upload │ │ Processing │ │ JSON Model │ │
│ │ API Endpoints │ │ Controller │ │ Generation │ │
│ └───────────────┘ └──────────────┘ └───────────────┘ │
└────────────────────────────┬──────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────┐
│ File Parsers │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Verilog (.v) │ │ SDF (.sdf) │ │
│ │ Parser │ │ Parser │ │
│ └───────────────┘ └───────────────┘ │
└───────────────────────────────────────────────────────────┘
-
Frontend Layer:
- React Application: Built with Vite and TypeScript, managing application state and UI rendering
- Code Editor: Monaco-based editor for Verilog with syntax highlighting
- Simulation Controls: Interface for controlling simulation playback (play, pause, step)
- FPGA Canvas Renderer: HTML Canvas implementation that visualizes the FPGA layout and signal propagation
-
Communication Layer:
- HTTP/Fetch API: Primary method for data exchange between frontend and backend
- JSON Data Model: Standardized format for representing FPGA components and connections
- Optional WebSockets: For real-time updates during simulation (Socket.io implementation)
-
Backend Layer:
- Express.js Server: Handles HTTP requests, file uploads, and processing coordination
- File Upload Endpoints: Manages multipart form uploads for .v and .sdf files
- Processing Controller: Orchestrates the parsing workflow and error handling
- JSON Model Generator: Creates the visualization model from parsed data
-
Processing Layer:
- Verilog Parser: Extracts FPGA component definitions, connections, and logic
- SDF Parser: Processes timing information for signal propagation simulation
- Combined Processing: Merges data from both parsers to create a comprehensive model
The FPGA visualization is based on a structured JSON model that defines both the elements (components) and their connections:
Elements (BELs) <---> Connections (Wires)
JSON Model Structure:
{
"elements": [
{
"id": 0,
"name": "LUT4",
"type": "logic_gate",
"position": { "x": 100, "y": 150 },
"inputs": [
{ "connectionId": 1, "name": "A" },
{ "connectionId": 2, "name": "B" }
],
"outputs": [
{ "connectionId": 3, "name": "OUT" }
],
"state": {
"active": false,
"value": 0
}
},
{
"id": 1,
"name": "FF1",
"type": "flip_flop",
"position": { "x": 200, "y": 150 },
"inputs": [
{ "connectionId": 3, "name": "D" },
{ "connectionId": 4, "name": "CLK" }
],
"outputs": [
{ "connectionId": 5, "name": "Q" }
],
"state": {
"active": false,
"value": 0
}
}
],
"connections": [
{
"id": 1,
"from": "INPUT_A",
"to": "0.A",
"path": [[50, 150], [75, 150], [100, 150]],
"color": "blue",
"delay": 2,
"state": {
"active": false,
"value": 0,
"propagating": false
}
},
{
"id": 3,
"from": "0.OUT",
"to": "1.D",
"path": [[150, 150], [175, 150], [200, 150]],
"color": "green",
"delay": 1.5,
"state": {
"active": false,
"value": 0,
"propagating": false
}
}
],
"metadata": {
"name": "2ffs_VTR",
"description": "Two flip-flops in series",
"timeUnit": "ns",
"gridSize": 10,
"canvasWidth": 800,
"canvasHeight": 600
}
}Key Components:
-
elements: Array of FPGA basic elements (BELs)
id: Unique identifier for the elementname: Display nametype: Element type (e.g., "logic_gate", "flip_flop", "buffer")position: X/Y coordinates on the canvasinputs/outputs: Arrays of connection pointsconnectionId: Reference to a specific connection in the connections arrayname: Label for the input/output (e.g., "A", "CLK", "OUT")
state: Current element state for simulation
-
connections: Array of wires connecting elements
id: Unique identifier for the connectionfrom: Source element and output (format: "elementId.outputName")to: Target element and input (format: "elementId.inputName")path: Array of coordinate pairs defining wire routingcolor: Visual representation colordelay: Signal propagation time in nanosecondsstate: Current connection state for simulation
-
metadata: Additional information about the design
name: Design namedescription: Short descriptiontimeUnit: Time unit for simulation (typically "ns")canvasWidth/canvasHeight: Visualization dimensions
This model provides a complete representation of the FPGA circuit for visualization and simulation, with the elements representing components and connections representing the signal paths between them.
- File Upload: Users upload
.vand.sdffiles via HTTP POST. - Processing: The backend validates and parses the files into a JSON model.
- Data Delivery: The JSON model is returned to the frontend.
- Visualization: The frontend renders the FPGA layout on HTML Canvas.
- Simulation: Users control simulation playback (play, pause, step, speed).
- Error Reporting: Descriptive error messages are provided if issues occur.
- Local Environment:
- Frontend served via Vite (
npm run dev). - Backend runs on Express.js locally (
npm run dev).
- Frontend served via Vite (
- Static Deployment:
- Optionally deploy the frontend on Vercel or GitHub Pages.
- Containerization:
- Optional Docker for consistent local testing.
- Data Privacy:
- All processing is local; no data is transmitted externally.
The project follows a modular organization reflecting the implementation:
Project Root
├── Code/
│ ├── Frontend/ # React frontend application
│ │ ├── public/ # Static assets
│ │ │ ├── data/ # Sample FPGA data files
│ │ │ │ └── samples/ # Example .v and .sdf files
│ │ │ │ ├── 1ff_no_rst_VTR/
│ │ │ │ ├── 1ff_VTR/
│ │ │ │ ├── 2ffs_no_rst_VTR/
│ │ │ │ ├── 2ffs_VTR/
│ │ │ │ ├── 5ffs_VTR/
│ │ │ │ ├── FULLLUT_VTR/
│ │ │ │ └── LUT_VTR/
│ │ ├── src/ # Frontend source code
│ │ │ ├── components/ # React components
│ │ │ │ ├── app/ # Application-specific components
│ │ │ │ │ ├── AddExampleModal.tsx # Modal for importing files
│ │ │ │ │ ├── CanvasActionBar.tsx # Controls for canvas actions
│ │ │ │ │ ├── CodeEditor.tsx # Monaco-based code editor
│ │ │ │ │ ├── Example.tsx # Example list item component
│ │ │ │ │ ├── ExamplesDrawer.tsx # Left-side drawer for examples
│ │ │ │ │ ├── Navbar.tsx # Top navigation bar
│ │ │ │ │ ├── SimulationCanvas.tsx # Main canvas for FPGA visualization
│ │ │ │ │ ├── TabDisplayer.tsx # Handles view mode display
│ │ │ │ │ └── TabsBar.tsx # File tabs management
│ │ │ │ ├── theme-provider.tsx # Theme handling (light/dark)
│ │ │ │ └── ui/ # Reusable UI components
│ │ │ │ ├── button.tsx
│ │ │ │ ├── dialog.tsx
│ │ │ │ ├── drawer.tsx
│ │ │ │ ├── separator.tsx
│ │ │ │ ├── skeleton.tsx # Loading skeleton component
│ │ │ │ ├── sonner.tsx # Toast notifications
│ │ │ │ └── toggle.tsx
│ │ │ ├── data/ # Static data
│ │ │ │ └── sample-elements.ts # FPGA element data structures
│ │ │ ├── lib/ # Core library code
│ │ │ │ ├── services/ # Application services
│ │ │ │ │ └── canvas-history.ts # Implements undo/redo for canvas
│ │ │ │ ├── types/ # TypeScript type definitions
│ │ │ │ │ └── types.ts # Core type definitions
│ │ │ │ └── utils.ts # Utility functions
│ │ │ ├── App.tsx # Main application component
│ │ │ └── main.tsx # Application entry point
│ │ ├── package.json # Frontend dependencies
│ │ ├── tsconfig.json # TypeScript configuration
│ │ ├── vercel.json # Vercel deployment configuration
│ │ ├── vite.config.ts # Vite configuration
│ │ └── tailwind.config.js # TailwindCSS configuration
│ ├── Backend/ # Node.js backend for file processing
│ │ ├── src/ # Backend source code
│ │ │ ├── controllers/ # Request handlers
│ │ │ │ ├── fileController.ts # Handles file uploads and processing
│ │ │ │ └── exampleController.ts # Manages example files
│ │ │ ├── routes/ # API routes
│ │ │ │ ├── fileRoutes.ts # File upload/processing endpoints
│ │ │ │ └── exampleRoutes.ts # Example file endpoints
│ │ │ ├── services/ # Business logic services
│ │ │ │ ├── parserService.ts # File parsing orchestration
│ │ │ │ └── storageService.ts # File storage management
│ │ │ ├── parsers/ # File parsers
│ │ │ │ ├── verilogParser.ts # Parses .v files
│ │ │ │ └── sdfParser.ts # Parses .sdf files
│ │ │ ├── utils/ # Utility functions
│ │ │ │ └── fileUtils.ts # File handling utilities
│ │ │ └── server.ts # Express server setup
│ │ ├── package.json # Backend dependencies
│ │ └── tsconfig.json # TypeScript configuration
│
├── Documents/ # Project documentation
│ ├── FunctionalSpecifications/
│ ├── TechnicalSpecifications/
│ ├── Management/
│ ├── QA/
│ └── UserManual/
├── README.md # Project overview
└── Scripts/ # Utility scripts
Key Components and Their Functions:
Core Frontend Components:
- App.tsx: Main application component managing state (activeView, tabs, examples)
- TabDisplayer.tsx: Controls the view mode switching between Code and Simulation
- SimulationCanvas.tsx: Main canvas for rendering FPGA visualizations
- CodeEditor.tsx: Monaco-based editor with Verilog syntax highlighting
File Management:
- ExamplesDrawer.tsx: Side drawer showing available examples with metadata
- Example.tsx: Individual example component with click handling
- AddExampleModal.tsx: Modal for importing new example files
Navigation and Controls:
- Navbar.tsx: Top navigation with export functionality and view mode controls
- TabsBar.tsx: Multi-tab interface for switching between open files
- CanvasActionBar.tsx: Controls for simulation playback and canvas manipulation
Parser Services:
- v-parser.ts: Parses Verilog (.v) files into structured JSON data
- sdf-parser.ts: Parses Standard Delay Format (.sdf) files
- parser.ts: Combines results from both parsers into a unified data model
Data Types and Models:
- types.ts: Core TypeScript type definitions for the application
- sample-elements.ts: Example data structures for FPGA elements
UI Infrastructure:
- theme-provider.tsx: Handles light/dark theme switching
- ui/: Reusable UI components built on Radix UI primitives
- button.tsx, dialog.tsx, drawer.tsx, dropdown-menu.tsx, etc.
- skeleton.tsx: Loading placeholder components
- sonner.tsx: Toast notification system
- tabs.tsx: Tab component for switching between views
Utility Functions:
- utils.ts: Helper functions for CSS class management, file handling, etc.
- services/canvas-history.ts: Undo/redo functionality for canvas operations
Backend Integration:
- The frontend communicates with the backend for file parsing and processing
- File upload handling via HTTP endpoints
- JSON model retrieval for visualization
- Fonts: Use sans-serif fonts such as Inter, Roboto, or Helvetica for readability.
- Headings:
- Use
#(H1) only for the main document title. - Use
##(H2) for major sections, and###(H3) for subsections.
- Use
- Code Blocks:
- Use backticks (
```) for code snippets with proper language tagging (e.g.,tsx,ts,json).
- Use backticks (
- Tables:
- Alternate row colors and consistent column widths for readability.
- Diagrams:
- Diagrams should be vector-based or SVG for scalability, with clear labels and color-coded components.
- File Naming Convention:
- Use
PascalCasefor documentation files. Example:TechnicalSpecification.md
- Use
- Content Style:
- Use concise and objective language.
- Prefer active voice (“The user clicks…” vs. “The button is clicked…”).
- Maintain consistent terminology for key concepts like “BEL”, “canvas”, “example”.
- Versioning:
- Maintain a version log in the header with dates and author notes.
- Languages: TypeScript for both frontend and backend.
- Conventions:
- Use
camelCasefor variables and functions (loadExample,uploadFile) - Use
PascalCasefor components (SimulationCanvas.tsx,ExampleDrawer.tsx) - Constants in
UPPER_SNAKE_CASE
- Use
- Formatting:
- Enforce formatting with Prettier (
.prettierrc). - Use ESLint (
.eslintrc) to maintain code quality.
- Enforce formatting with Prettier (
- Comments & Docstrings:
- Use JSDoc for function documentation.
- Comment complex logic or non-obvious code decisions.
- Preloaded Examples:
- A library of preloaded FPGA examples (
.vand.sdf) is provided.
- A library of preloaded FPGA examples (
- File Upload:
- Teachers can upload new files to create custom examples.
- Export:
- Users can export the current design as a
.zipfile containing the associated.vand.sdffiles.
- Users can export the current design as a
- Code Editor:
- Integrated Monaco editor with Verilog syntax highlighting.
- Supports real-time update of the FPGA visualization.
- Displays line numbers and syntax error highlighting.
- Simulation Controls:
- Play: Start simulation with continuous frame updates.
- Pause: Halt simulation while preserving current state.
- Step: Advance simulation by one time unit (asynchronous operation).
- Speed: Adjust playback rate (x0.5, x1, x2, x4) affecting the timing calculations.
- Reset: Return the simulation to its initial state (all signals and components).
- Processing Mode: Toggle between synchronous (blocking UI) and asynchronous (background) simulation processing, providing clear visual feedback during simulation execution.
- 2D Layout Rendering:
- Renders FPGA components (BELs) and signal connections on HTML Canvas.
- Highlights active elements and uses color coding for signals.
- Navigation:
- Supports zooming and panning.
- Interaction:
- Displays tooltips or info panels on hover.
- Optionally allows dragging of components for layout adjustments.
- Data Input:
- Uses the JSON model generated from parsed
.vand.sdffiles.
- Uses the JSON model generated from parsed
- Animation & Timing:
- Animates signal propagation based on timing data.
- Control Flow:
- Advances simulation in discrete time steps and updates the Canvas in real time.
A typical MVP screen includes:
- Header: Project Title, Navigation, Simulation Controls
- Left Panel: Code Editor (Verilog display, error logs)
- Right Panel: FPGA Visualization (HTML Canvas rendering)
- Footer: Zoom controls, status/error messages
- Loading an Example:
- User selects a preloaded example.
- The code editor loads the example; FPGA visualization updates accordingly.
- Uploading Files:
- User clicks "Import" and selects
.vand.sdffiles. - The backend processes the files; on success, the visualization and code editor update; on error, descriptive messages are displayed.
- User clicks "Import" and selects
- Running the Simulation:
- Teacher clicks "Play" to start the simulation.
- The animation displays signal propagation; simulation controls (Pause, Step, Speed) adjust the simulation.
- Exporting the Design:
- User clicks "Export" to download a
.zipfile containing the current.vand.sdffiles.
- User clicks "Export" to download a
| Error Category | Error Types | Example Message | User Experience |
|---|---|---|---|
| File Upload | Invalid Format | ❌ "Unsupported file format (.txt). Please upload only .v or .sdf files." | Toast notification with red icon |
| Size Exceeded | ❌ "File size exceeds 50MB limit. Please reduce file complexity or split into multiple files." | Modal dialog with warning icon | |
| Corrupt File | Toast notification with guidance | ||
| Code Editor | Syntax Error | 🔍 "Line 42: Unexpected token '{'. Expected ';' at end of line 41." | Inline editor highlighting with fix suggestion |
| Reference Error | 🔍 "Line 87: 'clock_in' used but not declared." | Squiggly underline with hover details | |
| Missing Module | Warning banner above editor | ||
| Simulation | Timing Conflict | Highlighted wire in visualization | |
| Missing Connection | ❌ "Cannot simulate: missing connection between FF1.Q and LUT2.A" | Error panel with visual indicator on canvas | |
| State Error | Warning badge on component | ||
| Rendering | Canvas Error | Status message in footer | |
| Layout Overflow | ℹ️ "Design too large for viewport. Use zoom controls to adjust view." | Info badge with zoom controls highlight |
| Error Category | HTTP Status | Error Code | Example Response |
|---|---|---|---|
| File Processing | 400 | FILE_PARSE_ERROR |
{"error":true,"code":"FILE_PARSE_ERROR","message":"Invalid SDF timing format on line 156","details":"Expected numeric value but found 'x'","status":400} |
| 413 | FILE_SIZE_EXCEEDED |
{"error":true,"code":"FILE_SIZE_EXCEEDED","message":"File size exceeds 50MB limit","details":"Maximum allowed size is 50MB, received 68MB","status":413} |
|
| 415 | UNSUPPORTED_FORMAT |
{"error":true,"code":"UNSUPPORTED_FORMAT","message":"Unsupported file format","details":"Only .v and .sdf files are supported","status":415} |
|
| Resource Access | 404 | EXAMPLE_NOT_FOUND |
{"error":true,"code":"EXAMPLE_NOT_FOUND","message":"Example '2ffs_VTR' not found","details":"Verify example name or browse available examples","status":404} |
| Data Validation | 422 | VALIDATION_ERROR |
{"error":true,"code":"VALIDATION_ERROR","message":"Invalid simulation parameters","details":"Time step must be positive integer","status":422} |
| Server Errors | 500 | SERVER_ERROR |
{"error":true,"code":"SERVER_ERROR","message":"Internal server error occurred","details":"Error reference: #E12345","status":500} |
| 503 | SERVICE_UNAVAILABLE |
{"error":true,"code":"SERVICE_UNAVAILABLE","message":"Service temporarily unavailable","details":"Try again later","status":503} |
Each error includes:
- Clear error identification
- Actionable guidance for resolution
- Reference codes for support (where applicable)
- Appropriate visual indicators based on severity
- HTML Canvas Rendering:
- Use
requestAnimationFramefor smooth animations. - Render only visible or active elements based on current zoom and pan.
- Use
- Batch Updates:
- Minimize re-renders by batching simulation frame updates.
| File Type | Recommended Limit | Maximum Limit | Handling Strategy |
|---|---|---|---|
| .sdf | 10MB | 50MB | Warn user; use chunked processing |
| .v | 5MB | 25MB | Warn user; display performance notice |
-
Exceeding Maximum Limits:
- Files exceeding maximum limits will be rejected with a clear error message
- Users will receive guidance on how to split or reduce file size
- Example error: "File size exceeds 50MB limit. Please reduce file complexity or split into multiple files."
-
Processing Strategy:
- Large files within limits use progressive loading indicators
- Memory usage monitoring prevents browser crashes
- Automatic background processing for files near maximum limits
- Local Storage:
- Cache JSON models, user settings, and preloaded examples in localStorage.
- File Fingerprinting:
- Detect file changes to prevent redundant parsing.
- Rendering Cache:
- Cache precomputed layouts for fast re-rendering.
- Multiple Browser Tabs:
- Supports usage across multiple tabs (primarily single-user local use).
- Session Persistence:
- Maintain user settings (theme, zoom level, last used files) across reloads.
To set up the development environment, run the following commands:
For the frontend:
cd code/frontend
npm install
npm run dev
For the backend:
cd code/backend
npm install
npm run dev
- File Storage:
- Store uploaded files in IndexedDB.
- Cache JSON models and user preferences in localStorage.
- Data Lifecycle:
- Provide options to clear temporary files; auto-cleanup of unused files.
- Offer export functionality.
- Privacy:
- All processing occurs locally; no data is transmitted externally.
Example Dockerfile for containerized deployment (text diagram):
# Use node as the base image
FROM node:23-alpine
# Set working directory
WORKDIR /app
RUN pwd
RUN ls
# Copy package files
COPY Code/Frontend/package.json Code/Frontend/package-lock.json ./
# Install dependencies
RUN npm ci
# Copy app source
COPY Code/Frontend ./
# Build the app
RUN npm run build
# Expose the port
EXPOSE 4173
# Run preview server
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0"]
- Build Process:
npm run build
- Deployment Configuration:
- Configure GitHub Actions for automated deployment.
- Set proper base paths and SPA routing.
- Configure caching headers.
- Backend Considerations:
- Provide API documentation.
- Include fallback processing methods on the frontend.
- Development Logging:
- Detailed console logs, performance metrics, and API request/response data.
- Production Logging:
- Error-only logging with optional verbose logs.
- Local log storage with rotation and export options.
- Crash Reporting:
- Capture unhandled exceptions and generate crash reports.
- Option for anonymous crash data reporting (opt-in).
graph TD
A["Web Browser UI"] --> B["React Application (Vite)"]
B --> C["Express.js Backend (Node.js)"]
C --> D["File Parsers (.v, .sdf)"]
graph LR
A[Upload Files] --> B[Validate Format]
B --> C[Parse Content]
C --> D[Generate JSON Model]
D --> E[Return JSON to Frontend]
graph TD
A["Select Example / Upload Files"] --> B["Receive Processing Feedback"]
B --> C["Display Code in Editor"]
C --> D["Render FPGA Layout on Canvas"]
D --> E["Control Simulation (Play, Pause, Step, Speed)"]
Text Table:
| Endpoint | Method | Purpose | Request Body | Response |
|---|---|---|---|---|
| /api/upload | POST | Upload .sdf and .v files | Multipart form data | Processing status, ID |
| /api/model/:id | GET | Retrieve generated JSON model | - | JSON model data |
| /api/status/:id | GET | Check processing progress | - | Status information |
| /api/examples | GET | List available example files | - | List of examples |
| /api/example/:name | GET | Retrieve specific example model | - | JSON model data |
Runtime Dependencies:
- @monaco-editor/react: ^4.7.0
- @radix-ui/react-dialog: ^1.1.6
- @radix-ui/react-dropdown-menu: ^2.1.6
- @radix-ui/react-label: ^2.1.2
- @radix-ui/react-separator: ^1.1.2
- @radix-ui/react-slot: ^1.1.2
- @radix-ui/react-tabs: ^1.1.3
- @radix-ui/react-toggle: ^1.1.2
- @radix-ui/react-toggle-group: ^1.1.2
- @radix-ui/react-tooltip: ^1.1.8
- class-variance-authority: ^0.7.1
- clsx: ^2.1.1
- file-saver: ^2.0.5
- fs: ^0.0.1-security
- jszip: ^3.10.1
- lucide-react: ^0.476.0
- next-themes: ^0.4.6
- react: ^19.0.0
- react-dom: ^19.0.0
- react-router: ^7.2.0
- sonner: ^2.0.1
- tailwind-merge: ^3.0.2
- tailwindcss-animate: ^1.0.7
- vaul: ^1.1.2
Development Dependencies:
- @eslint/js: ^9.21.0
- @tailwindcss/vite: ^4.0.9
- @types/file-saver: ^2.0.7
- @types/node: ^22.13.5
- @types/react: ^19.0.10
- @types/react-dom: ^19.0.4
- @vitejs/plugin-react: ^4.3.4
- @vitest/coverage-v8: ^3.0.7
- @vitest/ui: ^3.0.7
- autoprefixer: ^10.4.20
- eslint: ^9.21.0
- eslint-plugin-react-hooks: ^5.0.0
- eslint-plugin-react-refresh: ^0.4.19
- globals: ^15.15.0
- postcss: ^8.5.3
- tailwindcss: ^4.0.9
- typescript: ~5.7.2
- typescript-eslint: ^8.24.1
- vite: ^6.2.0
- vitest: ^3.0.7
- Test individual components and functions
- Validate file parsing logic
- Test simulation algorithms
- Verify UI component rendering
- Test end-to-end workflow
- Verify file upload and processing
- Test simulation controls
- Validate FPGA visualization
- Measure rendering performance
- Test with large files
- Evaluate memory usage
- Verify animation smoothness
- Test with sample users
- Gather feedback on usability
- Verify educational effectiveness
- Identify improvement areas
- Input validation for all file uploads
- Sanitize user inputs
- Local processing to avoid data transmission
- Secure storage of user files
This Technical Specification outlines a comprehensive, local-first FPGA signal propagation simulator designed for educational use. Teachers can select from preloaded FPGA examples or upload custom .v and .sdf files, which are processed into a JSON model and rendered on an HTML Canvas. The solution features an integrated code editor, robust simulation controls, detailed error handling, and efficient performance optimizations. Developed in TypeScript and deployable locally via Vite and Express.js—with optional static hosting on Vercel—the simulator effectively bridges FPGA theory with practical, visual learning while ensuring data privacy.
End of Document