Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROHD Module Hierarchy and Signals Visualization (Flutter UI) #435

Merged
merged 72 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2569e4d
Add simple inspector_service
quekyj Oct 25, 2023
ea6a21a
Add config.yaml for devtool extension
quekyj Oct 27, 2023
88ca48b
Add inspector service and the extension registration
quekyj Nov 2, 2023
27f32fa
Add rohd devtools extension flutter app
quekyj Nov 2, 2023
a64c0df
rename service extension method
quekyj Nov 2, 2023
e6dffb1
modified the path to rohd
quekyj Nov 2, 2023
18fb317
Added EvalOnDartLibrary use case
quekyj Nov 6, 2023
d5bf89e
Make ModuleTree a Singleton instead direct static properties
quekyj Nov 7, 2023
173761b
Manage to get the JSON data from ROHD package
quekyj Nov 7, 2023
fd17799
Added the tree structure
quekyj Nov 9, 2023
d2183e3
Clean unuse code and convention
quekyj Nov 9, 2023
c03f792
Tried send JSON to EvalOnDartLibrary
quekyj Nov 9, 2023
ddfc618
Add toJSON for Logic and LogicStructure
quekyj Nov 10, 2023
0116095
Clean up the inspector service
quekyj Nov 10, 2023
9d716ad
Use back the default example code
quekyj Nov 10, 2023
0729a81
make toMap instead of toJSOn to avoid double encode
quekyj Nov 10, 2023
7dff78f
Fix Dart analyze
quekyj Nov 10, 2023
43be2a3
update the generation of the tree
quekyj Nov 17, 2023
1b10591
Add simple tree view UI
quekyj Nov 20, 2023
5da2ec7
Restore the opriginal example
quekyj Nov 30, 2023
8411901
Added the SingleChildScrollView library
quekyj Nov 30, 2023
9d9c235
Add filters
quekyj Dec 15, 2023
2795cdb
Refractor to services
quekyj Dec 15, 2023
82d9d1f
Move all state to riverpod providers
quekyj Dec 18, 2023
fe3be5e
Add provider for search and clean up ui component
quekyj Dec 18, 2023
d609904
Fix missing text search field
quekyj Dec 18, 2023
c10a0e8
Move Scaffold body to ui widget
quekyj Dec 19, 2023
4677ef8
Fix Dart suggestion
quekyj Dec 19, 2023
59586b0
Added filter to signals search
quekyj Dec 19, 2023
29356a3
Refractor by adding Signal Model
quekyj Dec 19, 2023
0e93036
Rename tree module to model
quekyj Dec 20, 2023
e67e63c
Refractor code and rename classes
quekyj Dec 20, 2023
15c6184
Add mocktail mock dependencies
quekyj Dec 20, 2023
f9613d7
Refractor consumer widget to consumer stateful widget
quekyj Dec 26, 2023
af1dcf4
Added widget test
quekyj Dec 26, 2023
ba3983a
delete the setModule listener (can't fix the bug)
quekyj Dec 26, 2023
4c3c009
removed unused module
quekyj Dec 26, 2023
0ab1223
Fix alignment issue
quekyj Jan 2, 2024
8af7877
Add vertical scroll, horizontal not work
quekyj Jan 2, 2024
995decc
Added automated build of the devtool extension
quekyj Jan 3, 2024
e282ba3
Added scroll vertical and horizontal
quekyj Jan 3, 2024
ac16393
Fix layout scrolling issue
quekyj Jan 3, 2024
f66eba3
Fix the github action won't run
quekyj Jan 5, 2024
66a3582
Added sample example
quekyj Jan 5, 2024
72d4f86
Merge branch 'main' into rohd-service-provider
quekyj Jan 5, 2024
6558f45
Added toMap() to LogicStructure
quekyj Jan 5, 2024
a5ad6a6
Use chip icon for devtool tab
quekyj Jan 5, 2024
e2f467e
do not export inspector services for public to use
quekyj Jan 5, 2024
1873bbd
code cleanup
quekyj Jan 5, 2024
b4eddec
update flutter version
quekyj Jan 5, 2024
0f7af4f
Added the header for all of the flutter files
quekyj Jan 5, 2024
2abce0c
use beta channel instead of master
quekyj Jan 8, 2024
f9ec1e3
Add execute permission to the sh files
quekyj Jan 8, 2024
64e8cf0
do not show the waveformviewer
quekyj Jan 8, 2024
6ac823f
removed the import for waveform
quekyj Jan 8, 2024
32a6c9f
ask dart to ignore rohd_devtools_extension
quekyj Jan 8, 2024
c262326
Change toJson and hierarchy to private extension
quekyj Jan 9, 2024
f8cf72f
rearrange import
quekyj Jan 9, 2024
412d6eb
update headers
quekyj Jan 9, 2024
1739bb5
rename signal key to name for clearer meaning
quekyj Jan 9, 2024
ce52a0b
Convert SignalTable to ConsumerStaeful & rename key to name
quekyj Jan 9, 2024
6e4018a
Update input and output type to List<String>
quekyj Jan 9, 2024
78ce2c0
Refractor TreeModel to include SignalModel and removed ambiguos dynam…
quekyj Jan 9, 2024
d35fe15
ignore analysis for inputs
quekyj Jan 9, 2024
c44ee2e
Update Readme.md
quekyj Jan 10, 2024
fc7dbb5
Removed bare url
quekyj Jan 10, 2024
13b3ead
Add showLicensePage
quekyj Jan 11, 2024
6fdc209
Add reminder prompt
quekyj Jan 23, 2024
1b8d8c4
Fix the failing test
quekyj Jan 23, 2024
dd98504
Add header for inspector service
quekyj Jan 23, 2024
18d5523
typo module to model
quekyj Jan 23, 2024
ef7944a
docs: cleanup Readme.md
quekyj Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,24 @@ jobs:
with:
folder: doc/api
branch: docs

build-devtool:
name: Build Devtools
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v2
with:
channel: beta
version: 3.18.0-0.2.pre

- name: Run Flutter Test
run: tool/gh_actions/devtool/run_devtool_test.sh

- name: Build Static Web
run: tool/gh_actions/devtool/build_web.sh


1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ analyzer:
strict-raw-types: true
exclude:
- doc/tutorials/chapter_9/rohd_vf_example
- rohd_devtools_extension

# keep up to date, matching https://dart-lang.github.io/linter/lints/options/options.html
# some lints are not yet available, so disabled and marked with [not currently recognized]
Expand Down
4 changes: 4 additions & 0 deletions extension/devtools/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: rohd
issueTracker: https://github.com/intel/rohd/issues
version: 0.0.1
materialIconCodePoint: '0xe1c5'
89 changes: 89 additions & 0 deletions lib/src/diagnostics/inspector_service.dart
mkorbel1 marked this conversation as resolved.
Show resolved Hide resolved
quekyj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import 'dart:convert';
import 'package:rohd/rohd.dart';

extension _LogicDevToolUtils on Logic {
/// Converts the current object instance into a JSON string.
///
/// This function uses Dart's built-in `json.encode()` method to convert
/// the object's properties into a JSON string. The output string will
/// contain keys such as `name`, `width`, and `value`.
Map<String, dynamic> toMap() => {
'name': name,
'width': width,
'value': value.toString(),
};
}

extension _ModuleDevToolUtils on Module {
/// Convert the [Module] object and its sub-modules into a JSON
/// representation.
///
/// Returns a JSON map representing the [Module] and its properties.
///
/// If [skipCustomModules] is set to `true` (default), sub-modules that are
/// instances of [CustomSystemVerilog] will be excluded from the JSON schema.
Map<String, dynamic> toJson({bool skipCustomModules = true}) {
final json = {
'name': name,
// ignore: invalid_use_of_protected_member
'inputs': inputs.map((key, value) => MapEntry(key, value.toMap())),
'outputs': outputs.map((key, value) => MapEntry(key, value.toMap())),
};

final isCustomModule = this is CustomSystemVerilog;

if (!isCustomModule || !skipCustomModules) {
json['subModules'] = subModules
.where(
(module) => !(module is CustomSystemVerilog && skipCustomModules))
.map((module) => module.toJson(skipCustomModules: skipCustomModules))
.toList();
}

return json;
}

/// Generates a JSON schema representing a tree structure of the [Module]
/// object and its sub-modules.
///
/// The [module] parameter is the root [Module] object for which the JSON
/// schema is generated.
///
/// By default, sub-modules that are instances of [CustomSystemVerilog] will
/// be excluded from the schema.
/// Pass [skipCustomModules] as `false` to include them in the schema.
///
/// Returns a JSON string representing the schema of the [Module] object
/// and its sub-modules.
String buildModuleTreeJsonSchema(Module module,
{bool skipCustomModules = true}) =>
jsonEncode(toJson(skipCustomModules: skipCustomModules));
}

/// `ModuleTree` implements the Singleton design pattern
/// to ensure there is only one instance of it during runtime.
///
/// This class is used to maintain a tree-like structure
/// for managing modules in an application.
class ModuleTree {
/// Private constructor used to initialize the Singleton instance.
ModuleTree._();

/// Singleton instance of `ModuleTree`.
///
/// Always returns the same instance of `ModuleTree`.
static ModuleTree get instance => _instance;
mkorbel1 marked this conversation as resolved.
Show resolved Hide resolved
static final _instance = ModuleTree._();

/// Stores the root Module instance.
static Module? rootModuleInstance;

/// Returns the `hierarchyString` as JSON.
///
/// This getter allows access to the `_hierarchyString` string.
///
/// Returns: string representing hierarchical structure of modules in JSON
/// format.
String get hierarchyJSON =>
rootModuleInstance?.buildModuleTreeJsonSchema(rootModuleInstance!) ?? '';
}
3 changes: 3 additions & 0 deletions lib/src/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:collection/collection.dart';
import 'package:meta/meta.dart';

import 'package:rohd/rohd.dart';
import 'package:rohd/src/diagnostics/inspector_service.dart';
import 'package:rohd/src/utilities/config.dart';
import 'package:rohd/src/utilities/sanitizer.dart';
import 'package:rohd/src/utilities/timestamper.dart';
Expand Down Expand Up @@ -254,6 +255,8 @@ abstract class Module {
}

_hasBuilt = true;

ModuleTree.rootModuleInstance = this;
}

/// Adds a [Module] to this as a subModule.
Expand Down
43 changes: 43 additions & 0 deletions rohd_devtools_extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
30 changes: 30 additions & 0 deletions rohd_devtools_extension/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "f65dd3bac0c44c036fe4b158c5d550c4ec529a60"
channel: "master"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
base_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
- platform: web
create_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
base_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
34 changes: 34 additions & 0 deletions rohd_devtools_extension/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "rohd_devtools_extension",
"request": "launch",
"type": "dart"
},
{
"name": "rohd_devtools_extension (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "rohd_devtools_extension (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "rohd_devtools_extension + simulated environment",
"program": "lib/main.dart",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=use_simulated_environment=true"
],
},
]
}
27 changes: 27 additions & 0 deletions rohd_devtools_extension/README.md
quekyj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ROHD Devtool

The ROHD Devtool provides debugging functionality for hardware designers. Initial proposals and discussions for the devtool can be found at <https://github.com/intel/rohd/discussions/418>.

How to Use the ROHD Devtool:

1. Set a breakpoint on your ROHD design.
2. When the breakpoint is hit, an URL will be outputted.
3. Run the dart devtools command on your terminal.
4. A webpage will open, and you can paste the URL into the webpage.
5. Look for the tab labeled 'ROHD'.

## Contributions

We welcome contributions to the development of the ROHD Devtool. Please refer to our Contributing doc for guidance on how to get started.

## Running Tests on the Devtool

The ROHD Devtool runs in an iframe, which means that the --platform chrome flag is required to ensure tests are run in the browser.

Markdown Block
quekyj marked this conversation as resolved.
Show resolved Hide resolved

```cmd
flutter test --platform chrome Optional[test\modules\tree_structure\model_tree_card_test.dart] > test_output.txt
```

This command will output the test results to a text file named `test_output.txt`.
28 changes: 28 additions & 0 deletions rohd_devtools_extension/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
2 changes: 2 additions & 0 deletions rohd_devtools_extension/devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extensions:
- rohd: true
18 changes: 18 additions & 0 deletions rohd_devtools_extension/lib/main.dart
mkorbel1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// main.dart
// Entry point for main application.
//
// 2024 January 5
// Author: Yao Jing Quek <[email protected]>

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'src/modules/rohd_devtools_module.dart';

void main() {
runApp(const ProviderScope(
child: RohdDevToolsModule(),
));
}
Loading
Loading