From 86bdc23661cd41bd7365f08349e43dc915a7b66d Mon Sep 17 00:00:00 2001 From: Fabien Marteau Date: Fri, 2 Dec 2016 13:46:05 +0100 Subject: [PATCH 001/169] french translation --- app/resources/locale/fr_FR/fr_FR.po | 44 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/app/resources/locale/fr_FR/fr_FR.po b/app/resources/locale/fr_FR/fr_FR.po index 78a656161..90de44b13 100644 --- a/app/resources/locale/fr_FR/fr_FR.po +++ b/app/resources/locale/fr_FR/fr_FR.po @@ -133,6 +133,9 @@ msgid "" "Default toolchain not found. Toolchain will be downloaded. This operation " "requires Internet connection. Do you want to continue?" msgstr "" +"La toolchain par default n'a pas été trouvée. La toolchain va être " +"téléchargée. Cette operation nécessite une connexion internet." +"Voulez-vous continuer ?" #: app/views/menu.html:245 msgid "Disable" @@ -204,7 +207,7 @@ msgstr "Entrer le hostname distant user@host (experimentale)" #: app/scripts/services/tools.service.js:317 msgid "Error: default toolchain not found in '{{dir}}'" -msgstr "" +msgstr "Erreur: La toolchaine par défaut n'a pas été trouvée dans '{{dir}}'" #: app/scripts/services/utils.service.js:610 msgid "Error: {{error}}" @@ -228,15 +231,15 @@ msgstr "Exporter un bloc" #: app/scripts/services/tools.service.js:449 msgid "Extract default apio files..." -msgstr "" +msgstr "Extraction des fichiers apio par défaut..." #: app/scripts/services/tools.service.js:459 msgid "Extract default apio packages..." -msgstr "" +msgstr "Extraction des packets apio par défaut" #: app/scripts/services/tools.service.js:437 msgid "Extract virtual env files..." -msgstr "" +msgstr "Extraction des fichiers d'environnement virtuels" #: app/scripts/services/tools.service.js:211 #: app/scripts/services/tools.service.js:214 @@ -251,6 +254,8 @@ msgstr "Fichier" msgid "" "File {{file}} already exists in the project path. Do you want to replace it?" msgstr "" +"Le Fichier {{file}} existe déjà dans le chemin du projet. Voulez vous le" +"remplacer ?" #: app/scripts/services/tools.service.js:148 msgid "File {{file}} does not exist" @@ -286,7 +291,7 @@ msgstr "Chemin image" #: app/scripts/controllers/menu.js:322 msgid "Image {{name}} saved" -msgstr "" +msgstr "Image {{name}} sauvée" #: app/views/menu.html:73 msgid "Import block" @@ -302,11 +307,11 @@ msgstr "Entrée" #: app/views/menu.html:215 msgid "Install" -msgstr "" +msgstr "Installation" #: app/scripts/services/tools.service.js:454 msgid "Install default apio..." -msgstr "" +msgstr "Installer l'apio par défaut..." #: app/scripts/services/tools.service.js:503 msgid "Installation completed" @@ -324,15 +329,15 @@ msgstr "Une connexion internet est requise" #: app/scripts/services/graph.service.js:134 msgid "Invalid Pull up connection:
block already connected" -msgstr "" +msgstr "Connexion de Pull up invalide:
Le bloc est déjà connecté" #: app/scripts/services/graph.service.js:150 msgid "Invalid Pull up connection:
only Input blocks allowed" -msgstr "" +msgstr "Connexion de Pull up invalide:
Une seule entrée autorisée" #: app/scripts/services/graph.service.js:141 msgid "Invalid block connection:
Pull up already connected" -msgstr "" +msgstr "Connexion de bloc invalide:
Pull up déjà connectée" #: app/scripts/services/graph.service.js:113 msgid "Invalid connection" @@ -340,7 +345,7 @@ msgstr "Connexion invalide" #: app/scripts/services/graph.service.js:127 msgid "Invalid multiple input connections" -msgstr "" +msgstr "Connexions de multiples entrées invalides" #: app/scripts/services/graph.service.js:298 msgid "Label updated" @@ -352,7 +357,7 @@ msgstr "Langage" #: app/scripts/services/tools.service.js:442 msgid "Make virtual env..." -msgstr "" +msgstr "Faire l'environnement virtuel..." #: app/views/menu.html:27 msgid "New project" @@ -372,7 +377,7 @@ msgstr "Ouvrir un projet" #: app/scripts/services/common.service.js:156 msgid "Original file {{file}} does not exist" -msgstr "" +msgstr "Le fichier originel {{file}} n'éxiste pas" #: app/views/menu.html:291 msgid "Output" @@ -412,7 +417,7 @@ msgstr "Hostname distant" #: app/views/menu.html:223 msgid "Remove" -msgstr "" +msgstr "Supprimer" #: app/views/menu.html:110 msgid "Remove selected" @@ -420,7 +425,7 @@ msgstr "Supprimer la selection" #: app/views/menu.html:228 msgid "Reset default" -msgstr "" +msgstr "Réinitialiser avec les paramètres par défaut" #: app/views/menu.html:103 msgid "Reset view" @@ -474,13 +479,12 @@ msgstr "Le projet actuel sera supprimé. Continuer de charger le projet?" #: app/scripts/services/tools.service.js:322 msgid "The toolchain will be removed. Do you want to continue?" -msgstr "" -"Les répertoires de configuration d'Icestudio et apio vont être supprimés. " +msgstr "Les répertoires de configuration d'Icestudio et apio vont être supprimés. " "Voulez-vous continuer?" #: app/scripts/services/tools.service.js:310 msgid "The toolchain will be restored to default. Do you want to continue?" -msgstr "" +msgstr "La toolchain va être restaurée par défaut. Voulez vous continuer ?" #: app/scripts/services/tools.service.js:302 msgid "" @@ -493,6 +497,8 @@ msgid "" "This import operation requires a project path. You need to save the current " "project. Do you want to continue?" msgstr "" +"Cette opération d'import requière un chemin de projet (path). Vous devez" +" sauvez le projet actuel. Voulez vous continuer ?" #: app/views/menu.html:211 msgid "Toolchain" @@ -575,7 +581,7 @@ msgstr "Et" #: app/views/project.html:4 msgid "back" -msgstr "" +msgstr "retour" #. Bit #: app/resources/blocks/labels.js:4 From fbd6a969a034b19ca0750ba548d1dfc3d5cfa1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 2 Dec 2016 16:59:16 +0100 Subject: [PATCH 002/169] Update languages percentage in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99fd33c85..36757d02c 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ NOTE: in Mac OS X this command also generates a **dmg** package. |:----------:|:------------------------------------------:| | English | ![Progress](http://progressed.io/bar/100) | | Spanish | ![Progress](http://progressed.io/bar/100) | -| French | ![Progress](http://progressed.io/bar/84) | +| French | ![Progress](http://progressed.io/bar/96) | | Basque | ![Progress](http://progressed.io/bar/69) | | Galician | ![Progress](http://progressed.io/bar/67) | From 531cc9df4184c7d9db9959b7e98f8e5ec9c44220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sat, 3 Dec 2016 11:42:56 +0100 Subject: [PATCH 003/169] Fix iCE40-HX8K pinout --- app/resources/boards/iCE40-HX8K/pinout.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resources/boards/iCE40-HX8K/pinout.json b/app/resources/boards/iCE40-HX8K/pinout.json index ab7f19a63..4fd6ff653 100644 --- a/app/resources/boards/iCE40-HX8K/pinout.json +++ b/app/resources/boards/iCE40-HX8K/pinout.json @@ -1 +1 @@ -{"pinout": [{"name": "LED0", "value": "B5"}, {"name": "LED1", "value": "B4"}, {"name": "LED2", "value": "A2"}, {"name": "LED3", "value": "A1"}, {"name": "LED4", "value": "C5"}, {"name": "LED5", "value": "C4"}, {"name": "LED6", "value": "B3"}, {"name": "LED7", "value": "C3"}, {"name": "CLK", "value": "J3"}, {"name": "MISO", "value": "P12"}, {"name": "MOSI", "value": "P11"}, {"name": "SCK", "value": "R11"}, {"name": "SS", "value": "R12"}, {"name": "RTS", "value": "B13"}, {"name": "RESET", "value": "N11"}, {"name": "DONE", "value": "M10"}, {"name": "TX", "value": "B12"}, {"name": "RX", "value": "B10"}, {"name": "DCD", "value": "B15"}, {"name": "DSR", "value": "B14"}, {"name": "DTR", "value": "A16"}, {"name": "CTS", "value": "A15"}, {"name": "A16", "value": "A16"}, {"name": "A15", "value": "A15"}, {"name": "B15", "value": "B15"}, {"name": "B13", "value": "B13"}, {"name": "B14", "value": "B14"}, {"name": "B12", "value": "B12"}, {"name": "B11", "value": "B11"}, {"name": "A11", "value": "A11"}, {"name": "B10", "value": "B10"}, {"name": "A10", "value": "A10"}, {"name": "C9", "value": "C9"}, {"name": "A9", "value": "A9"}, {"name": "B9", "value": "B9"}, {"name": "B8", "value": "B8"}, {"name": "A7", "value": "A7"}, {"name": "B7", "value": "B7"}, {"name": "C7", "value": "C7"}, {"name": "A6", "value": "A6"}, {"name": "C6", "value": "C6"}, {"name": "B6", "value": "B6"}, {"name": "C5", "value": "C5"}, {"name": "A5", "value": "A5"}, {"name": "C4", "value": "C4"}, {"name": "B5", "value": "B5"}, {"name": "C3", "value": "C3"}, {"name": "B4", "value": "B4"}, {"name": "B3", "value": "B3"}, {"name": "A2", "value": "A2"}, {"name": "A1", "value": "A1"}, {"name": "R15", "value": "R15"}, {"name": "P16", "value": "P16"}, {"name": "P15", "value": "P15"}, {"name": "N16", "value": "N16"}, {"name": "M15", "value": "M15"}, {"name": "M16", "value": "M16"}, {"name": "L16", "value": "L16"}, {"name": "K15", "value": "K15"}, {"name": "K16", "value": "K16"}, {"name": "K14", "value": "K14"}, {"name": "J14", "value": "J14"}, {"name": "G14", "value": "G14"}, {"name": "F14", "value": "F14"}, {"name": "J15", "value": "J15"}, {"name": "H14", "value": "H14"}, {"name": "H16", "value": "H16"}, {"name": "G15", "value": "G15"}, {"name": "G16", "value": "G16"}, {"name": "F15", "value": "F15"}, {"name": "F16", "value": "F16"}, {"name": "E14", "value": "E14"}, {"name": "E16", "value": "E16"}, {"name": "D15", "value": "D15"}, {"name": "D14", "value": "D14"}, {"name": "B16", "value": "B16"}, {"name": "C16", "value": "C16"}, {"name": "B16", "value": "B16"}, {"name": "R16", "value": "R16"}, {"name": "T15", "value": "T15"}, {"name": "T16", "value": "T16"}, {"name": "T13", "value": "T13"}, {"name": "T14", "value": "T14"}, {"name": "N12", "value": "N12"}, {"name": "P13", "value": "P13"}, {"name": "N10", "value": "N10"}, {"name": "M11", "value": "M11"}, {"name": "T11", "value": "T11"}, {"name": "P10", "value": "P10"}, {"name": "T10", "value": "T10"}, {"name": "R10", "value": "R10"}, {"name": "P8", "value": "P8"}, {"name": "P9", "value": "P9"}, {"name": "T9", "value": "T9"}, {"name": "R9", "value": "R9"}, {"name": "T7", "value": "T7"}, {"name": "T8", "value": "T8"}, {"name": "T6", "value": "T6"}, {"name": "R6", "value": "R6"}, {"name": "T5", "value": "T5"}, {"name": "R5", "value": "R5"}, {"name": "R3", "value": "R3"}, {"name": "R4", "value": "R4"}, {"name": "R2", "value": "R2"}, {"name": "T3", "value": "T3"}, {"name": "T1", "value": "T1"}, {"name": "T2", "value": "T2"}, {"name": "R1", "value": "R1"}, {"name": "P1", "value": "P1"}, {"name": "P2", "value": "P2"}, {"name": "N3", "value": "N3"}, {"name": "N2", "value": "N2"}, {"name": "M2", "value": "M2"}, {"name": "M1", "value": "M1"}, {"name": "L3", "value": "L3"}, {"name": "L1", "value": "L1"}, {"name": "K3", "value": "K3"}, {"name": "K1", "value": "K1"}, {"name": "J2", "value": "J2"}, {"name": "J1", "value": "J1"}, {"name": "H2", "value": "H2"}, {"name": "J3", "value": "J3"}, {"name": "G2", "value": "G2"}, {"name": "H1", "value": "H1"}, {"name": "F2", "value": "F2"}, {"name": "G1", "value": "G1"}, {"name": "E2", "value": "E2"}, {"name": "F1", "value": "F1"}, {"name": "D1", "value": "D1"}, {"name": "D2", "value": "D2"}, {"name": "C1", "value": "C1"}, {"name": "C2", "value": "C2"}, {"name": "B2", "value": "B2"}, {"name": "B1", "value": ""}], "label": "iCE40-HX8K"} \ No newline at end of file +[{"name": "LED0", "value": "B5"}, {"name": "LED1", "value": "B4"}, {"name": "LED2", "value": "A2"}, {"name": "LED3", "value": "A1"}, {"name": "LED4", "value": "C5"}, {"name": "LED5", "value": "C4"}, {"name": "LED6", "value": "B3"}, {"name": "LED7", "value": "C3"}, {"name": "CLK", "value": "J3"}, {"name": "MISO", "value": "P12"}, {"name": "MOSI", "value": "P11"}, {"name": "SCK", "value": "R11"}, {"name": "SS", "value": "R12"}, {"name": "RTS", "value": "B13"}, {"name": "RESET", "value": "N11"}, {"name": "DONE", "value": "M10"}, {"name": "TX", "value": "B12"}, {"name": "RX", "value": "B10"}, {"name": "DCD", "value": "B15"}, {"name": "DSR", "value": "B14"}, {"name": "DTR", "value": "A16"}, {"name": "CTS", "value": "A15"}, {"name": "A16", "value": "A16"}, {"name": "A15", "value": "A15"}, {"name": "B15", "value": "B15"}, {"name": "B13", "value": "B13"}, {"name": "B14", "value": "B14"}, {"name": "B12", "value": "B12"}, {"name": "B11", "value": "B11"}, {"name": "A11", "value": "A11"}, {"name": "B10", "value": "B10"}, {"name": "A10", "value": "A10"}, {"name": "C9", "value": "C9"}, {"name": "A9", "value": "A9"}, {"name": "B9", "value": "B9"}, {"name": "B8", "value": "B8"}, {"name": "A7", "value": "A7"}, {"name": "B7", "value": "B7"}, {"name": "C7", "value": "C7"}, {"name": "A6", "value": "A6"}, {"name": "C6", "value": "C6"}, {"name": "B6", "value": "B6"}, {"name": "C5", "value": "C5"}, {"name": "A5", "value": "A5"}, {"name": "C4", "value": "C4"}, {"name": "B5", "value": "B5"}, {"name": "C3", "value": "C3"}, {"name": "B4", "value": "B4"}, {"name": "B3", "value": "B3"}, {"name": "A2", "value": "A2"}, {"name": "A1", "value": "A1"}, {"name": "R15", "value": "R15"}, {"name": "P16", "value": "P16"}, {"name": "P15", "value": "P15"}, {"name": "N16", "value": "N16"}, {"name": "M15", "value": "M15"}, {"name": "M16", "value": "M16"}, {"name": "L16", "value": "L16"}, {"name": "K15", "value": "K15"}, {"name": "K16", "value": "K16"}, {"name": "K14", "value": "K14"}, {"name": "J14", "value": "J14"}, {"name": "G14", "value": "G14"}, {"name": "F14", "value": "F14"}, {"name": "J15", "value": "J15"}, {"name": "H14", "value": "H14"}, {"name": "H16", "value": "H16"}, {"name": "G15", "value": "G15"}, {"name": "G16", "value": "G16"}, {"name": "F15", "value": "F15"}, {"name": "F16", "value": "F16"}, {"name": "E14", "value": "E14"}, {"name": "E16", "value": "E16"}, {"name": "D15", "value": "D15"}, {"name": "D14", "value": "D14"}, {"name": "B16", "value": "B16"}, {"name": "C16", "value": "C16"}, {"name": "B16", "value": "B16"}, {"name": "R16", "value": "R16"}, {"name": "T15", "value": "T15"}, {"name": "T16", "value": "T16"}, {"name": "T13", "value": "T13"}, {"name": "T14", "value": "T14"}, {"name": "N12", "value": "N12"}, {"name": "P13", "value": "P13"}, {"name": "N10", "value": "N10"}, {"name": "M11", "value": "M11"}, {"name": "T11", "value": "T11"}, {"name": "P10", "value": "P10"}, {"name": "T10", "value": "T10"}, {"name": "R10", "value": "R10"}, {"name": "P8", "value": "P8"}, {"name": "P9", "value": "P9"}, {"name": "T9", "value": "T9"}, {"name": "R9", "value": "R9"}, {"name": "T7", "value": "T7"}, {"name": "T8", "value": "T8"}, {"name": "T6", "value": "T6"}, {"name": "R6", "value": "R6"}, {"name": "T5", "value": "T5"}, {"name": "R5", "value": "R5"}, {"name": "R3", "value": "R3"}, {"name": "R4", "value": "R4"}, {"name": "R2", "value": "R2"}, {"name": "T3", "value": "T3"}, {"name": "T1", "value": "T1"}, {"name": "T2", "value": "T2"}, {"name": "R1", "value": "R1"}, {"name": "P1", "value": "P1"}, {"name": "P2", "value": "P2"}, {"name": "N3", "value": "N3"}, {"name": "N2", "value": "N2"}, {"name": "M2", "value": "M2"}, {"name": "M1", "value": "M1"}, {"name": "L3", "value": "L3"}, {"name": "L1", "value": "L1"}, {"name": "K3", "value": "K3"}, {"name": "K1", "value": "K1"}, {"name": "J2", "value": "J2"}, {"name": "J1", "value": "J1"}, {"name": "H2", "value": "H2"}, {"name": "J3", "value": "J3"}, {"name": "G2", "value": "G2"}, {"name": "H1", "value": "H1"}, {"name": "F2", "value": "F2"}, {"name": "G1", "value": "G1"}, {"name": "E2", "value": "E2"}, {"name": "F1", "value": "F1"}, {"name": "D1", "value": "D1"}, {"name": "D2", "value": "D2"}, {"name": "C1", "value": "C1"}, {"name": "C2", "value": "C2"}, {"name": "B2", "value": "B2"}, {"name": "B1", "value": "B1"}] \ No newline at end of file From a1adbf0988108f6ccaf405a6830b0903659318ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 4 Dec 2016 22:38:46 +0100 Subject: [PATCH 004/169] Fix 8K missing D16 pin --- app/resources/boards/iCE40-HX8K/pinout.json | 2 +- app/resources/boards/iCE40-HX8K/pinout.pcf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/resources/boards/iCE40-HX8K/pinout.json b/app/resources/boards/iCE40-HX8K/pinout.json index 4fd6ff653..a537f2df7 100644 --- a/app/resources/boards/iCE40-HX8K/pinout.json +++ b/app/resources/boards/iCE40-HX8K/pinout.json @@ -1 +1 @@ -[{"name": "LED0", "value": "B5"}, {"name": "LED1", "value": "B4"}, {"name": "LED2", "value": "A2"}, {"name": "LED3", "value": "A1"}, {"name": "LED4", "value": "C5"}, {"name": "LED5", "value": "C4"}, {"name": "LED6", "value": "B3"}, {"name": "LED7", "value": "C3"}, {"name": "CLK", "value": "J3"}, {"name": "MISO", "value": "P12"}, {"name": "MOSI", "value": "P11"}, {"name": "SCK", "value": "R11"}, {"name": "SS", "value": "R12"}, {"name": "RTS", "value": "B13"}, {"name": "RESET", "value": "N11"}, {"name": "DONE", "value": "M10"}, {"name": "TX", "value": "B12"}, {"name": "RX", "value": "B10"}, {"name": "DCD", "value": "B15"}, {"name": "DSR", "value": "B14"}, {"name": "DTR", "value": "A16"}, {"name": "CTS", "value": "A15"}, {"name": "A16", "value": "A16"}, {"name": "A15", "value": "A15"}, {"name": "B15", "value": "B15"}, {"name": "B13", "value": "B13"}, {"name": "B14", "value": "B14"}, {"name": "B12", "value": "B12"}, {"name": "B11", "value": "B11"}, {"name": "A11", "value": "A11"}, {"name": "B10", "value": "B10"}, {"name": "A10", "value": "A10"}, {"name": "C9", "value": "C9"}, {"name": "A9", "value": "A9"}, {"name": "B9", "value": "B9"}, {"name": "B8", "value": "B8"}, {"name": "A7", "value": "A7"}, {"name": "B7", "value": "B7"}, {"name": "C7", "value": "C7"}, {"name": "A6", "value": "A6"}, {"name": "C6", "value": "C6"}, {"name": "B6", "value": "B6"}, {"name": "C5", "value": "C5"}, {"name": "A5", "value": "A5"}, {"name": "C4", "value": "C4"}, {"name": "B5", "value": "B5"}, {"name": "C3", "value": "C3"}, {"name": "B4", "value": "B4"}, {"name": "B3", "value": "B3"}, {"name": "A2", "value": "A2"}, {"name": "A1", "value": "A1"}, {"name": "R15", "value": "R15"}, {"name": "P16", "value": "P16"}, {"name": "P15", "value": "P15"}, {"name": "N16", "value": "N16"}, {"name": "M15", "value": "M15"}, {"name": "M16", "value": "M16"}, {"name": "L16", "value": "L16"}, {"name": "K15", "value": "K15"}, {"name": "K16", "value": "K16"}, {"name": "K14", "value": "K14"}, {"name": "J14", "value": "J14"}, {"name": "G14", "value": "G14"}, {"name": "F14", "value": "F14"}, {"name": "J15", "value": "J15"}, {"name": "H14", "value": "H14"}, {"name": "H16", "value": "H16"}, {"name": "G15", "value": "G15"}, {"name": "G16", "value": "G16"}, {"name": "F15", "value": "F15"}, {"name": "F16", "value": "F16"}, {"name": "E14", "value": "E14"}, {"name": "E16", "value": "E16"}, {"name": "D15", "value": "D15"}, {"name": "D14", "value": "D14"}, {"name": "B16", "value": "B16"}, {"name": "C16", "value": "C16"}, {"name": "B16", "value": "B16"}, {"name": "R16", "value": "R16"}, {"name": "T15", "value": "T15"}, {"name": "T16", "value": "T16"}, {"name": "T13", "value": "T13"}, {"name": "T14", "value": "T14"}, {"name": "N12", "value": "N12"}, {"name": "P13", "value": "P13"}, {"name": "N10", "value": "N10"}, {"name": "M11", "value": "M11"}, {"name": "T11", "value": "T11"}, {"name": "P10", "value": "P10"}, {"name": "T10", "value": "T10"}, {"name": "R10", "value": "R10"}, {"name": "P8", "value": "P8"}, {"name": "P9", "value": "P9"}, {"name": "T9", "value": "T9"}, {"name": "R9", "value": "R9"}, {"name": "T7", "value": "T7"}, {"name": "T8", "value": "T8"}, {"name": "T6", "value": "T6"}, {"name": "R6", "value": "R6"}, {"name": "T5", "value": "T5"}, {"name": "R5", "value": "R5"}, {"name": "R3", "value": "R3"}, {"name": "R4", "value": "R4"}, {"name": "R2", "value": "R2"}, {"name": "T3", "value": "T3"}, {"name": "T1", "value": "T1"}, {"name": "T2", "value": "T2"}, {"name": "R1", "value": "R1"}, {"name": "P1", "value": "P1"}, {"name": "P2", "value": "P2"}, {"name": "N3", "value": "N3"}, {"name": "N2", "value": "N2"}, {"name": "M2", "value": "M2"}, {"name": "M1", "value": "M1"}, {"name": "L3", "value": "L3"}, {"name": "L1", "value": "L1"}, {"name": "K3", "value": "K3"}, {"name": "K1", "value": "K1"}, {"name": "J2", "value": "J2"}, {"name": "J1", "value": "J1"}, {"name": "H2", "value": "H2"}, {"name": "J3", "value": "J3"}, {"name": "G2", "value": "G2"}, {"name": "H1", "value": "H1"}, {"name": "F2", "value": "F2"}, {"name": "G1", "value": "G1"}, {"name": "E2", "value": "E2"}, {"name": "F1", "value": "F1"}, {"name": "D1", "value": "D1"}, {"name": "D2", "value": "D2"}, {"name": "C1", "value": "C1"}, {"name": "C2", "value": "C2"}, {"name": "B2", "value": "B2"}, {"name": "B1", "value": "B1"}] \ No newline at end of file +[{"name": "LED0", "value": "B5"}, {"name": "LED1", "value": "B4"}, {"name": "LED2", "value": "A2"}, {"name": "LED3", "value": "A1"}, {"name": "LED4", "value": "C5"}, {"name": "LED5", "value": "C4"}, {"name": "LED6", "value": "B3"}, {"name": "LED7", "value": "C3"}, {"name": "CLK", "value": "J3"}, {"name": "MISO", "value": "P12"}, {"name": "MOSI", "value": "P11"}, {"name": "SCK", "value": "R11"}, {"name": "SS", "value": "R12"}, {"name": "RTS", "value": "B13"}, {"name": "RESET", "value": "N11"}, {"name": "DONE", "value": "M10"}, {"name": "TX", "value": "B12"}, {"name": "RX", "value": "B10"}, {"name": "DCD", "value": "B15"}, {"name": "DSR", "value": "B14"}, {"name": "DTR", "value": "A16"}, {"name": "CTS", "value": "A15"}, {"name": "A16", "value": "A16"}, {"name": "A15", "value": "A15"}, {"name": "B15", "value": "B15"}, {"name": "B13", "value": "B13"}, {"name": "B14", "value": "B14"}, {"name": "B12", "value": "B12"}, {"name": "B11", "value": "B11"}, {"name": "A11", "value": "A11"}, {"name": "B10", "value": "B10"}, {"name": "A10", "value": "A10"}, {"name": "C9", "value": "C9"}, {"name": "A9", "value": "A9"}, {"name": "B9", "value": "B9"}, {"name": "B8", "value": "B8"}, {"name": "A7", "value": "A7"}, {"name": "B7", "value": "B7"}, {"name": "C7", "value": "C7"}, {"name": "A6", "value": "A6"}, {"name": "C6", "value": "C6"}, {"name": "B6", "value": "B6"}, {"name": "C5", "value": "C5"}, {"name": "A5", "value": "A5"}, {"name": "C4", "value": "C4"}, {"name": "B5", "value": "B5"}, {"name": "C3", "value": "C3"}, {"name": "B4", "value": "B4"}, {"name": "B3", "value": "B3"}, {"name": "A2", "value": "A2"}, {"name": "A1", "value": "A1"}, {"name": "R15", "value": "R15"}, {"name": "P16", "value": "P16"}, {"name": "P15", "value": "P15"}, {"name": "N16", "value": "N16"}, {"name": "M15", "value": "M15"}, {"name": "M16", "value": "M16"}, {"name": "L16", "value": "L16"}, {"name": "K15", "value": "K15"}, {"name": "K16", "value": "K16"}, {"name": "K14", "value": "K14"}, {"name": "J14", "value": "J14"}, {"name": "G14", "value": "G14"}, {"name": "F14", "value": "F14"}, {"name": "J15", "value": "J15"}, {"name": "H14", "value": "H14"}, {"name": "H16", "value": "H16"}, {"name": "G15", "value": "G15"}, {"name": "G16", "value": "G16"}, {"name": "F15", "value": "F15"}, {"name": "F16", "value": "F16"}, {"name": "E14", "value": "E14"}, {"name": "E16", "value": "E16"}, {"name": "D15", "value": "D15"}, {"name": "D16", "value": "D16"}, {"name": "D14", "value": "D14"}, {"name": "C16", "value": "C16"}, {"name": "B16", "value": "B16"}, {"name": "R16", "value": "R16"}, {"name": "T15", "value": "T15"}, {"name": "T16", "value": "T16"}, {"name": "T13", "value": "T13"}, {"name": "T14", "value": "T14"}, {"name": "N12", "value": "N12"}, {"name": "P13", "value": "P13"}, {"name": "N10", "value": "N10"}, {"name": "M11", "value": "M11"}, {"name": "T11", "value": "T11"}, {"name": "P10", "value": "P10"}, {"name": "T10", "value": "T10"}, {"name": "R10", "value": "R10"}, {"name": "P8", "value": "P8"}, {"name": "P9", "value": "P9"}, {"name": "T9", "value": "T9"}, {"name": "R9", "value": "R9"}, {"name": "T7", "value": "T7"}, {"name": "T8", "value": "T8"}, {"name": "T6", "value": "T6"}, {"name": "R6", "value": "R6"}, {"name": "T5", "value": "T5"}, {"name": "R5", "value": "R5"}, {"name": "R3", "value": "R3"}, {"name": "R4", "value": "R4"}, {"name": "R2", "value": "R2"}, {"name": "T3", "value": "T3"}, {"name": "T1", "value": "T1"}, {"name": "T2", "value": "T2"}, {"name": "R1", "value": "R1"}, {"name": "P1", "value": "P1"}, {"name": "P2", "value": "P2"}, {"name": "N3", "value": "N3"}, {"name": "N2", "value": "N2"}, {"name": "M2", "value": "M2"}, {"name": "M1", "value": "M1"}, {"name": "L3", "value": "L3"}, {"name": "L1", "value": "L1"}, {"name": "K3", "value": "K3"}, {"name": "K1", "value": "K1"}, {"name": "J2", "value": "J2"}, {"name": "J1", "value": "J1"}, {"name": "H2", "value": "H2"}, {"name": "J3", "value": "J3"}, {"name": "G2", "value": "G2"}, {"name": "H1", "value": "H1"}, {"name": "F2", "value": "F2"}, {"name": "G1", "value": "G1"}, {"name": "E2", "value": "E2"}, {"name": "F1", "value": "F1"}, {"name": "D1", "value": "D1"}, {"name": "D2", "value": "D2"}, {"name": "C1", "value": "C1"}, {"name": "C2", "value": "C2"}, {"name": "B1", "value": "B1"}, {"name": "B2", "value": "B2"}] \ No newline at end of file diff --git a/app/resources/boards/iCE40-HX8K/pinout.pcf b/app/resources/boards/iCE40-HX8K/pinout.pcf index 177ea7be5..4e5bb62b8 100644 --- a/app/resources/boards/iCE40-HX8K/pinout.pcf +++ b/app/resources/boards/iCE40-HX8K/pinout.pcf @@ -167,8 +167,8 @@ set_io --warn-no-port F16 F16 set_io --warn-no-port E14 E14 set_io --warn-no-port E16 E16 set_io --warn-no-port D15 D15 +set_io --warn-no-port D16 D16 set_io --warn-no-port D14 D14 -set_io --warn-no-port B16 B16 set_io --warn-no-port C16 C16 set_io --warn-no-port B16 B16 @@ -296,5 +296,5 @@ set_io --warn-no-port D1 D1 set_io --warn-no-port D2 D2 set_io --warn-no-port C1 C1 set_io --warn-no-port C2 C2 -set_io --warn-no-port B2 B2 set_io --warn-no-port B1 B1 +set_io --warn-no-port B2 B2 From fc8fab030f484c4a81c2fc0026b825edc2e18224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Mon, 5 Dec 2016 12:49:43 +0100 Subject: [PATCH 005/169] Add constant block --- app/scripts/plugins/shapes/joint.shapes.js | 61 ++++++++++++++++++++++ app/scripts/services/graph.service.js | 59 ++++++++++++++++++++- app/styles/project.css | 31 ++++++++++- app/views/menu.html | 5 +- 4 files changed, 150 insertions(+), 6 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 434d99d7d..e7720cec9 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -313,6 +313,67 @@ joint.shapes.ice.InputView = joint.shapes.ice.IOView; joint.shapes.ice.OutputView = joint.shapes.ice.IOView; +// Constant blocks + +joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ + defaults: joint.util.deepSupplement({ + type: 'ice.Constant', + outPorts: [{ + id: "out", + label: "", + gridUnits: 8 + }], + size: { + width: 96, + height: 64 + } + }, joint.shapes.ice.Model.prototype.defaults) +}); + + +joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ + + template: '\ +
\ + \ + \ +
\ + ', + + initialize: function() { + joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); + + // Prevent paper from handling pointerdown. + this.$box.find('.constant-input').on('mousedown click', function(evt) { evt.stopPropagation(); }); + + this.$box.find('.constant-input').on('change', _.bind(function(evt) { + this.model.attributes.data.value = $(evt.target).val(); + }, this)); + }, + renderLabel: function () { + var name = this.model.attributes.data.label; + this.$box.find('label').text(name); + }, + renderValue: function() { + if (this.model.get('disabled')) { + this.$box.find('.constant-input').css({'display': 'none'}); + } + else { + this.$box.find('.constant-input').val(this.model.get('data').value); + } + }, + clearValue: function () { + this.$box.find('.constant-input').val(''); + }, + update: function () { + this.renderLabel(); + this.renderPorts(); + this.renderValue(); + joint.dia.ElementView.prototype.update.apply(this, arguments); + } +}); + + // Code block joint.shapes.ice.Code = joint.shapes.ice.Model.extend({ diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index d643ef509..259c1bb2c 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -300,6 +300,19 @@ angular.module('icestudio') }); } } + else if (data.blockType == 'basic.constant') { + if (paper.options.enabled) { + alertify.prompt(gettextCatalog.getString('Update the block label'), data.data.label ? ' ' + data.data.label + ' ' : '', + function(evt, label) { + label = label.replace(/ /g, ''); + if (data.data.label != label) { + data.data.label = label; + cellView.renderLabel(); + alertify.success(gettextCatalog.getString('Label updated')); + } + }); + } + } else if (data.blockType == 'basic.code') { if (paper.options.enabled) { var block = { @@ -464,6 +477,7 @@ angular.module('icestudio') blockInstance.data.ports.out.push(outPorts[o]); } blockInstance.position.x = 31 * gridsize; + blockInstance.position.y = 18 * gridsize; if (block) { blockInstance.data.code = block.data.code; @@ -484,8 +498,7 @@ angular.module('icestudio') blockInstance.data = { info: '' }; - blockInstance.position.x = 31 * gridsize; - blockInstance.position.y = 26 * gridsize; + blockInstance.position.y = 30 * gridsize; var cell = addBasicInfoBlock(blockInstance); var cellView = paper.findViewByModel(cell); if (cellView.$box.css('z-index') < zIndex) { @@ -574,6 +587,31 @@ angular.module('icestudio') } }); } + else if (type == 'basic.constant') { + alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), ' C ', + function(evt, name) { + if (name) { + var names = name.replace(/ /g, '').split(','); + blockInstance.position.x = 20 * gridsize; + for (var n in names) { + if (names[n]) { + blockInstance.data = { + label: names[n], + value: '' + }; + var cell = addBasicConstantBlock(blockInstance); + var cellView = paper.findViewByModel(cell); + if (cellView.$box.css('z-index') < zIndex) { + cellView.$box.css('z-index', ++zIndex); + } + blockInstance.position.x += 15 * gridsize; + } + } + } + else { + } + }); + } else { if (block && block.graph && @@ -719,6 +757,9 @@ angular.module('icestudio') else if (blockInstance.type == 'basic.output') { addBasicOutputBlock(blockInstance, disabled); } + else if (blockInstance.type == 'basic.constant') { + addBasicConstantBlock(blockInstance, disabled); + } else { addGenericBlock(blockInstance, deps[blockInstance.type]); } @@ -778,6 +819,20 @@ angular.module('icestudio') return cell; }; + function addBasicConstantBlock(blockInstances, disabled) { + var cell = new joint.shapes.ice.Constant({ + id: blockInstances.id, + blockType: blockInstances.type, + data: blockInstances.data, + label: blockInstances.data.label, + position: blockInstances.position, + disabled: disabled + }); + + addCell(cell); + return cell; + }; + function addBasicCodeBlock(blockInstances, disabled) { var inPorts = []; var outPorts = []; diff --git a/app/styles/project.css b/app/styles/project.css index 8b1986549..412156755 100644 --- a/app/styles/project.css +++ b/app/styles/project.css @@ -82,7 +82,7 @@ } .config-block { - background: #FAFAD2; + background: #fafacd; } .generic-block img { @@ -105,7 +105,7 @@ .io-block { position: absolute; - background: #FAFAD2; + background: #fafacd; border-radius: 5px; border: 2px solid #888; pointer-events: none; @@ -129,6 +129,33 @@ pointer-events: auto; } +.constant-block { + position: absolute; + background: #faeaaf; + border-radius: 5px; + border: 2px solid #888; + pointer-events: none; + -webkit-user-select: none; + z-index: 0; +} + +.constant-block label { + display: block; + margin-top: 4px; + text-align: center; + font-size: 1em; + color: #444; +} + +.constant-block input { + position: absolute; + text-align: center; + left: 5px; + bottom: 5px; + width: 82px; + pointer-events: auto; +} + .code-block { position: absolute; background: #C0DFEB; diff --git a/app/views/menu.html b/app/views/menu.html index a9c61b2f4..a80198e72 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -285,10 +285,11 @@ {{ 'Basic' | translate }} From 44541503d309ba90c946f09dce7b52d3e77ef4df Mon Sep 17 00:00:00 2001 From: obijuan Date: Tue, 6 Dec 2016 13:29:29 +0100 Subject: [PATCH 006/169] Simple switch debouncer added in Logic/Sequential --- .../blocks/logic/sequential/debouncer.iceb | 100 ++++++++++++++++++ app/resources/images/debouncer.svg | 60 +++++++++++ 2 files changed, 160 insertions(+) create mode 100644 app/resources/blocks/logic/sequential/debouncer.iceb create mode 100644 app/resources/images/debouncer.svg diff --git a/app/resources/blocks/logic/sequential/debouncer.iceb b/app/resources/blocks/logic/sequential/debouncer.iceb new file mode 100644 index 000000000..251ca22b1 --- /dev/null +++ b/app/resources/blocks/logic/sequential/debouncer.iceb @@ -0,0 +1,100 @@ +{ + "image": "resources/images/debouncer.svg", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "graph": { + "blocks": [ + { + "id": "980b1169-a2fe-411d-9678-c8ad64a801a6", + "type": "basic.code", + "data": { + "code": "//-- Debouncer Circuit\n//-- It produces a stable output when the\n//-- input signal is bouncing\n\nreg btn_prev = 0;\nreg btn_out_r = 0;\n\nreg [16:0] counter = 0;\n\n\nalways @(posedge clk) begin\n\n //-- If btn_prev and btn_in are differents\n if (btn_prev ^ btn_in == 1'b1) begin\n \n //-- Reset the counter\n counter <= 0;\n \n //-- Capture the button status\n btn_prev <= btn_in;\n end\n \n //-- If no timeout, increase the counter\n else if (counter[16] == 1'b0)\n counter <= counter + 1;\n \n else\n //-- Set the output to the stable value\n btn_out_r <= btn_prev;\n\nend\n\nassign btn_out = btn_out_r;\n", + "ports": { + "in": [ + "clk", + "btn_in" + ], + "out": [ + "btn_out" + ] + } + }, + "position": { + "x": 368, + "y": 120 + } + }, + { + "id": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", + "type": "basic.input", + "data": { + "label": "clk" + }, + "position": { + "x": 152, + "y": 152 + } + }, + { + "id": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", + "type": "basic.input", + "data": { + "label": "btn_in" + }, + "position": { + "x": 152, + "y": 280 + } + }, + { + "id": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", + "type": "basic.output", + "data": { + "label": "btn_out" + }, + "position": { + "x": 872, + "y": 216 + } + } + ], + "wires": [ + { + "source": { + "block": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", + "port": "out" + }, + "target": { + "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", + "port": "clk" + } + }, + { + "source": { + "block": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", + "port": "out" + }, + "target": { + "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", + "port": "btn_in" + } + }, + { + "source": { + "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", + "port": "btn_out" + }, + "target": { + "block": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", + "port": "in" + } + } + ] + }, + "deps": {} +} diff --git a/app/resources/images/debouncer.svg b/app/resources/images/debouncer.svg new file mode 100644 index 000000000..0a5def855 --- /dev/null +++ b/app/resources/images/debouncer.svg @@ -0,0 +1,60 @@ + + + +image/svg+xml \ No newline at end of file From d1da861a8fc74d44a48a29ab4408d8e8533331bb Mon Sep 17 00:00:00 2001 From: obijuan Date: Tue, 6 Dec 2016 13:55:52 +0100 Subject: [PATCH 007/169] Tranlation for the debouncer component --- app/resources/blocks/labels.js | 3 +++ app/resources/locale/en/en.po | 5 +++++ app/resources/locale/es_ES/es_ES.po | 5 +++++ app/resources/locale/template.pot | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/app/resources/blocks/labels.js b/app/resources/blocks/labels.js index f7209d3f2..8c70e2216 100644 --- a/app/resources/blocks/labels.js +++ b/app/resources/blocks/labels.js @@ -54,3 +54,6 @@ gettext('dff_sr') gettext('tff_ar') /// T flip-flop gettext('tff_sr') +/// Debouncer +gettext('debouncer') + diff --git a/app/resources/locale/en/en.po b/app/resources/locale/en/en.po index 3d116c84f..d05c5ec61 100644 --- a/app/resources/locale/en/en.po +++ b/app/resources/locale/en/en.po @@ -598,6 +598,11 @@ msgstr "Combinational" msgid "config" msgstr "Config" +#. Debouncer +#: app/resources/blocks/labels.js:57 +msgid "debouncer" +msgstr "Debouncer" + #. Demux 1:2 #: app/resources/blocks/labels.js:18 msgid "demux_1_2" diff --git a/app/resources/locale/es_ES/es_ES.po b/app/resources/locale/es_ES/es_ES.po index 803984574..e325c9edc 100644 --- a/app/resources/locale/es_ES/es_ES.po +++ b/app/resources/locale/es_ES/es_ES.po @@ -601,6 +601,11 @@ msgstr "Combinacional" msgid "config" msgstr "Config" +#. Debouncer +#: app/resources/blocks/labels.js:57 +msgid "debouncer" +msgstr "Antirrebotes" + #. Demux 1:2 #: app/resources/blocks/labels.js:18 msgid "demux_1_2" diff --git a/app/resources/locale/template.pot b/app/resources/locale/template.pot index 5cbd1d24c..6a5a25ca1 100644 --- a/app/resources/locale/template.pot +++ b/app/resources/locale/template.pot @@ -560,6 +560,11 @@ msgstr "" msgid "config" msgstr "" +#. Debouncer +#: app/resources/blocks/labels.js:57 +msgid "debouncer" +msgstr "" + #. Demux 1:2 #: app/resources/blocks/labels.js:18 msgid "demux_1_2" From e3811371dbe0f3ff6956464655a7e6e146e222ab Mon Sep 17 00:00:00 2001 From: obijuan Date: Tue, 6 Dec 2016 15:35:42 +0100 Subject: [PATCH 008/169] Debouncer: change the pins names to in and out (instead of btn_in, btn_out) --- .../blocks/logic/sequential/debouncer.iceb | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/app/resources/blocks/logic/sequential/debouncer.iceb b/app/resources/blocks/logic/sequential/debouncer.iceb index 251ca22b1..ca7aca8a9 100644 --- a/app/resources/blocks/logic/sequential/debouncer.iceb +++ b/app/resources/blocks/logic/sequential/debouncer.iceb @@ -9,26 +9,6 @@ }, "graph": { "blocks": [ - { - "id": "980b1169-a2fe-411d-9678-c8ad64a801a6", - "type": "basic.code", - "data": { - "code": "//-- Debouncer Circuit\n//-- It produces a stable output when the\n//-- input signal is bouncing\n\nreg btn_prev = 0;\nreg btn_out_r = 0;\n\nreg [16:0] counter = 0;\n\n\nalways @(posedge clk) begin\n\n //-- If btn_prev and btn_in are differents\n if (btn_prev ^ btn_in == 1'b1) begin\n \n //-- Reset the counter\n counter <= 0;\n \n //-- Capture the button status\n btn_prev <= btn_in;\n end\n \n //-- If no timeout, increase the counter\n else if (counter[16] == 1'b0)\n counter <= counter + 1;\n \n else\n //-- Set the output to the stable value\n btn_out_r <= btn_prev;\n\nend\n\nassign btn_out = btn_out_r;\n", - "ports": { - "in": [ - "clk", - "btn_in" - ], - "out": [ - "btn_out" - ] - } - }, - "position": { - "x": 368, - "y": 120 - } - }, { "id": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", "type": "basic.input", @@ -44,7 +24,7 @@ "id": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", "type": "basic.input", "data": { - "label": "btn_in" + "label": "in" }, "position": { "x": 152, @@ -55,46 +35,66 @@ "id": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", "type": "basic.output", "data": { - "label": "btn_out" + "label": "out" }, "position": { "x": 872, "y": 216 } + }, + { + "id": "92490e7e-c3ba-4e9c-a917-2a771d99f1ef", + "type": "basic.code", + "data": { + "code": "//-- Debouncer Circuit\n//-- It produces a stable output when the\n//-- input signal is bouncing\n\nreg btn_prev = 0;\nreg btn_out_r = 0;\n\nreg [16:0] counter = 0;\n\n\nalways @(posedge clk) begin\n\n //-- If btn_prev and btn_in are differents\n if (btn_prev ^ in == 1'b1) begin\n \n //-- Reset the counter\n counter <= 0;\n \n //-- Capture the button status\n btn_prev <= in;\n end\n \n //-- If no timeout, increase the counter\n else if (counter[16] == 1'b0)\n counter <= counter + 1;\n \n else\n //-- Set the output to the stable value\n btn_out_r <= btn_prev;\n\nend\n\nassign out = btn_out_r;\n", + "ports": { + "in": [ + "clk", + "in" + ], + "out": [ + "out" + ] + } + }, + "position": { + "x": 368, + "y": 120 + } } ], "wires": [ { "source": { - "block": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", + "block": "92490e7e-c3ba-4e9c-a917-2a771d99f1ef", "port": "out" }, "target": { - "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", - "port": "clk" + "block": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", + "port": "in" } }, { "source": { - "block": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", + "block": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", "port": "out" }, "target": { - "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", - "port": "btn_in" + "block": "92490e7e-c3ba-4e9c-a917-2a771d99f1ef", + "port": "clk" } }, { "source": { - "block": "980b1169-a2fe-411d-9678-c8ad64a801a6", - "port": "btn_out" + "block": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", + "port": "out" }, "target": { - "block": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", + "block": "92490e7e-c3ba-4e9c-a917-2a771d99f1ef", "port": "in" } } ] }, "deps": {} -} +} \ No newline at end of file From 7900832f3f6a21d934664a64b00700e4ada439ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 6 Dec 2016 17:11:31 +0100 Subject: [PATCH 009/169] Manage top and bottom ports --- app/scripts/plugins/routers/joint.routers.js | 4 +- app/scripts/plugins/shapes/joint.shapes.js | 175 +++++++++++++------ app/scripts/services/graph.service.js | 44 ++--- 3 files changed, 146 insertions(+), 77 deletions(-) diff --git a/app/scripts/plugins/routers/joint.routers.js b/app/scripts/plugins/routers/joint.routers.js index c1591d61d..f09b3ab63 100644 --- a/app/scripts/plugins/routers/joint.routers.js +++ b/app/scripts/plugins/routers/joint.routers.js @@ -22,10 +22,10 @@ joint.routers.ice = (function(g, _, joint) { maximumLoops: 2000, // possible starting directions from an element - startDirections: ['right'], + startDirections: ['right', 'top', 'bottom'], // possible ending directions to an element - endDirections: ['left'], + endDirections: ['left', 'top', 'bottom'], // specify directions above directionMap: { diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index e7720cec9..d231a83b0 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -15,9 +15,9 @@ else { // Model element joint.shapes.ice = {}; -joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.shapes.basic.PortsModelInterface, { +joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({ - markup: '', + markup: '', portMarkup: '', defaults: joint.util.deepSupplement({ @@ -26,8 +26,10 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.sh width: 1, height: 1 }, - inPorts: [], - outPorts: [], + leftPorts: [], + rightPorts: [], + topPorts: [], + bottomPorts: [], attrs: { gridUnits: 1, '.': { @@ -43,24 +45,23 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.sh r: 16, opacity: 0 }, - '.inPorts .port-body': { + '.leftPorts .port-body': { type: 'input', magnet: false }, - '.outPorts .port-body': { + '.rightPorts .port-body': { type: 'output', magnet: true }, - '.inPorts .port-label': { - x: 12, - y: -10, - 'text-anchor': 'end', - fill: '#888' + '.topPorts .port-body': { + type: 'input', + magnet: false }, - '.outPorts .port-label': { - x: -12, - y: -10, - 'text-anchor': 'start', + '.bottomPorts .port-body': { + type: 'output', + magnet: true + }, + '.port-label': { fill: '#888' }, '.port-wire': { @@ -70,6 +71,35 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.sh } }, joint.shapes.basic.Generic.prototype.defaults), + + initialize: function() { + this.updatePortsAttrs(); + this.on('change:leftPorts change:rightPorts change:topPorts change:bottomPorts', this.updatePortsAttrs, this); + this.constructor.__super__.constructor.__super__.initialize.apply(this, arguments); + }, + + updatePortsAttrs: function(eventName) { + if (this._portSelectors) { + var newAttrs = _.omit(this.get('attrs'), this._portSelectors); + this.set('attrs', newAttrs, { silent: true }); + } + this._portSelectors = []; + var attrs = {}; + + _.each(['left', 'right', 'top', 'bottom'], function(type) { + var port = type + 'Ports'; + _.each(this.get(port), function(portName, index, ports) { + var portAttributes = this.getPortAttrs(portName, index, ports.length, '.' + port, type); + this._portSelectors = this._portSelectors.concat(_.keys(portAttributes)); + _.extend(attrs, portAttributes); + }, this); + }, this); + + this.attr(attrs, { silent: true }); + this.processPorts(); + this.trigger('process:ports'); + }, + getPortAttrs: function(port, index, total, selector, type) { var attrs = {}; @@ -80,10 +110,16 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.sh var portWireSelector = portSelector + '>.port-wire'; var portBodySelector = portSelector + '>.port-body'; + attrs[portSelector] = { + ref: '.body' + }; + attrs[portLabelSelector] = { text: port.label }; + attrs[portWireSelector] = {}; + attrs[portBodySelector] = { port: { id: port.id, @@ -91,33 +127,56 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend(_.extend({}, joint.sh } }; - var portY = (index + 0.5) / total; - - portY = Math.round(portY * port.gridUnits) / port.gridUnits; - - attrs[portSelector] = { - ref: '.body', - 'ref-y': portY - }; - - attrs[portWireSelector] = { - y: portY - }; - - if (type === 'in') { - attrs[portSelector]['ref-x'] = -16; - attrs[portWireSelector]['d'] = 'M 0 0 L 32 0'; + if ((type === 'leftPorts') || (type === 'topPorts')) { attrs[portSelector]['pointer-events'] = 'none'; attrs[portWireSelector]['pointer-events'] = 'none'; } - else { - attrs[portSelector]['ref-dx'] = 16; - attrs[portWireSelector]['d'] = 'M 0 0 L -32 0'; + + var gridUnits = 8; + var pos = Math.round((index + 0.5) / total * gridUnits) / gridUnits; + + switch (type) { + case 'left': + attrs[portSelector]['ref-x'] = -16; + attrs[portSelector]['ref-y'] = pos; + attrs[portLabelSelector]['dx'] = 10; + attrs[portLabelSelector]['y'] = -10; + attrs[portLabelSelector]['text-anchor'] = 'end'; + attrs[portWireSelector]['y'] = pos; + attrs[portWireSelector]['d'] = 'M 0 0 L 32 0'; + break; + case 'right': + attrs[portSelector]['ref-dx'] = 16; + attrs[portSelector]['ref-y'] = pos; + attrs[portLabelSelector]['dx'] = -10; + attrs[portLabelSelector]['y'] = -10; + attrs[portLabelSelector]['text-anchor'] = 'start'; + attrs[portWireSelector]['y'] = pos; + attrs[portWireSelector]['d'] = 'M 0 0 L -32 0'; + break; + case 'top': + attrs[portSelector]['ref-y'] = -16; + attrs[portSelector]['ref-x'] = pos; + attrs[portLabelSelector]['dx'] = 10; + attrs[portLabelSelector]['dy'] = 0; + attrs[portLabelSelector]['text-anchor'] = 'start'; + attrs[portWireSelector]['x'] = pos; + attrs[portWireSelector]['d'] = 'M 0 0 L 0 32'; + break; + case 'bottom': + attrs[portSelector]['ref-dy'] = 16; + attrs[portSelector]['ref-x'] = pos; + attrs[portLabelSelector]['dx'] = 10; + attrs[portLabelSelector]['y'] = 0; + attrs[portLabelSelector]['text-anchor'] = 'start'; + attrs[portWireSelector]['x'] = pos; + attrs[portWireSelector]['d'] = 'M 0 0 L 0 -32'; + break; } return attrs; } -})); +}); joint.shapes.ice.ModelView = joint.dia.ElementView.extend({ @@ -137,28 +196,40 @@ joint.shapes.ice.ModelView = joint.dia.ElementView.extend({ this.listenTo(this.model, 'process:ports', this.update); joint.dia.ElementView.prototype.initialize.apply(this, arguments); }, + render: function() { joint.dia.ElementView.prototype.render.apply(this, arguments); this.paper.$el.append(this.$box); this.updateBox(); return this; }, + renderPorts: function() { - var $inPorts = this.$('.inPorts').empty(); - var $outPorts = this.$('.outPorts').empty(); + var $leftPorts = this.$('.leftPorts').empty(); + var $rightPorts = this.$('.rightPorts').empty(); + var $topPorts = this.$('.topPorts').empty(); + var $bottomPorts = this.$('.bottomPorts').empty(); var portTemplate = _.template(this.model.portMarkup); - _.each(_.filter(this.model.ports, function (p) { return p.type === 'in' }), function (port, index) { - $inPorts.append(V(portTemplate({ id: index, port: port })).node); + _.each(_.filter(this.model.ports, function (p) { return p.type === 'left' }), function (port, index) { + $leftPorts.append(V(portTemplate({ id: index, port: port })).node); + }); + _.each(_.filter(this.model.ports, function (p) { return p.type === 'right' }), function (port, index) { + $rightPorts.append(V(portTemplate({ id: index, port: port })).node); }); - _.each(_.filter(this.model.ports, function (p) { return p.type === 'out' }), function (port, index) { - $outPorts.append(V(portTemplate({ id: index, port: port })).node); + _.each(_.filter(this.model.ports, function (p) { return p.type === 'top' }), function (port, index) { + $topPorts.append(V(portTemplate({ id: index, port: port })).node); + }); + _.each(_.filter(this.model.ports, function (p) { return p.type === 'bottom' }), function (port, index) { + $bottomPorts.append(V(portTemplate({ id: index, port: port })).node); }); }, + update: function() { this.renderPorts(); joint.dia.ElementView.prototype.update.apply(this, arguments); }, + updateBox: function() { var bbox = this.model.getBBox(); var state = this.model.attributes.state; @@ -173,6 +244,7 @@ joint.shapes.ice.ModelView = joint.dia.ElementView.extend({ transform: 'scale(' + state.zoom + ')' }); }, + removeBox: function(evt) { this.$box.remove(); } @@ -221,10 +293,9 @@ joint.shapes.ice.Input = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Input', choices: [], - outPorts: [{ - id: "out", - label: "", - gridUnits: 8 + rightPorts: [{ + id: 'out', + label: '' }], size: { width: 96, @@ -237,10 +308,9 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Output', choices: [], - inPorts: [{ - id: "in", - label: "", - gridUnits: 8 + leftPorts: [{ + id: 'in', + label: '' }], size: { width: 96, @@ -318,10 +388,9 @@ joint.shapes.ice.OutputView = joint.shapes.ice.IOView; joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Constant', - outPorts: [{ - id: "out", - label: "", - gridUnits: 8 + bottomPorts: [{ + id: 'out', + label: '' }], size: { width: 96, diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 259c1bb2c..75ffd9c19 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -477,7 +477,7 @@ angular.module('icestudio') blockInstance.data.ports.out.push(outPorts[o]); } blockInstance.position.x = 31 * gridsize; - blockInstance.position.y = 18 * gridsize; + blockInstance.position.y = 20 * gridsize; if (block) { blockInstance.data.code = block.data.code; @@ -834,11 +834,11 @@ angular.module('icestudio') }; function addBasicCodeBlock(blockInstances, disabled) { - var inPorts = []; - var outPorts = []; + var leftPorts = []; + var rightPorts = []; for (var i in blockInstances.data.ports.in) { - inPorts.push({ + leftPorts.push({ id: blockInstances.data.ports.in[i], label: blockInstances.data.ports.in[i], gridUnits: 32 @@ -846,7 +846,7 @@ angular.module('icestudio') } for (var o in blockInstances.data.ports.out) { - outPorts.push({ + rightPorts.push({ id: blockInstances.data.ports.out[o], label: blockInstances.data.ports.out[o], gridUnits: 32 @@ -859,8 +859,8 @@ angular.module('icestudio') data: blockInstances.data, position: blockInstances.position, disabled: disabled, - inPorts: inPorts, - outPorts: outPorts + leftPorts: leftPorts, + rightPorts: rightPorts }); addCell(cell); @@ -881,35 +881,35 @@ angular.module('icestudio') }; function addGenericBlock(blockInstance, block) { - var inPorts = []; - var outPorts = []; + var leftPorts = []; + var rightPorts = []; for (var i in block.graph.blocks) { var item = block.graph.blocks[i]; if (item.type == 'basic.input') { - inPorts.push({ + leftPorts.push({ id: item.id, label: item.data.label }); } else if (item.type == 'basic.output') { - outPorts.push({ + rightPorts.push({ id: item.id, label: item.data.label }); } } - var numPorts = Math.max(inPorts.length, outPorts.length); + var numPorts = Math.max(leftPorts.length, rightPorts.length); var height = Math.max(4 * gridsize * numPorts, 8 * gridsize); var gridUnits = height / gridsize; - for (var i in inPorts) { - inPorts[i].gridUnits = gridUnits; + for (var i in leftPorts) { + leftPorts[i].gridUnits = gridUnits; } - for (var o in outPorts) { - outPorts[o].gridUnits = gridUnits; + for (var o in rightPorts) { + rightPorts[o].gridUnits = gridUnits; } @@ -934,8 +934,8 @@ angular.module('icestudio') image: blockImage, label: blockLabel, position: blockInstance.position, - inPorts: inPorts, - outPorts: outPorts, + leftPorts: leftPorts, + rightPorts: rightPorts, size: { width: width, height: height @@ -957,14 +957,14 @@ angular.module('icestudio') // Find selectors var sourceSelector, targetSelector; - for (var _out = 0; _out < source.attributes.outPorts.length; _out++) { - if (source.attributes.outPorts[_out] == wire.source.port) { + for (var _out = 0; _out < source.attributes.rightPorts.length; _out++) { + if (source.attributes.rightPorts[_out] == wire.source.port) { sourcePort = _out; break; } } - for (var _in = 0; _in < source.attributes.inPorts.length; _in++) { - if (target.attributes.inPorts[_in] == wire.target.port) { + for (var _in = 0; _in < source.attributes.leftPorts.length; _in++) { + if (target.attributes.leftPorts[_in] == wire.target.port) { targetPort = _in; break; } From b478e84c54c71a24045ba6f783966d378d8f6ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 7 Dec 2016 09:39:28 +0100 Subject: [PATCH 010/169] Add parameters in code blocks --- app/scripts/plugins/shapes/joint.shapes.js | 7 +++--- app/scripts/services/common.service.js | 3 ++- app/scripts/services/graph.service.js | 29 +++++++++++++++++++--- app/views/menu.html | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index d231a83b0..f02e91d14 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -415,7 +415,7 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ // Prevent paper from handling pointerdown. this.$box.find('.constant-input').on('mousedown click', function(evt) { evt.stopPropagation(); }); - this.$box.find('.constant-input').on('change', _.bind(function(evt) { + this.$box.find('.constant-input').on('input', _.bind(function(evt) { this.model.attributes.data.value = $(evt.target).val(); }, this)); }, @@ -444,17 +444,18 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ // Code block +// Size: 64 * x joint.shapes.ice.Code = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Code', size: { - width: 400, + width: 384, height: 256 }, attrs: { '.body': { - width: 400, + width: 384, height: 256 } } diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index b9a201263..dfe18f33b 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -237,7 +237,8 @@ angular.module('icestudio') cell.type == 'ice.Input' || cell.type == 'ice.Output' || cell.type == 'ice.Code' || - cell.type == 'ice.Info') { + cell.type == 'ice.Info' || + cell.type == 'ice.Constant') { var block = {}; block.id = cell.id; block.type = cell.blockType; diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 75ffd9c19..c37d67537 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -449,24 +449,31 @@ angular.module('icestudio') if (type == 'basic.code') { utils.multiprompt( [ gettextCatalog.getString('Enter the input ports'), - gettextCatalog.getString('Enter the output ports') ], + gettextCatalog.getString('Enter the output ports'), + gettextCatalog.getString('Enter the parameters') ], [ ' a , b ', - ' c , d ' ], + ' c , d ', + '' ], function(evt, ports) { if (ports && (ports[0].length || ports[1].length)) { blockInstance.data = { code: '', + params: [], ports: { in: [], out: [] } }; // Parse ports var inPorts = []; var outPorts = []; + var params = []; if (ports.length > 0) { inPorts = ports[0].replace(/ /g, '').split(','); } if (ports.length > 1) { outPorts = ports[1].replace(/ /g, '').split(','); } + if (ports.length > 2) { + params = ports[2].replace(/ /g, '').split(','); + } for (var i in inPorts) { if (inPorts[i]) @@ -476,8 +483,12 @@ angular.module('icestudio') if (outPorts[o]) blockInstance.data.ports.out.push(outPorts[o]); } + for (var p in params) { + if (params[p]) + blockInstance.data.params.push(params[p]); + } blockInstance.position.x = 31 * gridsize; - blockInstance.position.y = 20 * gridsize; + blockInstance.position.y = 24 * gridsize; if (block) { blockInstance.data.code = block.data.code; @@ -836,6 +847,7 @@ angular.module('icestudio') function addBasicCodeBlock(blockInstances, disabled) { var leftPorts = []; var rightPorts = []; + var topPorts = []; for (var i in blockInstances.data.ports.in) { leftPorts.push({ @@ -853,6 +865,14 @@ angular.module('icestudio') }); } + for (var p in blockInstances.data.params) { + topPorts.push({ + id: blockInstances.data.params[p], + label: blockInstances.data.params[p], + gridUnits: 32 + }); + } + var cell = new joint.shapes.ice.Code({ id: blockInstances.id, blockType: blockInstances.type, @@ -860,7 +880,8 @@ angular.module('icestudio') position: blockInstances.position, disabled: disabled, leftPorts: leftPorts, - rightPorts: rightPorts + rightPorts: rightPorts, + topPorts: topPorts }); addCell(cell); diff --git a/app/views/menu.html b/app/views/menu.html index a80198e72..d68d985e6 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -287,9 +287,9 @@
  • {{ 'Input' | translate }} {{ 'Output' | translate }} - {{ 'Constant' | translate }} {{ 'Code' | translate }} {{ 'Info' | translate }} + {{ 'Constant' | translate }}
  • From c21799eabbb5a7bca1781d9ff19c895cceb2d509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 7 Dec 2016 12:01:02 +0100 Subject: [PATCH 011/169] Add constant module parameters to the compiler --- app/scripts/plugins/shapes/joint.shapes.js | 2 +- app/scripts/services/compiler.service.js | 662 ++++++++++++--------- 2 files changed, 366 insertions(+), 298 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index f02e91d14..4a3e14e9a 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -389,7 +389,7 @@ joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Constant', bottomPorts: [{ - id: 'out', + id: 'constant-out', label: '' }], size: { diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 9e1a4a565..1b7b22312 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -1,394 +1,462 @@ 'use strict'; angular.module('icestudio') - .service('compiler', ['nodeSha1', '_package', - function(nodeSha1, _package) { - - this.generateVerilog = function(project) { - var code = header('//'); - code += '`default_nettype none\n\n'; - code += verilogCompiler('main', project); - return code; - }; + .service('compiler', ['nodeSha1', '_package', + function(nodeSha1, _package) { + + this.generateVerilog = function(project) { + var code = header('//'); + code += '`default_nettype none\n\n'; + code += verilogCompiler('main', project); + return code; + }; + + this.generatePCF = function(project) { + var code = header('#'); + code += pcfCompiler(project); + return code; + }; + + this.generateTestbench = function(project) { + var code = header('//'); + code += testbenchCompiler(project); + return code; + }; + + this.generateGTKWave = function(project) { + var code = header('[*]'); + code += gtkwaveCompiler(project); + return code; + }; + + function header(comment) { + var header = ''; + var date = new Date(); + header += comment + ' Code generated by Icestudio ' + _package.version + '\n'; + header += comment + ' ' + date.toUTCString() + '\n'; + header += '\n'; + return header; + } + + function digestId(id, force) { + if (id.indexOf('-') != -1) { + return 'v' + nodeSha1(id).toString().substring(0, 6); + } + else { + return id.replace('.', '_'); + } + } - this.generatePCF = function(project) { - var code = header('#'); - code += pcfCompiler(project); - return code; - }; + function module(data) { + var code = ''; - this.generateTestbench = function(project) { - var code = header('//'); - code += testbenchCompiler(project); - return code; - }; + if (data && data.name && data.ports) { - this.generateGTKWave = function(project) { - var code = header('[*]'); - code += gtkwaveCompiler(project); - return code; - }; + // Header - function header(comment) { - var header = ''; - var date = new Date(); - header += comment + ' Code generated by Icestudio ' + _package.version + '\n'; - header += comment + ' ' + date.toUTCString() + '\n'; - header += '\n'; - return header; - } + code += 'module ' + data.name; - function digestId(id, force) { - if (id.indexOf('-') != -1) { - return 'v' + nodeSha1(id).toString().substring(0, 6); - } - else { - return id.replace('.', '_'); - } - } + //-- Parameters - function module(data) { - var code = ''; + if (data.params) { - if (data && - data.name && - data.ports) { + var params = []; + for (var p in data.params) { + params.push(' parameter ' + data.params[p] + '=0'); + } - // Header + code += ' #(\n'; + code += params.join(',\n'); + code += '\n)'; + } - code += 'module '; - code += data.name; - code += ' ('; + //-- Ports - var params = []; - var paramsSpace = 10 + data.name.length; + var ports = []; + for (var i in data.ports.in) { + ports.push(' input ' + data.ports.in[i]); + } + for (var o in data.ports.out) { + ports.push(' output ' + data.ports.out[o]); + } - for (var i in data.ports.in) { - params.push('input ' + data.ports.in[i]); - } - for (var o in data.ports.out) { - params.push('output ' + data.ports.out[o]); - } + code += ' (\n'; + code += ports.join(',\n'); + code += '\n);\n'; - code += params.join(',\n' + new Array(paramsSpace).join(' ')); + // Content - code += ');\n'; + if (data.content) { - // Content + var content = data.content.split('\n'); - if (data.content) { + content.forEach(function (element, index, array) { + array[index] = ' ' + element; + }); - var content = data.content.split('\n'); + code += content.join('\n'); + } - content.forEach(function (element, index, array) { - array[index] = ' ' + element; - }); + // Footer - code += content.join('\n'); - } + code += '\nendmodule\n\n'; + } + + return code; + } - // Footer + function getPorts(project) { + var ports = { + in: [], + out: [] + }; + var graph = project.graph; - code += '\nendmodule\n\n'; + for (var i in graph.blocks) { + var block = graph.blocks[i]; + if (block.type == 'basic.input') { + ports.in.push(digestId(block.id)); } + else if (block.type == 'basic.output') { + ports.out.push(digestId(block.id)); + } + } + + return ports; + } - return code; + function getContent(name, project) { + var content = []; + var graph = project.graph; + + // Wires + + for (var w in graph.wires) { + content.push('wire w' + w + ';'); } - function getPorts(project) { - var ports = { - in: [], - out: [] - }; - var graph = project.graph; + // I/O connections + for (var w in graph.wires) { + var wire = graph.wires[w]; for (var i in graph.blocks) { var block = graph.blocks[i]; if (block.type == 'basic.input') { - ports.in.push(digestId(block.id)); + if (wire.source.block == block.id) { + content.push('assign w' + w + ' = ' + digestId(block.id) + ';'); + } } else if (block.type == 'basic.output') { - ports.out.push(digestId(block.id)); + if (wire.target.block == block.id) { + content.push('assign ' + digestId(block.id) + ' = w' + w + ';'); + } } } - - return ports; } - function getContent(name, project) { - var content = ''; - var graph = project.graph; - - // Wires + // Wires Connections - for (var w in graph.wires) { - content += 'wire w' + w + ';\n' + var numWires = graph.wires.length; + for (var i = 1; i < numWires; i++) { + for (var j = 0; j < i; j++) { + var wi = graph.wires[i]; + var wj = graph.wires[j]; + if (wi.source.block == wj.source.block && + wi.source.port == wj.source.port) { + content.push('assign w' + i + ' = w' + j + ';'); + } } + } - // I/O connections + // Block instances - for (var w in graph.wires) { - var wire = graph.wires[w]; - for (var i in graph.blocks) { - var block = graph.blocks[i]; - if (block.type == 'basic.input') { - if (wire.source.block == block.id) { - content += 'assign w' + w + ' = ' + digestId(block.id) + ';\n'; - } - } - else if (block.type == 'basic.output') { - if (wire.target.block == block.id) { - content += 'assign ' + digestId(block.id) + ' = w' + w + ';\n'; - } - } - } - } + content = content.concat(getInstances(name, project.graph)); - // Wires Connections + return content.join('\n'); + } - var numWires = graph.wires.length; - for (var i = 1; i < numWires; i++) { - for (var j = 0; j < i; j++) { - var wi = graph.wires[i]; - var wj = graph.wires[j]; - if (wi.source.block == wj.source.block && - wi.source.port == wj.source.port) { - content += 'assign w' + i + ' = w' + j + ';\n'; - } - } - } + function getInstances(name, graph) { + var instances = []; + var blocks = graph.blocks; + var allWires = graph.wires; - // Block instances + for (var b in blocks) { + var instance = ''; + var block = blocks[b]; - var instances = [] - for (var b in graph.blocks) { - var block = graph.blocks[b]; - if (block.type != 'basic.input' && - block.type != 'basic.output' && - block.type != 'basic.info') { + if (block.type != 'basic.input' && + block.type != 'basic.output' && + block.type != 'basic.constant' && + block.type != 'basic.info') { - var id = digestId(block.type, true); - if (block.type == 'basic.code') { - id += '_' + digestId(block.id); - } - instances.push(name + '_' + digestId(id) + ' ' + digestId(block.id) + ' ('); + // Header - // Parameters + var id = digestId(block.type, true); + if (block.type == 'basic.code') { + id += '_' + digestId(block.id); + } + instance += name + '_' + digestId(id); + + //-- Parameters + + if (block.data.params) { var params = []; - var paramsNames = []; - for (var w in graph.wires) { - var param = ''; - var paramName = ''; - var wire = graph.wires[w]; - if (block.id == wire.source.block) { - paramName = digestId(wire.source.port); - } - else if (block.id == wire.target.block) { - paramName = digestId(wire.target.port); - } - if (paramName && paramsNames.indexOf(paramName) == -1) { - paramsNames.push(paramName); - param += ' .' + paramName; - param += '(w' + w + ')'; - params.push(param); + for (var p in block.data.params) { + var paramName = block.data.params[p]; + for (var w in allWires) { + var wire = allWires[w]; + if ((block.id == wire.target.block) && + (paramName == wire.target.port)) { + var constantBlock = findBlock(wire.source.block, graph); + var paramValue = constantBlock.data.value; + if (paramValue) { + var param = ''; + param += ' .' + paramName; + param += '(' + paramValue + ')'; + params.push(param); + } + break; + } } } - instances.push(params.join(',\n') + '\n);'); + instance += ' #(\n' + params.join(',\n') + '\n)'; } - } - content += instances.join('\n'); - return content; - } + //-- Instance name - function verilogCompiler(name, project) { - var code = ''; + instance += ' ' + digestId(block.id); - if (project && - project.graph) { + //-- Ports - // Scape dot in name + var ports = []; + var portsNames = []; + for (var w in graph.wires) { + var portName = ''; + var isConstant = false; + var wire = graph.wires[w]; + if (block.id == wire.source.block) { + portName = digestId(wire.source.port); + } + else if (block.id == wire.target.block) { + portName = digestId(wire.target.port); + isConstant = wire.source.port == 'constant-out'; + } + if (portName && !isConstant && + portsNames.indexOf(portName) == -1) { + portsNames.push(portName); + var port = ''; + port += ' .' + portName; + port += '(w' + w + ')'; + ports.push(port); + } + } - name = digestId(name); + instance += ' (\n' + ports.join(',\n') + '\n);'; + } - // Main module + if (instance) + instances.push(instance); + } + return instances; + } - if (name) { - var data = { - name: name, - ports: getPorts(project), - content: getContent(name, project) - }; - code += module(data); - } + function findBlock(id, graph) { + for (var b in graph.blocks) { + if (graph.blocks[b].id == id) + return graph.blocks[b]; + } + return null; + } - // Dependencies modules + function verilogCompiler(name, project) { + var code = ''; - for (var d in project.deps) { - code += verilogCompiler(name + '_' + digestId(d, true), project.deps[d]); - } + if (project && + project.graph) { - // Code modules + // Scape dot in name - for (var i in project.graph.blocks) { - var block = project.graph.blocks[i]; - if (block) { - if (block.type == 'basic.code') { - var data = { - name: name + '_' + digestId(block.type, true) + '_' + digestId(block.id), - ports: block.data.ports, - content: block.data.code - } - code += module(data); - } - } - } + name = digestId(name); + + // Main module + + if (name) { + var data = { + name: name, + ports: getPorts(project), + content: getContent(name, project) + }; + code += module(data); } - return code; - } + // Dependencies modules + + for (var d in project.deps) { + code += verilogCompiler(name + '_' + digestId(d, true), project.deps[d]); + } - function pcfCompiler(project) { - var code = ''; + // Code modules for (var i in project.graph.blocks) { var block = project.graph.blocks[i]; - if (block.type == 'basic.input' || - block.type == 'basic.output') { - code += 'set_io '; - code += digestId(block.id); - code += ' '; - code += block.data.pin.value; - code += '\n'; + if (block) { + if (block.type == 'basic.code') { + var data = { + name: name + '_' + digestId(block.type, true) + '_' + digestId(block.id), + params: block.data.params, + ports: block.data.ports, + content: block.data.code + } + code += module(data); + } } } + } - return code; + return code; + } + + function pcfCompiler(project) { + var code = ''; + + for (var i in project.graph.blocks) { + var block = project.graph.blocks[i]; + if (block.type == 'basic.input' || + block.type == 'basic.output') { + code += 'set_io '; + code += digestId(block.id); + code += ' '; + code += block.data.pin.value; + code += '\n'; + } } - function testbenchCompiler(project) { - var code = ''; + return code; + } - code += '// Testbench template\n\n' + function testbenchCompiler(project) { + var code = ''; - code += '`default_nettype none\n'; - code += '`define DUMPSTR(x) `"x.vcd`"\n'; - code += '`timescale 10 ns / 1 ns\n\n'; + code += '// Testbench template\n\n' - var ports = { in: [], out: [] }; - var content = '\n'; + code += '`default_nettype none\n'; + code += '`define DUMPSTR(x) `"x.vcd`"\n'; + code += '`timescale 10 ns / 1 ns\n\n'; - content += '// Simulation time: 100ns (10 * 10ns)\n'; - content += 'parameter DURATION = 10;\n\n'; + var ports = { in: [], out: [] }; + var content = '\n'; - var io = mainIO(project); - var input = io[0]; - var output = io[1]; + content += '// Simulation time: 100ns (10 * 10ns)\n'; + content += 'parameter DURATION = 10;\n\n'; - // Input/Output - content += '// Input/Output\n'; - for (var i in input) { - content += 'reg ' + input[i].label + ';\n'; - } - for (var o in output) { - content += 'wire ' + output[o].label + ';\n'; - } + var io = mainIO(project); + var input = io[0]; + var output = io[1]; - var wires = input.concat(output); + // Input/Output + content += '// Input/Output\n'; + for (var i in input) { + content += 'reg ' + input[i].label + ';\n'; + } + for (var o in output) { + content += 'wire ' + output[o].label + ';\n'; + } - // Module instance - content += '\n// Module instance\n'; - content += 'main MAIN (\n'; - var connections = []; - for (var w in wires) { - connections.push(' .' + wires[w].id + '(' + wires[w].label + ')'); - } - content += connections.join(',\n'); - content += '\n);\n'; - - // Clock signal - var hasClk = false; - for (var i in input) { - if (input[i].label.toLowerCase() == 'input_clk') { - hasClk = true; - break; - } - } - if (hasClk) { - content += '\n// Clock signal\n'; - content += 'always #0.5 input_clk = ~input_clk;\n'; - } + var wires = input.concat(output); - content += '\ninitial begin\n'; - content += ' // File were to store the simulation results\n'; - content += ' $dumpfile(`DUMPSTR(`VCD_OUTPUT));\n'; - content += ' $dumpvars(0, main_tb);\n\n'; - content += ' // TODO: initialize the registers here\n'; - content += ' // e.g. input_value = 1;\n'; - content += ' // e.g. #2 input_value = 0;\n'; - for (var i in input) { - content += ' ' + input[i].label + ' = 0;\n'; + // Module instance + content += '\n// Module instance\n'; + content += 'main MAIN (\n'; + var connections = []; + for (var w in wires) { + connections.push(' .' + wires[w].id + '(' + wires[w].label + ')'); + } + content += connections.join(',\n'); + content += '\n);\n'; + + // Clock signal + var hasClk = false; + for (var i in input) { + if (input[i].label.toLowerCase() == 'input_clk') { + hasClk = true; + break; } - content += '\n'; - content += ' #(DURATION) $display("End of simulation");\n'; - content += ' $finish;\n'; - content += 'end\n'; - - var data = { - name: 'main_tb', - ports: ports, - content: content - }; - code += module(data); - - return code; } + if (hasClk) { + content += '\n// Clock signal\n'; + content += 'always #0.5 input_clk = ~input_clk;\n'; + } + + content += '\ninitial begin\n'; + content += ' // File were to store the simulation results\n'; + content += ' $dumpfile(`DUMPSTR(`VCD_OUTPUT));\n'; + content += ' $dumpvars(0, main_tb);\n\n'; + content += ' // TODO: initialize the registers here\n'; + content += ' // e.g. input_value = 1;\n'; + content += ' // e.g. #2 input_value = 0;\n'; + for (var i in input) { + content += ' ' + input[i].label + ' = 0;\n'; + } + content += '\n'; + content += ' #(DURATION) $display("End of simulation");\n'; + content += ' $finish;\n'; + content += 'end\n'; + + var data = { + name: 'main_tb', + ports: ports, + content: content + }; + code += module(data); - function gtkwaveCompiler(project) { - var code = ''; + return code; + } - var io = mainIO(project); - var input = io[0]; - var output = io[1]; + function gtkwaveCompiler(project) { + var code = ''; - var wires = input.concat(output); - for (var w in wires) { - code += 'main_tb.' + wires[w].label + '\n'; - } + var io = mainIO(project); + var input = io[0]; + var output = io[1]; - return code; + var wires = input.concat(output); + for (var w in wires) { + code += 'main_tb.' + wires[w].label + '\n'; } - function mainIO(project) { - var input = []; - var output = []; - var input_unnamed = 0; - var output_unnamed = 0; - for (var i in project.graph.blocks) { - var block = project.graph.blocks[i]; - if (block.type == 'basic.input') { - if (block.data.label) { - input.push({ id: digestId(block.id), label: 'input_' + block.data.label.replace(' ', '_') }); - } - else { - input.push({ id: digestId(block.id), label: 'input_' + input_unnamed.toString() }); - input_unnamed += 1; - } + return code; + } + + function mainIO(project) { + var input = []; + var output = []; + var input_unnamed = 0; + var output_unnamed = 0; + for (var i in project.graph.blocks) { + var block = project.graph.blocks[i]; + if (block.type == 'basic.input') { + if (block.data.label) { + input.push({ id: digestId(block.id), label: 'input_' + block.data.label.replace(' ', '_') }); } - else if (block.type == 'basic.output') { - if (block.data.label) { - output.push({ id: digestId(block.id), label: 'output_' + block.data.label.replace(' ', '_') }); - } - else { - output.push({ id: digestId(block.id), label: 'output_' + output_unnamed.toString() }); - output_unnamed += 1; - } + else { + input.push({ id: digestId(block.id), label: 'input_' + input_unnamed.toString() }); + input_unnamed += 1; + } + } + else if (block.type == 'basic.output') { + if (block.data.label) { + output.push({ id: digestId(block.id), label: 'output_' + block.data.label.replace(' ', '_') }); + } + else { + output.push({ id: digestId(block.id), label: 'output_' + output_unnamed.toString() }); + output_unnamed += 1; } } - - return [input, output]; } - }]); + return [input, output]; + } + + }]); From 9457848b850a4687ac8551ad667845be3d30c328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 7 Dec 2016 17:45:23 +0100 Subject: [PATCH 012/169] Export block with parameters --- app/scripts/plugins/shapes/joint.shapes.js | 18 +++++----- app/scripts/services/compiler.service.js | 15 ++++++++ app/scripts/services/graph.service.js | 42 ++++++++++++++++------ 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 4a3e14e9a..e6f1ef72f 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -132,8 +132,7 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({ attrs[portWireSelector]['pointer-events'] = 'none'; } - var gridUnits = 8; - var pos = Math.round((index + 0.5) / total * gridUnits) / gridUnits; + var pos = Math.round((index + 0.5) / total * port.gridUnits) / port.gridUnits; switch (type) { case 'left': @@ -295,7 +294,8 @@ joint.shapes.ice.Input = joint.shapes.ice.Model.extend({ choices: [], rightPorts: [{ id: 'out', - label: '' + label: '', + gridUnits: 8 }], size: { width: 96, @@ -310,7 +310,8 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ choices: [], leftPorts: [{ id: 'in', - label: '' + label: '', + gridUnits: 8 }], size: { width: 96, @@ -390,7 +391,8 @@ joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ type: 'ice.Constant', bottomPorts: [{ id: 'constant-out', - label: '' + label: '', + gridUnits: 8 }], size: { width: 96, @@ -425,11 +427,9 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ }, renderValue: function() { if (this.model.get('disabled')) { - this.$box.find('.constant-input').css({'display': 'none'}); - } - else { - this.$box.find('.constant-input').val(this.model.get('data').value); + this.$box.find('.constant-input').css({'pointer-events': 'none'}); } + this.$box.find('.constant-input').val(this.model.get('data').value); }, clearValue: function () { this.$box.find('.constant-input').val(''); diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 1b7b22312..45f04bcef 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -105,6 +105,20 @@ angular.module('icestudio') return code; } + function getParams(project) { + var params = []; + var graph = project.graph; + + for (var i in graph.blocks) { + var block = graph.blocks[i]; + if (block.type == 'basic.constant') { + params.push(digestId(block.id)); + } + } + + return params; + } + function getPorts(project) { var ports = { in: [], @@ -285,6 +299,7 @@ angular.module('icestudio') if (name) { var data = { name: name, + params: getParams(project), ports: getPorts(project), content: getContent(name, project) }; diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index c37d67537..93bfbacde 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -869,7 +869,7 @@ angular.module('icestudio') topPorts.push({ id: blockInstances.data.params[p], label: blockInstances.data.params[p], - gridUnits: 32 + gridUnits: 48 }); } @@ -904,6 +904,8 @@ angular.module('icestudio') function addGenericBlock(blockInstance, block) { var leftPorts = []; var rightPorts = []; + var topPorts = []; + var bottomPorts = []; for (var i in block.graph.blocks) { var item = block.graph.blocks[i]; @@ -919,23 +921,42 @@ angular.module('icestudio') label: item.data.label }); } + else if (item.type == 'basic.constant') { + topPorts.push({ + id: item.id, + label: item.data.label + }); + } } - var numPorts = Math.max(leftPorts.length, rightPorts.length); - var height = Math.max(4 * gridsize * numPorts, 8 * gridsize); + var numPortsHeight = Math.max(leftPorts.length, rightPorts.length); + var numPortsWidth = Math.max(topPorts.length, bottomPorts.length); - var gridUnits = height / gridsize; + var height = 8 * gridsize; + height = Math.max(4 * gridsize * numPortsHeight, height); + var blockLabel = blockInstance.type.toUpperCase(); + var width = 12 * gridsize; + if (blockLabel.length > 4) { + width = Math.min((blockLabel.length + 8) * gridsize, 24 * gridsize); + } + width = Math.max(4 * gridsize * numPortsWidth, width); + + var gridUnitsHeight = height / gridsize; + var gridUnitsWidth = width / gridsize; for (var i in leftPorts) { - leftPorts[i].gridUnits = gridUnits; + leftPorts[i].gridUnits = gridUnitsHeight; } - for (var o in rightPorts) { - rightPorts[o].gridUnits = gridUnits; + for (var i in rightPorts) { + rightPorts[i].gridUnits = gridUnitsHeight; + } + for (var i in topPorts) { + topPorts[i].gridUnits = gridUnitsWidth; + } + for (var i in bottomPorts) { + bottomPorts[i].gridUnits = gridUnitsWidth; } - - var blockLabel = blockInstance.type.toUpperCase(); - var width = Math.min((blockLabel.length + 8) * gridsize, 24 * gridsize); if (blockInstance.type.indexOf('.') != -1) { blockLabel = blockInstance.type.split('.').join(' '); } @@ -957,6 +978,7 @@ angular.module('icestudio') position: blockInstance.position, leftPorts: leftPorts, rightPorts: rightPorts, + topPorts: topPorts, size: { width: width, height: height From 23138d937c423ae1618f88af4fa1fa3c8d46b856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 7 Dec 2016 18:36:05 +0100 Subject: [PATCH 013/169] Load code block status to multiprompt --- app/scripts/services/graph.service.js | 18 ++++++++++++++---- app/scripts/services/utils.service.js | 9 ++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 93bfbacde..038f6a5d0 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -317,7 +317,9 @@ angular.module('icestudio') if (paper.options.enabled) { var block = { data: { - code: self.getContent(cellView.model.id) + code: self.getContent(cellView.model.id), + params: data.data.params, + ports: data.data.ports }, position: cellView.model.attributes.position }; @@ -447,13 +449,21 @@ angular.module('icestudio') }; if (type == 'basic.code') { + var defaultValues = [ + ' a , b ', + ' c , d ', + '' + ]; + if (block && block.data) { + defaultValues[0] = ' ' + block.data.ports.in.join(' , ') + ' '; + defaultValues[1] = ' ' + block.data.ports.out.join(' , ') + ' '; + defaultValues[2] = ' ' + block.data.params.join(' , ') + ' '; + } utils.multiprompt( [ gettextCatalog.getString('Enter the input ports'), gettextCatalog.getString('Enter the output ports'), gettextCatalog.getString('Enter the parameters') ], - [ ' a , b ', - ' c , d ', - '' ], + defaultValues, function(evt, ports) { if (ports && (ports[0].length || ports[1].length)) { blockInstance.data = { diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 4b83d2ca3..886d2d3ef 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -585,13 +585,20 @@ angular.module('icestudio') } content.push(''); - alertify.confirm(content.join('\n')).set('onok', function(evt) { + alertify.confirm(content.join('\n')) + .set('onok', function(evt) { var values = []; for (var i = 0; i < n; i++) { values.push($('#input' + i.toString()).val()); } if (callback) callback(evt, values); + }) + .set('oncancel', function(evt) { + // Restore previous values + for (var i = 0; i < n; i++) { + $('#input' + i.toString()).val(values[i]); + } }); } From 51b898beb829c9b8508868ba1f80effed5e8313e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 09:42:22 +0100 Subject: [PATCH 014/169] Add nested parameters to the compiler --- app/scripts/services/compiler.service.js | 72 ++++++++++++++---------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 45f04bcef..229583651 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -58,13 +58,19 @@ angular.module('icestudio') //-- Parameters - if (data.params) { - - var params = []; - for (var p in data.params) { - params.push(' parameter ' + data.params[p] + '=0'); + var params = []; + for (var p in data.params) { + if (data.params[p] instanceof Object) { + // Generic block + params.push(' parameter ' + data.params[p].name + ' = ' + data.params[p].value); + } + else { + // Code block + params.push(' parameter ' + data.params[p] + ' = 0'); } + } + if (params.length > 0) { code += ' #(\n'; code += params.join(',\n'); code += '\n)'; @@ -80,9 +86,11 @@ angular.module('icestudio') ports.push(' output ' + data.ports.out[o]); } - code += ' (\n'; - code += ports.join(',\n'); - code += '\n);\n'; + if (ports.length > 0) { + code += ' (\n'; + code += ports.join(',\n'); + code += '\n);\n'; + } // Content @@ -112,7 +120,10 @@ angular.module('icestudio') for (var i in graph.blocks) { var block = graph.blocks[i]; if (block.type == 'basic.constant') { - params.push(digestId(block.id)); + params.push({ + name: digestId(block.id), + value: block.data.value + }); } } @@ -146,7 +157,9 @@ angular.module('icestudio') // Wires for (var w in graph.wires) { - content.push('wire w' + w + ';'); + if (graph.wires[w].source.port != 'constant-out') { + content.push('wire w' + w + ';'); + } } // I/O connections @@ -165,6 +178,7 @@ angular.module('icestudio') content.push('assign ' + digestId(block.id) + ' = w' + w + ';'); } } + // TODO: assign constant value } } @@ -213,28 +227,24 @@ angular.module('icestudio') //-- Parameters - if (block.data.params) { - - var params = []; - for (var p in block.data.params) { - var paramName = block.data.params[p]; - for (var w in allWires) { - var wire = allWires[w]; - if ((block.id == wire.target.block) && - (paramName == wire.target.port)) { - var constantBlock = findBlock(wire.source.block, graph); - var paramValue = constantBlock.data.value; - if (paramValue) { - var param = ''; - param += ' .' + paramName; - param += '(' + paramValue + ')'; - params.push(param); - } - break; - } + var params = []; + for (var w in graph.wires) { + var wire = graph.wires[w]; + if ((block.id == wire.target.block) && + (wire.source.port == 'constant-out')) { + var paramName = digestId(wire.target.port); + var constantBlock = findBlock(wire.source.block, graph); + var paramValue = digestId(constantBlock.id); + if (paramValue) { + var param = ''; + param += ' .' + paramName; + param += '(' + paramValue + ')'; + params.push(param); } } + } + if (params.length > 0) { instance += ' #(\n' + params.join(',\n') + '\n)'; } @@ -267,7 +277,9 @@ angular.module('icestudio') } } - instance += ' (\n' + ports.join(',\n') + '\n);'; + if (ports.length > 0) { + instance += ' (\n' + ports.join(',\n') + '\n);'; + } } if (instance) From 24e4bedacdb9267366e635646bcdc58c04e93921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 15:22:23 +0100 Subject: [PATCH 015/169] Use localparam for Constant block wires --- app/scripts/services/compiler.service.js | 65 ++++++++++++++---------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 229583651..88b1aa8a0 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -6,7 +6,7 @@ angular.module('icestudio') this.generateVerilog = function(project) { var code = header('//'); - code += '`default_nettype none\n\n'; + code += '`default_nettype none\n'; code += verilogCompiler('main', project); return code; }; @@ -54,7 +54,7 @@ angular.module('icestudio') // Header - code += 'module ' + data.name; + code += '\nmodule ' + data.name; //-- Parameters @@ -62,7 +62,7 @@ angular.module('icestudio') for (var p in data.params) { if (data.params[p] instanceof Object) { // Generic block - params.push(' parameter ' + data.params[p].name + ' = ' + data.params[p].value); + params.push(' parameter ' + data.params[p].name + ' = ' + (data.params[p].value ? data.params[p].value : '0')); } else { // Code block @@ -107,7 +107,7 @@ angular.module('icestudio') // Footer - code += '\nendmodule\n\n'; + code += '\nendmodule\n'; } return code; @@ -153,35 +153,51 @@ angular.module('icestudio') function getContent(name, project) { var content = []; var graph = project.graph; - - // Wires - - for (var w in graph.wires) { - if (graph.wires[w].source.port != 'constant-out') { - content.push('wire w' + w + ';'); - } - } - - // I/O connections + var connections = { + localparam: [], + wire: [], + assign: [] + }; for (var w in graph.wires) { var wire = graph.wires[w]; + if (wire.source.port == 'constant-out') { + // Local Parameters + var constantBlock = findBlock(wire.source.block, graph); + var paramValue = digestId(constantBlock.id); + if (paramValue) { + connections.localparam.push('localparam p' + w + ' = ' + paramValue + ';'); + } + } + else { + // Wires + connections.wire.push('wire w' + w + ';'); + } + // Assignations for (var i in graph.blocks) { var block = graph.blocks[i]; if (block.type == 'basic.input') { if (wire.source.block == block.id) { - content.push('assign w' + w + ' = ' + digestId(block.id) + ';'); + connections.assign.push('assign w' + w + ' = ' + digestId(block.id) + ';'); } } else if (block.type == 'basic.output') { if (wire.target.block == block.id) { - content.push('assign ' + digestId(block.id) + ' = w' + w + ';'); + if (wire.source.port == 'constant-out') { + connections.assign.push('assign ' + digestId(block.id) + ' = p' + w + ';'); + } + else { + connections.assign.push('assign ' + digestId(block.id) + ' = w' + w + ';'); + } } } - // TODO: assign constant value } } + content = content.concat(connections.localparam); + content = content.concat(connections.wire); + content = content.concat(connections.assign); + // Wires Connections var numWires = graph.wires.length; @@ -190,7 +206,8 @@ angular.module('icestudio') var wi = graph.wires[i]; var wj = graph.wires[j]; if (wi.source.block == wj.source.block && - wi.source.port == wj.source.port) { + wi.source.port == wj.source.port && + wi.source.port != 'constant-out') { content.push('assign w' + i + ' = w' + j + ';'); } } @@ -233,14 +250,10 @@ angular.module('icestudio') if ((block.id == wire.target.block) && (wire.source.port == 'constant-out')) { var paramName = digestId(wire.target.port); - var constantBlock = findBlock(wire.source.block, graph); - var paramValue = digestId(constantBlock.id); - if (paramValue) { - var param = ''; - param += ' .' + paramName; - param += '(' + paramValue + ')'; - params.push(param); - } + var param = ''; + param += ' .' + paramName; + param += '(p' + w + ')'; + params.push(param); } } From a088036628c19858eb9ff6794823e8fc3824d912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 15:26:29 +0100 Subject: [PATCH 016/169] Add demo projects --- .gitignore | 1 + demo/constant-code-block.ice | 85 ++++++++++ demo/constant-code-block.iceb | 80 ++++++++++ demo/constant-generic-block.ice | 155 ++++++++++++++++++ demo/constant-output.ice | 61 +++++++ demo/input-output.ice | 58 +++++++ demo/multi-block-block.ice | 219 ++++++++++++++++++++++++++ demo/multi-block-output.ice | 181 +++++++++++++++++++++ demo/multi-constant-generic-block.ice | 199 +++++++++++++++++++++++ demo/multi-input-output.ice | 83 ++++++++++ 10 files changed, 1122 insertions(+) create mode 100644 demo/constant-code-block.ice create mode 100644 demo/constant-code-block.iceb create mode 100644 demo/constant-generic-block.ice create mode 100644 demo/constant-output.ice create mode 100644 demo/input-output.ice create mode 100644 demo/multi-block-block.ice create mode 100644 demo/multi-block-output.ice create mode 100644 demo/multi-constant-generic-block.ice create mode 100644 demo/multi-input-output.ice diff --git a/.gitignore b/.gitignore index be82bc7d5..6a2245c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ app/profile.json app/_cache app/_build app/resources/locale/**/*.json +demo/*.v diff --git a/demo/constant-code-block.ice b/demo/constant-code-block.ice new file mode 100644 index 000000000..ad9b38df3 --- /dev/null +++ b/demo/constant-code-block.ice @@ -0,0 +1,85 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 0.9999999748467205 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 280, + "y": 48 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "led", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 624, + "y": 288 + } + }, + { + "id": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [], + "out": [ + "o" + ] + } + }, + "position": { + "x": 136, + "y": 192 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "v" + } + }, + { + "source": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/constant-code-block.iceb b/demo/constant-code-block.iceb new file mode 100644 index 000000000..75e086e23 --- /dev/null +++ b/demo/constant-code-block.iceb @@ -0,0 +1,80 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 280, + "y": 48 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "led" + }, + "position": { + "x": 624, + "y": 288 + } + }, + { + "id": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [], + "out": [ + "o" + ] + } + }, + "position": { + "x": 136, + "y": 192 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "v" + } + }, + { + "source": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/constant-generic-block.ice b/demo/constant-generic-block.ice new file mode 100644 index 000000000..1dc630eb6 --- /dev/null +++ b/demo/constant-generic-block.ice @@ -0,0 +1,155 @@ +{ + "image": "", + "state": { + "pan": { + "x": -21, + "y": 66 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "type": "constant-code-block", + "data": {}, + "position": { + "x": 248, + "y": 184 + } + }, + { + "id": "3ea55b72-cda0-4f43-886b-e225b00229a4", + "type": "basic.constant", + "data": { + "label": "Value", + "value": "1'b1" + }, + "position": { + "x": 296, + "y": 32 + } + }, + { + "id": "06bd1d14-7302-4dd7-9e95-650d1070a203", + "type": "basic.output", + "data": { + "label": "led", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 536, + "y": 184 + } + } + ], + "wires": [ + { + "source": { + "block": "3ea55b72-cda0-4f43-886b-e225b00229a4", + "port": "constant-out" + }, + "target": { + "block": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "port": "386bc685-d806-4487-bece-b442b8c8689c" + } + }, + { + "source": { + "block": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "06bd1d14-7302-4dd7-9e95-650d1070a203", + "port": "in" + } + } + ] + }, + "deps": { + "constant-code-block": { + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 280, + "y": 48 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "led" + }, + "position": { + "x": 624, + "y": 288 + } + }, + { + "id": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [], + "out": [ + "o" + ] + } + }, + "position": { + "x": 136, + "y": 192 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "v" + } + }, + { + "source": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + } + ] + }, + "deps": {} + } + } +} \ No newline at end of file diff --git a/demo/constant-output.ice b/demo/constant-output.ice new file mode 100644 index 000000000..1408b9b49 --- /dev/null +++ b/demo/constant-output.ice @@ -0,0 +1,61 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "7de57b0c-2b62-4d25-864f-4cd940aa2aa5", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b1" + }, + "position": { + "x": 152, + "y": 56 + } + }, + { + "id": "6ca79224-5f67-4c69-95fd-32d27bdc67b4", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 336, + "y": 184 + } + } + ], + "wires": [ + { + "source": { + "block": "7de57b0c-2b62-4d25-864f-4cd940aa2aa5", + "port": "constant-out" + }, + "target": { + "block": "6ca79224-5f67-4c69-95fd-32d27bdc67b4", + "port": "in" + }, + "vertices": [ + { + "x": 208, + "y": 216 + } + ] + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/input-output.ice b/demo/input-output.ice new file mode 100644 index 000000000..285925bc1 --- /dev/null +++ b/demo/input-output.ice @@ -0,0 +1,58 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "f4405019-32a9-4f31-8e42-441c85f1959c", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 104, + "y": 112 + } + }, + { + "id": "ef08c4f3-94b9-4e85-9fe7-78bc2a376c72", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 344, + "y": 112 + } + } + ], + "wires": [ + { + "source": { + "block": "f4405019-32a9-4f31-8e42-441c85f1959c", + "port": "out" + }, + "target": { + "block": "ef08c4f3-94b9-4e85-9fe7-78bc2a376c72", + "port": "in" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/multi-block-block.ice b/demo/multi-block-block.ice new file mode 100644 index 000000000..46e49a468 --- /dev/null +++ b/demo/multi-block-block.ice @@ -0,0 +1,219 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1.000000007072795 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 96, + "y": 128 + } + }, + { + "id": "7625149d-3511-4d95-8405-a100409a5d42", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED1", + "value": "96" + } + }, + "position": { + "x": 632, + "y": 208 + } + }, + { + "id": "c39221a3-87dd-4524-9f65-879112b27f51", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 632, + "y": 64 + } + }, + { + "id": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "type": "logic.gate.not", + "data": {}, + "position": { + "x": 272, + "y": 128 + } + }, + { + "id": "2f906ce2-8c79-49e9-abbb-7141484a9ba9", + "type": "logic.gate.not", + "data": {}, + "position": { + "x": 448, + "y": 64 + } + }, + { + "id": "870693a6-da68-41e8-880c-3defad4b7dde", + "type": "logic.gate.not", + "data": {}, + "position": { + "x": 448, + "y": 208 + } + } + ], + "wires": [ + { + "source": { + "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "port": "out" + }, + "target": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + } + }, + { + "source": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "2f906ce2-8c79-49e9-abbb-7141484a9ba9", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + } + }, + { + "source": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "870693a6-da68-41e8-880c-3defad4b7dde", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + } + }, + { + "source": { + "block": "2f906ce2-8c79-49e9-abbb-7141484a9ba9", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "c39221a3-87dd-4524-9f65-879112b27f51", + "port": "in" + } + }, + { + "source": { + "block": "870693a6-da68-41e8-880c-3defad4b7dde", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "7625149d-3511-4d95-8405-a100409a5d42", + "port": "in" + } + } + ] + }, + "deps": { + "logic.gate.not": { + "graph": { + "blocks": [ + { + "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 64, + "y": 144 + } + }, + { + "id": "664caf9e-5f40-4df4-800a-b626af702e62", + "type": "basic.output", + "data": { + "label": "" + }, + "position": { + "x": 752, + "y": 144 + } + }, + { + "id": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "type": "basic.code", + "data": { + "code": "// NOT logic gate\n\nassign c = ~ a;", + "ports": { + "in": [ + "a" + ], + "out": [ + "c" + ] + } + }, + "position": { + "x": 256, + "y": 48 + } + } + ], + "wires": [ + { + "source": { + "block": "18c2ebc7-5152-439c-9b3f-851c59bac834", + "port": "out" + }, + "target": { + "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "port": "a" + } + }, + { + "source": { + "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "port": "c" + }, + "target": { + "block": "664caf9e-5f40-4df4-800a-b626af702e62", + "port": "in" + } + } + ] + }, + "deps": {}, + "image": "resources/images/not.svg", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } + } +} \ No newline at end of file diff --git a/demo/multi-block-output.ice b/demo/multi-block-output.ice new file mode 100644 index 000000000..f8e40e690 --- /dev/null +++ b/demo/multi-block-output.ice @@ -0,0 +1,181 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1.000000007072795 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 96, + "y": 120 + } + }, + { + "id": "7625149d-3511-4d95-8405-a100409a5d42", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED1", + "value": "96" + } + }, + "position": { + "x": 464, + "y": 208 + } + }, + { + "id": "c39221a3-87dd-4524-9f65-879112b27f51", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 464, + "y": 40 + } + }, + { + "id": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "type": "logic.gate.not", + "data": {}, + "position": { + "x": 272, + "y": 120 + } + } + ], + "wires": [ + { + "source": { + "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "port": "out" + }, + "target": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + } + }, + { + "source": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "c39221a3-87dd-4524-9f65-879112b27f51", + "port": "in" + } + }, + { + "source": { + "block": "6ebac9b8-8eb9-4c4b-8b58-962ccc2919f4", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "7625149d-3511-4d95-8405-a100409a5d42", + "port": "in" + } + } + ] + }, + "deps": { + "logic.gate.not": { + "graph": { + "blocks": [ + { + "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 64, + "y": 144 + } + }, + { + "id": "664caf9e-5f40-4df4-800a-b626af702e62", + "type": "basic.output", + "data": { + "label": "" + }, + "position": { + "x": 752, + "y": 144 + } + }, + { + "id": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "type": "basic.code", + "data": { + "code": "// NOT logic gate\n\nassign c = ~ a;", + "ports": { + "in": [ + "a" + ], + "out": [ + "c" + ] + } + }, + "position": { + "x": 256, + "y": 48 + } + } + ], + "wires": [ + { + "source": { + "block": "18c2ebc7-5152-439c-9b3f-851c59bac834", + "port": "out" + }, + "target": { + "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "port": "a" + } + }, + { + "source": { + "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", + "port": "c" + }, + "target": { + "block": "664caf9e-5f40-4df4-800a-b626af702e62", + "port": "in" + } + } + ] + }, + "deps": {}, + "image": "resources/images/not.svg", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } + } +} \ No newline at end of file diff --git a/demo/multi-constant-generic-block.ice b/demo/multi-constant-generic-block.ice new file mode 100644 index 000000000..152c349a2 --- /dev/null +++ b/demo/multi-constant-generic-block.ice @@ -0,0 +1,199 @@ +{ + "image": "", + "state": { + "pan": { + "x": -139, + "y": 20 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "type": "constant-code-block", + "data": {}, + "position": { + "x": 248, + "y": 184 + } + }, + { + "id": "7217b44b-f3e6-4eb6-862b-1d55c0655ee7", + "type": "constant-code-block", + "data": {}, + "position": { + "x": 392, + "y": 328 + } + }, + { + "id": "3ea55b72-cda0-4f43-886b-e225b00229a4", + "type": "basic.constant", + "data": { + "label": "Value", + "value": "1'b1" + }, + "position": { + "x": 296, + "y": 32 + } + }, + { + "id": "06bd1d14-7302-4dd7-9e95-650d1070a203", + "type": "basic.output", + "data": { + "label": "led", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 536, + "y": 184 + } + }, + { + "id": "019e1dba-a150-483a-9c95-c2970ec781a9", + "type": "basic.output", + "data": { + "label": "led", + "pin": { + "name": "LED1", + "value": "96" + } + }, + "position": { + "x": 680, + "y": 328 + } + } + ], + "wires": [ + { + "source": { + "block": "7217b44b-f3e6-4eb6-862b-1d55c0655ee7", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "019e1dba-a150-483a-9c95-c2970ec781a9", + "port": "in" + } + }, + { + "source": { + "block": "3ea55b72-cda0-4f43-886b-e225b00229a4", + "port": "constant-out" + }, + "target": { + "block": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "port": "386bc685-d806-4487-bece-b442b8c8689c" + } + }, + { + "source": { + "block": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "06bd1d14-7302-4dd7-9e95-650d1070a203", + "port": "in" + } + }, + { + "source": { + "block": "3ea55b72-cda0-4f43-886b-e225b00229a4", + "port": "constant-out" + }, + "target": { + "block": "7217b44b-f3e6-4eb6-862b-1d55c0655ee7", + "port": "386bc685-d806-4487-bece-b442b8c8689c" + } + } + ] + }, + "deps": { + "constant-code-block": { + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 280, + "y": 48 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "led" + }, + "position": { + "x": 624, + "y": 288 + } + }, + { + "id": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [], + "out": [ + "o" + ] + } + }, + "position": { + "x": 136, + "y": 192 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "v" + } + }, + { + "source": { + "block": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + } + ] + }, + "deps": {} + } + } +} \ No newline at end of file diff --git a/demo/multi-input-output.ice b/demo/multi-input-output.ice new file mode 100644 index 000000000..335fd4e18 --- /dev/null +++ b/demo/multi-input-output.ice @@ -0,0 +1,83 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 168, + "y": 120 + } + }, + { + "id": "7625149d-3511-4d95-8405-a100409a5d42", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED1", + "value": "96" + } + }, + "position": { + "x": 408, + "y": 232 + } + }, + { + "id": "c39221a3-87dd-4524-9f65-879112b27f51", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 480, + "y": 120 + } + } + ], + "wires": [ + { + "source": { + "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "port": "out" + }, + "target": { + "block": "7625149d-3511-4d95-8405-a100409a5d42", + "port": "in" + } + }, + { + "source": { + "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", + "port": "out" + }, + "target": { + "block": "c39221a3-87dd-4524-9f65-879112b27f51", + "port": "in" + } + } + ] + }, + "deps": {} +} \ No newline at end of file From dd32f82f6f09ebad3e8f571ecef6b54b39f43d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 15:52:31 +0100 Subject: [PATCH 017/169] Add complex demo project --- demo/block.iceb | 114 ++++++++++ demo/complex.ice | 358 ++++++++++++++++++++++++++++++++ demo/constant-io-code-block.ice | 127 +++++++++++ 3 files changed, 599 insertions(+) create mode 100644 demo/block.iceb create mode 100644 demo/complex.ice create mode 100644 demo/constant-io-code-block.ice diff --git a/demo/block.iceb b/demo/block.iceb new file mode 100644 index 000000000..95e911752 --- /dev/null +++ b/demo/block.iceb @@ -0,0 +1,114 @@ +{ + "image": "", + "state": { + "pan": { + "x": 45.83406713517239, + "y": 43.306661649315814 + }, + "zoom": 0.8527620016280335 + }, + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 360, + "y": 8 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "out" + }, + "position": { + "x": 712, + "y": 264 + } + }, + { + "id": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [ + "i" + ], + "out": [ + "o" + ] + } + }, + "position": { + "x": 216, + "y": 168 + } + }, + { + "id": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "type": "basic.input", + "data": { + "label": "in" + }, + "position": { + "x": 24, + "y": 264 + } + }, + { + "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 24, + "y": 360 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "v" + } + }, + { + "source": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + }, + { + "source": { + "block": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "port": "out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "i" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/complex.ice b/demo/complex.ice new file mode 100644 index 000000000..bef5d1b15 --- /dev/null +++ b/demo/complex.ice @@ -0,0 +1,358 @@ +{ + "image": "", + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 0.9999999822412187 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "1aa80d81-052d-426d-a073-a6e9678a9959", + "type": "block", + "data": {}, + "position": { + "x": 232, + "y": 264 + } + }, + { + "id": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "type": "block", + "data": {}, + "position": { + "x": 448, + "y": 280 + } + }, + { + "id": "1ffad532-f6da-47b0-8e85-d27fdcc211a8", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 48, + "y": 248 + } + }, + { + "id": "3e7df107-03ee-4c35-9e52-607770f4c832", + "type": "basic.output", + "data": { + "label": "a", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 176, + "y": 80 + } + }, + { + "id": "8216800a-e417-4044-9adf-403f8568c3f5", + "type": "basic.output", + "data": { + "label": "b", + "pin": { + "name": "LED1", + "value": "96" + } + }, + "position": { + "x": 600, + "y": 80 + } + }, + { + "id": "083f6679-313b-497a-b2f0-4d972bc3cffa", + "type": "basic.output", + "data": { + "label": "c", + "pin": { + "name": "LED2", + "value": "97" + } + }, + "position": { + "x": 712, + "y": 184 + } + }, + { + "id": "8631a189-f5ed-4be1-88df-30d6acb97f99", + "type": "basic.output", + "data": { + "label": "d", + "pin": { + "name": "LED3", + "value": "98" + } + }, + "position": { + "x": 712, + "y": 280 + } + }, + { + "id": "365fa313-f3c1-433d-9d51-97429dfaa3c8", + "type": "basic.constant", + "data": { + "label": "Value", + "value": "1'b1" + }, + "position": { + "x": 344, + "y": 80 + } + } + ], + "wires": [ + { + "source": { + "block": "1ffad532-f6da-47b0-8e85-d27fdcc211a8", + "port": "out" + }, + "target": { + "block": "1aa80d81-052d-426d-a073-a6e9678a9959", + "port": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f" + } + }, + { + "source": { + "block": "1aa80d81-052d-426d-a073-a6e9678a9959", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "port": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f" + } + }, + { + "source": { + "block": "1aa80d81-052d-426d-a073-a6e9678a9959", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "1aa80d81-052d-426d-a073-a6e9678a9959", + "port": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf" + }, + "vertices": [ + { + "x": 288, + "y": 352 + } + ] + }, + { + "source": { + "block": "1ffad532-f6da-47b0-8e85-d27fdcc211a8", + "port": "out" + }, + "target": { + "block": "3e7df107-03ee-4c35-9e52-607770f4c832", + "port": "in" + }, + "vertices": [] + }, + { + "source": { + "block": "365fa313-f3c1-433d-9d51-97429dfaa3c8", + "port": "constant-out" + }, + "target": { + "block": "1aa80d81-052d-426d-a073-a6e9678a9959", + "port": "386bc685-d806-4487-bece-b442b8c8689c" + }, + "vertices": [] + }, + { + "source": { + "block": "365fa313-f3c1-433d-9d51-97429dfaa3c8", + "port": "constant-out" + }, + "target": { + "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "port": "386bc685-d806-4487-bece-b442b8c8689c" + } + }, + { + "source": { + "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "083f6679-313b-497a-b2f0-4d972bc3cffa", + "port": "in" + }, + "vertices": [ + { + "x": 592, + "y": 264 + } + ] + }, + { + "source": { + "block": "365fa313-f3c1-433d-9d51-97429dfaa3c8", + "port": "constant-out" + }, + "target": { + "block": "8216800a-e417-4044-9adf-403f8568c3f5", + "port": "in" + } + }, + { + "source": { + "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" + }, + "target": { + "block": "8631a189-f5ed-4be1-88df-30d6acb97f99", + "port": "in" + } + }, + { + "source": { + "block": "1ffad532-f6da-47b0-8e85-d27fdcc211a8", + "port": "out" + }, + "target": { + "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", + "port": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf" + }, + "vertices": [ + { + "x": 168, + "y": 392 + } + ] + } + ] + }, + "deps": { + "block": { + "image": "", + "state": { + "pan": { + "x": 45.83406713517239, + "y": 43.306661649315814 + }, + "zoom": 0.8527620016280335 + }, + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 360, + "y": 8 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "out" + }, + "position": { + "x": 712, + "y": 264 + } + }, + { + "id": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [ + "i" + ], + "out": [ + "o" + ] + } + }, + "position": { + "x": 216, + "y": 168 + } + }, + { + "id": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "type": "basic.input", + "data": { + "label": "in" + }, + "position": { + "x": 24, + "y": 264 + } + }, + { + "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 24, + "y": 360 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "v" + } + }, + { + "source": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + }, + { + "source": { + "block": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "port": "out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "i" + } + } + ] + }, + "deps": {} + } + } +} \ No newline at end of file diff --git a/demo/constant-io-code-block.ice b/demo/constant-io-code-block.ice new file mode 100644 index 000000000..819b5de0e --- /dev/null +++ b/demo/constant-io-code-block.ice @@ -0,0 +1,127 @@ +{ + "image": "", + "state": { + "pan": { + "x": 45.83406713517239, + "y": 43.306661649315814 + }, + "zoom": 0.8527620016280335 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "386bc685-d806-4487-bece-b442b8c8689c", + "type": "basic.constant", + "data": { + "label": "C", + "value": "1'b0" + }, + "position": { + "x": 360, + "y": 8 + } + }, + { + "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "type": "basic.output", + "data": { + "label": "out", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 712, + "y": 264 + } + }, + { + "id": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "type": "basic.code", + "data": { + "code": "assign o = v;", + "params": [ + "v" + ], + "ports": { + "in": [ + "i" + ], + "out": [ + "o" + ] + } + }, + "position": { + "x": 216, + "y": 168 + } + }, + { + "id": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "type": "basic.input", + "data": { + "label": "in", + "pin": { + "name": "SW1", + "value": "10" + } + }, + "position": { + "x": 24, + "y": 264 + } + }, + { + "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", + "type": "basic.input", + "data": { + "label": "", + "pin": { + "name": "", + "value": 0 + } + }, + "position": { + "x": 24, + "y": 360 + } + } + ], + "wires": [ + { + "source": { + "block": "386bc685-d806-4487-bece-b442b8c8689c", + "port": "constant-out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "v" + } + }, + { + "source": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "o" + }, + "target": { + "block": "94e9a915-defe-4437-8abd-d3e57dafbb45", + "port": "in" + } + }, + { + "source": { + "block": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", + "port": "out" + }, + "target": { + "block": "ec9b901f-4cda-4f53-81ae-bfd74a0f0ae6", + "port": "i" + } + } + ] + }, + "deps": {} +} \ No newline at end of file From 0bd65a7fd788c74e643c296aeb91ec2f43badfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 17:11:03 +0100 Subject: [PATCH 018/169] Add connections filters --- app/scripts/plugins/shapes/joint.shapes.js | 4 ++ app/scripts/services/compiler.service.js | 2 +- app/scripts/services/graph.service.js | 16 +++++- demo/complex.ice | 27 +--------- demo/constant-output.ice | 61 ---------------------- 5 files changed, 21 insertions(+), 89 deletions(-) delete mode 100644 demo/constant-output.ice diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index e6f1ef72f..f88c7c208 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -46,18 +46,22 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({ opacity: 0 }, '.leftPorts .port-body': { + pos: 'left', type: 'input', magnet: false }, '.rightPorts .port-body': { + pos: 'right', type: 'output', magnet: true }, '.topPorts .port-body': { + pos: 'top', type: 'input', magnet: false }, '.bottomPorts .port-body': { + pos: 'bottom', type: 'output', magnet: true }, diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 88b1aa8a0..bf826eaa5 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -184,7 +184,7 @@ angular.module('icestudio') else if (block.type == 'basic.output') { if (wire.target.block == block.id) { if (wire.source.port == 'constant-out') { - connections.assign.push('assign ' + digestId(block.id) + ' = p' + w + ';'); + // connections.assign.push('assign ' + digestId(block.id) + ' = p' + w + ';'); } else { connections.assign.push('assign ' + digestId(block.id) + ' = w' + w + ';'); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 038f6a5d0..f40fa1d8d 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -108,12 +108,26 @@ angular.module('icestudio') // Prevent output-output links if (magnetS.getAttribute('type') == 'output' && magnetT.getAttribute('type') == 'output') { - if (magnetS !== magnetT){ + if (magnetS !== magnetT) { // Show warning if source and target blocks are different warning(gettextCatalog.getString('Invalid connection')); } return false; } + // Ensure right -> left connections + if (magnetS.getAttribute('pos') == 'right') { + if (magnetT.getAttribute('pos') != 'left') { + warning(gettextCatalog.getString('Invalid connection')); + return false; + } + } + // Ensure bottom -> top connections + if (magnetS.getAttribute('pos') == 'bottom') { + if (magnetT.getAttribute('pos') != 'top') { + warning(gettextCatalog.getString('Invalid connection')); + return false; + } + } var links = graph.getLinks(); for (var i in links) { var linkIView = links[i].findView(paper); diff --git a/demo/complex.ice b/demo/complex.ice index bef5d1b15..222d1d5fc 100644 --- a/demo/complex.ice +++ b/demo/complex.ice @@ -5,7 +5,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999822412187 + "zoom": 1 }, "board": "icezum", "graph": { @@ -58,21 +58,6 @@ "y": 80 } }, - { - "id": "8216800a-e417-4044-9adf-403f8568c3f5", - "type": "basic.output", - "data": { - "label": "b", - "pin": { - "name": "LED1", - "value": "96" - } - }, - "position": { - "x": 600, - "y": 80 - } - }, { "id": "083f6679-313b-497a-b2f0-4d972bc3cffa", "type": "basic.output", @@ -201,16 +186,6 @@ } ] }, - { - "source": { - "block": "365fa313-f3c1-433d-9d51-97429dfaa3c8", - "port": "constant-out" - }, - "target": { - "block": "8216800a-e417-4044-9adf-403f8568c3f5", - "port": "in" - } - }, { "source": { "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", diff --git a/demo/constant-output.ice b/demo/constant-output.ice deleted file mode 100644 index 1408b9b49..000000000 --- a/demo/constant-output.ice +++ /dev/null @@ -1,61 +0,0 @@ -{ - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - }, - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "7de57b0c-2b62-4d25-864f-4cd940aa2aa5", - "type": "basic.constant", - "data": { - "label": "C", - "value": "1'b1" - }, - "position": { - "x": 152, - "y": 56 - } - }, - { - "id": "6ca79224-5f67-4c69-95fd-32d27bdc67b4", - "type": "basic.output", - "data": { - "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } - }, - "position": { - "x": 336, - "y": 184 - } - } - ], - "wires": [ - { - "source": { - "block": "7de57b0c-2b62-4d25-864f-4cd940aa2aa5", - "port": "constant-out" - }, - "target": { - "block": "6ca79224-5f67-4c69-95fd-32d27bdc67b4", - "port": "in" - }, - "vertices": [ - { - "x": 208, - "y": 216 - } - ] - } - ] - }, - "deps": {} -} \ No newline at end of file From 0df90fde4f72b85fbcd994901fa1e1b042a3a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 18:11:40 +0100 Subject: [PATCH 019/169] Remove templates --- app/package.json | 2 +- app/resources/templates/bit/0.ice | 60 ------------ app/resources/templates/bit/1.ice | 60 ------------ app/resources/templates/logic/and.ice | 113 ---------------------- app/resources/templates/logic/not.ice | 87 ----------------- app/resources/templates/logic/or.ice | 113 ---------------------- app/scripts/controllers/menu.js | 1 - app/scripts/services/graph.service.js | 10 +- app/scripts/services/resources.service.js | 4 - app/views/menu.html | 15 --- package.json | 2 +- 11 files changed, 9 insertions(+), 458 deletions(-) delete mode 100644 app/resources/templates/bit/0.ice delete mode 100644 app/resources/templates/bit/1.ice delete mode 100644 app/resources/templates/logic/and.ice delete mode 100644 app/resources/templates/logic/not.ice delete mode 100644 app/resources/templates/logic/or.ice diff --git a/app/package.json b/app/package.json index 0f1242a9e..d54304bba 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "icestudio", - "version": "0.2.3", + "version": "0.2.4-dev", "description": "Experimental graphic editor for open FPGAs", "author": "Jesús Arroyo Torrens ", "repository": "https://github.com/FPGAwars/icestudio", diff --git a/app/resources/templates/bit/0.ice b/app/resources/templates/bit/0.ice deleted file mode 100644 index 6eb2caab2..000000000 --- a/app/resources/templates/bit/0.ice +++ /dev/null @@ -1,60 +0,0 @@ -{ - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "type": "basic.code", - "data": { - "code": "// Bit 0\n\nassign v = 1'b0;", - "ports": { - "in": [], - "out": [ - "v" - ] - } - }, - "position": { - "x": 96, - "y": 96 - } - }, - { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "type": "basic.output", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 608, - "y": 192 - } - } - ], - "wires": [ - { - "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "port": "v" - }, - "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } -} \ No newline at end of file diff --git a/app/resources/templates/bit/1.ice b/app/resources/templates/bit/1.ice deleted file mode 100644 index 1c6f8e96b..000000000 --- a/app/resources/templates/bit/1.ice +++ /dev/null @@ -1,60 +0,0 @@ -{ - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "type": "basic.code", - "data": { - "code": "// Bit 1\n\nassign v = 1'b1;", - "ports": { - "in": [], - "out": [ - "v" - ] - } - }, - "position": { - "x": 96, - "y": 96 - } - }, - { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "type": "basic.output", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 608, - "y": 192 - } - } - ], - "wires": [ - { - "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "port": "v" - }, - "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } -} \ No newline at end of file diff --git a/app/resources/templates/logic/and.ice b/app/resources/templates/logic/and.ice deleted file mode 100644 index 2d7efe070..000000000 --- a/app/resources/templates/logic/and.ice +++ /dev/null @@ -1,113 +0,0 @@ -{ - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 64, - "y": 80 - } - }, - { - "id": "97b51945-d716-4b6c-9db9-970d08541249", - "type": "basic.input", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 64, - "y": 208 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 752, - "y": 144 - } - }, - { - "id": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "type": "basic.code", - "data": { - "code": "// AND logic gate\n\nassign c = a & b;", - "ports": { - "in": [ - "a", - "b" - ], - "out": [ - "c" - ] - } - }, - "position": { - "x": 256, - "y": 48 - } - } - ], - "wires": [ - { - "source": { - "block": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "port": "out" - }, - "target": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "a" - } - }, - { - "source": { - "block": "97b51945-d716-4b6c-9db9-970d08541249", - "port": "out" - }, - "target": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "b" - } - }, - { - "source": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "c" - }, - "target": { - "block": "664caf9e-5f40-4df4-800a-b626af702e62", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } -} \ No newline at end of file diff --git a/app/resources/templates/logic/not.ice b/app/resources/templates/logic/not.ice deleted file mode 100644 index 14945890e..000000000 --- a/app/resources/templates/logic/not.ice +++ /dev/null @@ -1,87 +0,0 @@ -{ - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 64, - "y": 144 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 752, - "y": 144 - } - }, - { - "id": "5365ed8c-e5db-4445-938f-8d689830ea5c", - "type": "basic.code", - "data": { - "code": "// NOT logic gate\n\nassign c = ~ a;", - "ports": { - "in": [ - "a" - ], - "out": [ - "c" - ] - } - }, - "position": { - "x": 256, - "y": 48 - } - } - ], - "wires": [ - { - "source": { - "block": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "port": "out" - }, - "target": { - "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", - "port": "a" - } - }, - { - "source": { - "block": "5365ed8c-e5db-4445-938f-8d689830ea5c", - "port": "c" - }, - "target": { - "block": "664caf9e-5f40-4df4-800a-b626af702e62", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } -} \ No newline at end of file diff --git a/app/resources/templates/logic/or.ice b/app/resources/templates/logic/or.ice deleted file mode 100644 index dc45f5f5b..000000000 --- a/app/resources/templates/logic/or.ice +++ /dev/null @@ -1,113 +0,0 @@ -{ - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 64, - "y": 80 - } - }, - { - "id": "97b51945-d716-4b6c-9db9-970d08541249", - "type": "basic.input", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 64, - "y": 208 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "", - "pin": { - "name": "", - "value": "" - } - }, - "position": { - "x": 752, - "y": 144 - } - }, - { - "id": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "type": "basic.code", - "data": { - "code": "// OR logic gate\n\nassign c = a | b;", - "ports": { - "in": [ - "a", - "b" - ], - "out": [ - "c" - ] - } - }, - "position": { - "x": 256, - "y": 48 - } - } - ], - "wires": [ - { - "source": { - "block": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "port": "out" - }, - "target": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "a" - } - }, - { - "source": { - "block": "97b51945-d716-4b6c-9db9-970d08541249", - "port": "out" - }, - "target": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "b" - } - }, - { - "source": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "c" - }, - "target": { - "block": "664caf9e-5f40-4df4-800a-b626af702e62", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } -} \ No newline at end of file diff --git a/app/scripts/controllers/menu.js b/app/scripts/controllers/menu.js index 970320283..fc7b4f8d2 100644 --- a/app/scripts/controllers/menu.js +++ b/app/scripts/controllers/menu.js @@ -25,7 +25,6 @@ angular.module('icestudio') $scope.profile = profile; $scope.examples = resources.getExamples(); - $scope.templates = resources.getTemplates(); $scope.currentBoards = boards.getBoards(); $scope.menuBlocks = resources.getMenuBlocks(); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index f40fa1d8d..4d3a2e736 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -469,9 +469,13 @@ angular.module('icestudio') '' ]; if (block && block.data) { - defaultValues[0] = ' ' + block.data.ports.in.join(' , ') + ' '; - defaultValues[1] = ' ' + block.data.ports.out.join(' , ') + ' '; - defaultValues[2] = ' ' + block.data.params.join(' , ') + ' '; + if (block.data.ports) { + defaultValues[0] = ' ' + block.data.ports.in.join(' , ') + ' '; + defaultValues[1] = ' ' + block.data.ports.out.join(' , ') + ' '; + } + if (block.data.params) { + defaultValues[2] = ' ' + block.data.params.join(' , ') + ' '; + } } utils.multiprompt( [ gettextCatalog.getString('Enter the input ports'), diff --git a/app/scripts/services/resources.service.js b/app/scripts/services/resources.service.js index 62832c6a1..2c4c1ff2c 100644 --- a/app/scripts/services/resources.service.js +++ b/app/scripts/services/resources.service.js @@ -8,10 +8,6 @@ angular.module('icestudio') return utils.getFilesRecursive(nodePath.join('resources', 'examples'), '.ice'); } - this.getTemplates = function() { - return utils.getFilesRecursive(nodePath.join('resources', 'templates'), '.ice'); - } - this.getMenuBlocks = function() { return utils.getFilesRecursive(nodePath.join('resources', 'blocks'), '.iceb'); } diff --git a/app/views/menu.html b/app/views/menu.html index d68d985e6..74c14006a 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -46,21 +46,6 @@ -
  • {{ 'Save' | translate }} diff --git a/package.json b/package.json index 7ffa7966b..b573ef17d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "icestudio", - "version": "0.2.3", + "version": "0.2.4-dev", "description": "Experimental graphic editor for open FPGAs", "author": "Jesús Arroyo Torrens ", "repository": "https://github.com/FPGAwars/icestudio", From 3f6777ad3c04645bb61c2b16f36c2509ef853d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 19:18:06 +0100 Subject: [PATCH 020/169] Add div demo. Move travis_trigger to scripts --- demo/div.ice | 112 ++++++++++++++++++ demo/div.iceb | 103 ++++++++++++++++ .../travis_trigger.sh | 0 3 files changed, 215 insertions(+) create mode 100644 demo/div.ice create mode 100644 demo/div.iceb rename travis_trigger.sh => scripts/travis_trigger.sh (100%) diff --git a/demo/div.ice b/demo/div.ice new file mode 100644 index 000000000..531e8b8f8 --- /dev/null +++ b/demo/div.ice @@ -0,0 +1,112 @@ +{ + "image": "", + "state": { + "pan": { + "x": 3, + "y": 145 + }, + "zoom": 1 + }, + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "5e63bca8-458e-4d7a-ae46-dc2e457fdbf7", + "type": "basic.input", + "data": { + "label": "clk", + "pin": { + "name": "CLK", + "value": "21" + } + }, + "position": { + "x": 64, + "y": 152 + } + }, + { + "id": "400c2d1d-bce3-4d7a-8ab9-078bd072e1b7", + "type": "basic.output", + "data": { + "label": "", + "pin": { + "name": "LED0", + "value": "95" + } + }, + "position": { + "x": 752, + "y": 152 + } + }, + { + "id": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "type": "basic.code", + "data": { + "code": "// Div 12MHz / M\n\nlocalparam N = $clog2(M);\n\nreg [N-1:0] c = 0;\n\nalways @(posedge clk_in)\n c <= (c == M - 1) ? 0 : c + 1;\n\nassign clk_out = c[N-1];", + "params": [ + "M" + ], + "ports": { + "in": [ + "clk_in" + ], + "out": [ + "clk_out" + ] + } + }, + "position": { + "x": 248, + "y": 56 + } + }, + { + "id": "4aba74c5-d08d-4d91-9401-099c6aeceb64", + "type": "basic.constant", + "data": { + "label": "M", + "value": "12000000" + }, + "position": { + "x": 392, + "y": -104 + } + } + ], + "wires": [ + { + "source": { + "block": "5e63bca8-458e-4d7a-ae46-dc2e457fdbf7", + "port": "out" + }, + "target": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "clk_in" + } + }, + { + "source": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "clk_out" + }, + "target": { + "block": "400c2d1d-bce3-4d7a-8ab9-078bd072e1b7", + "port": "in" + } + }, + { + "source": { + "block": "4aba74c5-d08d-4d91-9401-099c6aeceb64", + "port": "constant-out" + }, + "target": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "M" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/demo/div.iceb b/demo/div.iceb new file mode 100644 index 000000000..1e66a8203 --- /dev/null +++ b/demo/div.iceb @@ -0,0 +1,103 @@ +{ + "image": "", + "state": { + "pan": { + "x": 3, + "y": 145 + }, + "zoom": 1 + }, + "graph": { + "blocks": [ + { + "id": "5e63bca8-458e-4d7a-ae46-dc2e457fdbf7", + "type": "basic.input", + "data": { + "label": "clk" + }, + "position": { + "x": 64, + "y": 152 + } + }, + { + "id": "400c2d1d-bce3-4d7a-8ab9-078bd072e1b7", + "type": "basic.output", + "data": { + "label": "" + }, + "position": { + "x": 752, + "y": 152 + } + }, + { + "id": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "type": "basic.code", + "data": { + "code": "// Div 12MHz / M\n\nlocalparam N = $clog2(M);\n\nreg [N-1:0] c = 0;\n\nalways @(posedge clk_in)\n c <= (c == M - 1) ? 0 : c + 1;\n\nassign clk_out = c[N-1];", + "params": [ + "M" + ], + "ports": { + "in": [ + "clk_in" + ], + "out": [ + "clk_out" + ] + } + }, + "position": { + "x": 248, + "y": 56 + } + }, + { + "id": "4aba74c5-d08d-4d91-9401-099c6aeceb64", + "type": "basic.constant", + "data": { + "label": "M", + "value": "12000000" + }, + "position": { + "x": 392, + "y": -104 + } + } + ], + "wires": [ + { + "source": { + "block": "5e63bca8-458e-4d7a-ae46-dc2e457fdbf7", + "port": "out" + }, + "target": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "clk_in" + } + }, + { + "source": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "clk_out" + }, + "target": { + "block": "400c2d1d-bce3-4d7a-8ab9-078bd072e1b7", + "port": "in" + } + }, + { + "source": { + "block": "4aba74c5-d08d-4d91-9401-099c6aeceb64", + "port": "constant-out" + }, + "target": { + "block": "a2836617-8c44-4f54-9d1f-f2681c18db26", + "port": "M" + } + } + ] + }, + "deps": {} +} \ No newline at end of file diff --git a/travis_trigger.sh b/scripts/travis_trigger.sh similarity index 100% rename from travis_trigger.sh rename to scripts/travis_trigger.sh From 6ba26044fc77e3c8c4df4a4fd7056632168e24e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 8 Dec 2016 19:19:53 +0100 Subject: [PATCH 021/169] Check duplicated attributes in code block creation --- app/scripts/services/graph.service.js | 30 ++++++++++++++++++--------- app/scripts/services/utils.service.js | 8 +++---- app/views/menu.html | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 4d3a2e736..19e35991d 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -518,18 +518,28 @@ angular.module('icestudio') blockInstance.position.x = 31 * gridsize; blockInstance.position.y = 24 * gridsize; - if (block) { - blockInstance.data.code = block.data.code; - blockInstance.position = block.position; + var allAttrs= inPorts.concat(outPorts, params); + var numAttrs = allAttrs.length; + + // Check duplicated attributes + if (numAttrs == $.unique(allAttrs).length) { + evt.cancel = false; + if (block) { + blockInstance.data.code = block.data.code; + blockInstance.position = block.position; + } + var cell = addBasicCodeBlock(blockInstance); + var cellView = paper.findViewByModel(cell); + if (cellView.$box.css('z-index') < zIndex) { + cellView.$box.css('z-index', ++zIndex); + } + if (callback) + callback(); } - var cell = addBasicCodeBlock(blockInstance); - var cellView = paper.findViewByModel(cell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); } - - if (callback) - callback(); } }); } diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 886d2d3ef..34484c469 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -584,6 +584,10 @@ angular.module('icestudio') content.push(' '); } content.push(''); + // Restore values + for (var i = 0; i < n; i++) { + $('#input' + i.toString()).val(values[i]); + } alertify.confirm(content.join('\n')) .set('onok', function(evt) { @@ -595,10 +599,6 @@ angular.module('icestudio') callback(evt, values); }) .set('oncancel', function(evt) { - // Restore previous values - for (var i = 0; i < n; i++) { - $('#input' + i.toString()).val(values[i]); - } }); } diff --git a/app/views/menu.html b/app/views/menu.html index 74c14006a..9d070693e 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -272,9 +272,9 @@
  • {{ 'Input' | translate }} {{ 'Output' | translate }} + {{ 'Constant' | translate }} {{ 'Code' | translate }} {{ 'Info' | translate }} - {{ 'Constant' | translate }}
  • From cc28b5f4e12a8ad10cfb6de314d333f71d789edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 9 Dec 2016 06:36:26 +0100 Subject: [PATCH 022/169] Detect wire start/end directions --- app/scripts/plugins/routers/joint.routers.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/scripts/plugins/routers/joint.routers.js b/app/scripts/plugins/routers/joint.routers.js index f09b3ab63..8bd484183 100644 --- a/app/scripts/plugins/routers/joint.routers.js +++ b/app/scripts/plugins/routers/joint.routers.js @@ -22,10 +22,10 @@ joint.routers.ice = (function(g, _, joint) { maximumLoops: 2000, // possible starting directions from an element - startDirections: ['right', 'top', 'bottom'], + startDirections: ['right', 'bottom'], // possible ending directions to an element - endDirections: ['left', 'top', 'bottom'], + endDirections: ['left', 'top'], // specify directions above directionMap: { @@ -516,6 +516,14 @@ joint.routers.ice = (function(g, _, joint) { // public function return function(vertices, opt, linkView) { + if (linkView.sourceMagnet) { + opt.startDirections = [linkView.sourceMagnet.attributes.pos.value]; + } + + if (linkView.targetMagnet) { + opt.endDirections = [linkView.targetMagnet.attributes.pos.value]; + } + return router.call(linkView, vertices, _.extend({}, config, opt)); }; From 72df8555af000619ef609b850205bc5309878f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 9 Dec 2016 18:56:49 +0100 Subject: [PATCH 023/169] Check $phase before $apply --- app/scripts/controllers/menu.js | 4 +++- app/scripts/services/common.service.js | 4 +++- app/scripts/services/graph.service.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/menu.js b/app/scripts/controllers/menu.js index fc7b4f8d2..c24a4cb6d 100644 --- a/app/scripts/controllers/menu.js +++ b/app/scripts/controllers/menu.js @@ -380,7 +380,9 @@ angular.module('icestudio') boards.selectBoard(board.name); graph.resetIOChoices(); alertify.success(gettextCatalog.getString('Board {{name}} selected', { name: utils.bold(board.info.label) })); - $rootScope.$apply(); + if(!$rootScope.$$phase) { + $rootScope.$apply(); + } }); } else { diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index dfe18f33b..ddf92008e 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -57,7 +57,9 @@ angular.module('icestudio') else { alertify.notify(gettextCatalog.getString('Wrong project format: {{name}}', { name: utils.bold(name) }), 'error', 30); } - $rootScope.$apply(); + if(!$rootScope.$$phase) { + $rootScope.$apply(); + } }; this.saveProject = function(filepath) { diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 19e35991d..085de722b 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -810,7 +810,9 @@ angular.module('icestudio') addBasicConstantBlock(blockInstance, disabled); } else { - addGenericBlock(blockInstance, deps[blockInstance.type]); + if (deps && deps[blockInstance.type]) { + addGenericBlock(blockInstance, deps[blockInstance.type]); + } } } From 62ef02d1f38fdb8a10e1a40b92c4a45098e8a063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 9 Dec 2016 19:28:03 +0100 Subject: [PATCH 024/169] Update bower dependencies --- app/bower.json | 4 +--- app/index.html | 2 -- app/scripts/services/common.service.js | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/bower.json b/app/bower.json index a5d073a3b..5d85acf9e 100644 --- a/app/bower.json +++ b/app/bower.json @@ -21,9 +21,7 @@ "tests" ], "dependencies": { - "angular": "^1.5.5", - "angular-translate": "^2.11.0", - "angular-translate-loader-static-files": "^2.11.0", + "angular": "^1.6.0", "angular-route": "^1.5.5", "jquery": "^2.0.3", "backbone": "^1.2.1", diff --git a/app/index.html b/app/index.html index 611823b6a..e35d9e266 100644 --- a/app/index.html +++ b/app/index.html @@ -28,8 +28,6 @@ - - diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index ddf92008e..f6d38ed84 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -49,7 +49,7 @@ angular.module('icestudio') this.loadProject = function(name, project) { this.updateProjectName(name); - this.project = project; + this.project = JSON.parse(JSON.stringify(project)); boards.selectBoard(project.board); if (graph.loadGraph(project)) { alertify.success(gettextCatalog.getString('Project {{name}} loaded', { name: utils.bold(name) })); From 5ea7143b623779ad1c55e185197c73f86fc665dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 11 Dec 2016 14:14:09 +0100 Subject: [PATCH 025/169] Bugfix: wrong variable name --- app/scripts/services/tools.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/services/tools.service.js b/app/scripts/services/tools.service.js index 8c1027b44..1ff889c97 100644 --- a/app/scripts/services/tools.service.js +++ b/app/scripts/services/tools.service.js @@ -145,7 +145,7 @@ angular.module('icestudio') // Copy included file var copySuccess = utils.copySync(origPath, destPath, file); if (!copySuccess) { - alertify.notify(gettextCatalog.getString('File {{file}} does not exist', { file: filename }), 'error', 30); + alertify.notify(gettextCatalog.getString('File {{file}} does not exist', { file: file }), 'error', 30); break; } } From 600b4b6441be92b6d372dd733fccb4ae001af5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 11 Dec 2016 19:35:30 +0100 Subject: [PATCH 026/169] Add "local" setting to the Constant block --- app/scripts/plugins/shapes/joint.shapes.js | 10 ++++++++ app/scripts/services/graph.service.js | 29 ++++++++++++++++------ app/scripts/services/tools.service.js | 1 + app/scripts/services/utils.service.js | 28 +++++++++++++++++++++ app/styles/project.css | 8 ++++++ 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index f88c7c208..01bfd508a 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -410,6 +410,7 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ template: '\
    \ +

    *

    \ \ \
    \ @@ -425,6 +426,14 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ this.model.attributes.data.value = $(evt.target).val(); }, this)); }, + renderLocal: function() { + if (this.model.get('data').local) { + this.$box.find('p').removeClass('hidden'); + } + else { + this.$box.find('p').addClass('hidden'); + } + }, renderLabel: function () { var name = this.model.attributes.data.label; this.$box.find('label').text(name); @@ -439,6 +448,7 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ this.$box.find('.constant-input').val(''); }, update: function () { + this.renderLocal(); this.renderLabel(); this.renderPorts(); this.renderValue(); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 085de722b..c3362d0ad 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -305,7 +305,7 @@ angular.module('icestudio') if (paper.options.enabled) { alertify.prompt(gettextCatalog.getString('Update the port label'), data.data.label ? ' ' + data.data.label + ' ' : '', function(evt, label) { - label = label.replace(/ /g, ''); + var label = label.replace(/ /g, ''); if (data.data.label != label) { data.data.label = label; cellView.renderLabel(); @@ -316,14 +316,24 @@ angular.module('icestudio') } else if (data.blockType == 'basic.constant') { if (paper.options.enabled) { - alertify.prompt(gettextCatalog.getString('Update the block label'), data.data.label ? ' ' + data.data.label + ' ' : '', - function(evt, label) { - label = label.replace(/ /g, ''); + utils.constantprompt([ + gettextCatalog.getString('Update the block label'), + gettextCatalog.getString('Update the block status'), + gettextCatalog.getString('Local parameter') + ], [ + data.data.label ? ' ' + data.data.label + ' ' : '', + data.data.local ? data.data.local : false + ], + function(evt, values) { + var label = values[0].replace(/ /g, ''); if (data.data.label != label) { data.data.label = label; cellView.renderLabel(); alertify.success(gettextCatalog.getString('Label updated')); } + var local = values[1]; + data.data.local = local; + cellView.renderLocal(); }); } } @@ -646,6 +656,7 @@ angular.module('icestudio') if (names[n]) { blockInstance.data = { label: names[n], + local: false, value: '' }; var cell = addBasicConstantBlock(blockInstance); @@ -962,10 +973,12 @@ angular.module('icestudio') }); } else if (item.type == 'basic.constant') { - topPorts.push({ - id: item.id, - label: item.data.label - }); + if (!item.data.local) { + topPorts.push({ + id: item.id, + label: item.data.label + }); + } } } diff --git a/app/scripts/services/tools.service.js b/app/scripts/services/tools.service.js index 1ff889c97..0b836c737 100644 --- a/app/scripts/services/tools.service.js +++ b/app/scripts/services/tools.service.js @@ -146,6 +146,7 @@ angular.module('icestudio') var copySuccess = utils.copySync(origPath, destPath, file); if (!copySuccess) { alertify.notify(gettextCatalog.getString('File {{file}} does not exist', { file: file }), 'error', 30); + ret = false; break; } } diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 34484c469..3dd525dae 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -602,6 +602,34 @@ angular.module('icestudio') }); } + this.constantprompt = function(messages, values, callback) { + var content = []; + var n = messages.length; + content.push('
    '); + content.push('

    ' + messages[0] + '

    '); + content.push(' '); + content.push('
    '); + content.push('

    ' + messages[1] + '

    '); + content.push('
      '); + content.push('
    • ' + messages[2] + '

    • '); + content.push('
    '); + content.push('
    '); + // Restore values + $('#label').val(values[0]); + $('#local').prop('checked', values[1]); + + alertify.confirm(content.join('\n')) + .set('onok', function(evt) { + var values = []; + values.push($('#label').val()); + values.push($('#local').prop('checked')); + if (callback) + callback(evt, values); + }) + .set('oncancel', function(evt) { + }); + } + this.copySync = function(orig, dest, filename) { var ret = true; try { diff --git a/app/styles/project.css b/app/styles/project.css index 412156755..1f3552747 100644 --- a/app/styles/project.css +++ b/app/styles/project.css @@ -139,6 +139,14 @@ z-index: 0; } +.constant-block p { + position: absolute; + top: 0px; + right: 5px; + font-size: 1.5em; + color: #444; +} + .constant-block label { display: block; margin-top: 4px; From a24577a743967fb12b481a5c00800e74ffb4b527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 11 Dec 2016 19:50:23 +0100 Subject: [PATCH 027/169] Install libffi in Mac OS Drivers configuration --- app/scripts/services/utils.service.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 3dd525dae..2ecf3aa0e 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -441,7 +441,9 @@ angular.module('icestudio') var brewCommands = [ '/usr/local/bin/brew update', '/usr/local/bin/brew install libftdi', - '/usr/local/bin/brew link --overwrite libftdi' + '/usr/local/bin/brew link --overwrite libftdi', + '/usr/local/bin/brew install libffi', + '/usr/local/bin/brew link --overwrite libffi' ]; nodeChildProcess.exec(brewCommands.join('; '), function(error, stdout, stderr) { // console.log(error, stdout, stderr); From 7e6bd42eeb8d199b2d751e5691c3aafc43d75fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 14 Dec 2016 20:53:51 +0100 Subject: [PATCH 028/169] Add force to brew commands --- app/scripts/services/utils.service.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 2ecf3aa0e..3fa11136f 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -440,10 +440,12 @@ angular.module('icestudio') else { var brewCommands = [ '/usr/local/bin/brew update', - '/usr/local/bin/brew install libftdi', - '/usr/local/bin/brew link --overwrite libftdi', - '/usr/local/bin/brew install libffi', - '/usr/local/bin/brew link --overwrite libffi' + '/usr/local/bin/brew install --force libftdi', + '/usr/local/bin/brew unlink libftdi', + '/usr/local/bin/brew link --force libftdi', + '/usr/local/bin/brew install --force libffi', + '/usr/local/bin/brew unlink libffi', + '/usr/local/bin/brew link --force libffi' ]; nodeChildProcess.exec(brewCommands.join('; '), function(error, stdout, stderr) { // console.log(error, stdout, stderr); @@ -452,6 +454,7 @@ angular.module('icestudio') if ((stderr.indexOf('brew: command not found') != -1) || (stderr.indexOf('brew: No such file or directory') != -1)) { alertify.notify(gettextCatalog.getString('Homebrew is required'), 'error', 30); + // TODO: open web browser with Homebrew website on click } else if (stderr.indexOf('Error: Failed to download') != -1) { alertify.notify(gettextCatalog.getString('Internet connection required'), 'error', 30); From 90a785602271b2abbaba37cf5d44772de47dd871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 14 Dec 2016 22:00:38 +0100 Subject: [PATCH 029/169] Sort I/O ports by position --- app/scripts/services/common.service.js | 17 +++++++++++++++++ app/scripts/services/graph.service.js | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index f6d38ed84..74e10f5f0 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -171,6 +171,7 @@ angular.module('icestudio') this.exportAsBlock = function(filepath) { var name = utils.basename(filepath); + this.sortGraph(); this.refreshProject(); // Convert project to block var block = angular.copy(this.project); @@ -226,6 +227,22 @@ angular.module('icestudio') }, false); }; + this.sortGraph = function() { + var cells = graph.getCells(); + + // Sort cells by x-coordinate + cells = _.sortBy(cells, function(cell) { + return cell.attributes.position.x; + }); + + // Sort cells by y-coordinate + cells = _.sortBy(cells, function(cell) { + return cell.attributes.position.y; + }); + + graph.setCells(cells); + } + this.refreshProject = function(callback) { var graphData = graph.toJSON(); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index c3362d0ad..252cbd2d3 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -697,6 +697,14 @@ angular.module('icestudio') return graph.toJSON(); } + this.getCells = function() { + return graph.getCells(); + } + + this.setCells = function(cells) { + graph.attributes.cells.models = cells; + } + this.getContent = function(id) { return paper.findViewByModel(id).$box.find( '#content' + sha1(id).toString().substring(0, 6)).val(); From a57962f4e9ff87cb317d185146ad29c9f54cae34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 15 Dec 2016 12:07:45 +0100 Subject: [PATCH 030/169] Include compressed SVG image in the block --- app/package.json | 1 + app/resources/blocks/bit/0.iceb | 4 ++-- app/resources/blocks/bit/1.iceb | 4 ++-- app/scripts/factories/node.factory.js | 3 +++ app/scripts/plugins/shapes/joint.shapes.js | 2 +- app/scripts/services/graph.service.js | 11 +++++++---- demo/complex.ice | 20 ++++++++++---------- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/package.json b/app/package.json index d54304bba..2a144c8f4 100644 --- a/app/package.json +++ b/app/package.json @@ -36,6 +36,7 @@ "sha1": "^1.1.1", "ssh-exec": "^2.0.0", "sudo-prompt": "^6.2.0", + "svgo": "^0.7.1", "tarball-extract": "0.0.3" }, "readme": "../README.md", diff --git a/app/resources/blocks/bit/0.iceb b/app/resources/blocks/bit/0.iceb index f223d7ffe..2faefca14 100644 --- a/app/resources/blocks/bit/0.iceb +++ b/app/resources/blocks/bit/0.iceb @@ -44,7 +44,7 @@ ] }, "deps": {}, - "image": "resources/images/0.svg", + "image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2247.303%22%20height=%2227.648%22%20viewBox=%220%200%2044.346456%2025.919999%22%3E%3Ctext%20style=%22line-height:125%25%22%20x=%22325.37%22%20y=%22315.373%22%20font-weight=%22400%22%20font-size=%2212.669%22%20font-family=%22sans-serif%22%20letter-spacing=%220%22%20word-spacing=%220%22%20transform=%22translate(-307.01%20-298.51)%22%3E%3Ctspan%20x=%22325.37%22%20y=%22315.373%22%20style=%22-inkscape-font-specification:'Courier%2010%20Pitch'%22%20font-family=%22Courier%2010%20Pitch%22%3E0%3C/tspan%3E%3C/text%3E%3C/svg%3E", "state": { "pan": { "x": 0, @@ -52,4 +52,4 @@ }, "zoom": 1 } -} \ No newline at end of file +} diff --git a/app/resources/blocks/bit/1.iceb b/app/resources/blocks/bit/1.iceb index a8048566b..bc83e606f 100644 --- a/app/resources/blocks/bit/1.iceb +++ b/app/resources/blocks/bit/1.iceb @@ -44,7 +44,7 @@ ] }, "deps": {}, - "image": "resources/images/1.svg", + "image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2247.303%22%20height=%2227.648%22%20viewBox=%220%200%2044.346456%2025.919999%22%3E%3Ctext%20style=%22line-height:125%25%22%20x=%22325.218%22%20y=%22315.455%22%20font-weight=%22400%22%20font-size=%2212.669%22%20font-family=%22sans-serif%22%20letter-spacing=%220%22%20word-spacing=%220%22%20transform=%22translate(-307.01%20-298.51)%22%3E%3Ctspan%20x=%22325.218%22%20y=%22315.455%22%20style=%22-inkscape-font-specification:'Courier%2010%20Pitch'%22%20font-family=%22Courier%2010%20Pitch%22%3E1%3C/tspan%3E%3C/text%3E%3C/svg%3E", "state": { "pan": { "x": 0, @@ -52,4 +52,4 @@ }, "zoom": 1 } -} \ No newline at end of file +} diff --git a/app/scripts/factories/node.factory.js b/app/scripts/factories/node.factory.js index cd7fcde48..d9fe18323 100644 --- a/app/scripts/factories/node.factory.js +++ b/app/scripts/factories/node.factory.js @@ -48,4 +48,7 @@ angular.module('icestudio') }) .factory('nodeLangInfo', function() { return require('node-lang-info'); + }) + .factory('nodeSVGO', function() { + return require('svgo'); }); diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 01bfd508a..cc7d5d852 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -278,7 +278,7 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ var name = this.model.get('label'); if (image) { - this.$box.find('img').attr('src', image); + this.$box.find('img').attr('src', 'data:image/svg+xml,' + image); this.$box.find('img').removeClass('hidden'); this.$box.find('label').addClass('hidden'); } diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 252cbd2d3..beb052cf1 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -1023,11 +1023,14 @@ angular.module('icestudio') } var blockImage = ''; - if (block.image && - nodeFs.existsSync(block.image) && - nodeFs.lstatSync(block.image).isFile()) { - blockImage = block.image; + if (block.image) { width = 12 * gridsize; + if (block.image.startsWith('%3Csvg')) { + blockImage = block.image; + } + else if (block.image.startsWith(' Date: Thu, 15 Dec 2016 21:35:16 +0100 Subject: [PATCH 031/169] Start refactor: project service created --- app/index.html | 1 + app/package.json | 2 +- app/scripts/controllers/main.js | 35 +++++ app/scripts/controllers/menu.js | 180 ++++++++++------------- app/scripts/services/common.service.js | 158 +------------------- app/scripts/services/compiler.service.js | 47 +++--- app/scripts/services/graph.service.js | 36 +++-- app/scripts/services/project.service.js | 147 ++++++++++++++++++ app/scripts/services/utils.service.js | 63 +++++++- app/views/menu.html | 20 +-- package.json | 1 + 11 files changed, 383 insertions(+), 307 deletions(-) create mode 100644 app/scripts/services/project.service.js diff --git a/app/index.html b/app/index.html index e35d9e266..c8b5501eb 100644 --- a/app/index.html +++ b/app/index.html @@ -55,6 +55,7 @@ + diff --git a/app/package.json b/app/package.json index 2a144c8f4..8119f3a96 100644 --- a/app/package.json +++ b/app/package.json @@ -11,7 +11,7 @@ "height": 600, "min_width": 800, "min_height": 200, - "toolbar": false, + "toolbar": true, "resizable": true, "position": "center", "icon": "resources/images/icestudio-logo.png" diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index d8d5f7018..074282b40 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -19,4 +19,39 @@ angular.module('icestudio') alertify.set('confirm', 'labels', labels); }, 100); + /*var FS = require('fs'), + PATH = require('path'), + SVGO = require('svgo'), + filepath = PATH.resolve('resources', 'images', '1.svg'), + svgo = new SVGO(); + + FS.readFile(filepath, 'utf8', function(err, data) { + + if (err) { + throw err; + } + + svgo.optimize(data, function(result) { + + console.log(result); + + FS.writeFile('image.json', JSON.stringify({'image': encodeURI(result.data)}), function(err) { + if (err) throw err; + console.log('It\'s saved!'); + }); + + // { + // // optimized SVG data string + // data: 'test' + // // additional info such as width/height + // info: { + // width: '10', + // height: '20' + // } + // } + + }); + + });*/ + }); diff --git a/app/scripts/controllers/menu.js b/app/scripts/controllers/menu.js index c24a4cb6d..6969209aa 100644 --- a/app/scripts/controllers/menu.js +++ b/app/scripts/controllers/menu.js @@ -4,6 +4,7 @@ angular.module('icestudio') .controller('MenuCtrl', function ($rootScope, $scope, $timeout, + project, nodeLangInfo, nodeFs, nodePath, @@ -33,7 +34,6 @@ angular.module('icestudio') $scope.workingdir = ''; $scope.snapshotdir = ''; - $scope.currentProjectPath = ''; // Configure window var win = gui.Window.get(); @@ -71,129 +71,90 @@ angular.module('icestudio') // mouseleave event $scope.hideMenu = function (menu) { timer = $timeout(function () { - $scope.status[menu] = false; + $scope.status[menu] = false; }, 500); }; + // File $scope.newProject = function() { - alertify.prompt(gettextCatalog.getString('Enter the project\'s title'), - gettextCatalog.getString('untitled'), + alertify.prompt( + gettextCatalog.getString('Enter the project name'), + gettextCatalog.getString('untitled'), function(evt, name) { - if (name) { - common.newProject(name); - $scope.currentProjectPath = ''; - pathSync(); - } - }); - } + if (name) + project.new(name); + }); + }; $scope.openProject = function() { - setTimeout(function() { - var ctrl = angular.element('#input-open-project'); - ctrl.on('change', function(event) { - var file = event.target.files[0]; - event.target.files.clear(); - if (file) { - if (file.path.endsWith('.ice')) { - $scope.workingdir = utils.dirname(file.path) + utils.sep; - if (!graph.isEmpty()) { - alertify.confirm(gettextCatalog.getString('The current project will be removed. Do you want to continue loading the project?'), - function() { - common.openProject(file.path); - $scope.currentProjectPath = file.path; - pathSync(); - }); - } - else { - common.openProject(file.path); - $scope.currentProjectPath = file.path; - pathSync(); - } - - } - } + utils.openDialog('#input-open-project', '.ice', function(filepath) { + updateWorkingdir(filepath); + checkGraph(function() { + alertify.confirm( + gettextCatalog.getString('The current project will be removed. Do you want to continue loading the project?'), + function() { + project.open(filepath); + }); + }, + function() { + project.open(filepath); }); - ctrl.click(); - }, 0); - } + }); + }; - $scope.openStoredProject = function(name, project) { - if (project) { - if (!graph.isEmpty()) { - alertify.confirm(gettextCatalog.getString('The current project will be removed. Do you want to continue loading the project?'), - function() { - common.loadProject(name, project); - $scope.currentProjectPath = ''; - pathSync(); - }); - } - else { - common.loadProject(name, project); - $scope.currentProjectPath = ''; - pathSync(); - } + $scope.loadProject = function(name, data) { + if (data) { + checkGraph(function() { + alertify.confirm( + gettextCatalog.getString('The current project will be removed. Do you want to continue loading the project?'), + function() { + project.load(name, data); + }); + }, + function() { + project.load(name, data); + }); } - } + }; $scope.saveProject = function() { - var filepath = $scope.currentProjectPath; + var filepath = project.path; if (filepath) { - common.saveProject(filepath); + project.save(filepath); } else { $scope.saveProjectAs(); } - } + }; $scope.saveProjectAs = function(localCallback) { utils.saveDialog('#input-save-project', '.ice', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.saveProject(filepath); - $scope.currentProjectPath = filepath; - pathSync(); + updateWorkingdir(filepath); + project.save(filepath); if (localCallback) localCallback(); }); - } + }; $rootScope.$on('saveProjectAs', function(event, callback) { $scope.saveProjectAs(callback); - }) - - $scope.importBlock = function() { - setTimeout(function() { - var ctrl = angular.element('#input-import-block'); - ctrl.on('change', function(event) { - var files = JSON.parse(JSON.stringify(event.target.files)); - for (var i in files) { - if (files[i] && - files[i].path && - files[i].path.endsWith('.iceb')) { - common.importBlock(files[i].path); - } - } - event.target.files.clear(); - }); - ctrl.click(); - }, 0); - } + }); - $scope.exportAsBlock = function() { - checkGraph(function() { - utils.saveDialog('#input-export-block', '.iceb', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.exportAsBlock(filepath); + $scope.addAsBlock = function() { + utils.openDialog('#input-add-as-block', '.ice', function(filepath) { + checkGraph(function() { + project.addAsBlock(filepath); }); }); - } + }; $scope.exportVerilog = function() { checkGraph(function() { utils.saveDialog('#input-export-verilog', '.v', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.exportVerilog(filepath); + project.export('verilog', filepath, gettextCatalog.getString('Verilog code exported')); + updateWorkingdir(filepath); }); }); } @@ -201,8 +162,8 @@ angular.module('icestudio') $scope.exportPCF = function() { checkGraph(function() { utils.saveDialog('#input-export-pcf', '.pcf', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.exportPCF(filepath); + project.export('pcf', filepath, gettextCatalog.getString('PCF file exported')); + updateWorkingdir(filepath); }); }); } @@ -210,8 +171,8 @@ angular.module('icestudio') $scope.exportTestbench = function() { checkGraph(function() { utils.saveDialog('#input-export-testbench', '.v', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.exportTestbench(filepath); + project.export('testbench', filepath, gettextCatalog.getString('Testbench exported')); + updateWorkingdir(filepath); }); }); } @@ -219,20 +180,32 @@ angular.module('icestudio') $scope.exportGTKwave = function() { checkGraph(function() { utils.saveDialog('#input-export-gtkwave', '.gtkw', function(filepath) { - $scope.workingdir = utils.dirname(filepath) + utils.sep; - common.exportGTKWave(filepath); + project.export('gtkwave', filepath, gettextCatalog.getString('GTKWave exported')); + updateWorkingdir(filepath); }); }); } + function updateWorkingdir(filepath) { + $scope.workingdir = utils.dirname(filepath) + utils.sep; + }; + + // Edit - $scope.setImagePath = function() { - var current = common.project.image; + $scope.setProjectInformation = function() { + + var values = [ + + ]; + utils.projectinfoprompt(values, function(evt, values) { + + }); + /*var current = common.project.image; alertify.prompt(gettextCatalog.getString('Enter the project\'s image path'), (current) ? current : '', function(evt, imagePath) { common.setImagePath(imagePath); - }); + });*/ } $scope.setRemoteHostname = function() { @@ -413,13 +386,16 @@ angular.module('icestudio') }); } - function checkGraph(callback) { + function checkGraph(callback, callback2) { if (!graph.isEmpty()) { if (callback) callback(); } else { - alertify.notify(gettextCatalog.getString('Add a block to start'), 'warning', 5); + if (callback2) + callback2(); + else + alertify.notify(gettextCatalog.getString('Add a block to start'), 'warning', 5); } } @@ -450,10 +426,6 @@ angular.module('icestudio') // Help $scope.openUrl = function(url) { - /*gui.Window.open(url, { - nodejs: false, - "new-instance": false - });*/ event.preventDefault(); gui.Shell.openExternal(url); } diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index 74e10f5f0..b2685b085 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -3,73 +3,8 @@ angular.module('icestudio') .service('common', ['$rootScope', 'gettextCatalog', 'window', 'graph', 'boards', 'compiler', 'utils', 'nodePath', 'nodeFs', function($rootScope, gettextCatalog, window, graph, boards, compiler, utils, nodePath, nodeFs) { - - // Variables - - this.project = { - image: '', - state: null, - board: '', - graph: {}, - deps: {} - }; - this.projectName = ''; - this.projectPath = ''; - // Functions - this.setProjectPath = function(path) { - this.projectPath = path; - } - - this.newProject = function(name) { - this.project = { - image: '', - state: null, - board: '', - graph: {}, - deps: {} - }; - graph.clearAll(); - graph.setState(this.project.state); - this.updateProjectName(name); - alertify.success(gettextCatalog.getString('New project {{name}} created', { name: utils.bold(name) })); - }; - - this.openProject = function(filepath) { - var self = this; - utils.readFile(filepath, function(data) { - var project = data; - if (project) { - var name = utils.basename(filepath); - self.loadProject(name, project); - } - }); - }; - - this.loadProject = function(name, project) { - this.updateProjectName(name); - this.project = JSON.parse(JSON.stringify(project)); - boards.selectBoard(project.board); - if (graph.loadGraph(project)) { - alertify.success(gettextCatalog.getString('Project {{name}} loaded', { name: utils.bold(name) })); - } - else { - alertify.notify(gettextCatalog.getString('Wrong project format: {{name}}', { name: utils.bold(name) }), 'error', 30); - } - if(!$rootScope.$$phase) { - $rootScope.$apply(); - } - }; - - this.saveProject = function(filepath) { - var name = utils.basename(filepath); - this.updateProjectName(name); - this.refreshProject(); - utils.saveFile(filepath, this.project, function() { - alertify.success(gettextCatalog.getString('Project {{name}} saved', { name: utils.bold(name) })); - }, true); - }; this.importBlock = function(filepath) { var self = this; @@ -187,108 +122,27 @@ angular.module('icestudio') }, true); }; - this.exportVerilog = function(filepath) { - var name = utils.basename(filepath); - this.refreshProject(); - // Generate verilog code from project - var verilog = compiler.generateVerilog(this.project); - utils.saveFile(filepath, verilog, function() { - alertify.success(gettextCatalog.getString('Verilog code exported')); - }, false); - }; - - this.exportPCF = function(filepath) { - var name = utils.basename(filepath); - this.refreshProject(); - // Generate pcf code from project - var pcf = compiler.generatePCF(this.project); - utils.saveFile(filepath, pcf, function() { - alertify.success(gettextCatalog.getString('PCF file exported')); - }, false); - }; - - this.exportTestbench = function(filepath) { - var name = utils.basename(filepath); - this.refreshProject(); - // Generate testbench code from project - var testbench = compiler.generateTestbench(this.project); - utils.saveFile(filepath, testbench, function() { - alertify.success(gettextCatalog.getString('Testbench exported')); - }, false); - }; - - this.exportGTKWave = function(filepath) { - var name = utils.basename(filepath); - this.refreshProject(); - // Generate gtkwave code from project - var gtkwave = compiler.generateGTKWave(this.project); - utils.saveFile(filepath, gtkwave, function() { - alertify.success(gettextCatalog.getString('GTKWave exported')); - }, false); - }; - this.sortGraph = function() { var cells = graph.getCells(); // Sort cells by x-coordinate cells = _.sortBy(cells, function(cell) { - return cell.attributes.position.x; + if (!cell.isLink()) { + return cell.attributes.position.x; + } }); // Sort cells by y-coordinate cells = _.sortBy(cells, function(cell) { - return cell.attributes.position.y; + if (!cell.isLink()) { + return cell.attributes.position.y; + } }); graph.setCells(cells); } - this.refreshProject = function(callback) { - var graphData = graph.toJSON(); - - var blocks = []; - var wires = []; - for (var c = 0; c < graphData.cells.length; c++) { - var cell = graphData.cells[c]; - - if (cell.type == 'ice.Generic' || - cell.type == 'ice.Input' || - cell.type == 'ice.Output' || - cell.type == 'ice.Code' || - cell.type == 'ice.Info' || - cell.type == 'ice.Constant') { - var block = {}; - block.id = cell.id; - block.type = cell.blockType; - block.data = cell.data; - block.position = cell.position; - if (cell.type == 'ice.Code') { - block.data.code = graph.getContent(cell.id); - } - else if (cell.type == 'ice.Info') { - block.data.info = graph.getContent(cell.id); - } - blocks.push(block); - } - else if (cell.type == 'ice.Wire') { - var wire = {}; - wire.source = { block: cell.source.id, port: cell.source.port }; - wire.target = { block: cell.target.id, port: cell.target.port }; - wire.vertices = cell.vertices; - wires.push(wire); - } - } - - this.project.state = graph.getState(); - - this.project.board = boards.selectedBoard.name; - - this.project.graph = { blocks: blocks, wires: wires }; - - if (callback) - callback(); - }; this.clearProject = function() { this.project = { diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index bf826eaa5..10dc051b4 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -4,30 +4,31 @@ angular.module('icestudio') .service('compiler', ['nodeSha1', '_package', function(nodeSha1, _package) { - this.generateVerilog = function(project) { - var code = header('//'); - code += '`default_nettype none\n'; - code += verilogCompiler('main', project); - return code; - }; - - this.generatePCF = function(project) { - var code = header('#'); - code += pcfCompiler(project); - return code; - }; - - this.generateTestbench = function(project) { - var code = header('//'); - code += testbenchCompiler(project); - return code; - }; - - this.generateGTKWave = function(project) { - var code = header('[*]'); - code += gtkwaveCompiler(project); + this.generate = function(target, project) { + var code = ''; + switch(target) { + case 'verilog': + code += header('//'); + code += '`default_nettype none\n'; + code += verilogCompiler('main', project); + break; + case 'pcf': + code += header('#'); + code += pcfCompiler(project); + break; + case 'testbench': + code += header('//'); + code += testbenchCompiler(project); + break; + case 'verilog': + code += header('[*]'); + code += gtkwaveCompiler(project); + break; + default: + code += ''; + } return code; - }; + } function header(comment) { var header = ''; diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index beb052cf1..6d07f86d3 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -56,6 +56,16 @@ angular.module('icestudio') this.setState(null); } + this.resetBreadcrumbs = function(name) { + if (this.breadcrumbs.length > 1) { + this.breadcrumbs = [{ name: name }]; + } + this.breadcrumbs[0].name = name; + if(!$rootScope.$$phase) { + $rootScope.$apply(); + } + } + function setGrid(paper, size, offset) { // TODO: draw grid in a SVG because 'background' truncates the parameters @@ -361,12 +371,12 @@ angular.module('icestudio') zIndex = 1; if (self.breadcrumbs.length == 2) { $rootScope.$broadcast('refreshProject', function() { - self.loadGraph(dependencies[data.blockType], disabled); + self.loadDesign(dependencies[data.blockType], disabled); self.appEnable(false); }); } else { - self.loadGraph(dependencies[data.blockType], disabled); + self.loadDesign(dependencies[data.blockType], disabled); self.appEnable(false); } } @@ -793,22 +803,22 @@ angular.module('icestudio') return paper.options.enabled; } - this.loadGraph = function(project, disabled) { - if (project && - project.graph && - project.graph.blocks && - project.graph.wires && - project.deps) { + this.loadDesign = function(design, disabled) { + if (design && + design.graph && + design.graph.blocks && + design.graph.wires && + design.deps) { - var blockInstances = project.graph.blocks; - var wires = project.graph.wires; - var deps = project.deps; + var blockInstances = design.graph.blocks; + var wires = design.graph.wires; + var deps = design.deps; - dependencies = project.deps; + dependencies = design.deps; this.clearAll(); - this.setState(project.state); + this.setState(design.state); // Blocks for (var i in blockInstances) { diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js new file mode 100644 index 000000000..658989d23 --- /dev/null +++ b/app/scripts/services/project.service.js @@ -0,0 +1,147 @@ +'use strict'; + +angular.module('icestudio') + .service('project', function(graph, boards, compiler, utils, gettextCatalog) { + + this.path = ''; + this.project = {}; + + function _default() { + return { + version: '1.0', + package: { + name: '', + version: '', + description: '', + author: '', + image: '' + }, + design: { + board: '', + graph: { blocks: [], wires: [] }, + deps: {}, + state: { pan: { x: 0, y: 0 }, zoom: 1.0 } + } + } + }; + + this.new = function(name) { + this.path = ''; + this.project = _default(); + + graph.clearAll(); + graph.resetBreadcrumbs(name); + graph.setState(this.project.design.state); + + utils.updateWindowTitle(name + ' - Icestudio'); + alertify.success(gettextCatalog.getString('New project {{name}} created', { name: utils.bold(name) })); + }; + + this.open = function(filepath) { + var self = this; + utils.readFile(filepath, function(data) { + if (data) { + var name = utils.basename(filepath); + self.path = filepath; + self.load(name, data); + } + }); + }; + + this.load = function(name, data) { + this.name = name; + this.project = _safeLoad(name, data); + + if (graph.loadDesign(this.project.design)) { + graph.resetBreadcrumbs(name); + boards.selectBoard(this.project.design.board); + utils.rootScopeSafeApply(); + alertify.success(gettextCatalog.getString('Project {{name}} loaded', { name: utils.bold(name) })); + } + else { + alertify.notify(gettextCatalog.getString('Wrong project format: {{name}}', { name: utils.bold(name) }), 'error', 30); + } + }; + + function _safeLoad(name, data) { + var project = {}; + if (project.version) { + if (project.version == '1.0') { + // Version 1.0 + project = data; + } + } + else { + // Version 0.0 + project = _default() + project.package.name = name; + project.design = data; + } + return project; + }; + + this.save = function(filepath) { + var name = utils.basename(filepath); + utils.updateWindowTitle(name + ' - Icestudio'); + this.path = filepath; + + this.update(); + utils.saveFile(filepath, this.project, function() { + alertify.success(gettextCatalog.getString('Project {{name}} saved', { name: utils.bold(name) })); + }, true); + }; + + this.update = function(callback) { + var graphData = graph.toJSON(); + + var blocks = []; + var wires = []; + + for (var c = 0; c < graphData.cells.length; c++) { + var cell = graphData.cells[c]; + + if (cell.type == 'ice.Generic' || + cell.type == 'ice.Input' || + cell.type == 'ice.Output' || + cell.type == 'ice.Code' || + cell.type == 'ice.Info' || + cell.type == 'ice.Constant') { + var block = {}; + block.id = cell.id; + block.type = cell.blockType; + block.data = cell.data; + block.position = cell.position; + if (cell.type == 'ice.Code') { + block.data.code = graph.getContent(cell.id); + } + else if (cell.type == 'ice.Info') { + block.data.info = graph.getContent(cell.id); + } + blocks.push(block); + } + else if (cell.type == 'ice.Wire') { + var wire = {}; + wire.source = { block: cell.source.id, port: cell.source.port }; + wire.target = { block: cell.target.id, port: cell.target.port }; + wire.vertices = cell.vertices; + wires.push(wire); + } + } + + this.project.design.state = graph.getState(); + this.project.design.board = boards.selectedBoard.name; + this.project.design.graph = { blocks: blocks, wires: wires }; + + if (callback) + callback(); + }; + + this.export = function(target, filepath, message) { + this.update(); + var data = compiler.generate(target, this.project); + utils.saveFile(filepath, data, function() { + alertify.success(message); + }, false); + }; + + }); diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 3fa11136f..2c5c35b83 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -2,8 +2,8 @@ 'use strict'; angular.module('icestudio') - .service('utils', ['gettextCatalog', 'nodeFs', 'nodeFse', 'nodeOs', 'nodePath', 'nodeChildProcess', 'nodeTarball', 'nodeZlib', 'nodeSudo', 'nodeOnline', 'nodeGlob', '_package', - function(gettextCatalog, nodeFs, nodeFse, nodeOs, nodePath, nodeChildProcess, nodeTarball, nodeZlib, nodeSudo, nodeOnline, nodeGlob, _package) { + .service('utils', ['$rootScope', 'gettextCatalog', 'nodeFs', 'nodeFse', 'nodeOs', 'nodePath', 'nodeChildProcess', 'nodeTarball', 'nodeZlib', 'nodeSudo', 'nodeOnline', 'nodeGlob', '_package', 'window', + function($rootScope, gettextCatalog, nodeFs, nodeFse, nodeOs, nodePath, nodeChildProcess, nodeTarball, nodeZlib, nodeSudo, nodeOnline, nodeGlob, _package, window) { const WIN32 = Boolean(process.platform.indexOf('win32') > -1); const DARWIN = Boolean(process.platform.indexOf('darwin') > -1); @@ -635,6 +635,40 @@ angular.module('icestudio') }); } + this.projectinfoprompt = function(values, callback) { + var content = []; + var messages = [ + gettextCatalog.getString('Name'), + gettextCatalog.getString('Version'), + gettextCatalog.getString('Description'), + gettextCatalog.getString('Author') + ] + var n = messages.length; + content.push('
    '); + for (var i in messages) { + if (i > 0) content.push('
    '); + content.push('

    ' + messages[i] + '

    '); + content.push(' '); + } + content.push('
    '); + // Restore values + for (var i = 0; i < n; i++) { + $('#input' + i.toString()).val(values[i]); + } + + alertify.confirm(content.join('\n')) + .set('onok', function(evt) { + var values = []; + for (var i = 0; i < n; i++) { + values.push($('#input' + i.toString()).val()); + } + if (callback) + callback(evt, values); + }) + .set('oncancel', function(evt) { + }); + } + this.copySync = function(orig, dest, filename) { var ret = true; try { @@ -675,6 +709,20 @@ angular.module('icestudio') return '' + text + ''; } + this.openDialog = function(inputID, ext, callback) { + var chooser = $(inputID); + chooser.unbind('change'); + chooser.change(function(evt) { + var filepath = $(this).val(); + //if (filepath.endsWith(ext)) { + if (callback) + callback(filepath); + //} + $(this).val(''); + }); + chooser.trigger('click'); + } + this.saveDialog = function(inputID, ext, callback) { var chooser = $(inputID); chooser.unbind('change'); @@ -689,4 +737,15 @@ angular.module('icestudio') chooser.trigger('click'); } + this.updateWindowTitle = function(title) { + window.get().title = title; + } + + this.rootScopeSafeApply = function() { + if(!$rootScope.$$phase) { + $rootScope.$apply(); + } + } + + }]); diff --git a/app/views/menu.html b/app/views/menu.html index 9d070693e..d0af6601b 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -6,8 +6,7 @@ - - + @@ -24,10 +23,10 @@ {{ 'File' | translate }}
    • - {{ 'New project' | translate }} + {{ 'New' | translate }}
    • - {{ 'Open project' | translate }} + {{ 'Open' | translate }}...