Skip to content

Commit

Permalink
feat: support for yosys in colibri with webassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
qarlosalberto committed May 21, 2024
1 parent 0502d24 commit d5dd14a
Show file tree
Hide file tree
Showing 32 changed files with 2,017 additions and 974 deletions.
18 changes: 18 additions & 0 deletions buildLinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
OUTPUT_DIR=/tmp/vscode-terosHDL
CURRENT_DIR=$(pwd)

rm -rf $OUTPUT_DIR
cp -R . $OUTPUT_DIR

cd $OUTPUT_DIR
./clean.sh

# Colibri
cd packages/colibri
yarn install

# TerosHDL
cd ../teroshdl
yarn install
yarn package
cp -f ./*.vsix $CURRENT_DIR
4 changes: 3 additions & 1 deletion packages/colibri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ coverage
yarn.lock
package-lock.json
test_folder
*.save
*.save
examples/yosys/**/*.json
examples/yosys/**/*.out
31 changes: 31 additions & 0 deletions packages/colibri/jest.config-not-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"preset": "ts-jest",
"testEnvironment": "node",
"collectCoverage": true,
"coverageDirectory": "coverage",
"coveragePathIgnorePatterns": [
"src/config/config_declaration.ts",
"src/parser"
],
"coverageReporters": [
"text",
"clover",
"cobertura"
],
"reporters": [
"default",
[
"jest-html-reporters",
{
"publicPath": "./test-report",
"filename": "test-report.html",
"pageTitle": "Test Report",
"urlForTestFiles": "https://github.com/TerosTechnology/colibri/tree/main/"
}
]
],
"testPathIgnorePatterns": [
"tests_impr",
"tests/yosys"
]
}
15 changes: 13 additions & 2 deletions packages/colibri/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"preset": "ts-jest",
"preset": "ts-jest/presets/default-esm",
"testEnvironment": "node",
"collectCoverage": true,
"coverageDirectory": "coverage",
Expand All @@ -26,5 +26,16 @@
],
"testPathIgnorePatterns": [
"tests_impr"
]
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"useESM": true
}
]
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
}
}
6 changes: 4 additions & 2 deletions packages/colibri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"compile": "tsc -b tsconfig.json && npm run copy-files",
"copy-files": "python3 copy_files.py",
"lint": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' eslint . --quiet --ext .ts",
"test": "node --trace-warnings --experimental-vm-modules ./node_modules/.bin/jest --forceExit --runInBand",
"test-win": "node --trace-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --forceExit --runInBand --detectOpenHandles"
"test-esm": "node --trace-warnings --experimental-vm-modules ./node_modules/.bin/jest --forceExit --runInBand",
"test": "node --trace-warnings --experimental-vm-modules ./node_modules/.bin/jest --forceExit --runInBand --config ./jest.config-not-esm.json"
},
"directories": {
"lib": "./lib",
Expand All @@ -53,6 +53,7 @@
"@oclif/plugin-plugins": "^2.0.1",
"@types/node": "^17.0.31",
"@types/nunjucks": "^3.1.4",
"@yowasp/yosys": "0.41.721",
"chokidar": "3.5.3",
"cli-color": "^2.0.3",
"clone": "^2.1.2",
Expand Down Expand Up @@ -84,6 +85,7 @@
"@types/cli-color": "^2.0.2",
"@types/jest": "^29.4.3",
"@types/js-yaml": "^4.0.5",
"@types/temp": "^0.9.4",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"assert": "^2.0.0",
Expand Down
1,436 changes: 724 additions & 712 deletions packages/colibri/src/config/config_declaration.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/colibri/src/config/config_web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1474,10 +1474,10 @@ export const WEB_CONFIG = `
<span class="markConfig badge bg-secondary" id="mark_schematic-general-backend"></span>
</label>
<select class="form-select" aria-label="Select the backend:" id="schematic-general-backend">
<option value='yowasp'>YoWASP</option>
<option value='yosys'>Yosys</option>
<option value='yosys_ghdl'>GHDL + Yosys</option>
<option value='yosys_ghdl_module'>GHDL (module) + Yosys</option>
<option value='yowasp'>YoWASP (Only Verilog/SV)</option>
<option value='yosys'>Yosys (Only Verilog/SV)</option>
<option value='yosys_ghdl'>GHDL + Yosys (VHDL+Verilog/SV)</option>
<option value='standalone'>Standalone (Verilog/SV)</option>
</select>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/colibri/src/config/helpers/configs/schematic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ backend:
description: "Select the backend:"
type: select
options:
yowasp: "YoWASP"
yosys: "Yosys"
yosys_ghdl: "GHDL + Yosys"
yosys_ghdl_module: "GHDL (module) + Yosys"
yowasp: "YoWASP (Only Verilog/SV)"
yosys: "Yosys (Only Verilog/SV)"
yosys_ghdl: "GHDL + Yosys (VHDL+Verilog/SV)"
standalone: "Standalone (Verilog/SV)"
value: "yowasp"

extra:
Expand Down
23 changes: 16 additions & 7 deletions packages/colibri/src/config/web_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,10 @@ <h6 class="card-subtitle mb-2 text-muted"></h6>
<option value='none'>None</option>
</select>
</div>







<div class="mb-3">
<label for="documentation-general-tasks" class="form-label">
Include tasks:
Expand Down Expand Up @@ -1452,10 +1453,10 @@ <h6 class="card-subtitle mb-2 text-muted"></h6>
<span class="markConfig badge bg-secondary" id="mark_schematic-general-backend"></span>
</label>
<select class="form-select" aria-label="Select the backend:" id="schematic-general-backend">
<option value='yowasp'>YoWASP</option>
<option value='yosys'>Yosys</option>
<option value='yosys_ghdl'>GHDL + Yosys</option>
<option value='yosys_ghdl_module'>GHDL (module) + Yosys</option>
<option value='yowasp'>YoWASP (Only Verilog/SV)</option>
<option value='yosys'>Yosys (Only Verilog/SV)</option>
<option value='yosys_ghdl'>GHDL + Yosys (VHDL+Verilog/SV)</option>
<option value='standalone'>Standalone (Verilog/SV)</option>
</select>
</div>

Expand Down Expand Up @@ -4686,6 +4687,8 @@ <h4 class="card-subtitle text-muted">Simulation</h4>
config["documentation"]["general"]["process"] = element_value
element_value = document.getElementById("documentation-general-functions").value;
config["documentation"]["general"]["functions"] = element_value
element_value = document.getElementById("documentation-general-tasks").value;
config["documentation"]["general"]["tasks"] = element_value
element_value = document.getElementById("documentation-general-magic_config_path").value;
config["documentation"]["general"]["magic_config_path"] = element_value
config["editor"] = {}
Expand Down Expand Up @@ -5290,6 +5293,7 @@ <h4 class="card-subtitle text-muted">Simulation</h4>
document.getElementById("documentation-general-types").value = config["documentation"]["general"]["types"];
document.getElementById("documentation-general-process").value = config["documentation"]["general"]["process"];
document.getElementById("documentation-general-functions").value = config["documentation"]["general"]["functions"];
document.getElementById("documentation-general-tasks").value = config["documentation"]["general"]["tasks"];
document.getElementById("documentation-general-magic_config_path").value = config["documentation"]["general"]["magic_config_path"];
document.getElementById("editor-general-stutter_comment_shortcuts").checked = config["editor"]["general"]["stutter_comment_shortcuts"];
document.getElementById("editor-general-stutter_block_width").value = config["editor"]["general"]["stutter_block_width"];
Expand Down Expand Up @@ -5599,6 +5603,11 @@ <h4 class="card-subtitle text-muted">Simulation</h4>
}
document.getElementById("mark_documentation-general-functions").innerHTML = mark;
mark = "";
if (projectName !== undefined && config["documentation"]["general"]["tasks"] != undefined) {
mark = MODIFIEDMSG;
}
document.getElementById("mark_documentation-general-tasks").innerHTML = mark;
mark = "";
if (projectName !== undefined && config["documentation"]["general"]["magic_config_path"] != undefined) {
mark = MODIFIEDMSG;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/colibri/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export * as process from './process/export_t';
export * as template from './template/export_t';
export * as project_manager from './project_manager/export_t';
export * as config from './config/export_t';
export * as utils from './utils/export_t';
export * as utils from './utils/export_t';
export * as yosys from './yosys/export_t';
16 changes: 14 additions & 2 deletions packages/colibri/src/process/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import { OS, e_sentence } from "./common";
import * as os_lib from "os";
import * as path_lib from 'path';
import { makeid } from '../utils/common_utils';
import * as file_utils from '../utils/file_utils';
import * as fs from 'fs';
import * as temp from 'temp';

/**
* Get the current operative system name
Expand Down Expand Up @@ -101,8 +103,6 @@ function get_sentence_windows(sentence_type: e_sentence): string {
* @returns Temporal file path
**/
export function create_temp_file(content: string): string {
const temp = require('temp');

const temp_file = temp.openSync();
if (temp_file === undefined) {
throw "Unable to create temporary file";
Expand All @@ -112,6 +112,10 @@ export function create_temp_file(content: string): string {
return temp_file.path;
}

export function getTempFolder(): string {
return os_lib.tmpdir();
}

/**
* Get the home directory path
* @returns Home directory path
Expand All @@ -130,4 +134,12 @@ export function get_random_folder_in_home_directory(): string {
const random_id = makeid(5);
const random_folder = path_lib.join(user_hom_dir, `.teroshdl_${random_id}_`);
return random_folder;
}

export function createTempFileInHome(content: string): string {
const user_hom_dir = get_home_directory();
const random_id = makeid(5);
const filePath = path_lib.join(user_hom_dir, `.teroshdl_${random_id}`);
file_utils.save_file_sync(filePath, content);
return filePath;
}
Loading

0 comments on commit d5dd14a

Please sign in to comment.