From b5ce60ed24ee56c73f29994aeadb8efe5230ed12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 18 Dec 2016 09:58:35 +0100 Subject: [PATCH 01/35] Add Virtual-FGPA I/O ports management --- app/index.html | 2 +- app/scripts/plugins/shapes/joint.shapes.js | 94 ++++++++++++++-------- app/scripts/services/compiler.service.js | 4 +- app/scripts/services/graph.service.js | 48 ++++++----- app/scripts/services/project.service.js | 1 + app/scripts/services/utils.service.js | 9 +-- app/styles/{project.css => design.css} | 29 +++++-- 7 files changed, 120 insertions(+), 67 deletions(-) rename app/styles/{project.css => design.css} (92%) diff --git a/app/index.html b/app/index.html index 3e2ff3b32..c48401b00 100644 --- a/app/index.html +++ b/app/index.html @@ -16,7 +16,7 @@ - + diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index f7699e8f9..5ee639e52 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -327,59 +327,89 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ - template: '\ -
\ - \ - \ - \ -
\ - ', + id: '', initialize: function() { joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); - // Prevent paper from handling pointerdown. - this.$box.find('.io-combo').on('mousedown click', function(evt) { evt.stopPropagation(); }); + this.id = sha1(this.model.get('id')).toString().substring(0, 6); + var virtualPortId = 'virtualPort' + this.id; + var fpgaPortId = 'fpgaPort' + this.id; + var comboId = 'combo' + this.id; + var connected = this.model.get('data').connected; + this.$box = $(joint.util.template( + '\ +
\ + \ +
\ +
\ + \ + \ + \ +
\ + ' + )()); + + this.$box.find('#' + virtualPortId); - this.$box.find('.io-combo').on('change', _.bind(function(evt) { + // Prevent paper from handling pointerdown. + var comboSelector = this.$box.find('#' + comboId); + comboSelector.on('mousedown click', function(evt) { evt.stopPropagation(); }); + comboSelector.on('change', _.bind(function(evt) { this.model.attributes.data.pin.name = $(evt.target).find('option:selected').text(); this.model.attributes.data.pin.value = $(evt.target).val(); }, this)); }, - renderLabel: function () { - var name = this.model.attributes.data.label; - this.$box.find('label').text(name); + renderChoides: function() { + var comboId = '#combo' + this.id; + var comboSelector = this.$box.find(comboId); + var choices = this.model.get('choices'); + + comboSelector.empty(); + comboSelector.append(''); + for (var c in choices) { + comboSelector.append(''); + } }, - renderChoices: function() { - if (this.model.get('disabled')) { - this.$box.find('.io-combo').removeClass('select2'); - this.$box.find('.io-combo').css({'display': 'none'}); + renderBlock: function() { + var virtualPortId = '#virtualPort' + this.id; + var fpgaPortId = '#fpgaPort' + this.id; + var name = this.model.get('data').label; + + this.$box.find('label').text(name); + + if (this.model.get('data').connected) { + // FPGA I/O port (yellow) + $(virtualPortId).addClass('hidden'); + $(fpgaPortId).removeClass('hidden'); } else { - var choices = this.model.get('choices'); - var $select = this.$box.find('.io-combo').empty(); - - $select.append(''); - for (var c in choices) { - $select.append(''); - } + // Virtual port (green) + $(fpgaPortId).addClass('hidden'); + $(virtualPortId).removeClass('hidden'); + } + }, + renderValue: function() { + var comboId = '#combo' + this.id; + var comboSelector = this.$box.find(comboId); - if (this.model.get('data').pin) { - this.$box.find('.io-combo').val(this.model.get('data').pin.value); - } + if (this.model.get('data').pin) { + comboSelector.val(this.model.get('data').pin.value); } }, clearValue: function () { + var comboId = '#combo' + this.id; this.model.attributes.data.pin.name = ''; this.model.attributes.data.pin.value = 0; - this.$box.find('.io-combo').val(''); + this.$box.find(comboId).val(''); }, update: function () { - this.renderLabel(); this.renderPorts(); - this.renderChoices(); + this.renderBlock(); + this.renderChoides(); + this.renderValue(); joint.dia.ElementView.prototype.update.apply(this, arguments); } }); diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index ae135d599..374525988 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -377,7 +377,9 @@ angular.module('icestudio') code += 'set_io '; code += digestId(block.id); code += ' '; - code += block.data.pin.value; + if (block.data.connected) { + code += block.data.pin.value; + } code += '\n'; } } diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 986026ff3..6a09a316b 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -280,25 +280,32 @@ angular.module('icestudio') if (data.blockType === 'basic.input' || data.blockType === 'basic.output') { 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, ''); + utils.inputcheckboxprompt([ + gettextCatalog.getString('Update the port label'), + gettextCatalog.getString('Connect to an FPGA port') + ], [ + data.data.label ? data.data.label : '', + data.data.connected ? data.data.connected : 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')); + alertify.success(gettextCatalog.getString('Block updated')); } + var connected = values[1]; + data.data.connected = connected; + cellView.renderBlock(); }); } } else if (data.blockType === 'basic.constant') { if (paper.options.enabled) { - utils.constantprompt([ + utils.inputcheckboxprompt([ gettextCatalog.getString('Update the block label'), - gettextCatalog.getString('Update the block status'), gettextCatalog.getString('Local parameter') ], [ - data.data.label ? ' ' + data.data.label + ' ' : '', + data.data.label ? data.data.label : '', data.data.local ? data.data.local : false ], function(evt, values) { @@ -306,7 +313,7 @@ angular.module('icestudio') if (data.data.label !== label) { data.data.label = label; cellView.renderLabel(); - alertify.success(gettextCatalog.getString('Label updated')); + alertify.success(gettextCatalog.getString('Block updated')); } var local = values[1]; data.data.local = local; @@ -444,17 +451,17 @@ angular.module('icestudio') if (type === 'basic.code') { var defaultValues = [ - ' a , b ', - ' c , d ', + 'a , b', + 'c , d', '' ]; if (block && block.data) { if (block.data.ports) { - defaultValues[0] = ' ' + block.data.ports.in.join(' , ') + ' '; - defaultValues[1] = ' ' + block.data.ports.out.join(' , ') + ' '; + defaultValues[0] = block.data.ports.in.join(' , '); + defaultValues[1] = block.data.ports.out.join(' , '); } if (block.data.params) { - defaultValues[2] = ' ' + block.data.params.join(' , ') + ' '; + defaultValues[2] = block.data.params.join(' , '); } } utils.multiprompt( @@ -539,7 +546,7 @@ angular.module('icestudio') } } else if (type === 'basic.input') { - alertify.prompt(gettextCatalog.getString('Enter the input ports'), ' in ', + alertify.prompt(gettextCatalog.getString('Enter the input ports'), 'in', function(evt, name) { if (name) { var names = name.replace(/ /g, '').split(','); @@ -579,7 +586,7 @@ angular.module('icestudio') }); } else if (type === 'basic.output') { - alertify.prompt(gettextCatalog.getString('Enter the output ports'), ' out ', + alertify.prompt(gettextCatalog.getString('Enter the output ports'), 'out', function(evt, name) { if (name) { var names = name.replace(/ /g, '').split(','); @@ -621,7 +628,7 @@ angular.module('icestudio') }); } else if (type === 'basic.constant') { - alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), ' C ', + alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), 'C', function(evt, name) { if (name) { var names = name.replace(/ /g, '').split(','); @@ -854,9 +861,8 @@ angular.module('icestudio') id: blockInstances.id, blockType: blockInstances.type, data: blockInstances.data, - label: blockInstances.data.label, position: blockInstances.position, - disabled: disabled, + disabled: disabled, // Not used choices: boards.getPinout() }); @@ -869,9 +875,8 @@ angular.module('icestudio') id: blockInstances.id, blockType: blockInstances.type, data: blockInstances.data, - label: blockInstances.data.label, position: blockInstances.position, - disabled: disabled, + disabled: disabled, // Not used choices: boards.getPinout() }); @@ -884,7 +889,6 @@ angular.module('icestudio') id: blockInstances.id, blockType: blockInstances.type, data: blockInstances.data, - label: blockInstances.data.label, position: blockInstances.position, disabled: disabled }); diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index b7ffa1833..ac73c8153 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -224,6 +224,7 @@ angular.module('icestudio') if (block.design.graph.blocks[i].type === 'basic.input' || block.design.graph.blocks[i].type === 'basic.output') { delete block.design.graph.blocks[i].data.pin; + delete block.design.graph.blocks[i].data.connected; } } // Add block diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index d08a0578d..f7ee0918a 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -633,16 +633,13 @@ angular.module('icestudio') }); }; - this.constantprompt = function(messages, values, callback) { + this.inputcheckboxprompt = function(messages, values, callback) { var content = []; content.push('
'); content.push('

' + messages[0] + '

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

' + messages[1] + '

'); - content.push(' '); + content.push('
'); content.push('
'); // Restore values $('#label').val(values[0]); diff --git a/app/styles/project.css b/app/styles/design.css similarity index 92% rename from app/styles/project.css rename to app/styles/design.css index 1ed356620..d27f9524c 100644 --- a/app/styles/project.css +++ b/app/styles/design.css @@ -104,9 +104,28 @@ color: #444; } -.io-block { +.virtual-port { position: absolute; - background: #fafacd; + background: #E2FBC9; + border-radius: 5px; + border: 2px solid #888; + pointer-events: none; + -webkit-user-select: none; + user-select: none; + z-index: 0; +} + +.virtual-port label { + display: block; + margin-top: 20px; + text-align: center; + font-size: 1em; + color: #444; +} + +.fpga-port { + position: absolute; + background: #FBFBC9; border-radius: 5px; border: 2px solid #888; pointer-events: none; @@ -115,7 +134,7 @@ z-index: 0; } -.io-block label { +.fpga-port label { display: block; margin-top: 4px; text-align: center; @@ -123,7 +142,7 @@ color: #444; } -.io-block .select2 { +.select2 { position: absolute; left: 5px; bottom: 5px; @@ -133,7 +152,7 @@ .constant-block { position: absolute; - background: #faeaaf; + background: #FBF0C9; border-radius: 5px; border: 2px solid #888; pointer-events: none; From 6732b6d06e1ca2cc2a7244a8e157a1818ab5b272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 18 Dec 2016 11:33:53 +0100 Subject: [PATCH 02/35] User virtual flag in ports --- app/scripts/plugins/shapes/joint.shapes.js | 27 +++++++++-------- app/scripts/services/graph.service.js | 34 ++++++++++++++-------- app/scripts/services/project.service.js | 1 - 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 5ee639e52..bb4d3c003 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -283,7 +283,7 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ this.$box.find('label').addClass('hidden'); } else { - this.$box.find('label').text(name); + this.$box.find('label').html(name); this.$box.find('img').addClass('hidden'); this.$box.find('label').removeClass('hidden'); } @@ -336,13 +336,13 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ var virtualPortId = 'virtualPort' + this.id; var fpgaPortId = 'fpgaPort' + this.id; var comboId = 'combo' + this.id; - var connected = this.model.get('data').connected; + var virtual = this.model.get('data').virtual || this.model.get('disabled'); this.$box = $(joint.util.template( '\ -
\ +
\ \
\ -
\ +
\ \ \ - + diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index d60ef76ea..e376fcf0e 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -330,6 +330,7 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ id: '', + pins: [], initialize: function() { joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); @@ -339,6 +340,25 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ var fpgaPortId = 'fpgaPort' + this.id; var comboId = 'combo' + this.id; var virtual = this.model.get('data').virtual || this.model.get('disabled'); + + var selectCode = ''; + var selectScript = ''; + this.pins = this.model.attributes.data.pins; + + // a,b[0:1],c[0:2],d[0:3] + + if (this.pins) { + for (var i in this.pins) { + //selectCode += '

' + this.pins[i].index + '

'; + selectCode +=''; + + selectScript += '$("#' + comboId + this.pins[i].index + '").select2('; + selectScript += '{placeholder: "", allowClear: true, dropdownCssClass: "bigdrop"});'; + } + } + this.$box = $(joint.util.template( '\
\ @@ -346,33 +366,27 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({
\
\ \ - \ - \ +
' + selectCode + '
\ + \
\ ' )()); - this.$box.find('#' + virtualPortId); - // Prevent paper from handling pointerdown. - var comboSelector = this.$box.find('#' + comboId); + var comboSelector = this.$box.find('.select2'); comboSelector.on('mousedown click', function(evt) { evt.stopPropagation(); }); comboSelector.on('change', _.bind(function(evt) { - this.model.attributes.data.pin.name = $(evt.target).find('option:selected').text(); - this.model.attributes.data.pin.value = $(evt.target).val(); + var target = $(evt.target); + var index = target.attr('index'); + this.model.attributes.data.pins[index].name = target.find('option:selected').text(); + this.model.attributes.data.pins[index].value = target.val(); }, this)); }, renderChoides: function() { - var comboId = '#combo' + this.id; - var comboSelector = this.$box.find(comboId); - var choices = this.model.get('choices'); - - comboSelector.empty(); - comboSelector.append(''); - for (var c in choices) { - comboSelector.append(''); + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); + } } }, renderBlock: function() { @@ -387,19 +401,22 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ // Virtual port (green) $(fpgaPortId).addClass('hidden'); $(virtualPortId).removeClass('hidden'); + this.model.attributes.size.height = 64; } else { // FPGA I/O port (yellow) $(virtualPortId).addClass('hidden'); $(fpgaPortId).removeClass('hidden'); + if (this.pins) { + this.model.attributes.size.height = 32 + 32 * this.pins.length; + } } }, renderValue: function() { - var comboId = '#combo' + this.id; - var comboSelector = this.$box.find(comboId); - - if (this.model.get('data').pin) { - comboSelector.val(this.model.get('data').pin.value); + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).val(this.pins[i].value); + } } }, clearValue: function () { @@ -691,7 +708,7 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({ bifurcationMarkup: [ '', - '', + '', '' ].join(''), @@ -741,12 +758,14 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // console.log('render'); var pins = this.sourceView.model.attributes.data.pins; + var wireDot = (pins && pins.length > 1) ? 8 : 4; var wireWidth = (pins && pins.length > 1) ? 8 : 2; var wireLabel = (pins && pins.length > 1) ? '' + pins.length + '' : ''; // Set up the wire this.$('.connection').css('stroke-width', wireWidth); this.model.label(0, {attrs: { text: { text: wireLabel } } }); + this.model.bifurcationMarkup = this.model.bifurcationMarkup.replace(/<%= r %>/g, wireDot); return this; }, diff --git a/app/scripts/services/boards.service.js b/app/scripts/services/boards.service.js index 3b2dfc654..62ade991b 100644 --- a/app/scripts/services/boards.service.js +++ b/app/scripts/services/boards.service.js @@ -3,7 +3,7 @@ angular.module('icestudio') .service('boards', function(nodeFs, nodePath) { - + this.pinoutHTML = ''; this.selectedBoard = null; this.currentBoards = loadBoards(nodePath.join('resources', 'boards')); @@ -41,6 +41,7 @@ angular.module('icestudio') for (var i in this.currentBoards) { if (name === this.currentBoards[i].name) { this.selectedBoard = this.currentBoards[i]; + this.pinoutHTML = generateHTMLOptions(this.selectedBoard.pinout); break; } } @@ -53,8 +54,17 @@ angular.module('icestudio') return this.currentBoards; }; - this.getPinout = function() { - return this.selectedBoard.pinout; + this.getPinoutHTML = function() { + return this.pinoutHTML; }; + function generateHTMLOptions(pinout) { + var code = ''; + } + code += ''; + return code; + } + }); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index d409634e0..9e6d9eddc 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -295,7 +295,7 @@ angular.module('icestudio') } var virtual = values[1]; data.data.virtual = virtual; - cellView.renderBlock(); + cellView.render(); }); } } @@ -552,7 +552,6 @@ angular.module('icestudio') var labels = input.replace(/ /g, '').split(','); for (var l in labels) { var portInfo = utils.parsePortLabel(labels[l]); - console.log(portInfo); if (portInfo) { evt.cancel = false; var pins = []; @@ -567,7 +566,7 @@ angular.module('icestudio') } else { pins.push({ - index: '', + index: '0', name: '', value: 0 }); @@ -724,7 +723,7 @@ angular.module('icestudio') var cell = cells[i]; var type = cell.attributes.blockType; if (type === 'basic.input' || type === 'basic.output') { - cell.attributes.choices = boards.getPinout(); + cell.attributes.choices = boards.getPinoutHTML(); var view = paper.findViewByModel(cell.id); view.renderChoices(); view.clearValue(); @@ -888,7 +887,7 @@ angular.module('icestudio') data: blockInstances.data, position: blockInstances.position, disabled: disabled, - choices: boards.getPinout() + choices: boards.getPinoutHTML() }); addCell(cell); @@ -902,7 +901,7 @@ angular.module('icestudio') data: blockInstances.data, position: blockInstances.position, disabled: disabled, - choices: boards.getPinout() + choices: boards.getPinoutHTML() }); addCell(cell); diff --git a/app/styles/design.css b/app/styles/design.css index d27f9524c..2d6e27a0f 100644 --- a/app/styles/design.css +++ b/app/styles/design.css @@ -136,20 +136,32 @@ .fpga-port label { display: block; - margin-top: 4px; + margin-top: 3px; + margin-bottom: 4px; text-align: center; font-size: 1em; color: #444; } -.select2 { - position: absolute; - left: 5px; - bottom: 5px; +.fpga-port div p { + position: relative; + top: 0px; + left: -20px; + float: left; +} + +.fpga-port div .select2 { + position: relative; width: 82px; + left: 5px; + margin-bottom: 4px; pointer-events: auto; } +.bigdrop { + width: 96px !important; +} + .constant-block { position: absolute; background: #FBF0C9; From aa895970667b6d3ffca90a0e6105851ec248876a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Mon, 19 Dec 2016 19:32:54 +0100 Subject: [PATCH 08/35] Add bus backward compat. Update demo projects --- app/scripts/plugins/shapes/joint.shapes.js | 3 +- app/scripts/services/graph.service.js | 8 +- app/scripts/services/project.service.js | 16 ++++ demo/complex.ice | 92 +++++++++++++++++----- demo/constant-code-block.ice | 14 +++- demo/constant-generic-block.ice | 28 +++++-- demo/constant-io-code-block.ice | 42 +++++++--- demo/div.ice | 30 ++++--- demo/input-output.ice | 30 ++++--- demo/multi-block-block.ice | 68 ++++++++++++---- demo/multi-block-output.ice | 68 ++++++++++++---- demo/multi-constant-generic-block.ice | 42 +++++++--- demo/multi-input-output.ice | 46 +++++++---- tasks/toolchain_builder.js | 34 ++++---- 14 files changed, 386 insertions(+), 135 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index e376fcf0e..92c646c3a 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -395,7 +395,7 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ var name = this.model.get('data').label; var virtual = this.model.get('data').virtual || this.model.get('disabled'); - this.$box.find('label').text(name); + this.$box.find('label').text(name ? name : ' '); if (virtual) { // Virtual port (green) @@ -766,6 +766,7 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ this.$('.connection').css('stroke-width', wireWidth); this.model.label(0, {attrs: { text: { text: wireLabel } } }); this.model.bifurcationMarkup = this.model.bifurcationMarkup.replace(/<%= r %>/g, wireDot); + this.update(); return this; }, diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 9e6d9eddc..425639c7d 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -284,8 +284,8 @@ angular.module('icestudio') gettextCatalog.getString('Update the port label'), gettextCatalog.getString('Virtual port') ], [ - data.data.label ? data.data.label : '', - data.data.virtual ? data.data.virtual : false + data.data.label, + data.data.virtual ], function(evt, values) { var label = values[0].replace(/ /g, ''); @@ -305,8 +305,8 @@ angular.module('icestudio') gettextCatalog.getString('Update the block label'), gettextCatalog.getString('Local parameter') ], [ - data.data.label ? data.data.label : '', - data.data.local ? data.data.local : false + data.data.label, + data.data.local ], function(evt, values) { var label = values[0].replace(/ /g, ''); diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index b91ded4d9..06b63b53d 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -80,6 +80,22 @@ angular.module('icestudio') project = data; break; default: + var blocks = data.graph.blocks; + for (var b in blocks) { + var block = blocks[b]; + if (block.type === 'basic.input' || + block.type === 'basic.output') { + block.data.name = block.data.label; + block.data.range = ''; + block.data.pins = [{ + index: '0', + name: block.data.pin ? block.data.pin.name : '', + value: block.data.pin ? block.data.pin.value : 0 + }]; + block.data.virtual = false; + delete block.data.pin; + } + } project = _default(); project.design.board = data.board; project.design.graph = data.graph; diff --git a/demo/complex.ice b/demo/complex.ice index a6f74fb67..344dafe77 100644 --- a/demo/complex.ice +++ b/demo/complex.ice @@ -16,10 +16,16 @@ "type": "basic.output", "data": { "label": "a", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "a", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 216, @@ -43,10 +49,16 @@ "type": "basic.output", "data": { "label": "c", - "pin": { - "name": "LED2", - "value": "97" - } + "name": "c", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED2", + "value": "97" + } + ], + "virtual": false }, "position": { "x": 760, @@ -58,10 +70,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 48, @@ -91,10 +109,16 @@ "type": "basic.output", "data": { "label": "d", - "pin": { - "name": "LED3", - "value": "98" - } + "name": "d", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED3", + "value": "98" + } + ], + "virtual": false }, "position": { "x": 768, @@ -250,7 +274,17 @@ "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", "type": "basic.output", "data": { - "label": "out" + "label": "out", + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 712, @@ -283,7 +317,17 @@ "id": "a8faca21-4b86-4bb1-8cd1-8c5252d4038f", "type": "basic.input", "data": { - "label": "in" + "label": "in", + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 24, @@ -294,7 +338,17 @@ "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", "type": "basic.input", "data": { - "label": "" + "label": "", + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 24, diff --git a/demo/constant-code-block.ice b/demo/constant-code-block.ice index 8348859d9..db4de8682 100644 --- a/demo/constant-code-block.ice +++ b/demo/constant-code-block.ice @@ -48,10 +48,16 @@ "type": "basic.output", "data": { "label": "led", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 624, diff --git a/demo/constant-generic-block.ice b/demo/constant-generic-block.ice index b793e3dee..dcc1ccca4 100644 --- a/demo/constant-generic-block.ice +++ b/demo/constant-generic-block.ice @@ -37,10 +37,16 @@ "type": "basic.output", "data": { "label": "led", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 536, @@ -100,7 +106,17 @@ "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", "type": "basic.output", "data": { - "label": "led" + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 624, @@ -167,7 +183,7 @@ "x": -21, "y": 66 }, - "zoom": 1 + "zoom": 0.9999999999999893 } } } \ No newline at end of file diff --git a/demo/constant-io-code-block.ice b/demo/constant-io-code-block.ice index c664221dd..941351292 100644 --- a/demo/constant-io-code-block.ice +++ b/demo/constant-io-code-block.ice @@ -50,10 +50,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 24, @@ -65,10 +71,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 712, @@ -80,10 +92,16 @@ "type": "basic.input", "data": { "label": "", - "pin": { - "name": "", - "value": 0 - } + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 24, diff --git a/demo/div.ice b/demo/div.ice index 0d0634a64..0a83e14c5 100644 --- a/demo/div.ice +++ b/demo/div.ice @@ -50,10 +50,16 @@ "type": "basic.input", "data": { "label": "clk", - "pin": { - "name": "CLK", - "value": "21" - } + "name": "clk", + "range": "", + "pins": [ + { + "index": "0", + "name": "CLK", + "value": "21" + } + ], + "virtual": false }, "position": { "x": 64, @@ -65,10 +71,16 @@ "type": "basic.output", "data": { "label": "", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 752, @@ -115,7 +127,7 @@ "x": 3, "y": 145 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/demo/input-output.ice b/demo/input-output.ice index 2f4578734..275d36de2 100644 --- a/demo/input-output.ice +++ b/demo/input-output.ice @@ -16,10 +16,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 104, @@ -31,10 +37,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 344, @@ -61,7 +73,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/demo/multi-block-block.ice b/demo/multi-block-block.ice index be6d94fbf..390f96c24 100644 --- a/demo/multi-block-block.ice +++ b/demo/multi-block-block.ice @@ -25,10 +25,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 632, @@ -40,10 +46,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 96, @@ -73,10 +85,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED1", - "value": "96" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false }, "position": { "x": 632, @@ -174,7 +192,17 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "label": "", + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 64, @@ -185,7 +213,17 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "label": "", + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 752, @@ -232,7 +270,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/demo/multi-block-output.ice b/demo/multi-block-output.ice index e8bc59fe0..b50f500c9 100644 --- a/demo/multi-block-output.ice +++ b/demo/multi-block-output.ice @@ -16,10 +16,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 464, @@ -31,10 +37,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 96, @@ -55,10 +67,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED1", - "value": "96" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false }, "position": { "x": 464, @@ -136,7 +154,17 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "label": "", + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 64, @@ -147,7 +175,17 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "label": "", + "name": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 752, @@ -194,7 +232,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/demo/multi-constant-generic-block.ice b/demo/multi-constant-generic-block.ice index ccf421b28..c37737af3 100644 --- a/demo/multi-constant-generic-block.ice +++ b/demo/multi-constant-generic-block.ice @@ -37,10 +37,16 @@ "type": "basic.output", "data": { "label": "led", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 536, @@ -61,10 +67,16 @@ "type": "basic.output", "data": { "label": "led", - "pin": { - "name": "LED1", - "value": "96" - } + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false }, "position": { "x": 680, @@ -150,7 +162,17 @@ "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", "type": "basic.output", "data": { - "label": "led" + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": false }, "position": { "x": 624, @@ -217,7 +239,7 @@ "x": -139, "y": 20 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/demo/multi-input-output.ice b/demo/multi-input-output.ice index fb2a84d05..9bb7b741e 100644 --- a/demo/multi-input-output.ice +++ b/demo/multi-input-output.ice @@ -16,10 +16,16 @@ "type": "basic.input", "data": { "label": "in", - "pin": { - "name": "SW1", - "value": "10" - } + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false }, "position": { "x": 168, @@ -31,10 +37,16 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED0", - "value": "95" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false }, "position": { "x": 480, @@ -46,13 +58,19 @@ "type": "basic.output", "data": { "label": "out", - "pin": { - "name": "LED1", - "value": "96" - } + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false }, "position": { - "x": 408, + "x": 400, "y": 232 } } @@ -86,7 +104,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999638409349 + "zoom": 0.9999999403953552 } } } \ No newline at end of file diff --git a/tasks/toolchain_builder.js b/tasks/toolchain_builder.js index e8381aeaa..6b03cdcbd 100644 --- a/tasks/toolchain_builder.js +++ b/tasks/toolchain_builder.js @@ -25,7 +25,7 @@ function ToolchainBuilder(options) { // Assign options this.options = _.defaults(options, defaults); - if (this.options.platforms.length == 0) + if (this.options.platforms.length === 0) throw new Error('No platform to build!'); var venvRelease = 'virtualenv-15.0.1'; @@ -40,8 +40,8 @@ function ToolchainBuilder(options) { this.options.venvDir = path.join(this.options.toolchainDir, 'venv'); this.options.venvBinDir = path.join(this.options.venvDir, (process.platform === 'win32' ? 'Scripts' : 'bin')); - this.options.venvPip = path.join(this.options.venvBinDir, 'pip') - this.options.venvApio = path.join(this.options.venvBinDir, 'apio') + this.options.venvPip = path.join(this.options.venvBinDir, 'pip'); + this.options.venvApio = path.join(this.options.venvBinDir, 'apio'); } @@ -78,14 +78,14 @@ ToolchainBuilder.prototype.build = function (callback) { }); return hasCallback ? true : done.promise; -} +}; ToolchainBuilder.prototype.ensurePythonIsAvailable = function () { return new Promise(function(resolve, reject) { if (getPythonExecutable()) { resolve(); } else { reject('Python 2.7 is not available'); } }); -} +}; ToolchainBuilder.prototype.extractVirtualenv = function () { var self = this; @@ -94,9 +94,9 @@ ToolchainBuilder.prototype.extractVirtualenv = function () { targz().extract(self.options.venvTarPath, self.options.toolchainDir, function (error) { if (error) { reject(error); } else { resolve(); } - }) + }); }); -} +}; ToolchainBuilder.prototype.createVirtualenv = function () { var self = this; @@ -114,7 +114,7 @@ ToolchainBuilder.prototype.createVirtualenv = function () { } ); }); -} +}; ToolchainBuilder.prototype.downloadApio = function () { var self = this; @@ -131,7 +131,7 @@ ToolchainBuilder.prototype.downloadApio = function () { } ); }); -} +}; ToolchainBuilder.prototype.installApio = function () { var self = this; @@ -150,9 +150,9 @@ ToolchainBuilder.prototype.installApio = function () { } ); } - }) }); -} + }); +}; ToolchainBuilder.prototype.downloadApioPackages = function () { var self = this; @@ -163,7 +163,7 @@ ToolchainBuilder.prototype.downloadApioPackages = function () { return [ (process.platform === 'win32' ? 'set' : 'export'), 'APIO_HOME_DIR=' + dest + (process.platform === 'win32' ? '&' : ';'), self.options.venvApio, 'install', '--platform', platform ].concat(packages); - }; + } self.pFound = []; self.options.platforms.forEach(function(platform) { var p = getRealPlatform(platform); @@ -180,7 +180,7 @@ ToolchainBuilder.prototype.downloadApioPackages = function () { }); resolve(); }); -} +}; ToolchainBuilder.prototype.packageApio = function () { var self = this; @@ -194,7 +194,7 @@ ToolchainBuilder.prototype.packageApio = function () { else { resolve(); } }); }); -} +}; ToolchainBuilder.prototype.packageApioPackages = function () { var self = this; @@ -211,7 +211,7 @@ ToolchainBuilder.prototype.packageApioPackages = function () { path.join(self.options.apioPackagesDir, p), path.join(self.options.toolchainDir, 'default-apio-packages-' + p + '.tar.gz'), function (error) { - if (error) { reject(error) } + if (error) { reject(error); } callback(); } ); @@ -224,7 +224,7 @@ ToolchainBuilder.prototype.packageApioPackages = function () { resolve(); }); }); -} +}; ToolchainBuilder.prototype.createDefaultToolchains = function () { var self = this; @@ -252,7 +252,7 @@ ToolchainBuilder.prototype.createDefaultToolchains = function () { }); resolve(); }); -} +}; // Auxiliar functions From f2a71098e4425f48c8b3d0a5e5ef994b55cf516f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Mon, 19 Dec 2016 19:58:20 +0100 Subject: [PATCH 09/35] Implement multi-io ports in the verilog/pcf compiler --- app/scripts/services/compiler.service.js | 38 ++++++++++++++++++------ app/scripts/services/graph.service.js | 1 + app/scripts/services/utils.service.js | 1 + 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 9f4d8373a..28022f2c6 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -80,10 +80,12 @@ angular.module('icestudio') var ports = []; for (var i in data.ports.in) { - ports.push(' input ' + data.ports.in[i]); + var _in = data.ports.in[i]; + ports.push(' input ' + _in.range + (_in.range ? ' ' : '') + _in.name); } for (var o in data.ports.out) { - ports.push(' output ' + data.ports.out[o]); + var _out = data.ports.out[o]; + ports.push(' output ' + _out.range + (_out.range ? ' ' : '') + _out.name); } if (ports.length > 0) { @@ -142,10 +144,16 @@ angular.module('icestudio') for (var i in graph.blocks) { var block = graph.blocks[i]; if (block.type === 'basic.input') { - ports.in.push(digestId(block.id)); + ports.in.push({ + name: digestId(block.id), + range: block.data.range ? block.data.range : '' + }); } else if (block.type === 'basic.output') { - ports.out.push(digestId(block.id)); + ports.out.push({ + name: digestId(block.id), + range: block.data.range ? block.data.range : '' + }); } } @@ -374,13 +382,25 @@ angular.module('icestudio') var block = graph.blocks[i]; if (block.type === 'basic.input' || block.type === 'basic.output') { - code += 'set_io '; - code += digestId(block.id); - code += ' '; if (!block.data.virtual) { - code += block.data.pin.value; + if (block.data.pins.length > 1) { + for (var p in block.data.pins) { + var pin = block.data.pins[p]; + code += 'set_io '; + code += digestId(block.id); + code += '[' + pin.index + '] '; + code += pin.value; + code += '\n'; + } + } + else { + code += 'set_io '; + code += digestId(block.id); + code += ' '; + code += block.data.pins[0].value; + code += '\n'; + } } - code += '\n'; } } diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 425639c7d..f0f908d70 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -574,6 +574,7 @@ angular.module('icestudio') blockInstance.data = { label: portInfo.input, name: portInfo.name, + range: portInfo.rangestr ? portInfo.rangestr : '', pins: pins, virtual: true }; diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index d70436305..818088283 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -874,6 +874,7 @@ angular.module('icestudio') if (match && (match[0] === match.input)) { ret.input = match[0]; ret.name = match[1]; + ret.rangestr = match[2]; if (match[2]) { if (match[3] > match[4]) { ret.range = _.range(match[3], parseInt(match[4])-1, -1); From 26ce30bf9279aa472ab022dfd23706e25310e584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 10:28:35 +0100 Subject: [PATCH 10/35] Minor improvements in IO block --- app/scripts/plugins/shapes/joint.shapes.js | 30 ++++++++++++++-------- app/scripts/services/boards.service.js | 3 +-- app/scripts/services/compiler.service.js | 27 ++++++++++--------- app/styles/design.css | 3 ++- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 92c646c3a..357dc44f2 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -329,9 +329,6 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ - id: '', - pins: [], - initialize: function() { joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); @@ -378,11 +375,19 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ comboSelector.on('change', _.bind(function(evt) { var target = $(evt.target); var index = target.attr('index'); - this.model.attributes.data.pins[index].name = target.find('option:selected').text(); - this.model.attributes.data.pins[index].value = target.val(); + var name = target.find('option:selected').text(); + var value = target.val(); + this.model.attributes.data.pins[index].name = name; + this.model.attributes.data.pins[index].value = value; + this.$box.find('.select2-selection').css('font-size', computeFontSize(name)); }, this)); + + function computeFontSize(name) { + var n = name.length; + return Math.min(13, 17-n).toString() + 'px'; + } }, - renderChoides: function() { + renderChoices: function() { if (this.pins) { for (var i in this.pins) { this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); @@ -420,16 +425,19 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ } }, clearValue: function () { - var comboId = '#combo' + this.id; - this.model.attributes.data.pin.name = ''; - this.model.attributes.data.pin.value = 0; - this.$box.find(comboId).val(''); + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).val(''); + this.model.attributes.data.pins[i.toString()].name = ''; + this.model.attributes.data.pins[i.toString()].value = 0; + } + } }, update: function () { this.renderPorts(); this.renderBlock(); if (!this.model.get('disabled')) { - this.renderChoides(); + this.renderChoices(); this.renderValue(); } joint.dia.ElementView.prototype.update.apply(this, arguments); diff --git a/app/scripts/services/boards.service.js b/app/scripts/services/boards.service.js index 62ade991b..565bdc338 100644 --- a/app/scripts/services/boards.service.js +++ b/app/scripts/services/boards.service.js @@ -59,11 +59,10 @@ angular.module('icestudio') }; function generateHTMLOptions(pinout) { - var code = ''; for (var i in pinout) { code += ''; } - code += ''; return code; } diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 28022f2c6..a1e740afa 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -382,25 +382,24 @@ angular.module('icestudio') var block = graph.blocks[i]; if (block.type === 'basic.input' || block.type === 'basic.output') { - if (!block.data.virtual) { - if (block.data.pins.length > 1) { - for (var p in block.data.pins) { - var pin = block.data.pins[p]; - code += 'set_io '; - code += digestId(block.id); - code += '[' + pin.index + '] '; - code += pin.value; - code += '\n'; - } - } - else { + + if (block.data.pins.length > 1) { + for (var p in block.data.pins) { + var pin = block.data.pins[p]; code += 'set_io '; code += digestId(block.id); - code += ' '; - code += block.data.pins[0].value; + code += '[' + pin.index + '] '; + code += block.data.virtual ? '' : pin.value; code += '\n'; } } + else { + code += 'set_io '; + code += digestId(block.id); + code += ' '; + code += block.data.virtual ? '' : block.data.pins[0].value; + code += '\n'; + } } } diff --git a/app/styles/design.css b/app/styles/design.css index 2d6e27a0f..01c2f8405 100644 --- a/app/styles/design.css +++ b/app/styles/design.css @@ -159,7 +159,8 @@ } .bigdrop { - width: 96px !important; + width: 86px !important; + font-size: 12px; } .constant-block { From fe7486719494115641d4e50331e1a55efc90641d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 11:50:29 +0100 Subject: [PATCH 11/35] Add blocks service. Add multi-output port --- app/index.html | 21 +- app/scripts/services/blocks.service.js | 303 ++++++++++++++++++ app/scripts/services/graph.service.js | 408 +++---------------------- 3 files changed, 356 insertions(+), 376 deletions(-) create mode 100644 app/scripts/services/blocks.service.js diff --git a/app/index.html b/app/index.html index 31496e0af..3c8ecbce2 100644 --- a/app/index.html +++ b/app/index.html @@ -49,24 +49,25 @@ + - - + - - - - - - - - + + + + + + + + + diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js new file mode 100644 index 000000000..709c1478d --- /dev/null +++ b/app/scripts/services/blocks.service.js @@ -0,0 +1,303 @@ +'use strict'; + +angular.module('icestudio') + .service('blocks', function(joint, + boards, + utils, + gettextCatalog) { + var gridsize = 8; + + this.new = function(type, block, addCellcallback) { + switch(type) { + case 'basic.input': + case 'basic.output': + return newBasicIO(type, addCellcallback); + } + }; + + this.loadBasicInput = loadBasicInput; + this.loadBasicOutput = loadBasicOutput; + + function loadBasicInput(instance, disabled) { + var cell = new joint.shapes.ice.Input({ + id: instance.id, + blockType: instance.type, + data: instance.data, + position: instance.position, + disabled: disabled, + choices: boards.getPinoutHTML() + }); + return cell; + } + + function loadBasicOutput(instance, disabled) { + var cell = new joint.shapes.ice.Output({ + id: instance.id, + blockType: instance.type, + data: instance.data, + position: instance.position, + disabled: disabled, + choices: boards.getPinoutHTML() + }); + return cell; + } + + this.basicConstant = function(instance, disabled) { + var cell = new joint.shapes.ice.Constant({ + id: instance.id, + blockType: instance.type, + data: instance.data, + position: instance.position, + disabled: disabled + }); + return cell; + }; + + this.basicCode = function(instance, disabled) { + var leftPorts = []; + var rightPorts = []; + var topPorts = []; + + for (var i in instance.data.ports.in) { + leftPorts.push({ + id: instance.data.ports.in[i], + label: instance.data.ports.in[i], + gridUnits: 32 + }); + } + + for (var o in instance.data.ports.out) { + rightPorts.push({ + id: instance.data.ports.out[o], + label: instance.data.ports.out[o], + gridUnits: 32 + }); + } + + for (var p in instance.data.params) { + topPorts.push({ + id: instance.data.params[p], + label: instance.data.params[p], + gridUnits: 48 + }); + } + + var cell = new joint.shapes.ice.Code({ + id: instance.id, + blockType: instance.type, + data: instance.data, + position: instance.position, + disabled: disabled, + leftPorts: leftPorts, + rightPorts: rightPorts, + topPorts: topPorts + }); + return cell; + }; + + this.basicInfo = function(instance, disabled) { + var cell = new joint.shapes.ice.Info({ + id: instance.id, + blockType: instance.type, + data: instance.data, + position: instance.position, + disabled: disabled + }); + return cell; + }; + + this.generic = function(instance, block) { + var i; + var leftPorts = []; + var rightPorts = []; + var topPorts = []; + var bottomPorts = []; + var gridsize = 8; + + for (i in block.design.graph.blocks) { + var item = block.design.graph.blocks[i]; + if (item.type === 'basic.input') { + leftPorts.push({ + id: item.id, + label: item.data.label + }); + } + else if (item.type === 'basic.output') { + rightPorts.push({ + id: item.id, + label: item.data.label + }); + } + else if (item.type === 'basic.constant') { + if (!item.data.local) { + topPorts.push({ + id: item.id, + label: item.data.label + }); + } + } + } + + var numPortsHeight = Math.max(leftPorts.length, rightPorts.length); + var numPortsWidth = Math.max(topPorts.length, bottomPorts.length); + + var height = 8 * gridsize; + height = Math.max(4 * gridsize * numPortsHeight, height); + var blockLabel = instance.type.toUpperCase(); + var blockLabels = instance.type.split('.'); + var maxBlockLabel = ''; + var width = 12 * gridsize; + + for (var l in blockLabels) { + if (blockLabels[l].length > maxBlockLabel.length) { + maxBlockLabel = blockLabels[l]; + } + } + if (maxBlockLabel.length > 4) { + width = Math.min((maxBlockLabel.length + 8) * gridsize, 24 * gridsize); + } + width = Math.max(4 * gridsize * numPortsWidth, width); + + var gridUnitsHeight = height / gridsize; + var gridUnitsWidth = width / gridsize; + + for (i in leftPorts) { + leftPorts[i].gridUnits = gridUnitsHeight; + } + for (i in rightPorts) { + rightPorts[i].gridUnits = gridUnitsHeight; + } + for (i in topPorts) { + topPorts[i].gridUnits = gridUnitsWidth; + } + for (i in bottomPorts) { + bottomPorts[i].gridUnits = gridUnitsWidth; + } + + if (blockLabels.length > 1) { + blockLabel = blockLabels.join('
').toUpperCase(); + } + + var blockImage = ''; + if (block.package.image) { + width = 12 * gridsize; + if (block.package.image.startsWith('%3Csvg')) { + blockImage = block.package.image; + } + else if (block.package.image.startsWith(' maxBlockLabel.length) { - maxBlockLabel = blockLabels[l]; - } - } - if (maxBlockLabel.length > 4) { - width = Math.min((maxBlockLabel.length + 8) * gridsize, 24 * gridsize); - } - width = Math.max(4 * gridsize * numPortsWidth, width); - - var gridUnitsHeight = height / gridsize; - var gridUnitsWidth = width / gridsize; - - for (i in leftPorts) { - leftPorts[i].gridUnits = gridUnitsHeight; - } - for (i in rightPorts) { - rightPorts[i].gridUnits = gridUnitsHeight; - } - for (i in topPorts) { - topPorts[i].gridUnits = gridUnitsWidth; - } - for (i in bottomPorts) { - bottomPorts[i].gridUnits = gridUnitsWidth; - } - - if (blockLabels.length > 1) { - blockLabel = blockLabels.join('
').toUpperCase(); - } - - var blockImage = ''; - if (block.package.image) { - width = 12 * gridsize; - if (block.package.image.startsWith('%3Csvg')) { - blockImage = block.package.image; - } - else if (block.package.image.startsWith(' Date: Tue, 20 Dec 2016 12:55:06 +0100 Subject: [PATCH 12/35] Move all basic blocks to "blocks service" --- app/scripts/services/blocks.service.js | 207 +++++++++++++++++++-- app/scripts/services/graph.service.js | 233 +++--------------------- app/scripts/services/project.service.js | 2 +- 3 files changed, 220 insertions(+), 222 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 709c1478d..41c18a66f 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -7,16 +7,45 @@ angular.module('icestudio') gettextCatalog) { var gridsize = 8; - this.new = function(type, block, addCellcallback) { + this.newBasic = function(type, block, addCellCallback) { switch(type) { case 'basic.input': case 'basic.output': - return newBasicIO(type, addCellcallback); + newBasicIO(type, addCellCallback); + break; + case 'basic.constant': + newBasicConstant(addCellCallback); + break; + case 'basic.code': + newBasicCode(block, addCellCallback); // block + break; + case 'basic.info': + newBasicInfo(addCellCallback); + break; + default: + break; } }; + this.newGeneric = newGeneric; - this.loadBasicInput = loadBasicInput; - this.loadBasicOutput = loadBasicOutput; + this.loadBasic = function(instance, disabled) { + switch(instance.type) { + case 'basic.input': + return loadBasicInput(instance, disabled); + case 'basic.output': + return loadBasicOutput(instance, disabled); + case 'basic.constant': + return loadBasicConstant(instance, disabled); + case 'basic.code': + return loadBasicCode(instance, disabled); + case 'basic.info': + return loadBasicInfo(instance, disabled); + default: + break; + } + }; + this.loadGeneric = loadGeneric; + this.loadWire = loadWire; function loadBasicInput(instance, disabled) { var cell = new joint.shapes.ice.Input({ @@ -42,7 +71,7 @@ angular.module('icestudio') return cell; } - this.basicConstant = function(instance, disabled) { + function loadBasicConstant(instance, disabled) { var cell = new joint.shapes.ice.Constant({ id: instance.id, blockType: instance.type, @@ -51,9 +80,9 @@ angular.module('icestudio') disabled: disabled }); return cell; - }; + } - this.basicCode = function(instance, disabled) { + function loadBasicCode(instance, disabled) { var leftPorts = []; var rightPorts = []; var topPorts = []; @@ -93,9 +122,9 @@ angular.module('icestudio') topPorts: topPorts }); return cell; - }; + } - this.basicInfo = function(instance, disabled) { + function loadBasicInfo(instance, disabled) { var cell = new joint.shapes.ice.Info({ id: instance.id, blockType: instance.type, @@ -104,9 +133,9 @@ angular.module('icestudio') disabled: disabled }); return cell; - }; + } - this.generic = function(instance, block) { + function loadGeneric(instance, block) { var i; var leftPorts = []; var rightPorts = []; @@ -205,9 +234,9 @@ angular.module('icestudio') } }); return cell; - }; + } - this.wire = function(instance, source, target) { + function loadWire(instance, source, target) { // Find selectors var sourceSelector, targetSelector; @@ -238,7 +267,7 @@ angular.module('icestudio') vertices: instance.vertices }); return _wire; - }; + } function newBasicIO(type, addCellCallback) { var config = null; @@ -278,7 +307,7 @@ angular.module('icestudio') } else { evt.cancel = true; - alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', {name: labels[l]}), 'warning', 3); + alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: labels[l] }), 'warning', 3); break; } } @@ -300,4 +329,152 @@ angular.module('icestudio') return pins; } + function newBasicConstant(addCellCallback) { + var blockInstance = { + id: null, + data: {}, + type: 'basic.constant', + position: { x: 20 * gridsize, y: 4 * gridsize } + }; + alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), 'C', + function(evt, name) { + if (name) { + var names = name.replace(/ /g, '').split(','); + for (var n in names) { + if (names[n]) { + blockInstance.data = { + label: names[n], + local: false, + value: '' + }; + if (addCellCallback) { + addCellCallback(loadBasicConstant(blockInstance)); + } + blockInstance.position.x += 15 * gridsize; + } + } + } + }); + } + + function newBasicCode(block, addCellCallback) { + var blockInstance = { + id: null, + data: {}, + type: 'basic.code', + position: { x: 4 * gridsize, y: 4 * gridsize } + }; + var defaultValues = [ + 'a , b', + 'c , d', + '' + ]; + if (block && block.data) { + 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'), + gettextCatalog.getString('Enter the output ports'), + gettextCatalog.getString('Enter the parameters') ], + defaultValues, + 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]) { + blockInstance.data.ports.in.push(inPorts[i]); + } + } + for (var o in outPorts) { + 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 = 24 * gridsize; + + 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; + } + if (addCellCallback) { + addCellCallback(loadBasicCode(blockInstance)); + } + } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); + } + } + }); + } + + function newBasicInfo(addCellCallback) { + var blockInstance = { + id: null, + data: { info: '' }, + type: 'basic.info', + position: { x: 4 * gridsize, y: 30 * gridsize } + }; + if (addCellCallback) { + addCellCallback(loadBasicInfo(blockInstance)); + } + } + + function newGeneric(type, block, addCellCallback) { + var blockInstance = { + id: null, + type: type, + position: { x: 6 * gridsize, y: 16 * gridsize } + }; + if (block && + block.design && + block.design.graph && + block.design.graph.blocks && + block.design.graph.wires && + block.design.deps) { + if (addCellCallback) { + addCellCallback(loadGeneric(blockInstance, block)); + } + } + else { + alertify.notify(gettextCatalog.getString('Wrong block format: {{type}}', { type: type }), 'error', 30); + } + } + }); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 324ccaf77..50afccd4e 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -64,9 +64,7 @@ angular.module('icestudio') this.breadcrumbs = [{ name: name }]; } this.breadcrumbs[0].name = name; - if(!$rootScope.$$phase) { - $rootScope.$apply(); - } + utils.rootScopeSafeApply(); }; this.createPaper = function(element) { @@ -339,9 +337,7 @@ angular.module('icestudio') } else if (data.type !== 'ice.Wire' && data.type !== 'ice.Info') { self.breadcrumbs.push({ name: data.blockType }); - if(!$rootScope.$$phase) { - $rootScope.$apply(); - } + utils.rootScopeSafeApply(); zIndex = 1; if (self.breadcrumbs.length === 2) { $rootScope.$broadcast('updateProject', function() { @@ -443,165 +439,20 @@ angular.module('icestudio') }; this.createBlock = function(type, block, callback) { - blocks.new(type, block, function(cell) { + if (type.indexOf('basic.') !== -1) { + blocks.newBasic(type, block, addCellCallback); + } + else { + dependencies[type] = block; + blocks.newGeneric(type, block, addCellCallback); + } + + var addCellCallback = function(cell) { addCell(cell); if (callback) { callback(); } - }); - - /*var blockInstance = { - id: null, - data: {}, - type: type, - position: { x: 4 * gridsize, y: 4 * gridsize } }; - - if (type === 'basic.code') { - var defaultValues = [ - 'a , b', - 'c , d', - '' - ]; - if (block && block.data) { - 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'), - gettextCatalog.getString('Enter the output ports'), - gettextCatalog.getString('Enter the parameters') ], - defaultValues, - 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]) { - blockInstance.data.ports.in.push(inPorts[i]); - } - } - for (var o in outPorts) { - 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 = 24 * gridsize; - - 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 = blocks.basicCode(blockInstance); - addCell(cell); - var cellView = paper.findViewByModel(cell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); - } - if (callback) { - callback(); - } - } - else { - evt.cancel = true; - alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); - } - } - }); - } - else if (type === 'basic.info') { - blockInstance.data = { - info: '' - }; - blockInstance.position.y = 30 * gridsize; - var cell = blocks.basicInfo(blockInstance); - addCell(cell); - var cellView = paper.findViewByModel(cell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); - } - } - 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], - local: false, - value: '' - }; - var cell = addCell(blocks.basicConstant(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.design && - block.design.graph && - block.design.graph.blocks && - block.design.graph.wires && - block.design.deps) { - dependencies[type] = block; - blockInstance.position.x = 6 * gridsize; - blockInstance.position.y = 16 * gridsize; - var _cell = blocks.generic(blockInstance, block); - addCell(_cell); - var _cellView = paper.findViewByModel(_cell); - if (_cellView.$box.css('z-index') < zIndex) { - _cellView.$box.css('z-index', ++zIndex); - } - } - else { - alertify.notify(gettextCatalog.getString('Wrong block format: {{type}}', { type: type }), 'error', 30); - } - }*/ }; this.toJSON = function() { @@ -627,7 +478,8 @@ angular.module('icestudio') for (var i in cells) { var cell = cells[i]; var type = cell.attributes.blockType; - if (type === 'basic.input' || type === 'basic.output') { + if (type === 'basic.input' || + type === 'basic.output') { cell.attributes.choices = boards.getPinoutHTML(); var view = paper.findViewByModel(cell.id); view.renderChoices(); @@ -654,10 +506,6 @@ angular.module('icestudio') if (type.indexOf('config.') !== -1) { paper.findViewByModel(newCell).$box.addClass('config-block'); } - var cellView = paper.findViewByModel(newCell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); - } selection.reset(selection.without(cell)); selectionView.cancelSelection(); }); @@ -730,27 +578,12 @@ angular.module('icestudio') // Blocks for (i in blockInstances) { var blockInstance = blockInstances[i]; - if (blockInstance.type === 'basic.input') { - cell = blocks.loadBasicInput(blockInstance, disabled); - } - else if (blockInstance.type === 'basic.output') { - cell = blocks.loadBasicOutput(blockInstance, disabled); - } - else if (blockInstance.type === 'basic.code') { - cell = blocks.basicCode(blockInstance, disabled); - } - else if (blockInstance.type === 'basic.info') { - cell = blocks.basicInfo(blockInstance, disabled); - } - else if (blockInstance.type === 'basic.constant') { - cell = blocks.basicConstant(blockInstance, disabled); + if (blockInstance.type.indexOf('basic.') !== -1) { + cell = blocks.loadBasic(blockInstance, disabled); } else { if (deps && deps[blockInstance.type]) { - cell = blocks.generic(blockInstance, deps[blockInstance.type]); - if (blockInstance.type.indexOf('config.') !== -1) { - paper.findViewByModel(cell).$box.addClass('config-block'); - } + cell = blocks.loadGeneric(blockInstance, deps[blockInstance.type]); } } addCell(cell); @@ -758,14 +591,13 @@ angular.module('icestudio') // Wires for (i in wires) { - cell = blocks.wire(wires[i], - graph.getCell(wires[i].source.block), - graph.getCell(wires[i].target.block)); + var source = graph.getCell(wires[i].source.block); + var target = graph.getCell(wires[i].target.block); + cell = blocks.loadWire(wires[i], source, target); addCell(cell); } self.appEnable(!disabled); - $('body').removeClass('waiting'); if (callback) { @@ -778,28 +610,17 @@ angular.module('icestudio') } }; - this.importBlock = function(type, block) { - var blockInstance = { - id: null, - data: {}, - type: type, - position: { x: 6 * gridsize, y: 16 * gridsize } - }; - dependencies[type] = block; - var cell = blocks.generic(blockInstance, block); - addCell(cell); - var cellView = paper.findViewByModel(cell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); - } - }; - function addCell(cell) { cell.attributes.state = state; graph.addCell(cell); - var cellView = paper.findViewByModel(cell); - if (cellView.$box.css('z-index') < zIndex) { - cellView.$box.css('z-index', ++zIndex); + if (!cell.isLink()) { + var cellView = paper.findViewByModel(cell); + if (cellView.$box.css('z-index') < zIndex) { + cellView.$box.css('z-index', ++zIndex); + } + if (cell.attributes.blockType.indexOf('config.') !== -1) { + cellView.$box.addClass('config-block'); + } } } diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index 06b63b53d..07a059e81 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -249,7 +249,7 @@ angular.module('icestudio') } } // Add block - graph.importBlock(name, block); + graph.createBlock(name, block); self.project.design.deps[name] = block; alertify.success(gettextCatalog.getString('Block {{name}} imported', { name: utils.bold(name) })); } From 15699c4384eb6c601a29f04731e1b0923d543548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 13:02:20 +0100 Subject: [PATCH 13/35] Update examples --- .../examples/icestick/1_basic/1_led_on.ice | 253 +++++----- .../examples/icezum/1_basic/1_led_on.ice | 253 +++++----- .../examples/icezum/1_basic/2_switch_led.ice | 181 +++---- .../icezum/1_basic/3_switch_and_gate.ice | 441 ++++++++++-------- app/scripts/services/graph.service.js | 13 +- app/scripts/services/project.service.js | 4 +- 6 files changed, 626 insertions(+), 519 deletions(-) diff --git a/app/resources/examples/icestick/1_basic/1_led_on.ice b/app/resources/examples/icestick/1_basic/1_led_on.ice index a4aad45ce..d6022735f 100644 --- a/app/resources/examples/icestick/1_basic/1_led_on.ice +++ b/app/resources/examples/icestick/1_basic/1_led_on.ice @@ -1,130 +1,155 @@ { - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" }, - "board": "icestick", - "graph": { - "blocks": [ - { - "id": "a538a5b4-d5d5-4ace-a593-efb1fa9b930c", - "type": "basic.info", - "data": { - "info": "LED-ON Hello world circuit example!\n\nThe simplest digital circuit that turns a \nled on\n\nA bit set to 1 is wired directly to the\noutput FPGA pin, where the led is connected\n\nThe blue box is the bit (set to 1)\nIt is inside the FPGA\n\nThe yellow box is the output FPGA pin. Using\nthe bottom menu the pin can be changed\n\nEXERCISE 1: Upload this circuit into your \nFPGA board and watch the led. \nIt should be turned on\n\nEXERCISE 2: Change the pin number to turn\nanother led on and upload it again" + "design": { + "board": "icestick", + "graph": { + "blocks": [ + { + "id": "f9239f87-12a4-4141-85f7-c3862615af3a", + "type": "bit.1", + "data": {}, + "position": { + "x": 80, + "y": 64 + } }, - "position": { - "x": 40, - "y": 208 - } - }, - { - "id": "0d05784e-8e32-4c80-b85d-cde4e892dbf3", - "type": "basic.info", - "data": { - "info": "Ejemplo de circuito Hola mundo: LED-ON\n\nEs el circuito digital más sencillo que\nenciende un led\n\nUn bit a 1 se cablea directamente a una\nsalida de la FPGA, donde está conectado\nel LED\n\nLa caja azul es el bit a 1\nEstá dentro de la FPGA\n\nLa caja amarilla es el pin de salida de\nla FPGA. Por medio del menú desplegable\ninferior se puede cambiar el pin\n\nEJERCICIO 1: Carga este circuito en la FPGA\ny observa el LED0. Debe estar encendido\n\nEJERCICIO 2: Cambia el pin de salida para\nencender otro led (por ejemplo el LED1)\ny cárgalo en la FPGA de nuevo" + { + "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", + "type": "basic.output", + "data": { + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "D1", + "value": "99" + } + ], + "virtual": false + }, + "position": { + "x": 352, + "y": 64 + } }, - "position": { - "x": 464, - "y": 208 - } - }, - { - "id": "e657ee6f-9430-4fce-a539-72d12d32f5bb", - "type": "bit.1", - "data": {}, - "position": { - "x": 80, - "y": 64 - } - }, - { - "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", - "type": "basic.output", - "data": { - "label": "led", - "pin": { - "name": "D1", - "value": "99" + { + "id": "a538a5b4-d5d5-4ace-a593-efb1fa9b930c", + "type": "basic.info", + "data": { + "info": "LED-ON Hello world circuit example!\n\nThe simplest digital circuit that turns a \nled on\n\nA bit set to 1 is wired directly to the\noutput FPGA pin, where the led is connected\n\nThe blue box is the bit (set to 1)\nIt is inside the FPGA\n\nThe yellow box is the output FPGA pin. Using\nthe bottom menu the pin can be changed\n\nEXERCISE 1: Upload this circuit into your \nFPGA board and watch the led. \nIt should be turned on\n\nEXERCISE 2: Change the pin number to turn\nanother led on and upload it again" + }, + "position": { + "x": 40, + "y": 208 } }, - "position": { - "x": 352, - "y": 64 + { + "id": "0d05784e-8e32-4c80-b85d-cde4e892dbf3", + "type": "basic.info", + "data": { + "info": "Ejemplo de circuito Hola mundo: LED-ON\n\nEs el circuito digital más sencillo que\nenciende un led\n\nUn bit a 1 se cablea directamente a una\nsalida de la FPGA, donde está conectado\nel LED\n\nLa caja azul es el bit a 1\nEstá dentro de la FPGA\n\nLa caja amarilla es el pin de salida de\nla FPGA. Por medio del menú desplegable\ninferior se puede cambiar el pin\n\nEJERCICIO 1: Carga este circuito en la FPGA\ny observa el LED0. Debe estar encendido\n\nEJERCICIO 2: Cambia el pin de salida para\nencender otro led (por ejemplo el LED1)\ny cárgalo en la FPGA de nuevo" + }, + "position": { + "x": 464, + "y": 208 + } } - } - ], - "wires": [ - { - "source": { - "block": "e657ee6f-9430-4fce-a539-72d12d32f5bb", - "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" - }, - "target": { - "block": "949075cb-26c0-49da-ba76-2496ea9aa7cc", - "port": "in" + ], + "wires": [ + { + "source": { + "block": "f9239f87-12a4-4141-85f7-c3862615af3a", + "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" + }, + "target": { + "block": "949075cb-26c0-49da-ba76-2496ea9aa7cc", + "port": "in" + } } - } - ] - }, - "deps": { - "bit.1": { - "graph": { - "blocks": [ - { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "type": "basic.code", - "data": { - "code": "// Bit 1\n\nassign v = 1'b1;", - "ports": { - "in": [], - "out": [ - "v" - ] + ] + }, + "deps": { + "bit.1": { + "version": "1.0", + "package": { + "name": "Bit 1", + "version": "1.0.0", + "description": "Assign 1 to the output wire", + "author": "Jesús Arroyo", + "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" + }, + "design": { + "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": "" + }, + "position": { + "x": 608, + "y": 192 + } } - }, - "position": { - "x": 96, - "y": 96 - } + ], + "wires": [ + { + "source": { + "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "port": "v" + }, + "target": { + "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "port": "in" + } + } + ] }, - { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "type": "basic.output", - "data": { - "label": "" + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 }, - "position": { - "x": 608, - "y": 192 - } + "zoom": 1 } - ], - "wires": [ - { - "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "port": "v" - }, - "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "resources/images/1.svg", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 + } } + }, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 } } } \ No newline at end of file diff --git a/app/resources/examples/icezum/1_basic/1_led_on.ice b/app/resources/examples/icezum/1_basic/1_led_on.ice index 672560ecc..185c1ade2 100644 --- a/app/resources/examples/icezum/1_basic/1_led_on.ice +++ b/app/resources/examples/icezum/1_basic/1_led_on.ice @@ -1,130 +1,155 @@ { - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999813303895 + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" }, - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "a538a5b4-d5d5-4ace-a593-efb1fa9b930c", - "type": "basic.info", - "data": { - "info": "LED-ON Hello world circuit example!\n\nThe simplest digital circuit that turns a \nled on\n\nA bit set to 1 is wired directly to the\noutput FPGA pin, where the led is connected\n\nThe blue box is the bit (set to 1)\nIt is inside the FPGA\n\nThe yellow box is the output FPGA pin. Using\nthe bottom menu the pin can be changed\n\nEXERCISE 1: Upload this circuit into your \nFPGA board and watch the led. \nIt should be turned on\n\nEXERCISE 2: Change the pin number to turn\nanother led on and upload it again" + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "8c3d15a4-2311-4a24-8321-6036eb0eb92b", + "type": "bit.1", + "data": {}, + "position": { + "x": 80, + "y": 64 + } }, - "position": { - "x": 40, - "y": 208 - } - }, - { - "id": "0d05784e-8e32-4c80-b85d-cde4e892dbf3", - "type": "basic.info", - "data": { - "info": "Ejemplo de circuito Hola mundo: LED-ON\n\nEs el circuito digital más sencillo que\nenciende un led\n\nUn bit a 1 se cablea directamente a una\nsalida de la FPGA, donde está conectado\nel LED\n\nLa caja azul es el bit a 1\nEstá dentro de la FPGA\n\nLa caja amarilla es el pin de salida de\nla FPGA. Por medio del menú desplegable\ninferior se puede cambiar el pin\n\nEJERCICIO 1: Carga este circuito en la FPGA\ny observa el LED0. Debe estar encendido\n\nEJERCICIO 2: Cambia el pin de salida para\nencender otro led (por ejemplo el LED1)\ny cárgalo en la FPGA de nuevo" + { + "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", + "type": "basic.output", + "data": { + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 352, + "y": 64 + } }, - "position": { - "x": 464, - "y": 208 - } - }, - { - "id": "e657ee6f-9430-4fce-a539-72d12d32f5bb", - "type": "bit.1", - "data": {}, - "position": { - "x": 80, - "y": 64 - } - }, - { - "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", - "type": "basic.output", - "data": { - "label": "led", - "pin": { - "name": "LED0", - "value": "95" + { + "id": "a538a5b4-d5d5-4ace-a593-efb1fa9b930c", + "type": "basic.info", + "data": { + "info": "LED-ON Hello world circuit example!\n\nThe simplest digital circuit that turns a \nled on\n\nA bit set to 1 is wired directly to the\noutput FPGA pin, where the led is connected\n\nThe blue box is the bit (set to 1)\nIt is inside the FPGA\n\nThe yellow box is the output FPGA pin. Using\nthe bottom menu the pin can be changed\n\nEXERCISE 1: Upload this circuit into your \nFPGA board and watch the led. \nIt should be turned on\n\nEXERCISE 2: Change the pin number to turn\nanother led on and upload it again" + }, + "position": { + "x": 40, + "y": 208 } }, - "position": { - "x": 352, - "y": 64 + { + "id": "0d05784e-8e32-4c80-b85d-cde4e892dbf3", + "type": "basic.info", + "data": { + "info": "Ejemplo de circuito Hola mundo: LED-ON\n\nEs el circuito digital más sencillo que\nenciende un led\n\nUn bit a 1 se cablea directamente a una\nsalida de la FPGA, donde está conectado\nel LED\n\nLa caja azul es el bit a 1\nEstá dentro de la FPGA\n\nLa caja amarilla es el pin de salida de\nla FPGA. Por medio del menú desplegable\ninferior se puede cambiar el pin\n\nEJERCICIO 1: Carga este circuito en la FPGA\ny observa el LED0. Debe estar encendido\n\nEJERCICIO 2: Cambia el pin de salida para\nencender otro led (por ejemplo el LED1)\ny cárgalo en la FPGA de nuevo" + }, + "position": { + "x": 464, + "y": 208 + } } - } - ], - "wires": [ - { - "source": { - "block": "e657ee6f-9430-4fce-a539-72d12d32f5bb", - "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" - }, - "target": { - "block": "949075cb-26c0-49da-ba76-2496ea9aa7cc", - "port": "in" + ], + "wires": [ + { + "source": { + "block": "8c3d15a4-2311-4a24-8321-6036eb0eb92b", + "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" + }, + "target": { + "block": "949075cb-26c0-49da-ba76-2496ea9aa7cc", + "port": "in" + } } - } - ] - }, - "deps": { - "bit.1": { - "graph": { - "blocks": [ - { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "type": "basic.code", - "data": { - "code": "// Bit 1\n\nassign v = 1'b1;", - "ports": { - "in": [], - "out": [ - "v" - ] + ] + }, + "deps": { + "bit.1": { + "version": "1.0", + "package": { + "name": "Bit 1", + "version": "1.0.0", + "description": "Assign 1 to the output wire", + "author": "Jesús Arroyo", + "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" + }, + "design": { + "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": "" + }, + "position": { + "x": 608, + "y": 192 + } } - }, - "position": { - "x": 96, - "y": 96 - } + ], + "wires": [ + { + "source": { + "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "port": "v" + }, + "target": { + "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "port": "in" + } + } + ] }, - { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "type": "basic.output", - "data": { - "label": "" + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 }, - "position": { - "x": 608, - "y": 192 - } + "zoom": 1 } - ], - "wires": [ - { - "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", - "port": "v" - }, - "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", - "port": "in" - } - } - ] - }, - "deps": {}, - "image": "resources/images/1.svg", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 + } } + }, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 } } } \ No newline at end of file diff --git a/app/resources/examples/icezum/1_basic/2_switch_led.ice b/app/resources/examples/icezum/1_basic/2_switch_led.ice index 3adf6917a..7b42bc6ae 100644 --- a/app/resources/examples/icezum/1_basic/2_switch_led.ice +++ b/app/resources/examples/icezum/1_basic/2_switch_led.ice @@ -1,91 +1,112 @@ { - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999883960295 + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" }, - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "aac1b394-533e-4410-9f35-ba80af8abd63", - "type": "basic.input", - "data": { - "label": "button", - "pin": { - "name": "SW1", - "value": "10" + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "aac1b394-533e-4410-9f35-ba80af8abd63", + "type": "basic.input", + "data": { + "label": "button", + "name": "button", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false + }, + "position": { + "x": 48, + "y": 80 } }, - "position": { - "x": 48, - "y": 80 - } - }, - { - "id": "30a83e46-176d-40a8-ac0e-f19a131ea9d9", - "type": "basic.output", - "data": { - "label": "led", - "pin": { - "name": "LED0", - "value": "95" + { + "id": "30a83e46-176d-40a8-ac0e-f19a131ea9d9", + "type": "basic.output", + "data": { + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 320, + "y": 80 } }, - "position": { - "x": 320, - "y": 80 - } - }, - { - "id": "9e124703-5a80-4d0d-8c31-945447862085", - "type": "basic.info", - "data": { - "info": "Switch-led basic example\n\nA simple circuit that connects the input pin,\nwhere there is a button switch, with the\noutpun pin, where there is a led\n\nWhen the button is pressed (1), the led is\nturned on. When the button is released (0), the\nled is turned off\n\nNotice the blue box with a gear. It is a\nconfiguration block for activating the \nFPGA internal pull-up resistor in the SW1 pin" - }, - "position": { - "x": 32, - "y": 224 - } - }, - { - "id": "f76f55d3-ba32-42d8-8c16-9f4cbbd9d27c", - "type": "basic.info", - "data": { - "info": "Ejemplo básico switch-led\n\nSencillo circuito que conecta directamente\nun pin de entrada de la FPGA, donde hay\nun pulsador, con el pin de salida, donde está\nel led\n\nCuando se aprieta el pulsador (1), se enciende\nel led. Cuando se suelta (0) se apaga\n\nFíjate en la caja azul con el engranaje. Es un\nbloque de configuración que permite activar la\nresistencia de pull-up interna del pin de la \nFPGA" + { + "id": "9e124703-5a80-4d0d-8c31-945447862085", + "type": "basic.info", + "data": { + "info": "Switch-led basic example\n\nA simple circuit that connects the input pin,\nwhere there is a button switch, with the\noutpun pin, where there is a led\n\nWhen the button is pressed (1), the led is\nturned on. When the button is released (0), the\nled is turned off\n\nNotice the blue box with a gear. It is a\nconfiguration block for activating the \nFPGA internal pull-up resistor in the SW1 pin" + }, + "position": { + "x": 32, + "y": 224 + } }, - "position": { - "x": 448, - "y": 224 - } - }, - { - "id": "d556c4f6-736a-41a9-9f64-badf2b790010", - "type": "basic.info", - "data": { - "info": "EXERCISE 1: Upload the circuit into your FPGA\nboard and test it!\n\nEXERCISE 2: Change the button to SW2 and test\nit again\n\n---------------------------------------------\nEjercicio 1: Carga el circuito en la FPGA y\n¡pruébalo!\n\nEJERCICIO 2: Cambia el pulsador al SW2 y\npruébalo de nuevo" + { + "id": "f76f55d3-ba32-42d8-8c16-9f4cbbd9d27c", + "type": "basic.info", + "data": { + "info": "Ejemplo básico switch-led\n\nSencillo circuito que conecta directamente\nun pin de entrada de la FPGA, donde hay\nun pulsador, con el pin de salida, donde está\nel led\n\nCuando se aprieta el pulsador (1), se enciende\nel led. Cuando se suelta (0) se apaga\n\nFíjate en la caja azul con el engranaje. Es un\nbloque de configuración que permite activar la\nresistencia de pull-up interna del pin de la \nFPGA" + }, + "position": { + "x": 448, + "y": 224 + } }, - "position": { - "x": 864, - "y": 224 + { + "id": "d556c4f6-736a-41a9-9f64-badf2b790010", + "type": "basic.info", + "data": { + "info": "EXERCISE 1: Upload the circuit into your FPGA\nboard and test it!\n\nEXERCISE 2: Change the button to SW2 and test\nit again\n\n---------------------------------------------\nEjercicio 1: Carga el circuito en la FPGA y\n¡pruébalo!\n\nEJERCICIO 2: Cambia el pulsador al SW2 y\npruébalo de nuevo" + }, + "position": { + "x": 864, + "y": 224 + } } - } - ], - "wires": [ - { - "source": { - "block": "aac1b394-533e-4410-9f35-ba80af8abd63", - "port": "out" - }, - "target": { - "block": "30a83e46-176d-40a8-ac0e-f19a131ea9d9", - "port": "in" + ], + "wires": [ + { + "source": { + "block": "aac1b394-533e-4410-9f35-ba80af8abd63", + "port": "out" + }, + "target": { + "block": "30a83e46-176d-40a8-ac0e-f19a131ea9d9", + "port": "in" + } } - } - ] - }, - "deps": {} + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } } \ No newline at end of file diff --git a/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice b/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice index 50c4778b9..6edbb2630 100644 --- a/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice +++ b/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice @@ -1,225 +1,262 @@ { - "image": "", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999999999751 + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" }, - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", - "type": "basic.input", - "data": { - "label": "button1", - "pin": { - "name": "SW1", - "value": "10" + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", + "type": "basic.input", + "data": { + "label": "button1", + "name": "button1", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false + }, + "position": { + "x": 40, + "y": 32 } }, - "position": { - "x": 40, - "y": 32 - } - }, - { - "id": "5d1b4f33-ae65-4154-b4f4-ff1403437600", - "type": "basic.input", - "data": { - "label": "button2", - "pin": { - "name": "SW2", - "value": "11" + { + "id": "81f8eceb-3742-4350-8833-78fef262c542", + "type": "logic.gate.and", + "data": {}, + "position": { + "x": 248, + "y": 80 } }, - "position": { - "x": 40, - "y": 128 - } - }, - { - "id": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", - "type": "basic.output", - "data": { - "label": "led", - "pin": { - "name": "LED7", - "value": "104" + { + "id": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", + "type": "basic.output", + "data": { + "label": "led", + "name": "led", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED7", + "value": "104" + } + ], + "virtual": false + }, + "position": { + "x": 440, + "y": 80 } }, - "position": { - "x": 440, - "y": 80 - } - }, - { - "id": "cb5b06e5-0d7d-4c89-9c17-0cd7892369c1", - "type": "logic.and", - "data": {}, - "position": { - "x": 264, - "y": 80 - } - }, - { - "id": "cce8504a-dc1f-4deb-9ee3-5f215ac88408", - "type": "basic.info", - "data": { - "info": "Basic AND gate circuit\n\nA 2-inputs AND logic gate is used to turn on\nthe LED7 only when the 2 input buttons\nare pressed\n\nThis example shows the basic behaviour of\nthe AND gate\n\nEXERCISE: Upload this circuit into the FPGA\nboard and play with it" + { + "id": "5d1b4f33-ae65-4154-b4f4-ff1403437600", + "type": "basic.input", + "data": { + "label": "button2", + "name": "button2", + "range": "", + "pins": [ + { + "index": "0", + "name": "SW2", + "value": "11" + } + ], + "virtual": false + }, + "position": { + "x": 40, + "y": 128 + } }, - "position": { - "x": 40, - "y": 232 - } - }, - { - "id": "edf3b438-4271-45f7-bb14-2a6d040880dd", - "type": "basic.info", - "data": { - "info": "Circuito básico con puerta AND\n\nUna puerta lógica AND de 2 entradas se usa\npara encender un led solo cuando los dos\npulsadores de entrada están apretados\n\nEste ejemplo muestra el comportamiento básico\nde una puerta AND\n\nEJERCICIO: Carga este circuito en la FPGA y \njuega con él" + { + "id": "cce8504a-dc1f-4deb-9ee3-5f215ac88408", + "type": "basic.info", + "data": { + "info": "Basic AND gate circuit\n\nA 2-inputs AND logic gate is used to turn on\nthe LED7 only when the 2 input buttons\nare pressed\n\nThis example shows the basic behaviour of\nthe AND gate\n\nEXERCISE: Upload this circuit into the FPGA\nboard and play with it" + }, + "position": { + "x": 40, + "y": 232 + } }, - "position": { - "x": 464, - "y": 232 + { + "id": "edf3b438-4271-45f7-bb14-2a6d040880dd", + "type": "basic.info", + "data": { + "info": "Circuito básico con puerta AND\n\nUna puerta lógica AND de 2 entradas se usa\npara encender un led solo cuando los dos\npulsadores de entrada están apretados\n\nEste ejemplo muestra el comportamiento básico\nde una puerta AND\n\nEJERCICIO: Carga este circuito en la FPGA y \njuega con él" + }, + "position": { + "x": 464, + "y": 232 + } } - } - ], - "wires": [ - { - "source": { - "block": "cb5b06e5-0d7d-4c89-9c17-0cd7892369c1", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" + ], + "wires": [ + { + "source": { + "block": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", + "port": "out" + }, + "target": { + "block": "81f8eceb-3742-4350-8833-78fef262c542", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + } }, - "target": { - "block": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", - "port": "in" - } - }, - { - "source": { - "block": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", - "port": "out" + { + "source": { + "block": "5d1b4f33-ae65-4154-b4f4-ff1403437600", + "port": "out" + }, + "target": { + "block": "81f8eceb-3742-4350-8833-78fef262c542", + "port": "97b51945-d716-4b6c-9db9-970d08541249" + } }, - "target": { - "block": "cb5b06e5-0d7d-4c89-9c17-0cd7892369c1", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + { + "source": { + "block": "81f8eceb-3742-4350-8833-78fef262c542", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" + }, + "target": { + "block": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", + "port": "in" + } } - }, - { - "source": { - "block": "5d1b4f33-ae65-4154-b4f4-ff1403437600", - "port": "out" + ] + }, + "deps": { + "logic.gate.and": { + "version": "1.0", + "package": { + "name": "AND", + "version": "1.0.0", + "description": "AND logic gate", + "author": "Jesús Arroyo", + "image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%22-252%20400.9%2090%2040%22%3E%3Cpath%20d=%22M-252%20409.9h26v2h-26zM-252%20429.9h27v2h-27z%22/%3E%3Cpath%20d=%22M-227%20400.9v39.9h20.4c11.3%200%2020-9%2020-20s-8.7-20-20-20H-227zm2.9%202.8h17.6c9.8%200%2016.7%207.6%2016.7%2017.1%200%209.5-7.4%2017.1-17.1%2017.1H-224c-.1.1-.1-34.2-.1-34.2z%22/%3E%3Cpath%20d=%22M-187.911%20419.9H-162v2h-25.911z%22/%3E%3C/svg%3E" }, - "target": { - "block": "cb5b06e5-0d7d-4c89-9c17-0cd7892369c1", - "port": "97b51945-d716-4b6c-9db9-970d08541249" - } - } - ] - }, - "deps": { - "logic.and": { - "graph": { - "blocks": [ - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "" - }, - "position": { - "x": 64, - "y": 80 - } - }, - { - "id": "97b51945-d716-4b6c-9db9-970d08541249", - "type": "basic.input", - "data": { - "label": "" - }, - "position": { - "x": 64, - "y": 208 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "" - }, - "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" - ] + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "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 + } + }, + { + "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 64, + "y": 80 + } + }, + { + "id": "664caf9e-5f40-4df4-800a-b626af702e62", + "type": "basic.output", + "data": { + "label": "" + }, + "position": { + "x": 752, + "y": 144 + } + }, + { + "id": "97b51945-d716-4b6c-9db9-970d08541249", + "type": "basic.input", + "data": { + "label": "" + }, + "position": { + "x": 64, + "y": 208 + } } - }, - "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" - } + ], + "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" + } + } + ] }, - { - "source": { - "block": "00925b04-5004-4307-a737-fa4e97c8b6ab", - "port": "c" + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 }, - "target": { - "block": "664caf9e-5f40-4df4-800a-b626af702e62", - "port": "in" - } + "zoom": 0.9999999784900666 } - ] - }, - "deps": {}, - "image": "resources/images/and.svg", - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 + } } + }, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 } } } \ No newline at end of file diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 50afccd4e..4e6faeff3 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -439,6 +439,12 @@ angular.module('icestudio') }; this.createBlock = function(type, block, callback) { + var addCellCallback = function(cell) { + addCell(cell); + if (callback) { + callback(); + } + }; if (type.indexOf('basic.') !== -1) { blocks.newBasic(type, block, addCellCallback); } @@ -446,13 +452,6 @@ angular.module('icestudio') dependencies[type] = block; blocks.newGeneric(type, block, addCellCallback); } - - var addCellCallback = function(cell) { - addCell(cell); - if (callback) { - callback(); - } - }; }; this.toJSON = function() { diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index 07a059e81..9c7fc5d3b 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -57,7 +57,7 @@ angular.module('icestudio') this.load = function(name, data) { if (!data.version) { - alertify.notify(gettextCatalog.getString('Old project format'), 'warning', 3); + alertify.notify(gettextCatalog.getString('Old project format'), 'warning', 5); } this.project = _safeLoad(data); var ret = graph.loadDesign(this.project.design, false, function() { @@ -146,7 +146,7 @@ angular.module('icestudio') var self = this; utils.readFile(filepath, function(data) { if (!data.version) { - alertify.notify(gettextCatalog.getString('Old project format'), 'warning', 3); + alertify.notify(gettextCatalog.getString('Old project format'), 'warning', 5); } var block = _safeLoad(data); if (block) { From 96bbb304d7ead6347be1bf7d6f0fb55d87721d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 14:48:02 +0100 Subject: [PATCH 14/35] Edit multi-io blocks --- app/scripts/services/blocks.service.js | 481 +++++++++++++++---------- app/scripts/services/graph.service.js | 18 +- 2 files changed, 283 insertions(+), 216 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 41c18a66f..3b13a4c15 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -28,7 +28,235 @@ angular.module('icestudio') }; this.newGeneric = newGeneric; - this.loadBasic = function(instance, disabled) { + this.loadBasic = loadBasic; + this.loadGeneric = loadGeneric; + this.loadWire = loadWire; + + + this.editBasicIO = editBasicIO; + + + //-- New + + function newBasicIO(type, addCellCallback) { + var config = null; + if (type === 'basic.input') { + config = { type: type, _default: 'in', x: 4 }; + } + else if (type === 'basic.output') { + config = { type: type, _default: 'out', x: 95 }; + } + if (config) { + var blockInstance = { + id: null, + data: {}, + type: config.type, + position: { x: config.x * gridsize, y: 4 * gridsize } + }; + alertify.prompt(gettextCatalog.getString('Enter the ports'), config._default, + function(evt, input) { + if (input) { + var labels = input.replace(/ /g, '').split(','); + var portInfo, portInfos = []; + // Validate input + for (var l in labels) { + portInfo = utils.parsePortLabel(labels[l]); + if (portInfo) { + evt.cancel = false; + portInfos.push(portInfo); + } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: labels[l] }), 'warning', 3); + return; + } + } + // Create blocks + for (var p in portInfos) { + portInfo = portInfos[p]; + blockInstance.data = { + label: portInfo.input, + name: portInfo.name, + range: portInfo.rangestr ? portInfo.rangestr : '', + pins: getPins(portInfo), + virtual: true + }; + if (addCellCallback) { + addCellCallback(loadBasic(blockInstance)); + } + // Next block position + blockInstance.position.y += 10 * gridsize; + } + } + }); + } + } + + function getPins(portInfo) { + var pins = []; + if (portInfo.range) { + for (var r in portInfo.range) { + pins.push({ index: portInfo.range[r].toString(), name: '', value: 0 }); + } + } + else { + pins.push({ index: '0', name: '', value: 0 }); + } + return pins; + } + + function newBasicConstant(addCellCallback) { + var blockInstance = { + id: null, + data: {}, + type: 'basic.constant', + position: { x: 20 * gridsize, y: 4 * gridsize } + }; + alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), 'C', + function(evt, name) { + if (name) { + var names = name.replace(/ /g, '').split(','); + for (var n in names) { + if (names[n]) { + blockInstance.data = { + label: names[n], + local: false, + value: '' + }; + if (addCellCallback) { + addCellCallback(loadBasicConstant(blockInstance)); + } + blockInstance.position.x += 15 * gridsize; + } + } + } + }); + } + + function newBasicCode(block, addCellCallback) { + var blockInstance = { + id: null, + data: {}, + type: 'basic.code', + position: { x: 4 * gridsize, y: 4 * gridsize } + }; + var defaultValues = [ + 'a , b', + 'c , d', + '' + ]; + if (block && block.data) { + 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'), + gettextCatalog.getString('Enter the output ports'), + gettextCatalog.getString('Enter the parameters') ], + defaultValues, + 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]) { + blockInstance.data.ports.in.push(inPorts[i]); + } + } + for (var o in outPorts) { + 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 = 24 * gridsize; + + 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; + } + if (addCellCallback) { + addCellCallback(loadBasicCode(blockInstance)); + } + } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); + } + } + }); + } + + function newBasicInfo(addCellCallback) { + var blockInstance = { + id: null, + data: { info: '' }, + type: 'basic.info', + position: { x: 4 * gridsize, y: 30 * gridsize } + }; + if (addCellCallback) { + addCellCallback(loadBasicInfo(blockInstance)); + } + } + + function newGeneric(type, block, addCellCallback) { + var blockInstance = { + id: null, + type: type, + position: { x: 6 * gridsize, y: 16 * gridsize } + }; + if (block && + block.design && + block.design.graph && + block.design.graph.blocks && + block.design.graph.wires && + block.design.deps) { + if (addCellCallback) { + addCellCallback(loadGeneric(blockInstance, block)); + } + } + else { + alertify.notify(gettextCatalog.getString('Wrong block format: {{type}}', { type: type }), 'error', 30); + } + } + + + //-- Load + + function loadBasic(instance, disabled) { switch(instance.type) { case 'basic.input': return loadBasicInput(instance, disabled); @@ -43,9 +271,7 @@ angular.module('icestudio') default: break; } - }; - this.loadGeneric = loadGeneric; - this.loadWire = loadWire; + } function loadBasicInput(instance, disabled) { var cell = new joint.shapes.ice.Input({ @@ -269,212 +495,67 @@ angular.module('icestudio') return _wire; } - function newBasicIO(type, addCellCallback) { - var config = null; - if (type === 'basic.input') { - config = { type: type, _default: 'in', loadFunction: loadBasicInput, x: 4 }; - } - else if (type === 'basic.output') { - config = { type: type, _default: 'out',loadFunction: loadBasicOutput, x: 95 }; - } - if (config) { - var blockInstance = { - id: null, - data: {}, - type: config.type, - position: { x: config.x * gridsize, y: 4 * gridsize } - }; - alertify.prompt(gettextCatalog.getString('Enter the ports'), config._default, - function(evt, input) { - if (input) { - var labels = input.replace(/ /g, '').split(','); - for (var l in labels) { - var portInfo = utils.parsePortLabel(labels[l]); - if (portInfo) { - evt.cancel = false; - blockInstance.data = { + + //-- Edit + + function editBasicIO(cellView, addCellCallback) { + var block = cellView.model.attributes; + utils.inputcheckboxprompt([ + gettextCatalog.getString('Update the port'), + gettextCatalog.getString('Virtual port') + ], [ + block.data.label, + block.data.virtual + ], + function(evt, values) { + var label = values[0].replace(/ /g, ''); + var virtual = values[1]; + // Validate input + var portInfo = utils.parsePortLabel(label); + if (portInfo) { + evt.cancel = false; + if (!block.data.range) { + block.data.range = ''; + } + if (!portInfo.rangestr) { + portInfo.rangestr = ''; + } + if (block.data.range !== portInfo.rangestr) { + // Create new block + var blockInstance = { + id: null, + data: { label: portInfo.input, name: portInfo.name, range: portInfo.rangestr ? portInfo.rangestr : '', pins: getPins(portInfo), - virtual: true - }; - if (addCellCallback) { - addCellCallback(config.loadFunction(blockInstance)); - } - // Next block position - blockInstance.position.y += 10 * gridsize; - } - else { - evt.cancel = true; - alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: labels[l] }), 'warning', 3); - break; - } - } - } - }); - } - } - - function getPins(portInfo) { - var pins = []; - if (portInfo.range) { - for (var r in portInfo.range) { - pins.push({ index: portInfo.range[r].toString(), name: '', value: 0 }); - } - } - else { - pins.push({ index: '0', name: '', value: 0 }); - } - return pins; - } - - function newBasicConstant(addCellCallback) { - var blockInstance = { - id: null, - data: {}, - type: 'basic.constant', - position: { x: 20 * gridsize, y: 4 * gridsize } - }; - alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), 'C', - function(evt, name) { - if (name) { - var names = name.replace(/ /g, '').split(','); - for (var n in names) { - if (names[n]) { - blockInstance.data = { - label: names[n], - local: false, - value: '' - }; - if (addCellCallback) { - addCellCallback(loadBasicConstant(blockInstance)); - } - blockInstance.position.x += 15 * gridsize; - } - } - } - }); - } - - function newBasicCode(block, addCellCallback) { - var blockInstance = { - id: null, - data: {}, - type: 'basic.code', - position: { x: 4 * gridsize, y: 4 * gridsize } - }; - var defaultValues = [ - 'a , b', - 'c , d', - '' - ]; - if (block && block.data) { - 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'), - gettextCatalog.getString('Enter the output ports'), - gettextCatalog.getString('Enter the parameters') ], - defaultValues, - 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]) { - blockInstance.data.ports.in.push(inPorts[i]); - } - } - for (var o in outPorts) { - 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 = 24 * gridsize; - - 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; - } + virtual: virtual + }, + type: block.blockType, + position: block.position + }; if (addCellCallback) { - addCellCallback(loadBasicCode(blockInstance)); + addCellCallback(loadBasic(blockInstance)); + cellView.model.remove(); + alertify.success(gettextCatalog.getString('Block updated: create')); } } - else { - evt.cancel = true; - alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); + else if (block.data.name !== portInfo.name || + block.data.virtual !== virtual) { + // Edit block + block.data.label = portInfo.input; + block.data.name = portInfo.name; + block.data.pins = getPins(portInfo); + block.data.virtual = virtual; + cellView.render(); + alertify.success(gettextCatalog.getString('Block updated: edit')); } } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: label }), 'warning', 3); + } }); } - function newBasicInfo(addCellCallback) { - var blockInstance = { - id: null, - data: { info: '' }, - type: 'basic.info', - position: { x: 4 * gridsize, y: 30 * gridsize } - }; - if (addCellCallback) { - addCellCallback(loadBasicInfo(blockInstance)); - } - } - - function newGeneric(type, block, addCellCallback) { - var blockInstance = { - id: null, - type: type, - position: { x: 6 * gridsize, y: 16 * gridsize } - }; - if (block && - block.design && - block.design.graph && - block.design.graph.blocks && - block.design.graph.wires && - block.design.deps) { - if (addCellCallback) { - addCellCallback(loadGeneric(blockInstance, block)); - } - } - else { - alertify.notify(gettextCatalog.getString('Wrong block format: {{type}}', { type: type }), 'error', 30); - } - } - }); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 4e6faeff3..b375df8ea 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -279,22 +279,8 @@ angular.module('icestudio') if (data.blockType === 'basic.input' || data.blockType === 'basic.output') { if (paper.options.enabled) { - utils.inputcheckboxprompt([ - gettextCatalog.getString('Update the port label'), - gettextCatalog.getString('Virtual port') - ], [ - data.data.label, - data.data.virtual - ], - function(evt, values) { - var label = values[0].replace(/ /g, ''); - if (data.data.label !== label) { - data.data.label = label; - alertify.success(gettextCatalog.getString('Block updated')); - } - var virtual = values[1]; - data.data.virtual = virtual; - cellView.render(); + blocks.editBasicIO(cellView, function(cell) { + addCell(cell); }); } } From bf59b2d24e937ae98e1919edd40d02393145c25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 17:54:30 +0100 Subject: [PATCH 15/35] Add bus wires into the compiler. Minor io block fix --- app/scripts/plugins/shapes/joint.shapes.js | 55 ++++---- app/scripts/services/blocks.service.js | 5 +- app/scripts/services/compiler.service.js | 3 +- app/scripts/services/project.service.js | 1 + app/styles/design.css | 8 +- demo/bus-input-output.ice | 142 +++++++++++++++++++++ 6 files changed, 184 insertions(+), 30 deletions(-) create mode 100644 demo/bus-input-output.ice diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 357dc44f2..c5b4626b1 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -342,13 +342,11 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ var selectScript = ''; this.pins = this.model.attributes.data.pins; - // a,b[0:1],c[0:2],d[0:3] - if (this.pins) { for (var i in this.pins) { //selectCode += '

' + this.pins[i].index + '

'; selectCode +=''; selectScript += '$("#' + comboId + this.pins[i].index + '").select2('; @@ -374,24 +372,18 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ comboSelector.on('mousedown click', function(evt) { evt.stopPropagation(); }); comboSelector.on('change', _.bind(function(evt) { var target = $(evt.target); - var index = target.attr('index'); + var i = target.attr('i'); var name = target.find('option:selected').text(); var value = target.val(); - this.model.attributes.data.pins[index].name = name; - this.model.attributes.data.pins[index].value = value; - this.$box.find('.select2-selection').css('font-size', computeFontSize(name)); + this.model.attributes.data.pins[i].name = name; + this.model.attributes.data.pins[i].value = value; + //comboSelector.find('.select2-selection').css('font-size', this.computeFontSize(name)); }, this)); - function computeFontSize(name) { - var n = name.length; - return Math.min(13, 17-n).toString() + 'px'; - } - }, - renderChoices: function() { - if (this.pins) { - for (var i in this.pins) { - this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); - } + // Render data + if (!this.model.get('disabled')) { + this.renderChoices(); + this.renderValue(); } }, renderBlock: function() { @@ -417,10 +409,22 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ } } }, + renderChoices: function() { + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); + } + } + }, renderValue: function() { if (this.pins) { for (var i in this.pins) { - this.$box.find('#combo' + this.id + this.pins[i].index).val(this.pins[i].value); + var index = this.pins[i].index; + var comboId = 'combo' + this.id + index; + var comboSelector = this.$box.find('#' + comboId); + comboSelector.val(this.pins[i].value); + //var fontSize = this.computeFontSize(this.pins[i].name); + //$('#select2-' + comboId + '-container').css('font-size', fontSize); } } }, @@ -428,18 +432,18 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ if (this.pins) { for (var i in this.pins) { this.$box.find('#combo' + this.id + this.pins[i].index).val(''); - this.model.attributes.data.pins[i.toString()].name = ''; - this.model.attributes.data.pins[i.toString()].value = 0; + this.model.attributes.data.pins[i].name = ''; + this.model.attributes.data.pins[i].value = 0; } } }, + computeFontSize: function(name) { + var n = name.length; + return Math.min(13, 17-n).toString() + 'px'; + }, update: function () { this.renderPorts(); this.renderBlock(); - if (!this.model.get('disabled')) { - this.renderChoices(); - this.renderValue(); - } joint.dia.ElementView.prototype.update.apply(this, arguments); } }); @@ -773,6 +777,9 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // Set up the wire this.$('.connection').css('stroke-width', wireWidth); this.model.label(0, {attrs: { text: { text: wireLabel } } }); + if (pins && pins.length > 1) { + this.model.attributes.size = pins.length; + } this.model.bifurcationMarkup = this.model.bifurcationMarkup.replace(/<%= r %>/g, wireDot); this.update(); diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 3b13a4c15..c2b5a7fb6 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -537,7 +537,7 @@ angular.module('icestudio') if (addCellCallback) { addCellCallback(loadBasic(blockInstance)); cellView.model.remove(); - alertify.success(gettextCatalog.getString('Block updated: create')); + alertify.success(gettextCatalog.getString('Block updated')); } } else if (block.data.name !== portInfo.name || @@ -545,10 +545,9 @@ angular.module('icestudio') // Edit block block.data.label = portInfo.input; block.data.name = portInfo.name; - block.data.pins = getPins(portInfo); block.data.virtual = virtual; cellView.render(); - alertify.success(gettextCatalog.getString('Block updated: edit')); + alertify.success(gettextCatalog.getString('Block updated')); } } else { diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index a1e740afa..3ec7abf92 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -182,7 +182,8 @@ angular.module('icestudio') } else { // Wires - connections.wire.push('wire w' + w + ';'); + var range = wire.size ? '[0:' + (wire.size-1) +'] ' : ' '; + connections.wire.push('wire ' + range + 'w' + w + ';'); } // Assignations for (i in graph.blocks) { diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index 9c7fc5d3b..9d1370e08 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -288,6 +288,7 @@ angular.module('icestudio') var wire = {}; wire.source = { block: cell.source.id, port: cell.source.port }; wire.target = { block: cell.target.id, port: cell.target.port }; + wire.size = cell.size; wire.vertices = cell.vertices; wires.push(wire); } diff --git a/app/styles/design.css b/app/styles/design.css index 01c2f8405..d8dccf49a 100644 --- a/app/styles/design.css +++ b/app/styles/design.css @@ -158,9 +158,13 @@ pointer-events: auto; } +.select2-selection__rendered { + font-size: 13px; +} + .bigdrop { - width: 86px !important; - font-size: 12px; + width: 92px !important; + font-size: 13px; } .constant-block { diff --git a/demo/bus-input-output.ice b/demo/bus-input-output.ice new file mode 100644 index 000000000..c8e17d9ae --- /dev/null +++ b/demo/bus-input-output.ice @@ -0,0 +1,142 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "a63cb442-f0cf-4802-8542-0b50bf859a3c", + "type": "basic.input", + "data": { + "label": "buttons[0:1]", + "name": "buttons", + "range": "[0:1]", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + }, + { + "index": "1", + "name": "SW2", + "value": "11" + } + ], + "virtual": false + }, + "position": { + "x": 128, + "y": 64 + } + }, + { + "id": "39d544a4-e8fd-4c59-909e-61cddd5e7f98", + "type": "basic.output", + "data": { + "label": "leds[1:0]", + "name": "leds", + "range": "[1:0]", + "pins": [ + { + "index": "1", + "name": "LED0", + "value": "95" + }, + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false + }, + "position": { + "x": 408, + "y": 64 + } + }, + { + "id": "99ebca85-09ff-456a-8caa-cfa78955e25f", + "type": "basic.input", + "data": { + "label": "in", + "name": "in", + "range": "", + "pins": [ + { + "index": "0", + "name": "D10", + "value": "141" + } + ], + "virtual": false + }, + "position": { + "x": 184, + "y": 248 + } + }, + { + "id": "5b81602a-731c-42bd-9f81-3bec86dbe75c", + "type": "basic.output", + "data": { + "label": "out", + "name": "out", + "range": "", + "pins": [ + { + "index": "0", + "name": "LED2", + "value": "97" + } + ], + "virtual": false + }, + "position": { + "x": 384, + "y": 248 + } + } + ], + "wires": [ + { + "source": { + "block": "a63cb442-f0cf-4802-8542-0b50bf859a3c", + "port": "out" + }, + "target": { + "block": "39d544a4-e8fd-4c59-909e-61cddd5e7f98", + "port": "in" + }, + "size": 2 + }, + { + "source": { + "block": "99ebca85-09ff-456a-8caa-cfa78955e25f", + "port": "out" + }, + "target": { + "block": "5b81602a-731c-42bd-9f81-3bec86dbe75c", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file From 01e9a1f03d79ff4c45e772344c491623c8edd8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 18:06:15 +0100 Subject: [PATCH 16/35] Move editBasicConstant function to blocks service --- app/scripts/services/blocks.service.js | 26 ++++++++++++++++++++++++++ app/scripts/services/graph.service.js | 20 ++------------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index c2b5a7fb6..983029b93 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -34,6 +34,7 @@ angular.module('icestudio') this.editBasicIO = editBasicIO; + this.editBasicConstant = editBasicConstant; //-- New @@ -557,4 +558,29 @@ angular.module('icestudio') }); } + function editBasicConstant(cellView) { + var block = cellView.model.attributes; + utils.inputcheckboxprompt([ + gettextCatalog.getString('Update the block label'), + gettextCatalog.getString('Local parameter') + ], [ + block.data.label, + block.data.local + ], + function(evt, values) { + var label = values[0].replace(/ /g, ''); + var local = values[1]; + // Edit block + if (block.data.name !== label || + block.data.local !== local) { + // Edit block + block.data.label = label; + block.data.local = local; + cellView.renderLabel(); + cellView.renderLocal(); + alertify.success(gettextCatalog.getString('Block updated')); + } + }); + } + }); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index b375df8ea..bca8143f0 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -276,6 +276,7 @@ angular.module('icestudio') paper.on('cell:pointerdblclick', function(cellView/*, evt, x, y*/) { var data = cellView.model.attributes; + // TODO: move to blocks.service edit function if (data.blockType === 'basic.input' || data.blockType === 'basic.output') { if (paper.options.enabled) { @@ -286,24 +287,7 @@ angular.module('icestudio') } else if (data.blockType === 'basic.constant') { if (paper.options.enabled) { - utils.inputcheckboxprompt([ - gettextCatalog.getString('Update the block label'), - gettextCatalog.getString('Local parameter') - ], [ - data.data.label, - data.data.local - ], - function(evt, values) { - var label = values[0].replace(/ /g, ''); - if (data.data.label !== label) { - data.data.label = label; - cellView.renderLabel(); - alertify.success(gettextCatalog.getString('Block updated')); - } - var local = values[1]; - data.data.local = local; - cellView.renderLocal(); - }); + blocks.editBasicConstant(cellView); } } else if (data.blockType === 'basic.code') { From 075ba80f74b219a6ecc6623df65d1ade38b76fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Tue, 20 Dec 2016 18:30:46 +0100 Subject: [PATCH 17/35] Prevent different size connections --- app/scripts/plugins/shapes/joint.shapes.js | 4 +--- app/scripts/services/graph.service.js | 7 +++++++ app/scripts/services/project.service.js | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index c5b4626b1..f3e0401ca 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -776,10 +776,8 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // Set up the wire this.$('.connection').css('stroke-width', wireWidth); + this.model.attributes.size = pins.length; this.model.label(0, {attrs: { text: { text: wireLabel } } }); - if (pins && pins.length > 1) { - this.model.attributes.size = pins.length; - } this.model.bifurcationMarkup = this.model.bifurcationMarkup.replace(/<%= r %>/g, wireDot); this.update(); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index bca8143f0..79cb388b4 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -98,6 +98,13 @@ angular.module('icestudio') } return false; } + // Prevent different size connections + var tsize = cellViewT.model.attributes.data.pins.length; + var lsize = linkView.model.attributes.size; + if (tsize !== lsize) { + warning(gettextCatalog.getString('Invalid connection: ' + lsize + ' → ' + tsize)); + return false; + } // Ensure right -> left connections if (magnetS.getAttribute('pos') === 'right') { if (magnetT.getAttribute('pos') !== 'left') { diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index 9d1370e08..a487d412c 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -288,7 +288,9 @@ angular.module('icestudio') var wire = {}; wire.source = { block: cell.source.id, port: cell.source.port }; wire.target = { block: cell.target.id, port: cell.target.port }; - wire.size = cell.size; + if (cell.size > 1) { + wire.size = cell.size; + } wire.vertices = cell.vertices; wires.push(wire); } From 53429f627df91eb9eff7060f3d6d023bb165f43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 09:16:45 +0100 Subject: [PATCH 18/35] Improve I/O and Constant blocks creation prompt --- app/scripts/services/blocks.service.js | 61 +++++++++++++++----------- app/scripts/services/graph.service.js | 3 +- app/scripts/services/utils.service.js | 2 +- app/styles/design.css | 1 + app/styles/main.css | 4 +- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 983029b93..9567cb8fb 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -54,12 +54,18 @@ angular.module('icestudio') type: config.type, position: { x: config.x * gridsize, y: 4 * gridsize } }; - alertify.prompt(gettextCatalog.getString('Enter the ports'), config._default, - function(evt, input) { - if (input) { - var labels = input.replace(/ /g, '').split(','); + utils.inputcheckboxprompt([ + gettextCatalog.getString('Enter the ports'), + gettextCatalog.getString('Virtual port') + ], [ + config._default, + true + ], + function(evt, values) { + var labels = values[0].replace(/ /g, '').split(','); + var virtual = values[1]; + // Validate values var portInfo, portInfos = []; - // Validate input for (var l in labels) { portInfo = utils.parsePortLabel(labels[l]); if (portInfo) { @@ -75,20 +81,20 @@ angular.module('icestudio') // Create blocks for (var p in portInfos) { portInfo = portInfos[p]; + var pins = getPins(portInfo); blockInstance.data = { label: portInfo.input, name: portInfo.name, range: portInfo.rangestr ? portInfo.rangestr : '', - pins: getPins(portInfo), - virtual: true + pins: pins, + virtual: virtual }; if (addCellCallback) { addCellCallback(loadBasic(blockInstance)); } // Next block position - blockInstance.position.y += 10 * gridsize; + blockInstance.position.y += (virtual ? 10 : (6 + 4 * pins.length)) * gridsize; } - } }); } } @@ -113,22 +119,27 @@ angular.module('icestudio') type: 'basic.constant', position: { x: 20 * gridsize, y: 4 * gridsize } }; - alertify.prompt(gettextCatalog.getString('Enter the constant blocks'), 'C', - function(evt, name) { - if (name) { - var names = name.replace(/ /g, '').split(','); - for (var n in names) { - if (names[n]) { - blockInstance.data = { - label: names[n], - local: false, - value: '' - }; - if (addCellCallback) { - addCellCallback(loadBasicConstant(blockInstance)); - } - blockInstance.position.x += 15 * gridsize; + utils.inputcheckboxprompt([ + gettextCatalog.getString('Enter the constant blocks'), + gettextCatalog.getString('Local parameter') + ], [ + 'C', + false + ], + function(evt, values) { + var labels = values[0].replace(/ /g, '').split(','); + var local = values[1]; + for (var l in labels) { + if (labels[l]) { + blockInstance.data = { + label: labels[l], + local: local, + value: '' + }; + if (addCellCallback) { + addCellCallback(loadBasicConstant(blockInstance)); } + blockInstance.position.x += 15 * gridsize; } } }); @@ -511,7 +522,7 @@ angular.module('icestudio') function(evt, values) { var label = values[0].replace(/ /g, ''); var virtual = values[1]; - // Validate input + // Validate values var portInfo = utils.parsePortLabel(label); if (portInfo) { evt.cancel = false; diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 79cb388b4..38150f25c 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -99,7 +99,8 @@ angular.module('icestudio') return false; } // Prevent different size connections - var tsize = cellViewT.model.attributes.data.pins.length; + var pins = cellViewT.model.attributes.data.pins; + var tsize = pins ? pins.length : 1; var lsize = linkView.model.attributes.size; if (tsize !== lsize) { warning(gettextCatalog.getString('Invalid connection: ' + lsize + ' → ' + tsize)); diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 818088283..4f2deb5aa 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -869,7 +869,7 @@ angular.module('icestudio') this.parsePortLabel = function(data) { // e.g: name[x:y] var match, ret = {}; - var pattern = /([A-Za-z0-9_]+)(\[([0-9]+):([0-9]+)\]){0,1}/g; + var pattern = /([A-Za-z0-9_]*)(\[([0-9]+):([0-9]+)\]){0,1}/g; match = pattern.exec(data); if (match && (match[0] === match.input)) { ret.input = match[0]; diff --git a/app/styles/design.css b/app/styles/design.css index d8dccf49a..f3cbba2d0 100644 --- a/app/styles/design.css +++ b/app/styles/design.css @@ -200,6 +200,7 @@ left: 5px; bottom: 5px; width: 82px; + font-size: 13px; pointer-events: auto; } diff --git a/app/styles/main.css b/app/styles/main.css index 2f7bdd540..dd51c137c 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -26,11 +26,11 @@ body { cursor: progress; } -.alertify-notifier .ajs-right { +.alertify-notifier.ajs-right { bottom: 45px; } -.alertify-notifier .ajs-bottom { +.alertify-notifier.ajs-bottom { bottom: 45px; } From 44fd91ced57c81344f8630cd182a7932d628f355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 10:21:37 +0100 Subject: [PATCH 19/35] Add bus detection in Code block creation --- app/scripts/services/blocks.service.js | 220 ++++++++++++++----------- app/scripts/services/graph.service.js | 2 +- 2 files changed, 125 insertions(+), 97 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 9567cb8fb..951477065 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -7,7 +7,7 @@ angular.module('icestudio') gettextCatalog) { var gridsize = 8; - this.newBasic = function(type, block, addCellCallback) { + this.newBasic = function(type, addCellCallback) { switch(type) { case 'basic.input': case 'basic.output': @@ -17,7 +17,7 @@ angular.module('icestudio') newBasicConstant(addCellCallback); break; case 'basic.code': - newBasicCode(block, addCellCallback); // block + newBasicCode(addCellCallback); break; case 'basic.info': newBasicInfo(addCellCallback); @@ -40,33 +40,33 @@ angular.module('icestudio') //-- New function newBasicIO(type, addCellCallback) { - var config = null; + var config; if (type === 'basic.input') { config = { type: type, _default: 'in', x: 4 }; } - else if (type === 'basic.output') { + else { // 'basic.output' config = { type: type, _default: 'out', x: 95 }; } - if (config) { - var blockInstance = { - id: null, - data: {}, - type: config.type, - position: { x: config.x * gridsize, y: 4 * gridsize } - }; - utils.inputcheckboxprompt([ - gettextCatalog.getString('Enter the ports'), - gettextCatalog.getString('Virtual port') - ], [ - config._default, - true - ], - function(evt, values) { - var labels = values[0].replace(/ /g, '').split(','); - var virtual = values[1]; - // Validate values - var portInfo, portInfos = []; - for (var l in labels) { + var blockInstance = { + id: null, + data: {}, + type: config.type, + position: { x: config.x * gridsize, y: 4 * gridsize } + }; + utils.inputcheckboxprompt([ + gettextCatalog.getString('Enter the ports'), + gettextCatalog.getString('Virtual port') + ], [ + config._default, + true + ], + function(evt, values) { + var labels = values[0].replace(/ /g, '').split(','); + var virtual = values[1]; + // Validate values + var portInfo, portInfos = []; + for (var l in labels) { + if (labels[l]) { portInfo = utils.parsePortLabel(labels[l]); if (portInfo) { evt.cancel = false; @@ -78,25 +78,25 @@ angular.module('icestudio') return; } } - // Create blocks - for (var p in portInfos) { - portInfo = portInfos[p]; - var pins = getPins(portInfo); - blockInstance.data = { - label: portInfo.input, - name: portInfo.name, - range: portInfo.rangestr ? portInfo.rangestr : '', - pins: pins, - virtual: virtual - }; - if (addCellCallback) { - addCellCallback(loadBasic(blockInstance)); - } - // Next block position - blockInstance.position.y += (virtual ? 10 : (6 + 4 * pins.length)) * gridsize; + } + // Create blocks + for (var p in portInfos) { + portInfo = portInfos[p]; + var pins = getPins(portInfo); + blockInstance.data = { + label: portInfo.input, + name: portInfo.name, + range: portInfo.rangestr ? portInfo.rangestr : '', + pins: pins, + virtual: virtual + }; + if (addCellCallback) { + addCellCallback(loadBasic(blockInstance)); } - }); - } + // Next block position + blockInstance.position.y += (virtual ? 10 : (6 + 4 * pins.length)) * gridsize; + } + }); } function getPins(portInfo) { @@ -145,19 +145,19 @@ angular.module('icestudio') }); } - function newBasicCode(block, addCellCallback) { + function newBasicCode(addCellCallback) { var blockInstance = { id: null, data: {}, type: 'basic.code', - position: { x: 4 * gridsize, y: 4 * gridsize } + position: { x: 31 * gridsize, y: 24 * gridsize } }; var defaultValues = [ 'a , b', 'c , d', '' ]; - if (block && block.data) { + /*if (block && block.data) { if (block.data.ports) { defaultValues[0] = block.data.ports.in.join(' , '); defaultValues[1] = block.data.ports.out.join(' , '); @@ -165,70 +165,98 @@ angular.module('icestudio') if (block.data.params) { 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') ], defaultValues, - 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]) { - blockInstance.data.ports.in.push(inPorts[i]); - } - } - for (var o in outPorts) { - if (outPorts[o]) { - blockInstance.data.ports.out.push(outPorts[o]); + function(evt, values) { + var inPorts = values[0].replace(/ /g, '').split(','); + var outPorts = values[1].replace(/ /g, '').split(','); + var params = values[2].replace(/ /g, '').split(','); + var allNames = []; + // Validate values + var i, inPortInfo, inPortInfos = []; + for (i in inPorts) { + if (inPorts[i]) { + inPortInfo = utils.parsePortLabel(inPorts[i]); + if (inPortInfo) { + evt.cancel = false; + inPortInfos.push(inPortInfo); } - } - for (var p in params) { - if (params[p]) { - blockInstance.data.params.push(params[p]); + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: inPorts[i] }), 'warning', 3); + return; } } - blockInstance.position.x = 31 * gridsize; - blockInstance.position.y = 24 * gridsize; - - 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 o, outPortInfo, outPortInfos = []; + for (o in outPorts) { + if (outPorts[o]) { + outPortInfo = utils.parsePortLabel(outPorts[o]); + if (outPortInfo) { + evt.cancel = false; + outPortInfos.push(outPortInfo); } - if (addCellCallback) { - addCellCallback(loadBasicCode(blockInstance)); + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong port name {{name}}', { name: outPorts[o] }), 'warning', 3); + return; } } - else { - evt.cancel = true; - alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); + } + // Create ports + blockInstance.data = { + code: '', + params: [], + ports: { in: [], out: [] } + }; + var pins; + for (i in inPortInfos) { + if (inPortInfos[i]) { + pins = getPins(inPortInfos[i]); + blockInstance.data.ports.in.push({ + label: inPortInfos[i].input, + name: inPortInfos[i].name, + size: pins.length + }); + allNames.push(inPortInfos[i].name); + } + } + for (o in outPortInfos) { + if (outPortInfos[o]) { + pins = getPins(outPortInfos[o]); + blockInstance.data.ports.out.push({ + label: outPortInfos[o].input, + name: outPortInfos[o].name, + size: pins.length + }); + allNames.push(outPortInfos[o].name); + } + } + for (var p in params) { + if (params[p]) { + blockInstance.data.params.push({ + label: params[p], + name: params[p] + }); + allNames.push(params[p]); + } + } + // Check duplicated attributes + var numNames = allNames.length; + if (numNames === $.unique(allNames).length) { + evt.cancel = false; + if (addCellCallback) { + addCellCallback(loadBasicCode(blockInstance)); } } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Duplicated block attributes'), 'warning', 3); + } }); } diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 38150f25c..0300895e4 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -424,7 +424,7 @@ angular.module('icestudio') } }; if (type.indexOf('basic.') !== -1) { - blocks.newBasic(type, block, addCellCallback); + blocks.newBasic(type, addCellCallback); } else { dependencies[type] = block; From 736032e1d0e61a7a70d3154ad10aa535cc7234a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 12:39:27 +0100 Subject: [PATCH 20/35] Render buses in Code block --- app/scripts/plugins/shapes/joint.shapes.js | 72 +++++++++++++++++----- app/scripts/services/blocks.service.js | 14 +++-- app/scripts/services/graph.service.js | 1 + 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index f3e0401ca..f5fa59c30 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -18,7 +18,7 @@ joint.shapes.ice = {}; joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({ markup: '', - portMarkup: '', + portMarkup: '', defaults: joint.util.deepSupplement({ type: 'ice.Model', @@ -587,24 +587,41 @@ joint.shapes.ice.CodeView = joint.shapes.ice.ModelView.extend({ this.$box.find('#' + editorLabel).append(this.model.attributes.data.code); this.$box.find('#' + contentLabel).append(this.model.attributes.data.code); }, - update: function () { - this.renderPorts(); + renderValue: function() { var id = sha1(this.model.get('id')).toString().substring(0, 6); var editorLabel = 'editor' + id; var editor = ace.edit(this.$box.find('#' + editorLabel)[0]); editor.setReadOnly(this.model.get('disabled')); + }, + update: function () { + this.renderPorts(); + this.renderValue(); joint.dia.ElementView.prototype.update.apply(this, arguments); }, updateBox: function() { + var port, wireWidth; var bbox = this.model.getBBox(); var state = this.model.attributes.state; + var data = this.model.attributes.data; + // Render ports width this.$('.port-wire').css('stroke-width', 2 * state.zoom); + for (var i in data.ports.in) { + port = data.ports.in[i]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); + } + for (var o in data.ports.out) { + port = data.ports.out[o]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); + } this.$box.css({ width: bbox.width * state.zoom, height: bbox.height * state.zoom, left: bbox.x * state.zoom + state.pan.x, top: bbox.y * state.zoom + state.pan.y }); + // 'border-width': 2 * state.zoom: problem int instead of float } }); @@ -765,22 +782,45 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ + initialize: function() { + joint.dia.LinkView.prototype.initialize.apply(this, arguments); + + var self = this; + setTimeout(function() { + var portName = self.model.attributes.source.port; + var dataSource = self.sourceView.model.attributes.data; + + // Initialize wire properties + var size; + if (dataSource.pins) { + // I/O port block + size = dataSource.pins.length; + } + else { + // Code/Generic block + var port; + for (var o in dataSource.ports.out) { + port = dataSource.ports.out[o]; + if (portName === port.name) { + size = port.size; + break; + } + } + } + if (size) { + self.model.attributes.size = size; // For wire size connection validation + self.$('.connection').css('stroke-width', (size > 1) ? 8 : 2); + self.model.label(0, {attrs: { text: { text: (size > 1) ? '' + size + '' : '' } } }); + self.model.bifurcationMarkup = self.model.bifurcationMarkup.replace(/<%= r %>/g, (size > 1) ? 8 : 4); + } + self.update(); + + }, 0); + + }, render: function() { joint.dia.LinkView.prototype.render.apply(this, arguments); // console.log('render'); - - var pins = this.sourceView.model.attributes.data.pins; - var wireDot = (pins && pins.length > 1) ? 8 : 4; - var wireWidth = (pins && pins.length > 1) ? 8 : 2; - var wireLabel = (pins && pins.length > 1) ? '' + pins.length + '' : ''; - - // Set up the wire - this.$('.connection').css('stroke-width', wireWidth); - this.model.attributes.size = pins.length; - this.model.label(0, {attrs: { text: { text: wireLabel } } }); - this.model.bifurcationMarkup = this.model.bifurcationMarkup.replace(/<%= r %>/g, wireDot); - this.update(); - return this; }, diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 951477065..ddfba178f 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -355,24 +355,26 @@ angular.module('icestudio') for (var i in instance.data.ports.in) { leftPorts.push({ - id: instance.data.ports.in[i], - label: instance.data.ports.in[i], + id: instance.data.ports.in[i].name, + label: instance.data.ports.in[i].label, + size: instance.data.ports.in[i].size, gridUnits: 32 }); } for (var o in instance.data.ports.out) { rightPorts.push({ - id: instance.data.ports.out[o], - label: instance.data.ports.out[o], + id: instance.data.ports.out[o].name, + label: instance.data.ports.out[o].label, + size: instance.data.ports.out[o].size, gridUnits: 32 }); } for (var p in instance.data.params) { topPorts.push({ - id: instance.data.params[p], - label: instance.data.params[p], + id: instance.data.params[p].name, + label: instance.data.params[p].label, gridUnits: 48 }); } diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 0300895e4..eec5930da 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -99,6 +99,7 @@ angular.module('icestudio') return false; } // Prevent different size connections + // TODO: block port target var pins = cellViewT.model.attributes.data.pins; var tsize = pins ? pins.length : 1; var lsize = linkView.model.attributes.size; From 0b40f373602f1ac17019b13ef4d78d727152a93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 13:01:12 +0100 Subject: [PATCH 21/35] Check wire size connections for Code block port target --- app/scripts/services/graph.service.js | 36 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index eec5930da..b70ab341c 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -98,15 +98,6 @@ angular.module('icestudio') } return false; } - // Prevent different size connections - // TODO: block port target - var pins = cellViewT.model.attributes.data.pins; - var tsize = pins ? pins.length : 1; - var lsize = linkView.model.attributes.size; - if (tsize !== lsize) { - warning(gettextCatalog.getString('Invalid connection: ' + lsize + ' → ' + tsize)); - return false; - } // Ensure right -> left connections if (magnetS.getAttribute('pos') === 'right') { if (magnetT.getAttribute('pos') !== 'left') { @@ -121,8 +112,9 @@ angular.module('icestudio') return false; } } + var i; var links = graph.getLinks(); - for (var i in links) { + for (i in links) { var linkIView = links[i].findView(paper); if (linkView === linkIView) { //Skip the wire the user is drawing @@ -158,6 +150,30 @@ angular.module('icestudio') } return ret; } + // Prevent different size connections + var tsize; + var lsize = linkView.model.attributes.size; + var tdata = cellViewT.model.attributes.data; + var portName = magnetT.getAttribute('port'); + if (tdata.pins) { + // I/O port block + tsize = tdata.pins ? tdata.pins.length : 1; + } + else { + // Code/Generic block + var port; + for (i in tdata.ports.in) { + port = tdata.ports.in[i]; + if (portName === port.name) { + tsize = port.size; + break; + } + } + } + if (tsize !== lsize) { + warning(gettextCatalog.getString('Invalid connection: ' + lsize + ' → ' + tsize)); + return false; + } // Prevent loop links return magnetS !== magnetT; } From 43df5184524a2303d83fe787b9eadf08d64f56ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 13:28:27 +0100 Subject: [PATCH 22/35] Validate Constant block names --- app/scripts/services/blocks.service.js | 57 ++++++++++++++++++++------ app/scripts/services/utils.service.js | 15 ++++++- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index ddfba178f..ae57cec92 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -129,19 +129,35 @@ angular.module('icestudio') function(evt, values) { var labels = values[0].replace(/ /g, '').split(','); var local = values[1]; + // Validate values + var paramInfo, paramInfos = []; for (var l in labels) { if (labels[l]) { - blockInstance.data = { - label: labels[l], - local: local, - value: '' - }; - if (addCellCallback) { - addCellCallback(loadBasicConstant(blockInstance)); + paramInfo = utils.parseParamLabel(labels[l]); + if (paramInfo) { + evt.cancel = false; + paramInfos.push(paramInfo); + } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong parameter name {{name}}', { name: labels[l] }), 'warning', 3); + return; } - blockInstance.position.x += 15 * gridsize; } } + // Create blocks + for (var p in paramInfos) { + paramInfo = paramInfos[p]; + blockInstance.data = { + label: paramInfo.input, + local: local, + value: '' + }; + if (addCellCallback) { + addCellCallback(loadBasicConstant(blockInstance)); + } + blockInstance.position.x += 15 * gridsize; + } }); } @@ -207,6 +223,21 @@ angular.module('icestudio') } } } + var p, paramInfo, paramInfos = []; + for (p in params) { + if (params[p]) { + paramInfo = utils.parseParamLabel(params[p]); + if (paramInfo) { + evt.cancel = false; + paramInfos.push(paramInfo); + } + else { + evt.cancel = true; + alertify.notify(gettextCatalog.getString('Wrong parameter name {{name}}', { name: params[p] }), 'warning', 3); + return; + } + } + } // Create ports blockInstance.data = { code: '', @@ -236,13 +267,13 @@ angular.module('icestudio') allNames.push(outPortInfos[o].name); } } - for (var p in params) { - if (params[p]) { + for (p in paramInfos) { + if (paramInfos[p]) { blockInstance.data.params.push({ - label: params[p], - name: params[p] + label: paramInfos[p].input, + name: paramInfos[p].name }); - allNames.push(params[p]); + allNames.push(paramInfos[p].name); } } // Check duplicated attributes diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index 4f2deb5aa..eff998b19 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -869,7 +869,7 @@ angular.module('icestudio') this.parsePortLabel = function(data) { // e.g: name[x:y] var match, ret = {}; - var pattern = /([A-Za-z0-9_]*)(\[([0-9]+):([0-9]+)\]){0,1}/g; + var pattern = /([A-Za-z_]+[A-Za-z_0-9]*){0,1}(\[([0-9]+):([0-9]+)\]){0,1}/g; match = pattern.exec(data); if (match && (match[0] === match.input)) { ret.input = match[0]; @@ -888,4 +888,17 @@ angular.module('icestudio') return null; }; + this.parseParamLabel = function(data) { + // e.g: name + var match, ret = {}; + var pattern = /[A-Za-z_]+[A-Za-z_0-9]*/g; + match = pattern.exec(data); + if (match && (match[0] === match.input)) { + ret.input = match[0]; + ret.name = match[0]; + return ret; + } + return null; + }; + }); From f03dd0fce4d8466f23f0e37ff4ea4891fb2e32cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 14:42:28 +0100 Subject: [PATCH 23/35] Edit multi-Code blocks --- app/scripts/services/blocks.service.js | 103 ++++++++++++++++++------- app/scripts/services/graph.service.js | 56 +++++--------- 2 files changed, 95 insertions(+), 64 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index ae57cec92..3d45f265a 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -7,7 +7,19 @@ angular.module('icestudio') gettextCatalog) { var gridsize = 8; - this.newBasic = function(type, addCellCallback) { + this.newBasic = newBasic; + this.newGeneric = newGeneric; + + this.loadBasic = loadBasic; + this.loadGeneric = loadGeneric; + this.loadWire = loadWire; + + this.editBasic = editBasic; + + + //-- New + + function newBasic(type, addCellCallback) { switch(type) { case 'basic.input': case 'basic.output': @@ -25,19 +37,7 @@ angular.module('icestudio') default: break; } - }; - this.newGeneric = newGeneric; - - this.loadBasic = loadBasic; - this.loadGeneric = loadGeneric; - this.loadWire = loadWire; - - - this.editBasicIO = editBasicIO; - this.editBasicConstant = editBasicConstant; - - - //-- New + } function newBasicIO(type, addCellCallback) { var config; @@ -161,10 +161,14 @@ angular.module('icestudio') }); } - function newBasicCode(addCellCallback) { + function newBasicCode(addCellCallback, block) { var blockInstance = { id: null, - data: {}, + data: { + code: '', + params: [], + ports: { in: [], out: [] } + }, type: 'basic.code', position: { x: 31 * gridsize, y: 24 * gridsize } }; @@ -173,15 +177,29 @@ angular.module('icestudio') 'c , d', '' ]; - /*if (block && block.data) { + if (block) { + blockInstance = block; + var index; if (block.data.ports) { - defaultValues[0] = block.data.ports.in.join(' , '); - defaultValues[1] = block.data.ports.out.join(' , '); + var inPorts = []; + for (index in block.data.ports.in) { + inPorts.push(block.data.ports.in[index].label); + } + defaultValues[0] = inPorts.join(' , '); + var outPorts = []; + for (index in block.data.ports.out) { + outPorts.push(block.data.ports.out[index].label); + } + defaultValues[1] = outPorts.join(' , '); } if (block.data.params) { - defaultValues[2] = block.data.params.join(' , '); + var params = []; + for (index in block.data.params) { + params.push(block.data.params[index].label); + } + defaultValues[2] = params.join(' , '); } - }*/ + } utils.multiprompt( [ gettextCatalog.getString('Enter the input ports'), gettextCatalog.getString('Enter the output ports'), @@ -239,12 +257,8 @@ angular.module('icestudio') } } // Create ports - blockInstance.data = { - code: '', - params: [], - ports: { in: [], out: [] } - }; var pins; + blockInstance.data.ports.in = []; for (i in inPortInfos) { if (inPortInfos[i]) { pins = getPins(inPortInfos[i]); @@ -256,6 +270,7 @@ angular.module('icestudio') allNames.push(inPortInfos[i].name); } } + blockInstance.data.ports.out = []; for (o in outPortInfos) { if (outPortInfos[o]) { pins = getPins(outPortInfos[o]); @@ -267,6 +282,7 @@ angular.module('icestudio') allNames.push(outPortInfos[o].name); } } + blockInstance.data.params = []; for (p in paramInfos) { if (paramInfos[p]) { blockInstance.data.params.push({ @@ -280,6 +296,7 @@ angular.module('icestudio') var numNames = allNames.length; if (numNames === $.unique(allNames).length) { evt.cancel = false; + // Create block if (addCellCallback) { addCellCallback(loadBasicCode(blockInstance)); } @@ -571,6 +588,23 @@ angular.module('icestudio') //-- Edit + function editBasic(type, cellView, addCellCallback) { + switch(type) { + case 'basic.input': + case 'basic.output': + editBasicIO(cellView, addCellCallback); + break; + case 'basic.constant': + editBasicConstant(cellView, addCellCallback); + break; + case 'basic.code': + editBasicCode(cellView, addCellCallback); + break; + default: + break; + } + } + function editBasicIO(cellView, addCellCallback) { var block = cellView.model.attributes; utils.inputcheckboxprompt([ @@ -655,4 +689,21 @@ angular.module('icestudio') }); } + function editBasicCode(cellView, addCellCallback) { + var block = cellView.model.attributes; + var blockInstance = { + id: null, + data: block.data, + type: 'basic.code', + position: block.position + }; + newBasicCode(function(cell) { + if (addCellCallback) { + addCellCallback(cell); + cellView.model.remove(); + alertify.success(gettextCatalog.getString('Block updated')); + } + }, blockInstance); + } + }); diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index b70ab341c..c850f35fc 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -300,47 +300,29 @@ angular.module('icestudio') }); paper.on('cell:pointerdblclick', function(cellView/*, evt, x, y*/) { - var data = cellView.model.attributes; - // TODO: move to blocks.service edit function - if (data.blockType === 'basic.input' || - data.blockType === 'basic.output') { + var type = cellView.model.attributes.blockType; + if (type.indexOf('basic.') !== -1) { if (paper.options.enabled) { - blocks.editBasicIO(cellView, function(cell) { + if (type === 'basic.code') { + var content = self.getContent(cellView.model.id); + cellView.model.attributes.data.code = content; + } + blocks.editBasic(type, cellView, function(cell) { addCell(cell); }); } } - else if (data.blockType === 'basic.constant') { - if (paper.options.enabled) { - blocks.editBasicConstant(cellView); - } - } - else if (data.blockType === 'basic.code') { - if (paper.options.enabled) { - var block = { - data: { - code: self.getContent(cellView.model.id), - params: data.data.params, - ports: data.data.ports - }, - position: cellView.model.attributes.position - }; - self.createBlock('basic.code', block, function() { - cellView.model.remove(); - }); - } - } - else if (data.type !== 'ice.Wire' && data.type !== 'ice.Info') { - self.breadcrumbs.push({ name: data.blockType }); + else { + self.breadcrumbs.push({ name: type }); utils.rootScopeSafeApply(); zIndex = 1; if (self.breadcrumbs.length === 2) { $rootScope.$broadcast('updateProject', function() { - self.loadDesign(dependencies[data.blockType].design, true); + self.loadDesign(dependencies[type].design, true); }); } else { - self.loadDesign(dependencies[data.blockType].design, true); + self.loadDesign(dependencies[type].design, true); } } }); @@ -433,19 +415,17 @@ angular.module('icestudio') } }; - this.createBlock = function(type, block, callback) { - var addCellCallback = function(cell) { - addCell(cell); - if (callback) { - callback(); - } - }; + this.createBlock = function(type, block) { if (type.indexOf('basic.') !== -1) { - blocks.newBasic(type, addCellCallback); + blocks.newBasic(type, function(cell) { + addCell(cell); + }); } else { dependencies[type] = block; - blocks.newGeneric(type, block, addCellCallback); + blocks.newGeneric(type, block, function(cell) { + addCell(cell); + }); } }; From 46ffcf290c78a948752c2d2657e8499540f36691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 16:19:16 +0100 Subject: [PATCH 24/35] Add code bus ports in the compiler --- app/scripts/plugins/shapes/joint.shapes.js | 2 +- app/scripts/services/blocks.service.js | 2 + app/scripts/services/compiler.service.js | 9 +- app/scripts/services/graph.service.js | 2 + demo/constant-code-bus.ice | 125 +++++++++++++++++++++ 5 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 demo/constant-code-bus.ice diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index f5fa59c30..0598a58d8 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -796,7 +796,7 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // I/O port block size = dataSource.pins.length; } - else { + else if (dataSource.ports) { // Code/Generic block var port; for (var o in dataSource.ports.out) { diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 3d45f265a..e0cebbe7a 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -265,6 +265,7 @@ angular.module('icestudio') blockInstance.data.ports.in.push({ label: inPortInfos[i].input, name: inPortInfos[i].name, + range: inPortInfos[i].rangestr, size: pins.length }); allNames.push(inPortInfos[i].name); @@ -277,6 +278,7 @@ angular.module('icestudio') blockInstance.data.ports.out.push({ label: outPortInfos[o].input, name: outPortInfos[o].name, + range: outPortInfos[o].rangestr, size: pins.length }); allNames.push(outPortInfos[o].name); diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 3ec7abf92..af0d01b3a 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -61,13 +61,8 @@ angular.module('icestudio') 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 ? data.params[p].value : '0')); } - else { - // Code block - params.push(' parameter ' + data.params[p] + ' = 0'); - } } if (params.length > 0) { @@ -81,11 +76,11 @@ angular.module('icestudio') var ports = []; for (var i in data.ports.in) { var _in = data.ports.in[i]; - ports.push(' input ' + _in.range + (_in.range ? ' ' : '') + _in.name); + ports.push(' input ' + (_in.range ? (_in.range + ' ') : '') + _in.name); } for (var o in data.ports.out) { var _out = data.ports.out[o]; - ports.push(' output ' + _out.range + (_out.range ? ' ' : '') + _out.name); + ports.push(' output ' + (_out.range ? (_out.range + ' ') : '') + _out.name); } if (ports.length > 0) { diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index c850f35fc..5d84ce789 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -170,6 +170,8 @@ angular.module('icestudio') } } } + tsize = tsize || 1; + lsize = lsize || 1; if (tsize !== lsize) { warning(gettextCatalog.getString('Invalid connection: ' + lsize + ' → ' + tsize)); return false; diff --git a/demo/constant-code-bus.ice b/demo/constant-code-bus.ice new file mode 100644 index 000000000..1742c5850 --- /dev/null +++ b/demo/constant-code-bus.ice @@ -0,0 +1,125 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "04b316b2-452b-4e2f-bdc6-26d1a204c675", + "type": "basic.constant", + "data": { + "label": "C", + "local": false, + "value": "5" + }, + "position": { + "x": 232, + "y": 32 + } + }, + { + "id": "3d5412cf-96ac-4429-9a22-01d5095f0981", + "type": "basic.code", + "data": { + "code": "// Assign constant parameter\n\nassign out = value;", + "params": [ + { + "label": "value", + "name": "value" + } + ], + "ports": { + "in": [], + "out": [ + { + "label": "out[3:0]", + "name": "out", + "range": "[3:0]", + "size": 4 + } + ] + } + }, + "position": { + "x": 88, + "y": 176 + } + }, + { + "id": "6d4f9130-37c5-48d2-b481-b803d818c3c7", + "type": "basic.output", + "data": { + "label": "leds[3:0]", + "name": "leds", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "LED3", + "value": "98" + }, + { + "index": "2", + "name": "LED2", + "value": "97" + }, + { + "index": "1", + "name": "LED1", + "value": "96" + }, + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 624, + "y": 224 + } + } + ], + "wires": [ + { + "source": { + "block": "04b316b2-452b-4e2f-bdc6-26d1a204c675", + "port": "constant-out" + }, + "target": { + "block": "3d5412cf-96ac-4429-9a22-01d5095f0981", + "port": "value" + } + }, + { + "source": { + "block": "3d5412cf-96ac-4429-9a22-01d5095f0981", + "port": "out" + }, + "target": { + "block": "6d4f9130-37c5-48d2-b481-b803d818c3c7", + "port": "in" + }, + "size": 4 + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": -7, + "y": 13 + }, + "zoom": 1 + } + } +} \ No newline at end of file From 52bc416b0e383edbf7998b0dc43662fd1f2b7ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 17:35:37 +0100 Subject: [PATCH 25/35] Minor compiler improvement. Bit blocks updated --- app/resources/blocks/bit/0.ice | 32 ++++++++++++----- app/resources/blocks/bit/1.ice | 28 +++++++++++---- app/scripts/plugins/shapes/joint.shapes.js | 5 ++- app/scripts/services/compiler.service.js | 34 +++++++++---------- ...-input-output.ice => input-output-bus.ice} | 2 +- 5 files changed, 65 insertions(+), 36 deletions(-) rename demo/{bus-input-output.ice => input-output-bus.ice} (99%) diff --git a/app/resources/blocks/bit/0.ice b/app/resources/blocks/bit/0.ice index 12afc6a86..ae9f54780 100644 --- a/app/resources/blocks/bit/0.ice +++ b/app/resources/blocks/bit/0.ice @@ -12,16 +12,21 @@ "graph": { "blocks": [ { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "id": "1a748af9-e00b-40ae-a3d9-030da7397247", "type": "basic.code", "data": { "code": "// Bit 0\n\nassign v = 1'b0;", "ports": { "in": [], "out": [ - "v" + { + "label": "v", + "name": "v", + "size": 1 + } ] - } + }, + "params": [] }, "position": { "x": 96, @@ -29,10 +34,19 @@ } }, { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "id": "355855e8-69a6-472a-9212-dd5c3bece567", "type": "basic.output", "data": { - "label": "" + "label": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true }, "position": { "x": 608, @@ -43,11 +57,11 @@ "wires": [ { "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "block": "1a748af9-e00b-40ae-a3d9-030da7397247", "port": "v" }, "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "block": "355855e8-69a6-472a-9212-dd5c3bece567", "port": "in" } } @@ -59,7 +73,7 @@ "x": 0, "y": 0 }, - "zoom": 1 + "zoom": 1.0000000353093697 } } -} +} \ No newline at end of file diff --git a/app/resources/blocks/bit/1.ice b/app/resources/blocks/bit/1.ice index ed3410f62..4ae355e75 100644 --- a/app/resources/blocks/bit/1.ice +++ b/app/resources/blocks/bit/1.ice @@ -12,16 +12,21 @@ "graph": { "blocks": [ { - "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "id": "12170bab-1206-41e6-9b74-da1c86af6019", "type": "basic.code", "data": { "code": "// Bit 1\n\nassign v = 1'b1;", "ports": { "in": [], "out": [ - "v" + { + "label": "v", + "name": "v", + "size": 1 + } ] - } + }, + "params": [] }, "position": { "x": 96, @@ -29,10 +34,19 @@ } }, { - "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "id": "34f97cd9-8ec6-4ae3-a19e-606a977e1517", "type": "basic.output", "data": { - "label": "" + "label": "", + "range": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true }, "position": { "x": 608, @@ -43,11 +57,11 @@ "wires": [ { "source": { - "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", + "block": "12170bab-1206-41e6-9b74-da1c86af6019", "port": "v" }, "target": { - "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", + "block": "34f97cd9-8ec6-4ae3-a19e-606a977e1517", "port": "in" } } diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 0598a58d8..7bab4f9d9 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -406,6 +406,9 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ $(fpgaPortId).removeClass('hidden'); if (this.pins) { this.model.attributes.size.height = 32 + 32 * this.pins.length; + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + this.$box.css({ top: bbox.y * state.zoom + state.pan.y }); } } }, @@ -810,7 +813,7 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ if (size) { self.model.attributes.size = size; // For wire size connection validation self.$('.connection').css('stroke-width', (size > 1) ? 8 : 2); - self.model.label(0, {attrs: { text: { text: (size > 1) ? '' + size + '' : '' } } }); + self.model.label(0, {attrs: { text: { text: (size > 1) ? '|' + size + '|' : '' } } }); self.model.bifurcationMarkup = self.model.bifurcationMarkup.replace(/<%= r %>/g, (size > 1) ? 8 : 4); } self.update(); diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index af0d01b3a..828ef6f88 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -39,13 +39,13 @@ angular.module('icestudio') return header; } - function digestId(id, force) { - if (id.indexOf('-') !== -1 || force) { - return 'v' + nodeSha1(id).toString().substring(0, 6); - } - else { - return id.replace('.', '_'); - } + function digestId(id) { + if (id.indexOf('-') !== -1) { + return 'v' + nodeSha1(id).toString().substring(0, 6); + } + else { + return id.replace('.', '_'); + } } function module(data) { @@ -177,8 +177,8 @@ angular.module('icestudio') } else { // Wires - var range = wire.size ? '[0:' + (wire.size-1) +'] ' : ' '; - connections.wire.push('wire ' + range + 'w' + w + ';'); + var range = wire.size ? ' [0:' + (wire.size-1) +'] ' : ' '; + connections.wire.push('wire' + range + 'w' + w + ';'); } // Assignations for (i in graph.blocks) { @@ -243,11 +243,13 @@ angular.module('icestudio') // Header - var id = digestId(block.type, true); + instance += name; if (block.type === 'basic.code') { - id += '_' + digestId(block.id); + instance += '_' + digestId(block.id); + } + else { + instance += '_' + digestId(block.type); } - instance += name + '_' + digestId(id); //-- Parameters @@ -327,10 +329,6 @@ angular.module('icestudio') var graph = project.design.graph; var deps = project.design.deps; - // Scape dot in name - - name = digestId(name); - // Main module if (name) { @@ -346,7 +344,7 @@ angular.module('icestudio') // Dependencies modules for (var d in deps) { - code += verilogCompiler(name + '_' + digestId(d, true), deps[d]); + code += verilogCompiler(name + '_' + digestId(d), deps[d]); } // Code modules @@ -356,7 +354,7 @@ angular.module('icestudio') if (block) { if (block.type === 'basic.code') { data = { - name: name + '_' + digestId(block.type, true) + '_' + digestId(block.id), + name: name + '_' + digestId(block.id), params: block.data.params, ports: block.data.ports, content: block.data.code diff --git a/demo/bus-input-output.ice b/demo/input-output-bus.ice similarity index 99% rename from demo/bus-input-output.ice rename to demo/input-output-bus.ice index c8e17d9ae..b20c6243f 100644 --- a/demo/bus-input-output.ice +++ b/demo/input-output-bus.ice @@ -139,4 +139,4 @@ "zoom": 1 } } -} \ No newline at end of file +} From b37702950b934d518b67c9ef3b681c667a6e0b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 21 Dec 2016 18:20:50 +0100 Subject: [PATCH 26/35] Render buses in Generic blocks --- app/scripts/plugins/shapes/joint.shapes.js | 44 ++++++++++++++++++---- app/scripts/services/blocks.service.js | 6 ++- app/scripts/services/graph.service.js | 9 +++-- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 7bab4f9d9..11da08c4f 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -289,6 +289,34 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ this.$box.find('img').addClass('hidden'); this.$box.find('label').removeClass('hidden'); } + }, + updateBox: function() { + var port, wireWidth; + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + var leftPorts = this.model.attributes.leftPorts; + var rightPorts = this.model.attributes.rightPorts; + + // Render ports width + this.$('.port-wire').css('stroke-width', 2 * state.zoom); + for (var i in leftPorts) { + port = leftPorts[i]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); + } + for (var o in rightPorts) { + port = rightPorts[o]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); + } + + this.$box.css({ + left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), + top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), + width: bbox.width, + height: bbox.height, + transform: 'scale(' + state.zoom + ')' + }); } }); @@ -406,9 +434,10 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ $(fpgaPortId).removeClass('hidden'); if (this.pins) { this.model.attributes.size.height = 32 + 32 * this.pins.length; - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - this.$box.css({ top: bbox.y * state.zoom + state.pan.y }); + // TODO: move block and wire + //var bbox = this.model.getBBox(); + //var state = this.model.attributes.state; + //this.$box.css({ top: bbox.y * state.zoom + state.pan.y }); } } }, @@ -792,6 +821,7 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ setTimeout(function() { var portName = self.model.attributes.source.port; var dataSource = self.sourceView.model.attributes.data; + var rightPorts = self.sourceView.model.attributes.rightPorts; // Initialize wire properties var size; @@ -799,12 +829,12 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // I/O port block size = dataSource.pins.length; } - else if (dataSource.ports) { + else { // Code/Generic block var port; - for (var o in dataSource.ports.out) { - port = dataSource.ports.out[o]; - if (portName === port.name) { + for (var o in rightPorts) { + port = rightPorts[o]; + if (portName === port.id) { size = port.size; break; } diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index e0cebbe7a..3b9a88cf9 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -466,13 +466,15 @@ angular.module('icestudio') if (item.type === 'basic.input') { leftPorts.push({ id: item.id, - label: item.data.label + label: item.data.label, + size: block.design.graph.blocks[i].data.pins.length }); } else if (item.type === 'basic.output') { rightPorts.push({ id: item.id, - label: item.data.label + label: item.data.label, + size: block.design.graph.blocks[i].data.pins.length }); } else if (item.type === 'basic.constant') { diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 5d84ce789..5d27acb09 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -154,7 +154,8 @@ angular.module('icestudio') var tsize; var lsize = linkView.model.attributes.size; var tdata = cellViewT.model.attributes.data; - var portName = magnetT.getAttribute('port'); + var tLeftPorts = cellViewT.model.attributes.leftPorts; + var portId = magnetT.getAttribute('port'); if (tdata.pins) { // I/O port block tsize = tdata.pins ? tdata.pins.length : 1; @@ -162,9 +163,9 @@ angular.module('icestudio') else { // Code/Generic block var port; - for (i in tdata.ports.in) { - port = tdata.ports.in[i]; - if (portName === port.name) { + for (i in tLeftPorts) { + port = tLeftPorts[i]; + if (portId === port.id) { tsize = port.size; break; } From 4dc723b6ab51dff80477144ca4b081a3e177634b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 07:40:57 +0100 Subject: [PATCH 27/35] Update indentation in joint.shapes --- app/scripts/plugins/shapes/joint.shapes.js | 825 +++++++++++---------- demo/constant-code-bus.ice | 2 +- 2 files changed, 424 insertions(+), 403 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 11da08c4f..b6a79406c 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -183,76 +183,76 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({ joint.shapes.ice.ModelView = joint.dia.ElementView.extend({ - template: '', + template: '', - initialize: function() { - _.bindAll(this, 'updateBox'); - joint.dia.ElementView.prototype.initialize.apply(this, arguments); - - this.$box = $(joint.util.template(this.template)()); + initialize: function() { + _.bindAll(this, 'updateBox'); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); - this.model.on('change', this.updateBox, this); - this.model.on('remove', this.removeBox, this); + this.$box = $(joint.util.template(this.template)()); - this.updateBox(); - - 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; - }, + this.model.on('change', this.updateBox, this); + this.model.on('remove', this.removeBox, this); - renderPorts: function() { - 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); + this.updateBox(); - _.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 === '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); - }); - }, + this.listenTo(this.model, 'process:ports', this.update); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); + }, - update: function() { - this.renderPorts(); - joint.dia.ElementView.prototype.update.apply(this, arguments); - }, + render: function() { + joint.dia.ElementView.prototype.render.apply(this, arguments); + this.paper.$el.append(this.$box); + this.updateBox(); + return this; + }, - updateBox: function() { - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var pins = this.model.attributes.data.pins; - var wireWidth = (pins && pins.length > 1) ? 8 : 2; + renderPorts: function() { + 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 === '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 === '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); + }); + }, - this.$('.port-wire').css('stroke-width', wireWidth * state.zoom); + update: function() { + this.renderPorts(); + joint.dia.ElementView.prototype.update.apply(this, arguments); + }, - this.$box.css({ - left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), - top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), - width: bbox.width, - height: bbox.height, - transform: 'scale(' + state.zoom + ')' - }); - }, + updateBox: function() { + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + var pins = this.model.attributes.data.pins; + var wireWidth = (pins && pins.length > 1) ? 8 : 2; + + this.$('.port-wire').css('stroke-width', wireWidth * state.zoom); + + this.$box.css({ + left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), + top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), + width: bbox.width, + height: bbox.height, + transform: 'scale(' + state.zoom + ')' + }); + }, - removeBox: function(/*evt*/) { - this.$box.remove(); - } + removeBox: function(/*evt*/) { + this.$box.remove(); + } }); @@ -266,58 +266,59 @@ joint.shapes.ice.Generic = joint.shapes.ice.Model.extend({ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ - template: '\ -
\ - \ - \ -
\ - ', + template: '\ +
\ + \ + \ +
\ + ', - initialize: function() { - joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); + initialize: function() { + joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); - var image = this.model.get('image'); - var name = this.model.get('label'); + var image = this.model.get('image'); + var name = this.model.get('label'); - if (image) { - this.$box.find('img').attr('src', 'data:image/svg+xml,' + image); - this.$box.find('img').removeClass('hidden'); - this.$box.find('label').addClass('hidden'); - } - else { - this.$box.find('label').html(name); - this.$box.find('img').addClass('hidden'); - this.$box.find('label').removeClass('hidden'); - } - }, - updateBox: function() { - var port, wireWidth; - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var leftPorts = this.model.attributes.leftPorts; - var rightPorts = this.model.attributes.rightPorts; - - // Render ports width - this.$('.port-wire').css('stroke-width', 2 * state.zoom); - for (var i in leftPorts) { - port = leftPorts[i]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); - } - for (var o in rightPorts) { - port = rightPorts[o]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); - } + if (image) { + this.$box.find('img').attr('src', 'data:image/svg+xml,' + image); + this.$box.find('img').removeClass('hidden'); + this.$box.find('label').addClass('hidden'); + } + else { + this.$box.find('label').html(name); + this.$box.find('img').addClass('hidden'); + this.$box.find('label').removeClass('hidden'); + } + }, - this.$box.css({ - left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), - top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), - width: bbox.width, - height: bbox.height, - transform: 'scale(' + state.zoom + ')' - }); + updateBox: function() { + var port, wireWidth; + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + var leftPorts = this.model.attributes.leftPorts; + var rightPorts = this.model.attributes.rightPorts; + + // Render ports width + this.$('.port-wire').css('stroke-width', 2 * state.zoom); + for (var i in leftPorts) { + port = leftPorts[i]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); + } + for (var o in rightPorts) { + port = rightPorts[o]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); } + + this.$box.css({ + left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), + top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), + width: bbox.width, + height: bbox.height, + transform: 'scale(' + state.zoom + ')' + }); + } }); // I/O blocks @@ -357,127 +358,136 @@ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ - initialize: function() { - joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); + initialize: function() { + joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); + + this.id = sha1(this.model.get('id')).toString().substring(0, 6); + var virtualPortId = 'virtualPort' + this.id; + var fpgaPortId = 'fpgaPort' + this.id; + var comboId = 'combo' + this.id; + var virtual = this.model.get('data').virtual || this.model.get('disabled'); + + var selectCode = ''; + var selectScript = ''; + this.pins = this.model.attributes.data.pins; + + if (this.pins) { + for (var i in this.pins) { + //selectCode += '

' + this.pins[i].index + '

'; + selectCode +=''; + + selectScript += '$("#' + comboId + this.pins[i].index + '").select2('; + selectScript += '{placeholder: "", allowClear: true, dropdownCssClass: "bigdrop"});'; + } + } + + this.$box = $(joint.util.template( + '\ +
\ + \ +
\ +
\ + \ +
' + selectCode + '
\ + \ +
\ + ' + )()); + + // Prevent paper from handling pointerdown. + var comboSelector = this.$box.find('.select2'); + comboSelector.on('mousedown click', function(evt) { evt.stopPropagation(); }); + comboSelector.on('change', _.bind(function(evt) { + var target = $(evt.target); + var i = target.attr('i'); + var name = target.find('option:selected').text(); + var value = target.val(); + this.model.attributes.data.pins[i].name = name; + this.model.attributes.data.pins[i].value = value; + //comboSelector.find('.select2-selection').css('font-size', this.computeFontSize(name)); + }, this)); + + // Render data + if (!this.model.get('disabled')) { + this.renderChoices(); + this.renderValue(); + } + }, - this.id = sha1(this.model.get('id')).toString().substring(0, 6); - var virtualPortId = 'virtualPort' + this.id; - var fpgaPortId = 'fpgaPort' + this.id; - var comboId = 'combo' + this.id; - var virtual = this.model.get('data').virtual || this.model.get('disabled'); + renderBlock: function() { + var virtualPortId = '#virtualPort' + this.id; + var fpgaPortId = '#fpgaPort' + this.id; + var name = this.model.get('data').label; + var virtual = this.model.get('data').virtual || this.model.get('disabled'); - var selectCode = ''; - var selectScript = ''; - this.pins = this.model.attributes.data.pins; + this.$box.find('label').text(name ? name : ' '); + // Virtual -> FPGA I/O + // FPGA I/O -> Virtual + + if (virtual) { + // Virtual port (green) + $(fpgaPortId).addClass('hidden'); + $(virtualPortId).removeClass('hidden'); + this.model.attributes.size.height = 64; + } + else { + // FPGA I/O port (yellow) + $(virtualPortId).addClass('hidden'); + $(fpgaPortId).removeClass('hidden'); if (this.pins) { - for (var i in this.pins) { - //selectCode += '

' + this.pins[i].index + '

'; - selectCode +=''; - - selectScript += '$("#' + comboId + this.pins[i].index + '").select2('; - selectScript += '{placeholder: "", allowClear: true, dropdownCssClass: "bigdrop"});'; - } + this.model.attributes.size.height = 32 + 32 * this.pins.length; + // TODO: move block and wire + //var bbox = this.model.getBBox(); + //var state = this.model.attributes.state; + //this.$box.css({ top: bbox.y * state.zoom + state.pan.y }); } + } + }, - this.$box = $(joint.util.template( - '\ -
\ - \ -
\ -
\ - \ -
' + selectCode + '
\ - \ -
\ - ' - )()); - - // Prevent paper from handling pointerdown. - var comboSelector = this.$box.find('.select2'); - comboSelector.on('mousedown click', function(evt) { evt.stopPropagation(); }); - comboSelector.on('change', _.bind(function(evt) { - var target = $(evt.target); - var i = target.attr('i'); - var name = target.find('option:selected').text(); - var value = target.val(); - this.model.attributes.data.pins[i].name = name; - this.model.attributes.data.pins[i].value = value; - //comboSelector.find('.select2-selection').css('font-size', this.computeFontSize(name)); - }, this)); - - // Render data - if (!this.model.get('disabled')) { - this.renderChoices(); - this.renderValue(); - } - }, - renderBlock: function() { - var virtualPortId = '#virtualPort' + this.id; - var fpgaPortId = '#fpgaPort' + this.id; - var name = this.model.get('data').label; - var virtual = this.model.get('data').virtual || this.model.get('disabled'); - - this.$box.find('label').text(name ? name : ' '); - - if (virtual) { - // Virtual port (green) - $(fpgaPortId).addClass('hidden'); - $(virtualPortId).removeClass('hidden'); - this.model.attributes.size.height = 64; + renderChoices: function() { + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); } - else { - // FPGA I/O port (yellow) - $(virtualPortId).addClass('hidden'); - $(fpgaPortId).removeClass('hidden'); - if (this.pins) { - this.model.attributes.size.height = 32 + 32 * this.pins.length; - // TODO: move block and wire - //var bbox = this.model.getBBox(); - //var state = this.model.attributes.state; - //this.$box.css({ top: bbox.y * state.zoom + state.pan.y }); - } - } - }, - renderChoices: function() { - if (this.pins) { - for (var i in this.pins) { - this.$box.find('#combo' + this.id + this.pins[i].index).empty().append(this.model.get('choices')); - } - } - }, - renderValue: function() { - if (this.pins) { - for (var i in this.pins) { - var index = this.pins[i].index; - var comboId = 'combo' + this.id + index; - var comboSelector = this.$box.find('#' + comboId); - comboSelector.val(this.pins[i].value); - //var fontSize = this.computeFontSize(this.pins[i].name); - //$('#select2-' + comboId + '-container').css('font-size', fontSize); - } + } + }, + + renderValue: function() { + if (this.pins) { + for (var i in this.pins) { + var index = this.pins[i].index; + var comboId = 'combo' + this.id + index; + var comboSelector = this.$box.find('#' + comboId); + comboSelector.val(this.pins[i].value); + //var fontSize = this.computeFontSize(this.pins[i].name); + //$('#select2-' + comboId + '-container').css('font-size', fontSize); } - }, - clearValue: function () { - if (this.pins) { - for (var i in this.pins) { - this.$box.find('#combo' + this.id + this.pins[i].index).val(''); - this.model.attributes.data.pins[i].name = ''; - this.model.attributes.data.pins[i].value = 0; - } + } + }, + + clearValue: function () { + if (this.pins) { + for (var i in this.pins) { + this.$box.find('#combo' + this.id + this.pins[i].index).val(''); + this.model.attributes.data.pins[i].name = ''; + this.model.attributes.data.pins[i].value = 0; } - }, - computeFontSize: function(name) { - var n = name.length; - return Math.min(13, 17-n).toString() + 'px'; - }, - update: function () { - this.renderPorts(); - this.renderBlock(); - joint.dia.ElementView.prototype.update.apply(this, arguments); } + }, + + computeFontSize: function(name) { + var n = name.length; + return Math.min(13, 17-n).toString() + 'px'; + }, + + update: function () { + this.renderPorts(); + this.renderBlock(); + joint.dia.ElementView.prototype.update.apply(this, arguments); + } }); joint.shapes.ice.InputView = joint.shapes.ice.IOView; @@ -504,52 +514,57 @@ joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ - template: '\ -
\ -

*

\ - \ - \ -
\ - ', + template: '\ +
\ +

*

\ + \ + \ +
\ + ', - initialize: function() { - joint.shapes.ice.ModelView.prototype.initialize.apply(this, arguments); + 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(); }); + // Prevent paper from handling pointerdown. + this.$box.find('.constant-input').on('mousedown click', function(evt) { evt.stopPropagation(); }); - this.$box.find('.constant-input').on('input', _.bind(function(evt) { - 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); - }, - renderValue: function() { - if (this.model.get('disabled')) { - 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(''); - }, - update: function () { - this.renderLocal(); - this.renderLabel(); - this.renderPorts(); - this.renderValue(); - joint.dia.ElementView.prototype.update.apply(this, arguments); + this.$box.find('.constant-input').on('input', _.bind(function(evt) { + 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); + }, + + renderValue: function() { + if (this.model.get('disabled')) { + 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(''); + }, + + update: function () { + this.renderLocal(); + this.renderLabel(); + this.renderPorts(); + this.renderValue(); + joint.dia.ElementView.prototype.update.apply(this, arguments); + } }); @@ -574,87 +589,90 @@ joint.shapes.ice.Code = joint.shapes.ice.Model.extend({ joint.shapes.ice.CodeView = joint.shapes.ice.ModelView.extend({ - initialize: function() { - _.bindAll(this, 'updateBox'); - joint.dia.ElementView.prototype.initialize.apply(this, arguments); - - var id = sha1(this.model.get('id')).toString().substring(0, 6); - var blockLabel = 'block' + id; - var editorLabel = 'editor' + id; - var contentLabel = 'content' + id; - this.$box = $(joint.util.template( - '\ -
\ -
\ - \ - \ -
\ - ' - )()); - - this.model.on('change', this.updateBox, this); - this.model.on('remove', this.removeBox, this); - - this.updateBox(); - - this.listenTo(this.model, 'process:ports', this.update); - joint.dia.ElementView.prototype.initialize.apply(this, arguments); + initialize: function() { + _.bindAll(this, 'updateBox'); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); + + var id = sha1(this.model.get('id')).toString().substring(0, 6); + var blockLabel = 'block' + id; + var editorLabel = 'editor' + id; + var contentLabel = 'content' + id; + this.$box = $(joint.util.template( + '\ +
\ +
\ + \ + \ +
\ + ' + )()); + + this.model.on('change', this.updateBox, this); + this.model.on('remove', this.removeBox, this); + + this.updateBox(); + + this.listenTo(this.model, 'process:ports', this.update); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); + + // Prevent paper from handling pointerdown. + this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); + + this.$box.find('#' + editorLabel).append(this.model.attributes.data.code); + this.$box.find('#' + contentLabel).append(this.model.attributes.data.code); + }, - // Prevent paper from handling pointerdown. - this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); + renderValue: function() { + var id = sha1(this.model.get('id')).toString().substring(0, 6); + var editorLabel = 'editor' + id; + var editor = ace.edit(this.$box.find('#' + editorLabel)[0]); + editor.setReadOnly(this.model.get('disabled')); + }, - this.$box.find('#' + editorLabel).append(this.model.attributes.data.code); - this.$box.find('#' + contentLabel).append(this.model.attributes.data.code); - }, - renderValue: function() { - var id = sha1(this.model.get('id')).toString().substring(0, 6); - var editorLabel = 'editor' + id; - var editor = ace.edit(this.$box.find('#' + editorLabel)[0]); - editor.setReadOnly(this.model.get('disabled')); - }, - update: function () { - this.renderPorts(); - this.renderValue(); - joint.dia.ElementView.prototype.update.apply(this, arguments); - }, - updateBox: function() { - var port, wireWidth; - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var data = this.model.attributes.data; - - // Render ports width - this.$('.port-wire').css('stroke-width', 2 * state.zoom); - for (var i in data.ports.in) { - port = data.ports.in[i]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); - } - for (var o in data.ports.out) { - port = data.ports.out[o]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); - } + update: function () { + this.renderPorts(); + this.renderValue(); + joint.dia.ElementView.prototype.update.apply(this, arguments); + }, - this.$box.css({ width: bbox.width * state.zoom, - height: bbox.height * state.zoom, - left: bbox.x * state.zoom + state.pan.x, - top: bbox.y * state.zoom + state.pan.y }); - // 'border-width': 2 * state.zoom: problem int instead of float + updateBox: function() { + var port, wireWidth; + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + var data = this.model.attributes.data; + + // Render ports width + this.$('.port-wire').css('stroke-width', 2 * state.zoom); + for (var i in data.ports.in) { + port = data.ports.in[i]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); } + for (var o in data.ports.out) { + port = data.ports.out[o]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); + } + + this.$box.css({ width: bbox.width * state.zoom, + height: bbox.height * state.zoom, + left: bbox.x * state.zoom + state.pan.x, + top: bbox.y * state.zoom + state.pan.y }); + // 'border-width': 2 * state.zoom: problem int instead of float + } }); @@ -682,72 +700,76 @@ joint.shapes.ice.Info = joint.shapes.basic.Rect.extend({ joint.shapes.ice.InfoView = joint.dia.ElementView.extend({ - initialize: function() { - _.bindAll(this, 'updateBox'); - joint.dia.ElementView.prototype.initialize.apply(this, arguments); - - var id = sha1(this.model.get('id')).toString().substring(0, 6); - var blockLabel = 'block' + id; - var editorLabel = 'editor' + id; - var contentLabel = 'content' + id; - this.$box = $(joint.util.template( - '\ -
\ -
\ - \ - \ -
\ - ' - )()); - - this.model.on('change', this.updateBox, this); - this.model.on('remove', this.removeBox, this); + initialize: function() { + _.bindAll(this, 'updateBox'); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); + + var id = sha1(this.model.get('id')).toString().substring(0, 6); + var blockLabel = 'block' + id; + var editorLabel = 'editor' + id; + var contentLabel = 'content' + id; + this.$box = $(joint.util.template( + '\ +
\ +
\ + \ + \ +
\ + ' + )()); + + this.model.on('change', this.updateBox, this); + this.model.on('remove', this.removeBox, this); + + this.updateBox(); + + // Prevent paper from handling pointerdown. + this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); + + this.$box.find('#' + editorLabel).append(this.model.attributes.data.info); + this.$box.find('#' + contentLabel).append(this.model.attributes.data.info); + }, + render: function () { + joint.dia.ElementView.prototype.render.apply(this, arguments); + this.paper.$el.append(this.$box); this.updateBox(); + return this; + }, - // Prevent paper from handling pointerdown. - this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); + update: function () { + var id = sha1(this.model.get('id')).toString().substring(0, 6); + var editorLabel = 'editor' + id; + var editor = ace.edit(this.$box.find('#' + editorLabel)[0]); + editor.setReadOnly(this.model.get('disabled')); + joint.dia.ElementView.prototype.update.apply(this, arguments); + }, - this.$box.find('#' + editorLabel).append(this.model.attributes.data.info); - this.$box.find('#' + contentLabel).append(this.model.attributes.data.info); - }, - render: function () { - joint.dia.ElementView.prototype.render.apply(this, arguments); - this.paper.$el.append(this.$box); - this.updateBox(); - return this; - }, - update: function () { - var id = sha1(this.model.get('id')).toString().substring(0, 6); - var editorLabel = 'editor' + id; - var editor = ace.edit(this.$box.find('#' + editorLabel)[0]); - editor.setReadOnly(this.model.get('disabled')); - joint.dia.ElementView.prototype.update.apply(this, arguments); - }, - updateBox: function() { - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - - this.$box.css({ width: bbox.width * state.zoom, - height: bbox.height * state.zoom, - left: bbox.x * state.zoom + state.pan.x, - top: bbox.y * state.zoom + state.pan.y }); - }, - removeBox: function(/*evt*/) { - this.$box.remove(); - } + updateBox: function() { + var bbox = this.model.getBBox(); + var state = this.model.attributes.state; + + this.$box.css({ width: bbox.width * state.zoom, + height: bbox.height * state.zoom, + left: bbox.x * state.zoom + state.pan.x, + top: bbox.y * state.zoom + state.pan.y }); + }, + + removeBox: function(/*evt*/) { + this.$box.remove(); + } }); @@ -843,14 +865,13 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ if (size) { self.model.attributes.size = size; // For wire size connection validation self.$('.connection').css('stroke-width', (size > 1) ? 8 : 2); - self.model.label(0, {attrs: { text: { text: (size > 1) ? '|' + size + '|' : '' } } }); + self.model.label(0, {attrs: { text: { text: (size > 1) ? '' + size + '' : '' } } }); self.model.bifurcationMarkup = self.model.bifurcationMarkup.replace(/<%= r %>/g, (size > 1) ? 8 : 4); } self.update(); - }, 0); - }, + render: function() { joint.dia.LinkView.prototype.render.apply(this, arguments); // console.log('render'); diff --git a/demo/constant-code-bus.ice b/demo/constant-code-bus.ice index 1742c5850..2756f76d4 100644 --- a/demo/constant-code-bus.ice +++ b/demo/constant-code-bus.ice @@ -16,7 +16,7 @@ "type": "basic.constant", "data": { "label": "C", - "local": false, + "local": true, "value": "5" }, "position": { From 0de843ff20ed14e3a0c4777ba668e31c5c6fb281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 08:25:42 +0100 Subject: [PATCH 28/35] Refactor wire size render --- app/scripts/plugins/shapes/joint.shapes.js | 141 +++++++-------------- app/scripts/services/blocks.service.js | 23 +++- app/scripts/services/graph.service.js | 21 +-- 3 files changed, 76 insertions(+), 109 deletions(-) diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index b6a79406c..3a0fcf11a 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -234,12 +234,24 @@ joint.shapes.ice.ModelView = joint.dia.ElementView.extend({ }, updateBox: function() { + var port, wireWidth; var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var pins = this.model.attributes.data.pins; - var wireWidth = (pins && pins.length > 1) ? 8 : 2; + var state = this.model.get('state'); + var leftPorts = this.model.get('leftPorts'); + var rightPorts = this.model.get('rightPorts'); - this.$('.port-wire').css('stroke-width', wireWidth * state.zoom); + // Render ports width + this.$('.port-wire').css('stroke-width', 2 * state.zoom); + for (var i in leftPorts) { + port = leftPorts[i]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); + } + for (var o in rightPorts) { + port = rightPorts[o]; + wireWidth = (port.size > 1) ? 8 : 2; + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); + } this.$box.css({ left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), @@ -289,35 +301,6 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ this.$box.find('img').addClass('hidden'); this.$box.find('label').removeClass('hidden'); } - }, - - updateBox: function() { - var port, wireWidth; - var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var leftPorts = this.model.attributes.leftPorts; - var rightPorts = this.model.attributes.rightPorts; - - // Render ports width - this.$('.port-wire').css('stroke-width', 2 * state.zoom); - for (var i in leftPorts) { - port = leftPorts[i]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); - } - for (var o in rightPorts) { - port = rightPorts[o]; - wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); - } - - this.$box.css({ - left: bbox.x * state.zoom + state.pan.x + bbox.width / 2.0 * (state.zoom - 1), - top: bbox.y * state.zoom + state.pan.y + bbox.height / 2.0 * (state.zoom - 1), - width: bbox.width, - height: bbox.height, - transform: 'scale(' + state.zoom + ')' - }); } }); @@ -326,12 +309,6 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({ joint.shapes.ice.Input = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Input', - choices: [], - rightPorts: [{ - id: 'out', - label: '', - gridUnits: 8 - }], size: { width: 96, height: 64 @@ -342,12 +319,6 @@ joint.shapes.ice.Input = joint.shapes.ice.Model.extend({ joint.shapes.ice.Output = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Output', - choices: [], - leftPorts: [{ - id: 'in', - label: '', - gridUnits: 8 - }], size: { width: 96, height: 64 @@ -369,7 +340,7 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ var selectCode = ''; var selectScript = ''; - this.pins = this.model.attributes.data.pins; + this.pins = this.model.get('data').pins; if (this.pins) { for (var i in this.pins) { @@ -499,11 +470,6 @@ joint.shapes.ice.OutputView = joint.shapes.ice.IOView; joint.shapes.ice.Constant = joint.shapes.ice.Model.extend({ defaults: joint.util.deepSupplement({ type: 'ice.Constant', - bottomPorts: [{ - id: 'constant-out', - label: '', - gridUnits: 8 - }], size: { width: 96, height: 64 @@ -543,7 +509,7 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ }, renderLabel: function () { - var name = this.model.attributes.data.label; + var name = this.model.get('data').label; this.$box.find('label').text(name); }, @@ -631,8 +597,8 @@ joint.shapes.ice.CodeView = joint.shapes.ice.ModelView.extend({ // Prevent paper from handling pointerdown. this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); - this.$box.find('#' + editorLabel).append(this.model.attributes.data.code); - this.$box.find('#' + contentLabel).append(this.model.attributes.data.code); + this.$box.find('#' + editorLabel).append(this.model.get('data').code); + this.$box.find('#' + contentLabel).append(this.model.get('data').code); }, renderValue: function() { @@ -651,20 +617,21 @@ joint.shapes.ice.CodeView = joint.shapes.ice.ModelView.extend({ updateBox: function() { var port, wireWidth; var bbox = this.model.getBBox(); - var state = this.model.attributes.state; - var data = this.model.attributes.data; + var state = this.model.get('state'); + var leftPorts = this.model.get('leftPorts'); + var rightPorts = this.model.get('rightPorts'); // Render ports width this.$('.port-wire').css('stroke-width', 2 * state.zoom); - for (var i in data.ports.in) { - port = data.ports.in[i]; + for (var i in leftPorts) { + port = leftPorts[i]; wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); } - for (var o in data.ports.out) { - port = data.ports.out[o]; + for (var o in rightPorts) { + port = rightPorts[o]; wireWidth = (port.size > 1) ? 8 : 2; - this.$('#port-wire-' + port.name).css('stroke-width', wireWidth * state.zoom); + this.$('#port-wire-' + port.id).css('stroke-width', wireWidth * state.zoom); } this.$box.css({ width: bbox.width * state.zoom, @@ -738,8 +705,8 @@ joint.shapes.ice.InfoView = joint.dia.ElementView.extend({ // Prevent paper from handling pointerdown. this.$box.find('#' + editorLabel).on('mousedown click', function(evt) { evt.stopPropagation(); }); - this.$box.find('#' + editorLabel).append(this.model.attributes.data.info); - this.$box.find('#' + contentLabel).append(this.model.attributes.data.info); + this.$box.find('#' + editorLabel).append(this.model.get('data').info); + this.$box.find('#' + contentLabel).append(this.model.get('data').info); }, render: function () { @@ -759,7 +726,7 @@ joint.shapes.ice.InfoView = joint.dia.ElementView.extend({ updateBox: function() { var bbox = this.model.getBBox(); - var state = this.model.attributes.state; + var state = this.model.get('state'); this.$box.css({ width: bbox.width * state.zoom, height: bbox.height * state.zoom, @@ -841,34 +808,22 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ var self = this; setTimeout(function() { - var portName = self.model.attributes.source.port; - var dataSource = self.sourceView.model.attributes.data; - var rightPorts = self.sourceView.model.attributes.rightPorts; + var portName = self.model.get('source').port; + var rightPorts = self.sourceView.model.get('rightPorts'); // Initialize wire properties - var size; - if (dataSource.pins) { - // I/O port block - size = dataSource.pins.length; - } - else { - // Code/Generic block - var port; - for (var o in rightPorts) { - port = rightPorts[o]; - if (portName === port.id) { - size = port.size; - break; - } + var port; + for (var o in rightPorts) { + port = rightPorts[o]; + if (portName === port.id) { + self.model.attributes.size = port.size; // For wire size connection validation + self.$('.connection').css('stroke-width', (port.size > 1) ? 8 : 2); + self.model.label(0, {attrs: { text: { text: (port.size > 1) ? '' + port.size + '' : '' } } }); + self.model.bifurcationMarkup = self.model.bifurcationMarkup.replace(/<%= r %>/g, (port.size > 1) ? 8 : 4); + self.update(); + break; } } - if (size) { - self.model.attributes.size = size; // For wire size connection validation - self.$('.connection').css('stroke-width', (size > 1) ? 8 : 2); - self.model.label(0, {attrs: { text: { text: (size > 1) ? '' + size + '' : '' } } }); - self.model.bifurcationMarkup = self.model.bifurcationMarkup.replace(/<%= r %>/g, (size > 1) ? 8 : 4); - } - self.update(); }, 0); }, @@ -940,15 +895,17 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({ // Find all the wires in the same port var portWires = []; _.each(allWires, function(wire) { - if ((wire.attributes.source.id === currentWire.attributes.source.id) && - (wire.attributes.source.port === currentWire.attributes.source.port)) + var wireSource = wire.get('source'); + var cwireSource = currentWire.get('source'); + if ((wireSource.id === cwireSource.id) && + (wireSource.port === cwireSource.port)) { // Wire with the same source of currentWire var wireView = self.paper.findViewByModel(wire); // Clean the wire bifurcations var markerBifurcations = $(wireView._V.markerBifurcations.node).empty(); portWires.push({ - id: wire.attributes.id, + id: wire.get('id'), view: wireView, markers: markerBifurcations }); diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 3b9a88cf9..5f5a27b3e 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -364,36 +364,56 @@ angular.module('icestudio') } function loadBasicInput(instance, disabled) { + var rightPorts = [{ + id: 'out', + label: '', + size: instance.data.pins.length, + gridUnits: 8 + }]; var cell = new joint.shapes.ice.Input({ id: instance.id, blockType: instance.type, data: instance.data, position: instance.position, disabled: disabled, + rightPorts: rightPorts, choices: boards.getPinoutHTML() }); return cell; } function loadBasicOutput(instance, disabled) { + var leftPorts = [{ + id: 'in', + label: '', + size: instance.data.pins.length, + gridUnits: 8 + }]; var cell = new joint.shapes.ice.Output({ id: instance.id, blockType: instance.type, data: instance.data, position: instance.position, disabled: disabled, + leftPorts: leftPorts, choices: boards.getPinoutHTML() }); return cell; } function loadBasicConstant(instance, disabled) { + var bottomPorts = [{ + id: 'constant-out', + label: '', + gridUnits: 8 + }]; var cell = new joint.shapes.ice.Constant({ id: instance.id, blockType: instance.type, data: instance.data, position: instance.position, - disabled: disabled + disabled: disabled, + bottomPorts: bottomPorts }); return cell; } @@ -541,7 +561,6 @@ angular.module('icestudio') var cell = new joint.shapes.ice.Generic({ id: instance.id, blockType: instance.type, - data: {}, image: blockImage, label: blockLabel, position: instance.position, diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 5d27acb09..e270d347b 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -153,22 +153,13 @@ angular.module('icestudio') // Prevent different size connections var tsize; var lsize = linkView.model.attributes.size; - var tdata = cellViewT.model.attributes.data; - var tLeftPorts = cellViewT.model.attributes.leftPorts; var portId = magnetT.getAttribute('port'); - if (tdata.pins) { - // I/O port block - tsize = tdata.pins ? tdata.pins.length : 1; - } - else { - // Code/Generic block - var port; - for (i in tLeftPorts) { - port = tLeftPorts[i]; - if (portId === port.id) { - tsize = port.size; - break; - } + var tLeftPorts = cellViewT.model.attributes.leftPorts; + for (i in tLeftPorts) { + var port = tLeftPorts[i]; + if (portId === port.id) { + tsize = port.size; + break; } } tsize = tsize || 1; From c8f663b49f6ed4dd322497b8e4dae6737b4ed89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 17:43:06 +0100 Subject: [PATCH 29/35] Optimize project 1.0 format --- app/scripts/controllers/menu.js | 3 + app/scripts/plugins/shapes/joint.shapes.js | 7 +- app/scripts/services/blocks.service.js | 79 +++++++++++----------- app/scripts/services/utils.service.js | 8 +-- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/app/scripts/controllers/menu.js b/app/scripts/controllers/menu.js index 23de657d1..5b8e59c6c 100644 --- a/app/scripts/controllers/menu.js +++ b/app/scripts/controllers/menu.js @@ -76,6 +76,9 @@ angular.module('icestudio') if (name) { project.new(name); } + else { + evt.cancel = true; + } }); }; diff --git a/app/scripts/plugins/shapes/joint.shapes.js b/app/scripts/plugins/shapes/joint.shapes.js index 3a0fcf11a..094479257 100644 --- a/app/scripts/plugins/shapes/joint.shapes.js +++ b/app/scripts/plugins/shapes/joint.shapes.js @@ -390,8 +390,9 @@ joint.shapes.ice.IOView = joint.shapes.ice.ModelView.extend({ renderBlock: function() { var virtualPortId = '#virtualPort' + this.id; var fpgaPortId = '#fpgaPort' + this.id; - var name = this.model.get('data').label; - var virtual = this.model.get('data').virtual || this.model.get('disabled'); + var data = this.model.get('data'); + var name = data.name + (data.range ? data.range : ''); + var virtual = data.virtual || this.model.get('disabled'); this.$box.find('label').text(name ? name : ' '); @@ -509,7 +510,7 @@ joint.shapes.ice.ConstantView = joint.shapes.ice.ModelView.extend({ }, renderLabel: function () { - var name = this.model.get('data').label; + var name = this.model.get('data').name; this.$box.find('label').text(name); }, diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index 5f5a27b3e..c18e009c5 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -78,15 +78,18 @@ angular.module('icestudio') return; } } + else { + evt.cancel = true; + //return; + } } // Create blocks for (var p in portInfos) { portInfo = portInfos[p]; var pins = getPins(portInfo); blockInstance.data = { - label: portInfo.input, name: portInfo.name, - range: portInfo.rangestr ? portInfo.rangestr : '', + range: portInfo.rangestr, pins: pins, virtual: virtual }; @@ -144,14 +147,18 @@ angular.module('icestudio') return; } } + else { + evt.cancel = true; + //return; + } } // Create blocks for (var p in paramInfos) { paramInfo = paramInfos[p]; blockInstance.data = { - label: paramInfo.input, - local: local, - value: '' + name: paramInfo.name, + value: '', + local: local }; if (addCellCallback) { addCellCallback(loadBasicConstant(blockInstance)); @@ -179,23 +186,25 @@ angular.module('icestudio') ]; if (block) { blockInstance = block; - var index; + var index, port; if (block.data.ports) { var inPorts = []; for (index in block.data.ports.in) { - inPorts.push(block.data.ports.in[index].label); + port = block.data.ports.in[index]; + inPorts.push(port.name + (port.range ? port.range : '')); } defaultValues[0] = inPorts.join(' , '); var outPorts = []; for (index in block.data.ports.out) { - outPorts.push(block.data.ports.out[index].label); + port = block.data.ports.out[index]; + outPorts.push(port.name + (port.range ? port.range : '')); } defaultValues[1] = outPorts.join(' , '); } if (block.data.params) { var params = []; for (index in block.data.params) { - params.push(block.data.params[index].label); + params.push(block.data.params[index].name); } defaultValues[2] = params.join(' , '); } @@ -263,7 +272,6 @@ angular.module('icestudio') if (inPortInfos[i]) { pins = getPins(inPortInfos[i]); blockInstance.data.ports.in.push({ - label: inPortInfos[i].input, name: inPortInfos[i].name, range: inPortInfos[i].rangestr, size: pins.length @@ -276,7 +284,6 @@ angular.module('icestudio') if (outPortInfos[o]) { pins = getPins(outPortInfos[o]); blockInstance.data.ports.out.push({ - label: outPortInfos[o].input, name: outPortInfos[o].name, range: outPortInfos[o].rangestr, size: pins.length @@ -288,7 +295,6 @@ angular.module('icestudio') for (p in paramInfos) { if (paramInfos[p]) { blockInstance.data.params.push({ - label: paramInfos[p].input, name: paramInfos[p].name }); allNames.push(paramInfos[p].name); @@ -419,32 +425,36 @@ angular.module('icestudio') } function loadBasicCode(instance, disabled) { + var port; var leftPorts = []; var rightPorts = []; var topPorts = []; for (var i in instance.data.ports.in) { + port = instance.data.ports.in[i]; leftPorts.push({ - id: instance.data.ports.in[i].name, - label: instance.data.ports.in[i].label, - size: instance.data.ports.in[i].size, + id: port.name, + label: port.name + (port.range ? port.range : ''), + size: port.size, gridUnits: 32 }); } for (var o in instance.data.ports.out) { + port = instance.data.ports.out[o]; rightPorts.push({ - id: instance.data.ports.out[o].name, - label: instance.data.ports.out[o].label, - size: instance.data.ports.out[o].size, + id: port.name, + label: port.name + (port.range ? port.range : ''), + size: port.size, gridUnits: 32 }); } for (var p in instance.data.params) { + port = instance.data.params[p]; topPorts.push({ - id: instance.data.params[p].name, - label: instance.data.params[p].label, + id: port.name, + label: port.name, gridUnits: 48 }); } @@ -486,14 +496,14 @@ angular.module('icestudio') if (item.type === 'basic.input') { leftPorts.push({ id: item.id, - label: item.data.label, + label: item.data.name + (item.data.range ? item.data.range : ''), size: block.design.graph.blocks[i].data.pins.length }); } else if (item.type === 'basic.output') { rightPorts.push({ id: item.id, - label: item.data.label, + label: item.data.name + (item.data.range ? item.data.range : ''), size: block.design.graph.blocks[i].data.pins.length }); } @@ -501,7 +511,7 @@ angular.module('icestudio') if (!item.data.local) { topPorts.push({ id: item.id, - label: item.data.label + label: item.data.name }); } } @@ -634,7 +644,7 @@ angular.module('icestudio') gettextCatalog.getString('Update the port'), gettextCatalog.getString('Virtual port') ], [ - block.data.label, + block.data.name + (block.data.range ? block.data.range : ''), block.data.virtual ], function(evt, values) { @@ -644,20 +654,14 @@ angular.module('icestudio') var portInfo = utils.parsePortLabel(label); if (portInfo) { evt.cancel = false; - if (!block.data.range) { - block.data.range = ''; - } - if (!portInfo.rangestr) { - portInfo.rangestr = ''; - } - if (block.data.range !== portInfo.rangestr) { + if ((block.data.range ? block.data.range : '') !== + (portInfo.rangestr ? portInfo.rangestr : '')) { // Create new block var blockInstance = { id: null, data: { - label: portInfo.input, name: portInfo.name, - range: portInfo.rangestr ? portInfo.rangestr : '', + range: portInfo.rangestr, pins: getPins(portInfo), virtual: virtual }, @@ -673,7 +677,6 @@ angular.module('icestudio') else if (block.data.name !== portInfo.name || block.data.virtual !== virtual) { // Edit block - block.data.label = portInfo.input; block.data.name = portInfo.name; block.data.virtual = virtual; cellView.render(); @@ -693,17 +696,17 @@ angular.module('icestudio') gettextCatalog.getString('Update the block label'), gettextCatalog.getString('Local parameter') ], [ - block.data.label, + block.data.name, block.data.local ], function(evt, values) { - var label = values[0].replace(/ /g, ''); + var name = values[0].replace(/ /g, ''); var local = values[1]; // Edit block - if (block.data.name !== label || + if (block.data.name !== name || block.data.local !== local) { // Edit block - block.data.label = label; + block.data.name = name; block.data.local = local; cellView.renderLabel(); cellView.renderLocal(); diff --git a/app/scripts/services/utils.service.js b/app/scripts/services/utils.service.js index eff998b19..e083c52b3 100644 --- a/app/scripts/services/utils.service.js +++ b/app/scripts/services/utils.service.js @@ -872,8 +872,7 @@ angular.module('icestudio') var pattern = /([A-Za-z_]+[A-Za-z_0-9]*){0,1}(\[([0-9]+):([0-9]+)\]){0,1}/g; match = pattern.exec(data); if (match && (match[0] === match.input)) { - ret.input = match[0]; - ret.name = match[1]; + ret.name = match[1] ? match[1] : ''; ret.rangestr = match[2]; if (match[2]) { if (match[3] > match[4]) { @@ -891,11 +890,10 @@ angular.module('icestudio') this.parseParamLabel = function(data) { // e.g: name var match, ret = {}; - var pattern = /[A-Za-z_]+[A-Za-z_0-9]*/g; + var pattern = /([A-Za-z_]+[A-Za-z_0-9]*){0,1}/g; match = pattern.exec(data); if (match && (match[0] === match.input)) { - ret.input = match[0]; - ret.name = match[0]; + ret.name = match[1] ? match[1] : ''; return ret; } return null; From a043461817ed2a0c5d1b6d93deb793ce639d8eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 17:44:14 +0100 Subject: [PATCH 30/35] Add "block" sample --- samples/block.ice | 230 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 samples/block.ice diff --git a/samples/block.ice b/samples/block.ice new file mode 100644 index 000000000..6609d744c --- /dev/null +++ b/samples/block.ice @@ -0,0 +1,230 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "deddfc29-7bf1-4ac4-a24e-e91b4cc14335", + "type": "basic.constant", + "data": { + "name": "C", + "value": "4'b1111", + "local": false + }, + "position": { + "x": 296, + "y": 32 + } + }, + { + "id": "a9f85080-6523-428b-966c-359be16be956", + "type": "basic.constant", + "data": { + "name": "D", + "value": "4'b0000", + "local": true + }, + "position": { + "x": 488, + "y": 32 + } + }, + { + "id": "4aa2ce96-a449-42f1-b612-2c852dc50da8", + "type": "basic.input", + "data": { + "name": "p", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 680, + "y": 64 + } + }, + { + "id": "7f5654cf-4591-4a66-9147-d0cbdcb95f79", + "type": "basic.output", + "data": { + "name": "q", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 896, + "y": 64 + } + }, + { + "id": "fecaab8e-c7d4-4823-81fb-2b0d42f38026", + "type": "basic.code", + "data": { + "code": "reg [3:0] b_aux;\n\nalways @(a)\nbegin\n if (a == 1)\n b_aux = C;\n else\n b_aux = D;\nend\n\nassign b = b_aux;\n", + "params": [ + { + "name": "C" + }, + { + "name": "D" + } + ], + "ports": { + "in": [ + { + "name": "a", + "size": 1 + } + ], + "out": [ + { + "name": "b", + "range": "[3:0]", + "size": 4 + } + ] + } + }, + "position": { + "x": 248, + "y": 176 + } + }, + { + "id": "cbd336da-6d61-4c71-90e1-e11bbe6817fc", + "type": "basic.input", + "data": { + "name": "in", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 48, + "y": 272 + } + }, + { + "id": "15e91005-34e6-4ce9-80b4-8c33c6c1e5a0", + "type": "basic.output", + "data": { + "name": "out", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "", + "value": 0 + }, + { + "index": "2", + "name": "", + "value": 0 + }, + { + "index": "1", + "name": "", + "value": 0 + }, + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 760, + "y": 272 + } + } + ], + "wires": [ + { + "source": { + "block": "a9f85080-6523-428b-966c-359be16be956", + "port": "constant-out" + }, + "target": { + "block": "fecaab8e-c7d4-4823-81fb-2b0d42f38026", + "port": "D" + } + }, + { + "source": { + "block": "deddfc29-7bf1-4ac4-a24e-e91b4cc14335", + "port": "constant-out" + }, + "target": { + "block": "fecaab8e-c7d4-4823-81fb-2b0d42f38026", + "port": "C" + } + }, + { + "source": { + "block": "cbd336da-6d61-4c71-90e1-e11bbe6817fc", + "port": "out" + }, + "target": { + "block": "fecaab8e-c7d4-4823-81fb-2b0d42f38026", + "port": "a" + } + }, + { + "source": { + "block": "fecaab8e-c7d4-4823-81fb-2b0d42f38026", + "port": "b" + }, + "target": { + "block": "15e91005-34e6-4ce9-80b4-8c33c6c1e5a0", + "port": "in" + }, + "size": 4 + }, + { + "source": { + "block": "4aa2ce96-a449-42f1-b612-2c852dc50da8", + "port": "out" + }, + "target": { + "block": "7f5654cf-4591-4a66-9147-d0cbdcb95f79", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 24.988850906836912, + "y": 53.895818245976436 + }, + "zoom": 0.8154432847623143 + } + } +} \ No newline at end of file From 8e06c8673d012477f03f36c2469584620452e9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 18:11:58 +0100 Subject: [PATCH 31/35] Add more samples --- samples/assign.ice | 148 +++++++++++ samples/complex.ice | 623 ++++++++++++++++++++++++++++++++++++++++++++ samples/in-out.ice | 104 ++++++++ samples/mux.ice | 170 ++++++++++++ samples/not.ice | 111 ++++++++ 5 files changed, 1156 insertions(+) create mode 100644 samples/assign.ice create mode 100644 samples/complex.ice create mode 100644 samples/in-out.ice create mode 100644 samples/mux.ice create mode 100644 samples/not.ice diff --git a/samples/assign.ice b/samples/assign.ice new file mode 100644 index 000000000..8cf289611 --- /dev/null +++ b/samples/assign.ice @@ -0,0 +1,148 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "909655b9-5ef0-4c45-9494-c0238d2e4732", + "type": "basic.constant", + "data": { + "name": "Value", + "value": "4'b1110", + "local": false + }, + "position": { + "x": 192, + "y": 56 + } + }, + { + "id": "7e351e09-634d-407c-ab7e-452519468292", + "type": "basic.constant", + "data": { + "name": "offset", + "value": "0", + "local": true + }, + "position": { + "x": 384, + "y": 56 + } + }, + { + "id": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "type": "basic.code", + "data": { + "code": "assign out = C + D;", + "params": [ + { + "name": "C" + }, + { + "name": "D" + } + ], + "ports": { + "in": [], + "out": [ + { + "name": "out", + "range": "[3:0]", + "size": 4 + } + ] + } + }, + "position": { + "x": 144, + "y": 200 + } + }, + { + "id": "ef743d41-5941-4831-becd-0d930c4eed54", + "type": "basic.output", + "data": { + "name": "out", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "LED3", + "value": "98" + }, + { + "index": "2", + "name": "LED2", + "value": "97" + }, + { + "index": "1", + "name": "LED1", + "value": "96" + }, + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 672, + "y": 248 + } + } + ], + "wires": [ + { + "source": { + "block": "909655b9-5ef0-4c45-9494-c0238d2e4732", + "port": "constant-out" + }, + "target": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "C" + } + }, + { + "source": { + "block": "7e351e09-634d-407c-ab7e-452519468292", + "port": "constant-out" + }, + "target": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "D" + } + }, + { + "source": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "out" + }, + "target": { + "block": "ef743d41-5941-4831-becd-0d930c4eed54", + "port": "in" + }, + "size": 4 + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file diff --git a/samples/complex.ice b/samples/complex.ice new file mode 100644 index 000000000..ab8b6a58c --- /dev/null +++ b/samples/complex.ice @@ -0,0 +1,623 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "bfebb831-8b03-43e1-9b87-013f1b5a9cdf", + "type": "basic.constant", + "data": { + "name": "C", + "value": "4'b1010", + "local": false + }, + "position": { + "x": 128, + "y": 40 + } + }, + { + "id": "6c168fad-742d-42aa-a286-ec235bf61951", + "type": "assign", + "position": { + "x": 120, + "y": 184 + } + }, + { + "id": "731465bb-f103-4cf5-a273-79b43e628246", + "type": "mux", + "position": { + "x": 352, + "y": 200 + } + }, + { + "id": "fab70b68-1a4e-426c-8a29-fa02328401e7", + "type": "not", + "position": { + "x": 528, + "y": 200 + } + }, + { + "id": "0fbbb687-4a61-4b1d-a022-8884a20bef5c", + "type": "basic.output", + "data": { + "name": "led", + "pins": [ + { + "index": "0", + "name": "LED7", + "value": "104" + } + ], + "virtual": false + }, + "position": { + "x": 712, + "y": 200 + } + }, + { + "id": "21e9e7f9-9b8a-4fca-904d-e266f1496454", + "type": "basic.input", + "data": { + "name": "in", + "range": "[1:0]", + "pins": [ + { + "index": "1", + "name": "SW1", + "value": "10" + }, + { + "index": "0", + "name": "SW2", + "value": "11" + } + ], + "virtual": false + }, + "position": { + "x": 152, + "y": 280 + } + }, + { + "id": "6c809d38-547d-4c70-92eb-2d5c389429e7", + "type": "basic.output", + "data": { + "name": "debug", + "range": "[1:0]", + "pins": [ + { + "index": "1", + "name": "LED1", + "value": "96" + }, + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 712, + "y": 280 + } + } + ], + "wires": [ + { + "source": { + "block": "bfebb831-8b03-43e1-9b87-013f1b5a9cdf", + "port": "constant-out" + }, + "target": { + "block": "6c168fad-742d-42aa-a286-ec235bf61951", + "port": "909655b9-5ef0-4c45-9494-c0238d2e4732" + } + }, + { + "source": { + "block": "6c168fad-742d-42aa-a286-ec235bf61951", + "port": "ef743d41-5941-4831-becd-0d930c4eed54" + }, + "target": { + "block": "731465bb-f103-4cf5-a273-79b43e628246", + "port": "95f8c313-6e18-4ee3-b9cf-7266dec53c93" + }, + "size": 4 + }, + { + "source": { + "block": "731465bb-f103-4cf5-a273-79b43e628246", + "port": "60d40fc8-3388-4066-8f0a-af17e179a9bd" + }, + "target": { + "block": "fab70b68-1a4e-426c-8a29-fa02328401e7", + "port": "a4058fa5-b66e-4e5e-b542-28d7c3e9d3cd" + } + }, + { + "source": { + "block": "21e9e7f9-9b8a-4fca-904d-e266f1496454", + "port": "out" + }, + "target": { + "block": "731465bb-f103-4cf5-a273-79b43e628246", + "port": "f6528039-852b-41f9-aa41-268994b3f631" + }, + "size": 2 + }, + { + "source": { + "block": "fab70b68-1a4e-426c-8a29-fa02328401e7", + "port": "07895985-9d14-4a6f-8f2d-b2a6ddf61852" + }, + "target": { + "block": "0fbbb687-4a61-4b1d-a022-8884a20bef5c", + "port": "in" + } + }, + { + "source": { + "block": "21e9e7f9-9b8a-4fca-904d-e266f1496454", + "port": "out" + }, + "target": { + "block": "6c809d38-547d-4c70-92eb-2d5c389429e7", + "port": "in" + }, + "size": 2 + } + ] + }, + "deps": { + "assign": { + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "graph": { + "blocks": [ + { + "id": "909655b9-5ef0-4c45-9494-c0238d2e4732", + "type": "basic.constant", + "data": { + "name": "Value", + "value": "4'b1110", + "local": false + }, + "position": { + "x": 192, + "y": 56 + } + }, + { + "id": "7e351e09-634d-407c-ab7e-452519468292", + "type": "basic.constant", + "data": { + "name": "offset", + "value": "0", + "local": true + }, + "position": { + "x": 384, + "y": 56 + } + }, + { + "id": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "type": "basic.code", + "data": { + "code": "assign out = C + D;", + "params": [ + { + "name": "C" + }, + { + "name": "D" + } + ], + "ports": { + "in": [], + "out": [ + { + "name": "out", + "range": "[3:0]", + "size": 4 + } + ] + } + }, + "position": { + "x": 144, + "y": 200 + } + }, + { + "id": "ef743d41-5941-4831-becd-0d930c4eed54", + "type": "basic.output", + "data": { + "name": "out", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "LED3", + "value": "98" + }, + { + "index": "2", + "name": "LED2", + "value": "97" + }, + { + "index": "1", + "name": "LED1", + "value": "96" + }, + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 672, + "y": 248 + } + } + ], + "wires": [ + { + "source": { + "block": "909655b9-5ef0-4c45-9494-c0238d2e4732", + "port": "constant-out" + }, + "target": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "C" + } + }, + { + "source": { + "block": "7e351e09-634d-407c-ab7e-452519468292", + "port": "constant-out" + }, + "target": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "D" + } + }, + { + "source": { + "block": "b6bc7556-6362-45ca-80e5-6db7a3100c7d", + "port": "out" + }, + "target": { + "block": "ef743d41-5941-4831-becd-0d930c4eed54", + "port": "in" + }, + "size": 4 + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } + }, + "mux": { + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "graph": { + "blocks": [ + { + "id": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "type": "basic.code", + "data": { + "code": "// Multiplexer 4 to 1 \nassign out = data[sel];", + "params": [], + "ports": { + "in": [ + { + "name": "data", + "range": "[3:0]", + "size": 4 + }, + { + "name": "sel", + "range": "[1:0]", + "size": 2 + } + ], + "out": [ + { + "name": "out", + "size": 1 + } + ] + } + }, + "position": { + "x": 288, + "y": 112 + } + }, + { + "id": "95f8c313-6e18-4ee3-b9cf-7266dec53c93", + "type": "basic.input", + "data": { + "name": "d", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "", + "value": 0 + }, + { + "index": "2", + "name": "", + "value": 0 + }, + { + "index": "1", + "name": "", + "value": 0 + }, + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 48, + "y": 144 + } + }, + { + "id": "60d40fc8-3388-4066-8f0a-af17e179a9bd", + "type": "basic.output", + "data": { + "name": "out", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 760, + "y": 208 + } + }, + { + "id": "f6528039-852b-41f9-aa41-268994b3f631", + "type": "basic.input", + "data": { + "name": "s", + "range": "[1:0]", + "pins": [ + { + "index": "1", + "name": "", + "value": 0 + }, + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 48, + "y": 272 + } + } + ], + "wires": [ + { + "source": { + "block": "95f8c313-6e18-4ee3-b9cf-7266dec53c93", + "port": "out" + }, + "target": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "data" + }, + "size": 4 + }, + { + "source": { + "block": "f6528039-852b-41f9-aa41-268994b3f631", + "port": "out" + }, + "target": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "sel" + }, + "size": 2 + }, + { + "source": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "out" + }, + "target": { + "block": "60d40fc8-3388-4066-8f0a-af17e179a9bd", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } + }, + "not": { + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "graph": { + "blocks": [ + { + "id": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "type": "basic.code", + "data": { + "code": "// NOT logic gate\nassign b = ~a;", + "params": [], + "ports": { + "in": [ + { + "name": "a", + "size": 1 + } + ], + "out": [ + { + "name": "b", + "size": 1 + } + ] + } + }, + "position": { + "x": 248, + "y": 88 + } + }, + { + "id": "a4058fa5-b66e-4e5e-b542-28d7c3e9d3cd", + "type": "basic.input", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 72, + "y": 184 + } + }, + { + "id": "07895985-9d14-4a6f-8f2d-b2a6ddf61852", + "type": "basic.output", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 728, + "y": 184 + } + } + ], + "wires": [ + { + "source": { + "block": "a4058fa5-b66e-4e5e-b542-28d7c3e9d3cd", + "port": "out" + }, + "target": { + "block": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "port": "a" + } + }, + { + "source": { + "block": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "port": "b" + }, + "target": { + "block": "07895985-9d14-4a6f-8f2d-b2a6ddf61852", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } + } + }, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file diff --git a/samples/in-out.ice b/samples/in-out.ice new file mode 100644 index 000000000..6989126d9 --- /dev/null +++ b/samples/in-out.ice @@ -0,0 +1,104 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "b25e5929-162c-4631-8d04-156e0b382590", + "type": "basic.input", + "data": { + "name": "in", + "pins": [ + { + "index": "0", + "name": "SW1", + "value": "10" + } + ], + "virtual": false + }, + "position": { + "x": 224, + "y": 112 + } + }, + { + "id": "2a8315b1-437e-40b7-adfb-ff961a0aa8f6", + "type": "basic.output", + "data": { + "name": "out", + "pins": [ + { + "index": "0", + "name": "LED0", + "value": "95" + } + ], + "virtual": false + }, + "position": { + "x": 488, + "y": 112 + } + }, + { + "id": "f8ffb071-9a46-4b46-86d2-cd5b83bae395", + "type": "basic.output", + "data": { + "name": "out", + "pins": [ + { + "index": "0", + "name": "LED1", + "value": "96" + } + ], + "virtual": false + }, + "position": { + "x": 488, + "y": 248 + } + } + ], + "wires": [ + { + "source": { + "block": "b25e5929-162c-4631-8d04-156e0b382590", + "port": "out" + }, + "target": { + "block": "2a8315b1-437e-40b7-adfb-ff961a0aa8f6", + "port": "in" + } + }, + { + "source": { + "block": "b25e5929-162c-4631-8d04-156e0b382590", + "port": "out" + }, + "target": { + "block": "f8ffb071-9a46-4b46-86d2-cd5b83bae395", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file diff --git a/samples/mux.ice b/samples/mux.ice new file mode 100644 index 000000000..f4d921c39 --- /dev/null +++ b/samples/mux.ice @@ -0,0 +1,170 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "type": "basic.code", + "data": { + "code": "// Multiplexer 4 to 1 \nassign out = data[sel];", + "params": [], + "ports": { + "in": [ + { + "name": "data", + "range": "[3:0]", + "size": 4 + }, + { + "name": "sel", + "range": "[1:0]", + "size": 2 + } + ], + "out": [ + { + "name": "out", + "size": 1 + } + ] + } + }, + "position": { + "x": 288, + "y": 112 + } + }, + { + "id": "95f8c313-6e18-4ee3-b9cf-7266dec53c93", + "type": "basic.input", + "data": { + "name": "d", + "range": "[3:0]", + "pins": [ + { + "index": "3", + "name": "", + "value": 0 + }, + { + "index": "2", + "name": "", + "value": 0 + }, + { + "index": "1", + "name": "", + "value": 0 + }, + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 48, + "y": 144 + } + }, + { + "id": "60d40fc8-3388-4066-8f0a-af17e179a9bd", + "type": "basic.output", + "data": { + "name": "out", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 760, + "y": 208 + } + }, + { + "id": "f6528039-852b-41f9-aa41-268994b3f631", + "type": "basic.input", + "data": { + "name": "s", + "range": "[1:0]", + "pins": [ + { + "index": "1", + "name": "", + "value": 0 + }, + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 48, + "y": 272 + } + } + ], + "wires": [ + { + "source": { + "block": "95f8c313-6e18-4ee3-b9cf-7266dec53c93", + "port": "out" + }, + "target": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "data" + }, + "size": 4 + }, + { + "source": { + "block": "f6528039-852b-41f9-aa41-268994b3f631", + "port": "out" + }, + "target": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "sel" + }, + "size": 2 + }, + { + "source": { + "block": "5e1563d7-86de-4618-a9b0-2a08075af9ec", + "port": "out" + }, + "target": { + "block": "60d40fc8-3388-4066-8f0a-af17e179a9bd", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file diff --git a/samples/not.ice b/samples/not.ice new file mode 100644 index 000000000..426794ebe --- /dev/null +++ b/samples/not.ice @@ -0,0 +1,111 @@ +{ + "version": "1.0", + "package": { + "name": "", + "version": "", + "description": "", + "author": "", + "image": "" + }, + "design": { + "board": "icezum", + "graph": { + "blocks": [ + { + "id": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "type": "basic.code", + "data": { + "code": "// NOT logic gate\nassign b = ~a;", + "params": [], + "ports": { + "in": [ + { + "name": "a", + "size": 1 + } + ], + "out": [ + { + "name": "b", + "size": 1 + } + ] + } + }, + "position": { + "x": 248, + "y": 88 + } + }, + { + "id": "a4058fa5-b66e-4e5e-b542-28d7c3e9d3cd", + "type": "basic.input", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 72, + "y": 184 + } + }, + { + "id": "07895985-9d14-4a6f-8f2d-b2a6ddf61852", + "type": "basic.output", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": 0 + } + ], + "virtual": true + }, + "position": { + "x": 728, + "y": 184 + } + } + ], + "wires": [ + { + "source": { + "block": "a4058fa5-b66e-4e5e-b542-28d7c3e9d3cd", + "port": "out" + }, + "target": { + "block": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "port": "a" + } + }, + { + "source": { + "block": "364b95cc-e8ff-4c65-b332-d6125c5968ee", + "port": "b" + }, + "target": { + "block": "07895985-9d14-4a6f-8f2d-b2a6ddf61852", + "port": "in" + } + } + ] + }, + "deps": {}, + "state": { + "pan": { + "x": 0, + "y": 0 + }, + "zoom": 1 + } + } +} \ No newline at end of file From d99d404163502f86aa6d4dc3cdef86a9fd8918cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 18:33:21 +0100 Subject: [PATCH 32/35] Update backward compatibility function --- app/scripts/services/blocks.service.js | 8 ++-- app/scripts/services/project.service.js | 61 +++++++++++++++++++------ app/views/menu.html | 2 +- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/scripts/services/blocks.service.js b/app/scripts/services/blocks.service.js index c18e009c5..fff0cdcb6 100644 --- a/app/scripts/services/blocks.service.js +++ b/app/scripts/services/blocks.service.js @@ -106,11 +106,11 @@ angular.module('icestudio') var pins = []; if (portInfo.range) { for (var r in portInfo.range) { - pins.push({ index: portInfo.range[r].toString(), name: '', value: 0 }); + pins.push({ index: portInfo.range[r].toString(), name: '', value: '0' }); } } else { - pins.push({ index: '0', name: '', value: 0 }); + pins.push({ index: '0', name: '', value: '0' }); } return pins; } @@ -224,7 +224,7 @@ angular.module('icestudio') for (i in inPorts) { if (inPorts[i]) { inPortInfo = utils.parsePortLabel(inPorts[i]); - if (inPortInfo) { + if (inPortInfo && inPortInfo.name) { evt.cancel = false; inPortInfos.push(inPortInfo); } @@ -239,7 +239,7 @@ angular.module('icestudio') for (o in outPorts) { if (outPorts[o]) { outPortInfo = utils.parsePortLabel(outPorts[o]); - if (outPortInfo) { + if (outPortInfo && outPortInfo.name) { evt.cancel = false; outPortInfos.push(outPortInfo); } diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index a487d412c..3f3ac48ef 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -80,20 +80,53 @@ angular.module('icestudio') project = data; break; default: - var blocks = data.graph.blocks; - for (var b in blocks) { - var block = blocks[b]; - if (block.type === 'basic.input' || - block.type === 'basic.output') { - block.data.name = block.data.label; - block.data.range = ''; - block.data.pins = [{ - index: '0', - name: block.data.pin ? block.data.pin.name : '', - value: block.data.pin ? block.data.pin.value : 0 - }]; - block.data.virtual = false; - delete block.data.pin; + for (var b in data.graph.blocks) { + var block = data.graph.blocks[b]; + switch(block.type) { + case 'basic.input': + case 'basic.output': + block.data = { + name: block.data.label, + pins: [{ + index: '0', + name: '', + value: '0' + }], + virtual: false + }; + break; + case 'basic.constant': + block.data = { + name: block.data.label, + value: block.data.value, + local: false + }; + break; + case 'basic.code': + var params = []; + for (var p in block.data.params) { + params.push({ + name: block.data.params[p] + }); + } + block.data.params = params; + var inPorts = []; + for (var i in block.data.ports.in) { + params.push({ + name: block.data.ports.in[i], + size: 1 + }); + } + block.data.ports.in = inPorts; + var outPorts = []; + for (var o in block.data.ports.out) { + params.push({ + name: block.data.ports.out[o], + size: 1 + }); + } + block.data.ports.out = outPorts; + break; } } project = _default(); diff --git a/app/views/menu.html b/app/views/menu.html index 52777f30c..83dccb4a4 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -7,7 +7,7 @@ - + From ea4057d16ed65708277bd2430569494fe0baf409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 18:34:20 +0100 Subject: [PATCH 33/35] Clear demo files --- demo/complex.ice | 411 -------------------------- demo/constant-code-block.ice | 100 ------- demo/constant-code-bus.ice | 125 -------- demo/constant-generic-block.ice | 189 ------------ demo/constant-io-code-block.ice | 154 ---------- demo/div.ice | 133 --------- demo/input-output-bus.ice | 142 --------- demo/input-output.ice | 79 ----- demo/multi-block-block.ice | 276 ----------------- demo/multi-block-output.ice | 238 --------------- demo/multi-constant-generic-block.ice | 245 --------------- demo/multi-input-output.ice | 110 ------- 12 files changed, 2202 deletions(-) delete mode 100644 demo/complex.ice delete mode 100644 demo/constant-code-block.ice delete mode 100644 demo/constant-code-bus.ice delete mode 100644 demo/constant-generic-block.ice delete mode 100644 demo/constant-io-code-block.ice delete mode 100644 demo/div.ice delete mode 100644 demo/input-output-bus.ice delete mode 100644 demo/input-output.ice delete mode 100644 demo/multi-block-block.ice delete mode 100644 demo/multi-block-output.ice delete mode 100644 demo/multi-constant-generic-block.ice delete mode 100644 demo/multi-input-output.ice diff --git a/demo/complex.ice b/demo/complex.ice deleted file mode 100644 index 344dafe77..000000000 --- a/demo/complex.ice +++ /dev/null @@ -1,411 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "3e7df107-03ee-4c35-9e52-607770f4c832", - "type": "basic.output", - "data": { - "label": "a", - "name": "a", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 216, - "y": 80 - } - }, - { - "id": "365fa313-f3c1-433d-9d51-97429dfaa3c8", - "type": "basic.constant", - "data": { - "label": "Value", - "value": "1'b1" - }, - "position": { - "x": 344, - "y": 80 - } - }, - { - "id": "083f6679-313b-497a-b2f0-4d972bc3cffa", - "type": "basic.output", - "data": { - "label": "c", - "name": "c", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED2", - "value": "97" - } - ], - "virtual": false - }, - "position": { - "x": 760, - "y": 144 - } - }, - { - "id": "1ffad532-f6da-47b0-8e85-d27fdcc211a8", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 48, - "y": 248 - } - }, - { - "id": "1aa80d81-052d-426d-a073-a6e9678a9959", - "type": "block", - "data": {}, - "position": { - "x": 280, - "y": 264 - } - }, - { - "id": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", - "type": "block", - "data": {}, - "position": { - "x": 536, - "y": 280 - } - }, - { - "id": "8631a189-f5ed-4be1-88df-30d6acb97f99", - "type": "basic.output", - "data": { - "label": "d", - "name": "d", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED3", - "value": "98" - } - ], - "virtual": false - }, - "position": { - "x": 768, - "y": 280 - } - } - ], - "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" - }, - "vertices": [ - { - "x": 496, - "y": 224 - } - ] - }, - { - "source": { - "block": "e55fa1d9-ac88-461c-b5c1-4f4302c547cc", - "port": "94e9a915-defe-4437-8abd-d3e57dafbb45" - }, - "target": { - "block": "083f6679-313b-497a-b2f0-4d972bc3cffa", - "port": "in" - }, - "vertices": [ - { - "x": 680, - "y": 256 - } - ] - }, - { - "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": 200, - "y": 400 - } - ] - } - ] - }, - "deps": { - "block": { - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "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", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "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", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "position": { - "x": 24, - "y": 264 - } - }, - { - "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", - "type": "basic.input", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "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": {}, - "state": { - "pan": { - "x": 45.83406713517239, - "y": 43.306661649315814 - }, - "zoom": 0.8527620016280335 - } - } - } - }, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } -} \ No newline at end of file diff --git a/demo/constant-code-block.ice b/demo/constant-code-block.ice deleted file mode 100644 index db4de8682..000000000 --- a/demo/constant-code-block.ice +++ /dev/null @@ -1,100 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "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": "b38fa7c5-3a2e-403b-b3d3-ac32917b5596", - "type": "basic.code", - "data": { - "code": "assign o = v;", - "params": [ - "v" - ], - "ports": { - "in": [], - "out": [ - "o" - ] - } - }, - "position": { - "x": 136, - "y": 192 - } - }, - { - "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", - "type": "basic.output", - "data": { - "label": "led", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 624, - "y": 288 - } - } - ], - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } -} \ No newline at end of file diff --git a/demo/constant-code-bus.ice b/demo/constant-code-bus.ice deleted file mode 100644 index 2756f76d4..000000000 --- a/demo/constant-code-bus.ice +++ /dev/null @@ -1,125 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "04b316b2-452b-4e2f-bdc6-26d1a204c675", - "type": "basic.constant", - "data": { - "label": "C", - "local": true, - "value": "5" - }, - "position": { - "x": 232, - "y": 32 - } - }, - { - "id": "3d5412cf-96ac-4429-9a22-01d5095f0981", - "type": "basic.code", - "data": { - "code": "// Assign constant parameter\n\nassign out = value;", - "params": [ - { - "label": "value", - "name": "value" - } - ], - "ports": { - "in": [], - "out": [ - { - "label": "out[3:0]", - "name": "out", - "range": "[3:0]", - "size": 4 - } - ] - } - }, - "position": { - "x": 88, - "y": 176 - } - }, - { - "id": "6d4f9130-37c5-48d2-b481-b803d818c3c7", - "type": "basic.output", - "data": { - "label": "leds[3:0]", - "name": "leds", - "range": "[3:0]", - "pins": [ - { - "index": "3", - "name": "LED3", - "value": "98" - }, - { - "index": "2", - "name": "LED2", - "value": "97" - }, - { - "index": "1", - "name": "LED1", - "value": "96" - }, - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 624, - "y": 224 - } - } - ], - "wires": [ - { - "source": { - "block": "04b316b2-452b-4e2f-bdc6-26d1a204c675", - "port": "constant-out" - }, - "target": { - "block": "3d5412cf-96ac-4429-9a22-01d5095f0981", - "port": "value" - } - }, - { - "source": { - "block": "3d5412cf-96ac-4429-9a22-01d5095f0981", - "port": "out" - }, - "target": { - "block": "6d4f9130-37c5-48d2-b481-b803d818c3c7", - "port": "in" - }, - "size": 4 - } - ] - }, - "deps": {}, - "state": { - "pan": { - "x": -7, - "y": 13 - }, - "zoom": 1 - } - } -} \ No newline at end of file diff --git a/demo/constant-generic-block.ice b/demo/constant-generic-block.ice deleted file mode 100644 index dcc1ccca4..000000000 --- a/demo/constant-generic-block.ice +++ /dev/null @@ -1,189 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "3ea55b72-cda0-4f43-886b-e225b00229a4", - "type": "basic.constant", - "data": { - "label": "Value", - "value": "1'b1" - }, - "position": { - "x": 296, - "y": 32 - } - }, - { - "id": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", - "type": "constant-code-block", - "data": {}, - "position": { - "x": 248, - "y": 184 - } - }, - { - "id": "06bd1d14-7302-4dd7-9e95-650d1070a203", - "type": "basic.output", - "data": { - "label": "led", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "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": { - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "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", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } - } - }, - "state": { - "pan": { - "x": -21, - "y": 66 - }, - "zoom": 0.9999999999999893 - } - } -} \ No newline at end of file diff --git a/demo/constant-io-code-block.ice b/demo/constant-io-code-block.ice deleted file mode 100644 index 941351292..000000000 --- a/demo/constant-io-code-block.ice +++ /dev/null @@ -1,154 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "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": "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", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 24, - "y": 264 - } - }, - { - "id": "94e9a915-defe-4437-8abd-d3e57dafbb45", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 712, - "y": 264 - } - }, - { - "id": "9051bd8c-0c39-4b19-bb08-71ac0ba8e9bf", - "type": "basic.input", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "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": {}, - "state": { - "pan": { - "x": 45.83406713517239, - "y": 43.306661649315814 - }, - "zoom": 0.85276198387146 - } - } -} \ No newline at end of file diff --git a/demo/div.ice b/demo/div.ice deleted file mode 100644 index 0a83e14c5..000000000 --- a/demo/div.ice +++ /dev/null @@ -1,133 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "4aba74c5-d08d-4d91-9401-099c6aeceb64", - "type": "basic.constant", - "data": { - "label": "M", - "value": "12000000" - }, - "position": { - "x": 392, - "y": -104 - } - }, - { - "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": "5e63bca8-458e-4d7a-ae46-dc2e457fdbf7", - "type": "basic.input", - "data": { - "label": "clk", - "name": "clk", - "range": "", - "pins": [ - { - "index": "0", - "name": "CLK", - "value": "21" - } - ], - "virtual": false - }, - "position": { - "x": 64, - "y": 152 - } - }, - { - "id": "400c2d1d-bce3-4d7a-8ab9-078bd072e1b7", - "type": "basic.output", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 752, - "y": 152 - } - } - ], - "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": {}, - "state": { - "pan": { - "x": 3, - "y": 145 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file diff --git a/demo/input-output-bus.ice b/demo/input-output-bus.ice deleted file mode 100644 index b20c6243f..000000000 --- a/demo/input-output-bus.ice +++ /dev/null @@ -1,142 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "a63cb442-f0cf-4802-8542-0b50bf859a3c", - "type": "basic.input", - "data": { - "label": "buttons[0:1]", - "name": "buttons", - "range": "[0:1]", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - }, - { - "index": "1", - "name": "SW2", - "value": "11" - } - ], - "virtual": false - }, - "position": { - "x": 128, - "y": 64 - } - }, - { - "id": "39d544a4-e8fd-4c59-909e-61cddd5e7f98", - "type": "basic.output", - "data": { - "label": "leds[1:0]", - "name": "leds", - "range": "[1:0]", - "pins": [ - { - "index": "1", - "name": "LED0", - "value": "95" - }, - { - "index": "0", - "name": "LED1", - "value": "96" - } - ], - "virtual": false - }, - "position": { - "x": 408, - "y": 64 - } - }, - { - "id": "99ebca85-09ff-456a-8caa-cfa78955e25f", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "D10", - "value": "141" - } - ], - "virtual": false - }, - "position": { - "x": 184, - "y": 248 - } - }, - { - "id": "5b81602a-731c-42bd-9f81-3bec86dbe75c", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED2", - "value": "97" - } - ], - "virtual": false - }, - "position": { - "x": 384, - "y": 248 - } - } - ], - "wires": [ - { - "source": { - "block": "a63cb442-f0cf-4802-8542-0b50bf859a3c", - "port": "out" - }, - "target": { - "block": "39d544a4-e8fd-4c59-909e-61cddd5e7f98", - "port": "in" - }, - "size": 2 - }, - { - "source": { - "block": "99ebca85-09ff-456a-8caa-cfa78955e25f", - "port": "out" - }, - "target": { - "block": "5b81602a-731c-42bd-9f81-3bec86dbe75c", - "port": "in" - } - } - ] - }, - "deps": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } -} diff --git a/demo/input-output.ice b/demo/input-output.ice deleted file mode 100644 index 275d36de2..000000000 --- a/demo/input-output.ice +++ /dev/null @@ -1,79 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "f4405019-32a9-4f31-8e42-441c85f1959c", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 104, - "y": 112 - } - }, - { - "id": "ef08c4f3-94b9-4e85-9fe7-78bc2a376c72", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file diff --git a/demo/multi-block-block.ice b/demo/multi-block-block.ice deleted file mode 100644 index 390f96c24..000000000 --- a/demo/multi-block-block.ice +++ /dev/null @@ -1,276 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "215b7e1b-9d43-410b-ab88-1410f6a39cc1", - "type": "logic.gate.not", - "data": {}, - "position": { - "x": 456, - "y": 64 - } - }, - { - "id": "c39221a3-87dd-4524-9f65-879112b27f51", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 632, - "y": 64 - } - }, - { - "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 96, - "y": 128 - } - }, - { - "id": "c31c5c84-2f92-40f8-abe7-8dc9b214fb39", - "type": "logic.gate.not", - "data": {}, - "position": { - "x": 272, - "y": 128 - } - }, - { - "id": "7be8e651-1218-45ac-ac26-ef34a903e50e", - "type": "logic.gate.not", - "data": {}, - "position": { - "x": 456, - "y": 208 - } - }, - { - "id": "7625149d-3511-4d95-8405-a100409a5d42", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED1", - "value": "96" - } - ], - "virtual": false - }, - "position": { - "x": 632, - "y": 208 - } - } - ], - "wires": [ - { - "source": { - "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", - "port": "out" - }, - "target": { - "block": "c31c5c84-2f92-40f8-abe7-8dc9b214fb39", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" - } - }, - { - "source": { - "block": "c31c5c84-2f92-40f8-abe7-8dc9b214fb39", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "215b7e1b-9d43-410b-ab88-1410f6a39cc1", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" - } - }, - { - "source": { - "block": "215b7e1b-9d43-410b-ab88-1410f6a39cc1", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "c39221a3-87dd-4524-9f65-879112b27f51", - "port": "in" - } - }, - { - "source": { - "block": "c31c5c84-2f92-40f8-abe7-8dc9b214fb39", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "7be8e651-1218-45ac-ac26-ef34a903e50e", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" - } - }, - { - "source": { - "block": "7be8e651-1218-45ac-ac26-ef34a903e50e", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "7625149d-3511-4d95-8405-a100409a5d42", - "port": "in" - } - } - ] - }, - "deps": { - "logic.gate.not": { - "version": "1.0", - "package": { - "name": "NOT", - "version": "1.0.0", - "description": "NOT logic gate", - "author": "Jesús Arroyo", - "image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2291.33%22%20height=%2245.752%22%20version=%221%22%3E%3Cpath%20d=%22M0%2020.446h27v2H0zM70.322%2020.447h15.3v2h-15.3z%22/%3E%3Cpath%20d=%22M66.05%2026.746c-2.9%200-5.3-2.4-5.3-5.3s2.4-5.3%205.3-5.3%205.3%202.4%205.3%205.3-2.4%205.3-5.3%205.3zm0-8.6c-1.8%200-3.3%201.5-3.3%203.3%200%201.8%201.5%203.3%203.3%203.3%201.8%200%203.3-1.5%203.3-3.3%200-1.8-1.5-3.3-3.3-3.3z%22/%3E%3Cpath%20d=%22M25.962%202.563l33.624%2018.883L25.962%2040.33V2.563z%22%20fill=%22none%22%20stroke=%22#000%22%20stroke-width=%223%22/%3E%3C/svg%3E" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "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 - } - }, - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "position": { - "x": 64, - "y": 144 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "position": { - "x": 752, - "y": 144 - } - } - ], - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } - } - }, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file diff --git a/demo/multi-block-output.ice b/demo/multi-block-output.ice deleted file mode 100644 index b50f500c9..000000000 --- a/demo/multi-block-output.ice +++ /dev/null @@ -1,238 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "c39221a3-87dd-4524-9f65-879112b27f51", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 464, - "y": 40 - } - }, - { - "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 96, - "y": 120 - } - }, - { - "id": "b2763905-e8ff-483f-9d94-96c7ed5715f4", - "type": "logic.gate.not", - "data": {}, - "position": { - "x": 272, - "y": 120 - } - }, - { - "id": "7625149d-3511-4d95-8405-a100409a5d42", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED1", - "value": "96" - } - ], - "virtual": false - }, - "position": { - "x": 464, - "y": 208 - } - } - ], - "wires": [ - { - "source": { - "block": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", - "port": "out" - }, - "target": { - "block": "b2763905-e8ff-483f-9d94-96c7ed5715f4", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" - } - }, - { - "source": { - "block": "b2763905-e8ff-483f-9d94-96c7ed5715f4", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "c39221a3-87dd-4524-9f65-879112b27f51", - "port": "in" - } - }, - { - "source": { - "block": "b2763905-e8ff-483f-9d94-96c7ed5715f4", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" - }, - "target": { - "block": "7625149d-3511-4d95-8405-a100409a5d42", - "port": "in" - } - } - ] - }, - "deps": { - "logic.gate.not": { - "version": "1.0", - "package": { - "name": "NOT", - "version": "1.0.0", - "description": "NOT logic gate", - "author": "Jesús Arroyo", - "image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2291.33%22%20height=%2245.752%22%20version=%221%22%3E%3Cpath%20d=%22M0%2020.446h27v2H0zM70.322%2020.447h15.3v2h-15.3z%22/%3E%3Cpath%20d=%22M66.05%2026.746c-2.9%200-5.3-2.4-5.3-5.3s2.4-5.3%205.3-5.3%205.3%202.4%205.3%205.3-2.4%205.3-5.3%205.3zm0-8.6c-1.8%200-3.3%201.5-3.3%203.3%200%201.8%201.5%203.3%203.3%203.3%201.8%200%203.3-1.5%203.3-3.3%200-1.8-1.5-3.3-3.3-3.3z%22/%3E%3Cpath%20d=%22M25.962%202.563l33.624%2018.883L25.962%2040.33V2.563z%22%20fill=%22none%22%20stroke=%22#000%22%20stroke-width=%223%22/%3E%3C/svg%3E" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "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 - } - }, - { - "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", - "type": "basic.input", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "position": { - "x": 64, - "y": 144 - } - }, - { - "id": "664caf9e-5f40-4df4-800a-b626af702e62", - "type": "basic.output", - "data": { - "label": "", - "name": "", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "position": { - "x": 752, - "y": 144 - } - } - ], - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } - } - }, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file diff --git a/demo/multi-constant-generic-block.ice b/demo/multi-constant-generic-block.ice deleted file mode 100644 index c37737af3..000000000 --- a/demo/multi-constant-generic-block.ice +++ /dev/null @@ -1,245 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "3ea55b72-cda0-4f43-886b-e225b00229a4", - "type": "basic.constant", - "data": { - "label": "Value", - "value": "1'b1" - }, - "position": { - "x": 296, - "y": 32 - } - }, - { - "id": "eb6dddea-3a81-4e26-ab7d-ed107b3676c9", - "type": "constant-code-block", - "data": {}, - "position": { - "x": 248, - "y": 184 - } - }, - { - "id": "06bd1d14-7302-4dd7-9e95-650d1070a203", - "type": "basic.output", - "data": { - "label": "led", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 536, - "y": 184 - } - }, - { - "id": "7217b44b-f3e6-4eb6-862b-1d55c0655ee7", - "type": "constant-code-block", - "data": {}, - "position": { - "x": 392, - "y": 328 - } - }, - { - "id": "019e1dba-a150-483a-9c95-c2970ec781a9", - "type": "basic.output", - "data": { - "label": "led", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED1", - "value": "96" - } - ], - "virtual": false - }, - "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" - }, - "vertices": [ - { - "x": 472, - "y": 152 - } - ] - } - ] - }, - "deps": { - "constant-code-block": { - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "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", - "name": "led", - "range": "", - "pins": [ - { - "index": "0", - "name": "", - "value": 0 - } - ], - "virtual": false - }, - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 1 - } - } - } - }, - "state": { - "pan": { - "x": -139, - "y": 20 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file diff --git a/demo/multi-input-output.ice b/demo/multi-input-output.ice deleted file mode 100644 index 9bb7b741e..000000000 --- a/demo/multi-input-output.ice +++ /dev/null @@ -1,110 +0,0 @@ -{ - "version": "1.0", - "package": { - "name": "", - "version": "", - "description": "", - "author": "", - "image": "" - }, - "design": { - "board": "icezum", - "graph": { - "blocks": [ - { - "id": "4f302bff-d4d1-4d6f-a7ec-b74698a3cd03", - "type": "basic.input", - "data": { - "label": "in", - "name": "in", - "range": "", - "pins": [ - { - "index": "0", - "name": "SW1", - "value": "10" - } - ], - "virtual": false - }, - "position": { - "x": 168, - "y": 120 - } - }, - { - "id": "c39221a3-87dd-4524-9f65-879112b27f51", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED0", - "value": "95" - } - ], - "virtual": false - }, - "position": { - "x": 480, - "y": 120 - } - }, - { - "id": "7625149d-3511-4d95-8405-a100409a5d42", - "type": "basic.output", - "data": { - "label": "out", - "name": "out", - "range": "", - "pins": [ - { - "index": "0", - "name": "LED1", - "value": "96" - } - ], - "virtual": false - }, - "position": { - "x": 400, - "y": 232 - } - } - ], - "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": {}, - "state": { - "pan": { - "x": 0, - "y": 0 - }, - "zoom": 0.9999999403953552 - } - } -} \ No newline at end of file From 5b80992d676bfe75062910315b1ea98d12d61db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 19:24:27 +0100 Subject: [PATCH 34/35] Update all blocks to final format 1.0 --- app/resources/blocks/bit/0.ice | 22 +- app/resources/blocks/bit/1.ice | 20 +- app/resources/blocks/config/pull_up.ice | 35 ++- app/resources/blocks/config/pull_up_inv.ice | 35 ++- app/resources/blocks/config/tri_state.ice | 63 +++- .../blocks/logic/combinational/demux_1_2.ice | 89 ++++-- .../blocks/logic/combinational/demux_1_4.ice | 144 ++++++--- .../blocks/logic/combinational/demux_1_8.ice | 279 +++++++++++++----- .../logic/combinational/hex_7seg_ca.ice | 212 +++++++++++-- .../logic/combinational/hex_7seg_cc.ice | 202 +++++++++++-- .../blocks/logic/combinational/mux_2_1.ice | 63 +++- .../blocks/logic/combinational/mux_4_1.ice | 110 ++++++- app/resources/blocks/logic/gate/and.ice | 48 ++- app/resources/blocks/logic/gate/nand.ice | 48 ++- app/resources/blocks/logic/gate/nor.ice | 46 ++- app/resources/blocks/logic/gate/not.ice | 33 ++- app/resources/blocks/logic/gate/or.ice | 48 ++- app/resources/blocks/logic/gate/xnor.ice | 46 ++- app/resources/blocks/logic/gate/xor.ice | 48 ++- .../blocks/logic/sequential/debouncer.ice | 66 ++++- .../blocks/logic/sequential/dff_ar.ice | 93 +++++- .../blocks/logic/sequential/dff_sr.ice | 91 +++++- .../blocks/logic/sequential/tff_ar.ice | 93 +++++- .../blocks/logic/sequential/tff_sr.ice | 93 +++++- app/scripts/services/project.service.js | 20 +- 25 files changed, 1673 insertions(+), 374 deletions(-) diff --git a/app/resources/blocks/bit/0.ice b/app/resources/blocks/bit/0.ice index ae9f54780..3c7f9feba 100644 --- a/app/resources/blocks/bit/0.ice +++ b/app/resources/blocks/bit/0.ice @@ -12,21 +12,20 @@ "graph": { "blocks": [ { - "id": "1a748af9-e00b-40ae-a3d9-030da7397247", + "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", "type": "basic.code", "data": { "code": "// Bit 0\n\nassign v = 1'b0;", + "params": [], "ports": { "in": [], "out": [ { - "label": "v", "name": "v", "size": 1 } ] - }, - "params": [] + } }, "position": { "x": 96, @@ -34,16 +33,15 @@ } }, { - "id": "355855e8-69a6-472a-9212-dd5c3bece567", + "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "type": "basic.output", "data": { - "label": "", - "range": "", + "name": "", "pins": [ { "index": "0", "name": "", - "value": 0 + "value": "0" } ], "virtual": true @@ -57,11 +55,11 @@ "wires": [ { "source": { - "block": "1a748af9-e00b-40ae-a3d9-030da7397247", + "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", "port": "v" }, "target": { - "block": "355855e8-69a6-472a-9212-dd5c3bece567", + "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "port": "in" } } @@ -73,7 +71,7 @@ "x": 0, "y": 0 }, - "zoom": 1.0000000353093697 + "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/bit/1.ice b/app/resources/blocks/bit/1.ice index 4ae355e75..87964be30 100644 --- a/app/resources/blocks/bit/1.ice +++ b/app/resources/blocks/bit/1.ice @@ -12,21 +12,20 @@ "graph": { "blocks": [ { - "id": "12170bab-1206-41e6-9b74-da1c86af6019", + "id": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", "type": "basic.code", "data": { "code": "// Bit 1\n\nassign v = 1'b1;", + "params": [], "ports": { "in": [], "out": [ { - "label": "v", "name": "v", "size": 1 } ] - }, - "params": [] + } }, "position": { "x": 96, @@ -34,16 +33,15 @@ } }, { - "id": "34f97cd9-8ec6-4ae3-a19e-606a977e1517", + "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "type": "basic.output", "data": { - "label": "", - "range": "", + "name": "", "pins": [ { "index": "0", "name": "", - "value": 0 + "value": "0" } ], "virtual": true @@ -57,11 +55,11 @@ "wires": [ { "source": { - "block": "12170bab-1206-41e6-9b74-da1c86af6019", + "block": "b959fb96-ac67-4aea-90b3-ed35a4c17bf5", "port": "v" }, "target": { - "block": "34f97cd9-8ec6-4ae3-a19e-606a977e1517", + "block": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "port": "in" } } @@ -76,4 +74,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/config/pull_up.ice b/app/resources/blocks/config/pull_up.ice index d36960ce3..d0a3a3e8c 100644 --- a/app/resources/blocks/config/pull_up.ice +++ b/app/resources/blocks/config/pull_up.ice @@ -16,12 +16,19 @@ "type": "basic.code", "data": { "code": "// Pull up\n\nwire din, dout, outen;\n\nassign o = din;\n\nSB_IO #(\n .PIN_TYPE(6'b 1010_01),\n .PULLUP(1'b 1)\n) io_pin (\n .PACKAGE_PIN(i),\n .OUTPUT_ENABLE(outen),\n .D_OUT_0(dout),\n .D_IN_0(din)\n);", + "params": [], "ports": { "in": [ - "i" + { + "name": "i", + "size": 1 + } ], "out": [ - "o" + { + "name": "o", + "size": 1 + } ] } }, @@ -34,7 +41,15 @@ "id": "bb4a1ca9-1b30-471e-92ca-ca7ff2fc1150", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -45,7 +60,15 @@ "id": "a139fa0d-9b45-4480-a251-f4a66b49aa23", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 760, @@ -79,8 +102,8 @@ "deps": {}, "state": { "pan": { - "x": -23, - "y": 8 + "x": 0, + "y": 0 }, "zoom": 1 } diff --git a/app/resources/blocks/config/pull_up_inv.ice b/app/resources/blocks/config/pull_up_inv.ice index 6d8b8a698..129e0c67c 100644 --- a/app/resources/blocks/config/pull_up_inv.ice +++ b/app/resources/blocks/config/pull_up_inv.ice @@ -16,12 +16,19 @@ "type": "basic.code", "data": { "code": "// Pull up inv\n\nwire din, dout, outen;\n\nassign o = ~din;\n\nSB_IO #(\n .PIN_TYPE(6'b 1010_01),\n .PULLUP(1'b 1)\n) io_pin (\n .PACKAGE_PIN(i),\n .OUTPUT_ENABLE(outen),\n .D_OUT_0(dout),\n .D_IN_0(din)\n);", + "params": [], "ports": { "in": [ - "i" + { + "name": "i", + "size": 1 + } ], "out": [ - "o" + { + "name": "o", + "size": 1 + } ] } }, @@ -34,7 +41,15 @@ "id": "bb4a1ca9-1b30-471e-92ca-ca7ff2fc1150", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -45,7 +60,15 @@ "id": "a139fa0d-9b45-4480-a251-f4a66b49aa23", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 760, @@ -79,8 +102,8 @@ "deps": {}, "state": { "pan": { - "x": -23, - "y": 8 + "x": 0, + "y": 0 }, "zoom": 1 } diff --git a/app/resources/blocks/config/tri_state.ice b/app/resources/blocks/config/tri_state.ice index 6a673429d..7168cffa6 100644 --- a/app/resources/blocks/config/tri_state.ice +++ b/app/resources/blocks/config/tri_state.ice @@ -16,14 +16,27 @@ "type": "basic.code", "data": { "code": " SB_IO #(\n .PIN_TYPE(6'b1010_01),\n .PULLUP(1'b0)\n ) triState (\n .PACKAGE_PIN(pin),\n .OUTPUT_ENABLE(oe),\n .D_OUT_0(din),\n .D_IN_0(dout)\n );", + "params": [], "ports": { "in": [ - "pin", - "oe", - "din" + { + "name": "pin", + "size": 1 + }, + { + "name": "oe", + "size": 1 + }, + { + "name": "din", + "size": 1 + } ], "out": [ - "dout" + { + "name": "dout", + "size": 1 + } ] } }, @@ -36,7 +49,15 @@ "id": "076fd025-aa42-4f23-ae97-b65aec2298ce", "type": "basic.input", "data": { - "label": "pin" + "name": "pin", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 32, @@ -47,7 +68,15 @@ "id": "f96a1baf-fc8b-4c25-b132-12552605743f", "type": "basic.input", "data": { - "label": "oe" + "name": "oe", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 32, @@ -58,7 +87,15 @@ "id": "0b2a85b3-b6ac-4e8a-8b16-dd5a195fb058", "type": "basic.output", "data": { - "label": "dout" + "name": "dout", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 760, @@ -69,7 +106,15 @@ "id": "04fdb7a7-2740-4ff1-ad26-56407ef5b958", "type": "basic.input", "data": { - "label": "din" + "name": "din", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 32, @@ -129,4 +174,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/combinational/demux_1_2.ice b/app/resources/blocks/logic/combinational/demux_1_2.ice index 3e844f7e2..6e35eb0a4 100644 --- a/app/resources/blocks/logic/combinational/demux_1_2.ice +++ b/app/resources/blocks/logic/combinational/demux_1_2.ice @@ -16,64 +16,109 @@ "type": "basic.code", "data": { "code": "assign {out1,out0} = in0 << sel0;", + "params": [], "ports": { "in": [ - "in0", - "sel0" + { + "name": "in0", + "size": 1 + }, + { + "name": "sel0", + "size": 1 + } ], "out": [ - "out0", - "out1" + { + "name": "out0", + "size": 1 + }, + { + "name": "out1", + "size": 1 + } ] } }, "position": { - "x": 208, - "y": 64 + "x": 248, + "y": 88 } }, { "id": "5fc9a8e9-d463-4c1f-b6a3-185d5cabb406", "type": "basic.input", "data": { - "label": "i" + "name": "i", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 0, - "y": 96 + "x": 40, + "y": 120 } }, { "id": "91e2ff2d-2430-41e5-9d21-bc9ec4082aaa", "type": "basic.output", "data": { - "label": "o0" + "name": "o0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 720, - "y": 96 + "x": 760, + "y": 120 } }, { "id": "75cafe5a-1968-49ed-9e05-70d1bc3fbd0f", "type": "basic.input", "data": { - "label": "sel" + "name": "sel", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 0, - "y": 224 + "x": 40, + "y": 248 } }, { "id": "c6dc7002-dfc0-45fd-88e2-b5e5a75231f2", "type": "basic.output", "data": { - "label": "o1" + "name": "o1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 720, - "y": 224 + "x": 760, + "y": 248 } } ], @@ -123,10 +168,10 @@ "deps": {}, "state": { "pan": { - "x": 104.8444188797269, - "y": 152.1580250587398 + "x": 0, + "y": 0 }, - "zoom": 0.8586960682653878 + "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/combinational/demux_1_4.ice b/app/resources/blocks/logic/combinational/demux_1_4.ice index 8a4a6fa81..216ad1229 100644 --- a/app/resources/blocks/logic/combinational/demux_1_4.ice +++ b/app/resources/blocks/logic/combinational/demux_1_4.ice @@ -15,11 +15,19 @@ "id": "91e2ff2d-2430-41e5-9d21-bc9ec4082aaa", "type": "basic.output", "data": { - "label": "o0" + "name": "o0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 760, - "y": 40 + "x": 800, + "y": 64 } }, { @@ -27,89 +35,159 @@ "type": "basic.code", "data": { "code": "assign {out3,out2,out1,out0} = in0 << {sel1,sel0};", + "params": [], "ports": { "in": [ - "in0", - "sel0", - "sel1" + { + "name": "in0", + "size": 1 + }, + { + "name": "sel0", + "size": 1 + }, + { + "name": "sel1", + "size": 1 + } ], "out": [ - "out0", - "out1", - "out2", - "out3" + { + "name": "out0", + "size": 1 + }, + { + "name": "out1", + "size": 1 + }, + { + "name": "out2", + "size": 1 + }, + { + "name": "out3", + "size": 1 + } ] } }, "position": { - "x": 208, - "y": 64 + "x": 248, + "y": 88 } }, { "id": "5fc9a8e9-d463-4c1f-b6a3-185d5cabb406", "type": "basic.input", "data": { - "label": "i" + "name": "i", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 72 + "x": 56, + "y": 96 } }, { "id": "c6dc7002-dfc0-45fd-88e2-b5e5a75231f2", "type": "basic.output", "data": { - "label": "o1" + "name": "o1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 760, - "y": 120 + "x": 800, + "y": 144 } }, { "id": "75cafe5a-1968-49ed-9e05-70d1bc3fbd0f", "type": "basic.input", "data": { - "label": "sel0" + "name": "sel0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 160 + "x": 56, + "y": 184 } }, { "id": "5e246f93-51ad-4d6f-83f1-4fcce69c5ae3", "type": "basic.output", "data": { - "label": "o2" + "name": "o2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 760, - "y": 200 + "x": 800, + "y": 224 } }, { "id": "657dab9e-6580-4f02-b54f-66477863f26a", "type": "basic.input", "data": { - "label": "sel1" + "name": "sel1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 248 + "x": 56, + "y": 272 } }, { "id": "b9d764ea-538a-420f-a8d3-45af7a8e30a2", "type": "basic.output", "data": { - "label": "o3" + "name": "o3", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 760, - "y": 280 + "x": 800, + "y": 304 } } ], @@ -189,10 +267,10 @@ "deps": {}, "state": { "pan": { - "x": 75.84442855228853, - "y": 63.15803102316195 + "x": 11.176135344899718, + "y": 3.2150526334643024 }, - "zoom": 0.8586960434913635 + "zoom": 0.9234510996506167 } } } diff --git a/app/resources/blocks/logic/combinational/demux_1_8.ice b/app/resources/blocks/logic/combinational/demux_1_8.ice index 0784a2757..823421011 100644 --- a/app/resources/blocks/logic/combinational/demux_1_8.ice +++ b/app/resources/blocks/logic/combinational/demux_1_8.ice @@ -15,44 +15,76 @@ "id": "91e2ff2d-2430-41e5-9d21-bc9ec4082aaa", "type": "basic.output", "data": { - "label": "o0" + "name": "o0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": -128 + "x": 760, + "y": -120 } }, { "id": "c6dc7002-dfc0-45fd-88e2-b5e5a75231f2", "type": "basic.output", "data": { - "label": "o1" + "name": "o1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": -48 + "x": 760, + "y": -40 } }, { "id": "5e246f93-51ad-4d6f-83f1-4fcce69c5ae3", "type": "basic.output", "data": { - "label": "o2" + "name": "o2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 32 + "x": 760, + "y": 40 } }, { "id": "5fc9a8e9-d463-4c1f-b6a3-185d5cabb406", "type": "basic.input", "data": { - "label": "i" + "name": "i", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 40 + "x": -8, + "y": 48 } }, { @@ -60,116 +92,217 @@ "type": "basic.code", "data": { "code": "assign {out7,out6,out5,out4,out3,out2,out1,out0} = in0 << {sel2,sel1,sel0};", + "params": [], "ports": { "in": [ - "in0", - "sel0", - "sel1", - "sel2" + { + "name": "in0", + "size": 1 + }, + { + "name": "sel0", + "size": 1 + }, + { + "name": "sel1", + "size": 1 + }, + { + "name": "sel2", + "size": 1 + } ], "out": [ - "out0", - "out1", - "out2", - "out3", - "out4", - "out5", - "out6", - "out7" + { + "name": "out0", + "size": 1 + }, + { + "name": "out1", + "size": 1 + }, + { + "name": "out2", + "size": 1 + }, + { + "name": "out3", + "size": 1 + }, + { + "name": "out4", + "size": 1 + }, + { + "name": "out5", + "size": 1 + }, + { + "name": "out6", + "size": 1 + }, + { + "name": "out7", + "size": 1 + } ] } }, "position": { - "x": 208, - "y": 64 + "x": 184, + "y": 72 } }, { "id": "b9d764ea-538a-420f-a8d3-45af7a8e30a2", "type": "basic.output", "data": { - "label": "o3" + "name": "o3", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 112 + "x": 760, + "y": 120 } }, { "id": "75cafe5a-1968-49ed-9e05-70d1bc3fbd0f", "type": "basic.input", "data": { - "label": "sel0" + "name": "sel0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 120 + "x": -8, + "y": 128 } }, { "id": "657dab9e-6580-4f02-b54f-66477863f26a", "type": "basic.input", "data": { - "label": "sel1" + "name": "sel1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 200 + "x": -8, + "y": 208 } }, { "id": "1b8510ac-d723-4226-bf28-c7329d0f73fb", "type": "basic.output", "data": { - "label": "o4" + "name": "o4", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 208 + "x": 760, + "y": 216 } }, { "id": "e1a156c8-5813-46f6-a4d4-c672857f3396", "type": "basic.input", "data": { - "label": "sel2" + "name": "sel2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 16, - "y": 280 + "x": -8, + "y": 288 } }, { "id": "65f31fca-d607-4d5c-82cc-878a93b8e580", "type": "basic.output", "data": { - "label": "o5" + "name": "o5", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 304 + "x": 760, + "y": 312 } }, { "id": "c8fadd68-77e1-47be-a262-b076e878e6fd", "type": "basic.output", "data": { - "label": "o6" + "name": "o6", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 384 + "x": 760, + "y": 392 } }, { "id": "99ca2a23-7e0d-4c34-9ab1-988c6bf69633", "type": "basic.output", "data": { - "label": "o7" + "name": "o7", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 784, - "y": 464 + "x": 760, + "y": 472 } } ], @@ -225,8 +358,8 @@ }, "vertices": [ { - "x": 664, - "y": -24 + "x": 640, + "y": -16 } ] }, @@ -241,8 +374,8 @@ }, "vertices": [ { - "x": 664, - "y": 416 + "x": 640, + "y": 424 } ] }, @@ -257,8 +390,8 @@ }, "vertices": [ { - "x": 680, - "y": 32 + "x": 656, + "y": 40 } ] }, @@ -273,8 +406,8 @@ }, "vertices": [ { - "x": 696, - "y": 112 + "x": 672, + "y": 120 } ] }, @@ -289,8 +422,8 @@ }, "vertices": [ { - "x": 712, - "y": 176 + "x": 688, + "y": 184 } ] }, @@ -315,8 +448,8 @@ }, "vertices": [ { - "x": 696, - "y": 288 + "x": 672, + "y": 296 } ] }, @@ -331,20 +464,20 @@ }, "vertices": [ { - "x": 680, - "y": 320 + "x": 656, + "y": 328 }, { - "x": 680, - "y": 360 + "x": 656, + "y": 368 }, { - "x": 680, - "y": 376 + "x": 656, + "y": 384 }, { - "x": 688, - "y": 416 + "x": 664, + "y": 424 } ] } @@ -353,10 +486,10 @@ "deps": {}, "state": { "pan": { - "x": 75.69774669071234, - "y": 148.91048230054443 + "x": 143.76402059142058, + "y": 110.755583226028 }, - "zoom": 0.6331667332315369 + "zoom": 0.7272029968400818 } } } diff --git a/app/resources/blocks/logic/combinational/hex_7seg_ca.ice b/app/resources/blocks/logic/combinational/hex_7seg_ca.ice index 6dc70db99..4435b169b 100644 --- a/app/resources/blocks/logic/combinational/hex_7seg_ca.ice +++ b/app/resources/blocks/logic/combinational/hex_7seg_ca.ice @@ -15,7 +15,15 @@ "id": "8b73e273-3603-443a-b952-0ab9ad826a96", "type": "basic.output", "data": { - "label": "a" + "name": "a", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -26,7 +34,15 @@ "id": "f2fce5fa-be07-46fe-bee1-bb2a497fe747", "type": "basic.output", "data": { - "label": "b" + "name": "b", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -37,7 +53,15 @@ "id": "16e44a6a-853a-4264-9e9d-2269827ed136", "type": "basic.input", "data": { - "label": "h0" + "name": "h0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -49,21 +73,55 @@ "type": "basic.code", "data": { "code": "// Ánodo común\n// gfe_dcba\nlocalparam BCD_0 = 7'b011_1111,\n BCD_1 = 7'b000_0110,\n BCD_2 = 7'b101_1011,\n BCD_3 = 7'b100_1111,\n BCD_4 = 7'b110_0110,\n BCD_5 = 7'b110_1101,\n BCD_6 = 7'b111_1101,\n BCD_7 = 7'b000_0111,\n BCD_8 = 7'b111_1111,\n BCD_9 = 7'b110_1111,\n BCD_A = 7'b111_0111,\n BCD_B = 7'b111_1100,\n BCD_C = 7'b011_1001,\n BCD_D = 7'b101_1110,\n BCD_E = 7'b111_1001,\n BCD_F = 7'b111_0001;\n\nreg [6:0] _o;\n\nalways @(*)\nbegin\n\n case({h3, h2, h1, h0})\n 4'h0: _o <= BCD_0;\n 4'h1: _o <= BCD_1;\n 4'h2: _o <= BCD_2;\n 4'h3: _o <= BCD_3;\n 4'h4: _o <= BCD_4;\n 4'h5: _o <= BCD_5;\n 4'h6: _o <= BCD_6;\n 4'h7: _o <= BCD_7;\n 4'h8: _o <= BCD_8;\n 4'h9: _o <= BCD_9;\n 4'hA: _o <= BCD_A;\n 4'hB: _o <= BCD_B;\n 4'hC: _o <= BCD_C;\n 4'hD: _o <= BCD_D;\n 4'hE: _o <= BCD_E;\n 4'hF: _o <= BCD_F;\n default: _o <= 0;\n endcase\nend\n\nassign {g, f, e, d, c, b, a} = ~_o;", + "params": [], "ports": { "in": [ - "h0", - "h1", - "h2", - "h3" + { + "name": "h0", + "size": 1 + }, + { + "name": "h1", + "size": 1 + }, + { + "name": "h2", + "size": 1 + }, + { + "name": "h3", + "size": 1 + } ], "out": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + }, + { + "name": "c", + "size": 1 + }, + { + "name": "d", + "size": 1 + }, + { + "name": "e", + "size": 1 + }, + { + "name": "f", + "size": 1 + }, + { + "name": "g", + "size": 1 + } ] } }, @@ -76,7 +134,15 @@ "id": "bf0ea22e-3ac2-4756-87d5-020a6ea6a1a8", "type": "basic.output", "data": { - "label": "c" + "name": "c", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -87,7 +153,15 @@ "id": "9cdbdf9f-f086-4427-9719-e13470658d97", "type": "basic.input", "data": { - "label": "h1" + "name": "h1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -98,7 +172,15 @@ "id": "4687e984-3f19-44d7-baee-ca89513f8f1a", "type": "basic.output", "data": { - "label": "d" + "name": "d", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -109,7 +191,15 @@ "id": "f40ab7a8-10e5-4e7f-94f9-cefd697d5d40", "type": "basic.input", "data": { - "label": "h2" + "name": "h2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -120,7 +210,15 @@ "id": "1691b072-9102-4986-a900-fefd1a5a7b9e", "type": "basic.output", "data": { - "label": "e" + "name": "e", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -131,7 +229,15 @@ "id": "2d774807-3ec8-492c-98e2-f1c9da8d68ff", "type": "basic.input", "data": { - "label": "h3" + "name": "h3", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -142,7 +248,15 @@ "id": "7c14afe7-1ac0-4394-b38e-fa8a00ffa21c", "type": "basic.output", "data": { - "label": "f" + "name": "f", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -153,7 +267,15 @@ "id": "2565c42b-00b0-4b1d-92a4-66c715834b33", "type": "basic.output", "data": { - "label": "g" + "name": "g", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -230,7 +352,13 @@ "target": { "block": "f2fce5fa-be07-46fe-bee1-bb2a497fe747", "port": "in" - } + }, + "vertices": [ + { + "x": 952, + "y": 504 + } + ] }, { "source": { @@ -240,7 +368,13 @@ "target": { "block": "8b73e273-3603-443a-b952-0ab9ad826a96", "port": "in" - } + }, + "vertices": [ + { + "x": 928, + "y": 440 + } + ] }, { "source": { @@ -250,7 +384,13 @@ "target": { "block": "1691b072-9102-4986-a900-fefd1a5a7b9e", "port": "in" - } + }, + "vertices": [ + { + "x": 976, + "y": 704 + } + ] }, { "source": { @@ -260,7 +400,13 @@ "target": { "block": "7c14afe7-1ac0-4394-b38e-fa8a00ffa21c", "port": "in" - } + }, + "vertices": [ + { + "x": 952, + "y": 752 + } + ] }, { "source": { @@ -270,17 +416,23 @@ "target": { "block": "2565c42b-00b0-4b1d-92a4-66c715834b33", "port": "in" - } + }, + "vertices": [ + { + "x": 928, + "y": 824 + } + ] } ] }, "deps": {}, "state": { "pan": { - "x": -155.98941303266986, - "y": -230.62665026580393 + "x": -152.07320110504, + "y": -209.21075900090992 }, - "zoom": 0.7823535799980164 + "zoom": 0.7373584811199316 } } } diff --git a/app/resources/blocks/logic/combinational/hex_7seg_cc.ice b/app/resources/blocks/logic/combinational/hex_7seg_cc.ice index 2aa29a892..9d64d44c5 100644 --- a/app/resources/blocks/logic/combinational/hex_7seg_cc.ice +++ b/app/resources/blocks/logic/combinational/hex_7seg_cc.ice @@ -15,7 +15,15 @@ "id": "8b73e273-3603-443a-b952-0ab9ad826a96", "type": "basic.output", "data": { - "label": "a" + "name": "a", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -26,7 +34,15 @@ "id": "f2fce5fa-be07-46fe-bee1-bb2a497fe747", "type": "basic.output", "data": { - "label": "b" + "name": "b", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -37,7 +53,15 @@ "id": "16e44a6a-853a-4264-9e9d-2269827ed136", "type": "basic.input", "data": { - "label": "h0" + "name": "h0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -49,21 +73,55 @@ "type": "basic.code", "data": { "code": "// Catodo común\n// gfe_dcba\nlocalparam BCD_0 = 7'b011_1111,\n BCD_1 = 7'b000_0110,\n BCD_2 = 7'b101_1011,\n BCD_3 = 7'b100_1111,\n BCD_4 = 7'b110_0110,\n BCD_5 = 7'b110_1101,\n BCD_6 = 7'b111_1101,\n BCD_7 = 7'b000_0111,\n BCD_8 = 7'b111_1111,\n BCD_9 = 7'b110_1111,\n BCD_A = 7'b111_0111,\n BCD_B = 7'b111_1100,\n BCD_C = 7'b011_1001,\n BCD_D = 7'b101_1110,\n BCD_E = 7'b111_1001,\n BCD_F = 7'b111_0001;\n\nreg [6:0] _o;\n\nalways @(*)\nbegin\n\n case({h3, h2, h1, h0})\n 4'h0: _o <= BCD_0;\n 4'h1: _o <= BCD_1;\n 4'h2: _o <= BCD_2;\n 4'h3: _o <= BCD_3;\n 4'h4: _o <= BCD_4;\n 4'h5: _o <= BCD_5;\n 4'h6: _o <= BCD_6;\n 4'h7: _o <= BCD_7;\n 4'h8: _o <= BCD_8;\n 4'h9: _o <= BCD_9;\n 4'hA: _o <= BCD_A;\n 4'hB: _o <= BCD_B;\n 4'hC: _o <= BCD_C;\n 4'hD: _o <= BCD_D;\n 4'hE: _o <= BCD_E;\n 4'hF: _o <= BCD_F;\n default: _o <= 0;\n endcase\nend\n\nassign {g, f, e, d, c, b, a} = _o;", + "params": [], "ports": { "in": [ - "h0", - "h1", - "h2", - "h3" + { + "name": "h0", + "size": 1 + }, + { + "name": "h1", + "size": 1 + }, + { + "name": "h2", + "size": 1 + }, + { + "name": "h3", + "size": 1 + } ], "out": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + }, + { + "name": "c", + "size": 1 + }, + { + "name": "d", + "size": 1 + }, + { + "name": "e", + "size": 1 + }, + { + "name": "f", + "size": 1 + }, + { + "name": "g", + "size": 1 + } ] } }, @@ -76,7 +134,15 @@ "id": "bf0ea22e-3ac2-4756-87d5-020a6ea6a1a8", "type": "basic.output", "data": { - "label": "c" + "name": "c", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -87,7 +153,15 @@ "id": "9cdbdf9f-f086-4427-9719-e13470658d97", "type": "basic.input", "data": { - "label": "h1" + "name": "h1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -98,7 +172,15 @@ "id": "4687e984-3f19-44d7-baee-ca89513f8f1a", "type": "basic.output", "data": { - "label": "d" + "name": "d", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -109,7 +191,15 @@ "id": "f40ab7a8-10e5-4e7f-94f9-cefd697d5d40", "type": "basic.input", "data": { - "label": "h2" + "name": "h2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -120,7 +210,15 @@ "id": "1691b072-9102-4986-a900-fefd1a5a7b9e", "type": "basic.output", "data": { - "label": "e" + "name": "e", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -131,7 +229,15 @@ "id": "2d774807-3ec8-492c-98e2-f1c9da8d68ff", "type": "basic.input", "data": { - "label": "h3" + "name": "h3", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 312, @@ -142,7 +248,15 @@ "id": "7c14afe7-1ac0-4394-b38e-fa8a00ffa21c", "type": "basic.output", "data": { - "label": "f" + "name": "f", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -153,7 +267,15 @@ "id": "2565c42b-00b0-4b1d-92a4-66c715834b33", "type": "basic.output", "data": { - "label": "g" + "name": "g", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 1016, @@ -230,7 +352,13 @@ "target": { "block": "f2fce5fa-be07-46fe-bee1-bb2a497fe747", "port": "in" - } + }, + "vertices": [ + { + "x": 952, + "y": 528 + } + ] }, { "source": { @@ -240,7 +368,13 @@ "target": { "block": "8b73e273-3603-443a-b952-0ab9ad826a96", "port": "in" - } + }, + "vertices": [ + { + "x": 928, + "y": 448 + } + ] }, { "source": { @@ -260,7 +394,13 @@ "target": { "block": "7c14afe7-1ac0-4394-b38e-fa8a00ffa21c", "port": "in" - } + }, + "vertices": [ + { + "x": 952, + "y": 776 + } + ] }, { "source": { @@ -270,7 +410,13 @@ "target": { "block": "2565c42b-00b0-4b1d-92a4-66c715834b33", "port": "in" - } + }, + "vertices": [ + { + "x": 928, + "y": 824 + } + ] } ] }, @@ -280,7 +426,7 @@ "x": -152.07320110504, "y": -209.21075900090992 }, - "zoom": 0.7373584508895874 + "zoom": 0.7373584371699413 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/combinational/mux_2_1.ice b/app/resources/blocks/logic/combinational/mux_2_1.ice index f10bd5288..1e939fdf3 100644 --- a/app/resources/blocks/logic/combinational/mux_2_1.ice +++ b/app/resources/blocks/logic/combinational/mux_2_1.ice @@ -16,14 +16,27 @@ "type": "basic.code", "data": { "code": "reg _o;\n\nalways @(*) begin\n case(sel0)\n 0: _o = in0;\n 1: _o = in1;\n default: _o = in0;\n endcase\nend\n\nassign o = _o;", + "params": [], "ports": { "in": [ - "in0", - "in1", - "sel0" + { + "name": "in0", + "size": 1 + }, + { + "name": "in1", + "size": 1 + }, + { + "name": "sel0", + "size": 1 + } ], "out": [ - "o" + { + "name": "o", + "size": 1 + } ] } }, @@ -36,7 +49,15 @@ "id": "c3f73f68-1074-4355-b69f-6a20f7bea3e7", "type": "basic.input", "data": { - "label": "i0" + "name": "i0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 80, @@ -47,7 +68,15 @@ "id": "5fb29465-2ee7-45bb-afa4-9a3de895c774", "type": "basic.input", "data": { - "label": "i1" + "name": "i1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 80, @@ -58,7 +87,15 @@ "id": "061aa997-2f30-4591-8841-fb6abf5c3b2e", "type": "basic.output", "data": { - "label": "o" + "name": "o", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 792, @@ -69,7 +106,15 @@ "id": "67ed5e09-486d-4f97-929f-aefea9c43951", "type": "basic.input", "data": { - "label": "sel" + "name": "sel", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 80, @@ -126,7 +171,7 @@ "x": -21.03752160981206, "y": 29.479234822175684 }, - "zoom": 1.000000703366588 + "zoom": 1 } } } diff --git a/app/resources/blocks/logic/combinational/mux_4_1.ice b/app/resources/blocks/logic/combinational/mux_4_1.ice index 7480c7521..66b25ea73 100644 --- a/app/resources/blocks/logic/combinational/mux_4_1.ice +++ b/app/resources/blocks/logic/combinational/mux_4_1.ice @@ -15,7 +15,15 @@ "id": "c3f73f68-1074-4355-b69f-6a20f7bea3e7", "type": "basic.input", "data": { - "label": "i0" + "name": "i0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -26,7 +34,15 @@ "id": "5fb29465-2ee7-45bb-afa4-9a3de895c774", "type": "basic.input", "data": { - "label": "i1" + "name": "i1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -38,17 +54,39 @@ "type": "basic.code", "data": { "code": "reg _o;\nwire [1:0] _sel;\n\nassign _sel = {sel1, sel0};\n\nalways @(*) begin\n case(_sel)\n 0: _o = in0;\n 1: _o = in1;\n 2: _o = in2;\n 3: _o = in3;\n default: _o = in0;\n endcase\nend\n\nassign o = _o;", + "params": [], "ports": { "in": [ - "in0", - "in1", - "in2", - "in3", - "sel0", - "sel1" + { + "name": "in0", + "size": 1 + }, + { + "name": "in1", + "size": 1 + }, + { + "name": "in2", + "size": 1 + }, + { + "name": "in3", + "size": 1 + }, + { + "name": "sel0", + "size": 1 + }, + { + "name": "sel1", + "size": 1 + } ], "out": [ - "o" + { + "name": "o", + "size": 1 + } ] } }, @@ -61,7 +99,15 @@ "id": "67ed5e09-486d-4f97-929f-aefea9c43951", "type": "basic.input", "data": { - "label": "i2" + "name": "i2", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -72,7 +118,15 @@ "id": "061aa997-2f30-4591-8841-fb6abf5c3b2e", "type": "basic.output", "data": { - "label": "o" + "name": "o", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 776, @@ -83,7 +137,15 @@ "id": "8be9cded-6d06-4b23-b73c-94c7ff311dbc", "type": "basic.input", "data": { - "label": "i3" + "name": "i3", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -94,7 +156,15 @@ "id": "1b7db016-c89a-4f65-b6f0-0f87c851c077", "type": "basic.input", "data": { - "label": "sel0" + "name": "sel0", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -105,7 +175,15 @@ "id": "a014971e-5470-490b-9058-b4b00f2dd125", "type": "basic.input", "data": { - "label": "sel1" + "name": "sel1", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 40, @@ -204,7 +282,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999999994884 + "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/gate/and.ice b/app/resources/blocks/logic/gate/and.ice index 64b081da8..41d70ac1c 100644 --- a/app/resources/blocks/logic/gate/and.ice +++ b/app/resources/blocks/logic/gate/and.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// AND logic gate\n\nassign c = a & b;", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -104,7 +138,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999784900666 + "zoom": 1 } } } diff --git a/app/resources/blocks/logic/gate/nand.ice b/app/resources/blocks/logic/gate/nand.ice index 0d5fe5a31..cb8a28934 100644 --- a/app/resources/blocks/logic/gate/nand.ice +++ b/app/resources/blocks/logic/gate/nand.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// NAND logic gate\n\nassign c = ~(a & b);", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -107,4 +141,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/gate/nor.ice b/app/resources/blocks/logic/gate/nor.ice index 1d9f38242..b1157273c 100644 --- a/app/resources/blocks/logic/gate/nor.ice +++ b/app/resources/blocks/logic/gate/nor.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// NOR logic gate\n\nassign c = ~(a | b);", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, diff --git a/app/resources/blocks/logic/gate/not.ice b/app/resources/blocks/logic/gate/not.ice index 0586db3bc..12ff9752b 100644 --- a/app/resources/blocks/logic/gate/not.ice +++ b/app/resources/blocks/logic/gate/not.ice @@ -16,12 +16,19 @@ "type": "basic.code", "data": { "code": "// NOT logic gate\n\nassign c = ~ a;", + "params": [], "ports": { "in": [ - "a" + { + "name": "a", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -34,7 +41,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -45,7 +60,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -85,4 +108,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/gate/or.ice b/app/resources/blocks/logic/gate/or.ice index 35c0f1515..440294bb7 100644 --- a/app/resources/blocks/logic/gate/or.ice +++ b/app/resources/blocks/logic/gate/or.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// OR logic gate\n\nassign c = a | b;", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -107,4 +141,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/gate/xnor.ice b/app/resources/blocks/logic/gate/xnor.ice index f55df49ff..b90ac28a1 100644 --- a/app/resources/blocks/logic/gate/xnor.ice +++ b/app/resources/blocks/logic/gate/xnor.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// XNOR logic gate\n\nassign c = ~(a ^ b);", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, diff --git a/app/resources/blocks/logic/gate/xor.ice b/app/resources/blocks/logic/gate/xor.ice index 37e840d56..b0a081f16 100644 --- a/app/resources/blocks/logic/gate/xor.ice +++ b/app/resources/blocks/logic/gate/xor.ice @@ -16,13 +16,23 @@ "type": "basic.code", "data": { "code": "// XOR logic gate\n\nassign c = a ^ b;", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -35,7 +45,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -46,7 +64,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -57,7 +83,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -107,4 +141,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/sequential/debouncer.ice b/app/resources/blocks/logic/sequential/debouncer.ice index d28c6ea5c..3b6019dd2 100644 --- a/app/resources/blocks/logic/sequential/debouncer.ice +++ b/app/resources/blocks/logic/sequential/debouncer.ice @@ -16,52 +16,86 @@ "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", + "params": [], "ports": { "in": [ - "clk", - "in" + { + "name": "clk", + "size": 1 + }, + { + "name": "in", + "size": 1 + } ], "out": [ - "out" + { + "name": "out", + "size": 1 + } ] } }, "position": { - "x": 368, - "y": 120 + "x": 264, + "y": 112 } }, { "id": "4bf41c17-a2da-4140-95f7-2a80d51b1e1a", "type": "basic.input", "data": { - "label": "clk" + "name": "clk", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 152, - "y": 152 + "x": 48, + "y": 144 } }, { "id": "22ff3fa1-943b-4d1a-bd89-36e1c054d077", "type": "basic.output", "data": { - "label": "out" + "name": "out", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 872, - "y": 216 + "x": 768, + "y": 208 } }, { "id": "c9e1af2a-6f09-4cf6-a5b3-fdf7ec2c6530", "type": "basic.input", "data": { - "label": "in" + "name": "in", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { - "x": 152, - "y": 280 + "x": 48, + "y": 272 } } ], @@ -104,7 +138,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999623653131 + "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/sequential/dff_ar.ice b/app/resources/blocks/logic/sequential/dff_ar.ice index fae0d636e..7f04bfbc3 100644 --- a/app/resources/blocks/logic/sequential/dff_ar.ice +++ b/app/resources/blocks/logic/sequential/dff_ar.ice @@ -15,7 +15,15 @@ "id": "b32a6101-5bd1-4bcf-ae5f-e569b958a6a2", "type": "basic.input", "data": { - "label": "D" + "name": "D", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -27,16 +35,35 @@ "type": "basic.code", "data": { "code": "// D flip-flop with asynchronous reset\n\nreg _q = 1'b0;\n\nalways @(posedge clk or negedge rst_n)\nbegin\n if(rst_n == 0)\n _q = 1'b0;\n else if(en)\n _q <= d;\nend\n\nassign {q, q_n} = {_q, ~_q};\n", + "params": [], "ports": { "in": [ - "d", - "en", - "rst_n", - "clk" + { + "name": "d", + "size": 1 + }, + { + "name": "en", + "size": 1 + }, + { + "name": "rst_n", + "size": 1 + }, + { + "name": "clk", + "size": 1 + } ], "out": [ - "q", - "q_n" + { + "name": "q", + "size": 1 + }, + { + "name": "q_n", + "size": 1 + } ] } }, @@ -49,7 +76,15 @@ "id": "ffdd9aa2-aea3-4aa9-8431-80e799226774", "type": "basic.output", "data": { - "label": "Q" + "name": "Q", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -60,7 +95,15 @@ "id": "50d69ac2-949d-476e-a711-420ba9f510cd", "type": "basic.input", "data": { - "label": "en" + "name": "en", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -71,7 +114,15 @@ "id": "07105e68-401b-49e9-b85f-2cddbfee9fbe", "type": "basic.input", "data": { - "label": "rst*" + "name": "rst*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -82,7 +133,15 @@ "id": "4a261f0b-523c-4fe0-ae1c-de05b8eb7e8a", "type": "basic.output", "data": { - "label": "Q*" + "name": "Q*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -93,7 +152,15 @@ "id": "6855f64f-fa1c-4371-b2e1-a98970674a96", "type": "basic.input", "data": { - "label": "clk" + "name": "clk", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -170,7 +237,7 @@ "x": -100, "y": 0 }, - "zoom": 1.0000000596046377 + "zoom": 1 } } } diff --git a/app/resources/blocks/logic/sequential/dff_sr.ice b/app/resources/blocks/logic/sequential/dff_sr.ice index 2dfabb8d0..f57c59a0d 100644 --- a/app/resources/blocks/logic/sequential/dff_sr.ice +++ b/app/resources/blocks/logic/sequential/dff_sr.ice @@ -15,7 +15,15 @@ "id": "b32a6101-5bd1-4bcf-ae5f-e569b958a6a2", "type": "basic.input", "data": { - "label": "D" + "name": "D", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -27,16 +35,35 @@ "type": "basic.code", "data": { "code": "// D flip-flop with synchronous reset\n\nreg _q = 1'b0;\n\nalways @(posedge clk)\nbegin\n if(rst_n == 0)\n _q = 1'b0;\n else if(en)\n _q <= d;\nend\n\nassign {q, q_n} = {_q, ~_q};\n", + "params": [], "ports": { "in": [ - "d", - "en", - "rst_n", - "clk" + { + "name": "d", + "size": 1 + }, + { + "name": "en", + "size": 1 + }, + { + "name": "rst_n", + "size": 1 + }, + { + "name": "clk", + "size": 1 + } ], "out": [ - "q", - "q_n" + { + "name": "q", + "size": 1 + }, + { + "name": "q_n", + "size": 1 + } ] } }, @@ -49,7 +76,15 @@ "id": "ffdd9aa2-aea3-4aa9-8431-80e799226774", "type": "basic.output", "data": { - "label": "Q" + "name": "Q", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -60,7 +95,15 @@ "id": "50d69ac2-949d-476e-a711-420ba9f510cd", "type": "basic.input", "data": { - "label": "en" + "name": "en", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -71,7 +114,15 @@ "id": "07105e68-401b-49e9-b85f-2cddbfee9fbe", "type": "basic.input", "data": { - "label": "rst*" + "name": "rst*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -82,7 +133,15 @@ "id": "4a261f0b-523c-4fe0-ae1c-de05b8eb7e8a", "type": "basic.output", "data": { - "label": "Q*" + "name": "Q*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -93,7 +152,15 @@ "id": "6855f64f-fa1c-4371-b2e1-a98970674a96", "type": "basic.input", "data": { - "label": "clk" + "name": "clk", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, diff --git a/app/resources/blocks/logic/sequential/tff_ar.ice b/app/resources/blocks/logic/sequential/tff_ar.ice index 33e16dfc7..0c1d6ba47 100644 --- a/app/resources/blocks/logic/sequential/tff_ar.ice +++ b/app/resources/blocks/logic/sequential/tff_ar.ice @@ -15,7 +15,15 @@ "id": "b32a6101-5bd1-4bcf-ae5f-e569b958a6a2", "type": "basic.input", "data": { - "label": "T" + "name": "T", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -27,16 +35,35 @@ "type": "basic.code", "data": { "code": "// T flip-flop with asynchronous reset\n\nreg _q = 1'b0;\n\nalways @(posedge clk or negedge rst_n)\nbegin\n if(rst_n == 0)\n _q <= 1'b0;\n else\n if(en & t)\n _q = ~_q;\nend\n\nassign {q, q_n} = {_q, ~_q};", + "params": [], "ports": { "in": [ - "t", - "en", - "rst_n", - "clk" + { + "name": "t", + "size": 1 + }, + { + "name": "en", + "size": 1 + }, + { + "name": "rst_n", + "size": 1 + }, + { + "name": "clk", + "size": 1 + } ], "out": [ - "q", - "q_n" + { + "name": "q", + "size": 1 + }, + { + "name": "q_n", + "size": 1 + } ] } }, @@ -49,7 +76,15 @@ "id": "ffdd9aa2-aea3-4aa9-8431-80e799226774", "type": "basic.output", "data": { - "label": "Q" + "name": "Q", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -60,7 +95,15 @@ "id": "50d69ac2-949d-476e-a711-420ba9f510cd", "type": "basic.input", "data": { - "label": "en" + "name": "en", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -71,7 +114,15 @@ "id": "8fa94192-fba9-4c2a-be61-b8ca88389423", "type": "basic.input", "data": { - "label": "rst*" + "name": "rst*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -82,7 +133,15 @@ "id": "4a261f0b-523c-4fe0-ae1c-de05b8eb7e8a", "type": "basic.output", "data": { - "label": "Q*" + "name": "Q*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -93,7 +152,15 @@ "id": "6855f64f-fa1c-4371-b2e1-a98970674a96", "type": "basic.input", "data": { - "label": "clk" + "name": "clk", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -173,4 +240,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/resources/blocks/logic/sequential/tff_sr.ice b/app/resources/blocks/logic/sequential/tff_sr.ice index 95267f2e8..825b32d4f 100644 --- a/app/resources/blocks/logic/sequential/tff_sr.ice +++ b/app/resources/blocks/logic/sequential/tff_sr.ice @@ -15,7 +15,15 @@ "id": "b32a6101-5bd1-4bcf-ae5f-e569b958a6a2", "type": "basic.input", "data": { - "label": "T" + "name": "T", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -27,16 +35,35 @@ "type": "basic.code", "data": { "code": "// T flip-flop with synchronous reset\n\nreg _q = 1'b0;\n\nalways @(posedge clk)\nbegin\n if(rst_n == 0)\n _q <= 1'b0;\n else\n if(en & t)\n _q = ~_q;\nend\n\nassign {q, q_n} = {_q, ~_q};", + "params": [], "ports": { "in": [ - "t", - "en", - "rst_n", - "clk" + { + "name": "t", + "size": 1 + }, + { + "name": "en", + "size": 1 + }, + { + "name": "rst_n", + "size": 1 + }, + { + "name": "clk", + "size": 1 + } ], "out": [ - "q", - "q_n" + { + "name": "q", + "size": 1 + }, + { + "name": "q_n", + "size": 1 + } ] } }, @@ -49,7 +76,15 @@ "id": "ffdd9aa2-aea3-4aa9-8431-80e799226774", "type": "basic.output", "data": { - "label": "Q" + "name": "Q", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -60,7 +95,15 @@ "id": "50d69ac2-949d-476e-a711-420ba9f510cd", "type": "basic.input", "data": { - "label": "en" + "name": "en", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -71,7 +114,15 @@ "id": "8fa94192-fba9-4c2a-be61-b8ca88389423", "type": "basic.input", "data": { - "label": "rst*" + "name": "rst*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -82,7 +133,15 @@ "id": "4a261f0b-523c-4fe0-ae1c-de05b8eb7e8a", "type": "basic.output", "data": { - "label": "Q*" + "name": "Q*", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 824, @@ -93,7 +152,15 @@ "id": "6855f64f-fa1c-4371-b2e1-a98970674a96", "type": "basic.input", "data": { - "label": "clk" + "name": "clk", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 168, @@ -173,4 +240,4 @@ "zoom": 1 } } -} \ No newline at end of file +} diff --git a/app/scripts/services/project.service.js b/app/scripts/services/project.service.js index 3f3ac48ef..b7236b61c 100644 --- a/app/scripts/services/project.service.js +++ b/app/scripts/services/project.service.js @@ -89,8 +89,8 @@ angular.module('icestudio') name: block.data.label, pins: [{ index: '0', - name: '', - value: '0' + name: block.data.pin ? block.data.pin.name : '', + value: block.data.pin? block.data.pin.value : '0' }], virtual: false }; @@ -109,23 +109,29 @@ angular.module('icestudio') name: block.data.params[p] }); } - block.data.params = params; var inPorts = []; for (var i in block.data.ports.in) { - params.push({ + inPorts.push({ name: block.data.ports.in[i], size: 1 }); } - block.data.ports.in = inPorts; + var outPorts = []; for (var o in block.data.ports.out) { - params.push({ + outPorts.push({ name: block.data.ports.out[o], size: 1 }); } - block.data.ports.out = outPorts; + block.data = { + code: block.data.code, + params: params, + ports: { + in: inPorts, + out: outPorts + } + }; break; } } From b82c1ec84c47c2c9a6b64527653d8e3896f0fa15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Thu, 22 Dec 2016 19:51:03 +0100 Subject: [PATCH 35/35] Update all examples to final format 1.0 --- .../examples/icestick/1_basic/1_led_on.ice | 27 ++++--- .../examples/icezum/1_basic/1_led_on.ice | 27 ++++--- .../examples/icezum/1_basic/2_switch_led.ice | 8 +- .../icezum/1_basic/3_switch_and_gate.ice | 81 ++++++++++++------- app/scripts/services/compiler.service.js | 3 +- 5 files changed, 93 insertions(+), 53 deletions(-) diff --git a/app/resources/examples/icestick/1_basic/1_led_on.ice b/app/resources/examples/icestick/1_basic/1_led_on.ice index d6022735f..c34f87a6a 100644 --- a/app/resources/examples/icestick/1_basic/1_led_on.ice +++ b/app/resources/examples/icestick/1_basic/1_led_on.ice @@ -1,8 +1,8 @@ { "version": "1.0", "package": { - "name": "", - "version": "", + "name": "Led on", + "version": "1.0.0", "description": "", "author": "", "image": "" @@ -12,9 +12,8 @@ "graph": { "blocks": [ { - "id": "f9239f87-12a4-4141-85f7-c3862615af3a", + "id": "eaf792b5-de98-4e2f-b78a-4023eb9a7f2b", "type": "bit.1", - "data": {}, "position": { "x": 80, "y": 64 @@ -24,9 +23,7 @@ "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", "type": "basic.output", "data": { - "label": "led", "name": "led", - "range": "", "pins": [ { "index": "0", @@ -67,7 +64,7 @@ "wires": [ { "source": { - "block": "f9239f87-12a4-4141-85f7-c3862615af3a", + "block": "eaf792b5-de98-4e2f-b78a-4023eb9a7f2b", "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" }, "target": { @@ -96,10 +93,14 @@ "type": "basic.code", "data": { "code": "// Bit 1\n\nassign v = 1'b1;", + "params": [], "ports": { "in": [], "out": [ - "v" + { + "name": "v", + "size": 1 + } ] } }, @@ -112,7 +113,15 @@ "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 608, diff --git a/app/resources/examples/icezum/1_basic/1_led_on.ice b/app/resources/examples/icezum/1_basic/1_led_on.ice index 185c1ade2..c66fb5642 100644 --- a/app/resources/examples/icezum/1_basic/1_led_on.ice +++ b/app/resources/examples/icezum/1_basic/1_led_on.ice @@ -1,8 +1,8 @@ { "version": "1.0", "package": { - "name": "", - "version": "", + "name": "Led on", + "version": "1.0.0", "description": "", "author": "", "image": "" @@ -12,9 +12,8 @@ "graph": { "blocks": [ { - "id": "8c3d15a4-2311-4a24-8321-6036eb0eb92b", + "id": "eaf792b5-de98-4e2f-b78a-4023eb9a7f2b", "type": "bit.1", - "data": {}, "position": { "x": 80, "y": 64 @@ -24,9 +23,7 @@ "id": "949075cb-26c0-49da-ba76-2496ea9aa7cc", "type": "basic.output", "data": { - "label": "led", "name": "led", - "range": "", "pins": [ { "index": "0", @@ -67,7 +64,7 @@ "wires": [ { "source": { - "block": "8c3d15a4-2311-4a24-8321-6036eb0eb92b", + "block": "eaf792b5-de98-4e2f-b78a-4023eb9a7f2b", "port": "19c8f68d-5022-487f-9ab0-f0a3cd58bead" }, "target": { @@ -96,10 +93,14 @@ "type": "basic.code", "data": { "code": "// Bit 1\n\nassign v = 1'b1;", + "params": [], "ports": { "in": [], "out": [ - "v" + { + "name": "v", + "size": 1 + } ] } }, @@ -112,7 +113,15 @@ "id": "19c8f68d-5022-487f-9ab0-f0a3cd58bead", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 608, diff --git a/app/resources/examples/icezum/1_basic/2_switch_led.ice b/app/resources/examples/icezum/1_basic/2_switch_led.ice index 7b42bc6ae..d428f6e3e 100644 --- a/app/resources/examples/icezum/1_basic/2_switch_led.ice +++ b/app/resources/examples/icezum/1_basic/2_switch_led.ice @@ -1,8 +1,8 @@ { "version": "1.0", "package": { - "name": "", - "version": "", + "name": "Switch led", + "version": "1.0.0", "description": "", "author": "", "image": "" @@ -15,9 +15,7 @@ "id": "aac1b394-533e-4410-9f35-ba80af8abd63", "type": "basic.input", "data": { - "label": "button", "name": "button", - "range": "", "pins": [ { "index": "0", @@ -36,9 +34,7 @@ "id": "30a83e46-176d-40a8-ac0e-f19a131ea9d9", "type": "basic.output", "data": { - "label": "led", "name": "led", - "range": "", "pins": [ { "index": "0", diff --git a/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice b/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice index 6edbb2630..3a7a02bf6 100644 --- a/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice +++ b/app/resources/examples/icezum/1_basic/3_switch_and_gate.ice @@ -15,9 +15,7 @@ "id": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", "type": "basic.input", "data": { - "label": "button1", "name": "button1", - "range": "", "pins": [ { "index": "0", @@ -33,11 +31,10 @@ } }, { - "id": "81f8eceb-3742-4350-8833-78fef262c542", + "id": "840e71b2-bf5a-4e20-8413-d386500c87fa", "type": "logic.gate.and", - "data": {}, "position": { - "x": 248, + "x": 256, "y": 80 } }, @@ -45,9 +42,7 @@ "id": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", "type": "basic.output", "data": { - "label": "led", "name": "led", - "range": "", "pins": [ { "index": "0", @@ -66,9 +61,7 @@ "id": "5d1b4f33-ae65-4154-b4f4-ff1403437600", "type": "basic.input", "data": { - "label": "button2", "name": "button2", - "range": "", "pins": [ { "index": "0", @@ -109,32 +102,32 @@ "wires": [ { "source": { - "block": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", - "port": "out" + "block": "840e71b2-bf5a-4e20-8413-d386500c87fa", + "port": "664caf9e-5f40-4df4-800a-b626af702e62" }, "target": { - "block": "81f8eceb-3742-4350-8833-78fef262c542", - "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" + "block": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", + "port": "in" } }, { "source": { - "block": "5d1b4f33-ae65-4154-b4f4-ff1403437600", + "block": "aa8bab8b-61e4-4e28-b444-0e68d9484ea1", "port": "out" }, "target": { - "block": "81f8eceb-3742-4350-8833-78fef262c542", - "port": "97b51945-d716-4b6c-9db9-970d08541249" + "block": "840e71b2-bf5a-4e20-8413-d386500c87fa", + "port": "18c2ebc7-5152-439c-9b3f-851c59bac834" } }, { "source": { - "block": "81f8eceb-3742-4350-8833-78fef262c542", - "port": "664caf9e-5f40-4df4-800a-b626af702e62" + "block": "5d1b4f33-ae65-4154-b4f4-ff1403437600", + "port": "out" }, "target": { - "block": "3cad6e72-e7d3-4273-be1c-ce5f9b4c020a", - "port": "in" + "block": "840e71b2-bf5a-4e20-8413-d386500c87fa", + "port": "97b51945-d716-4b6c-9db9-970d08541249" } } ] @@ -158,13 +151,23 @@ "type": "basic.code", "data": { "code": "// AND logic gate\n\nassign c = a & b;", + "params": [], "ports": { "in": [ - "a", - "b" + { + "name": "a", + "size": 1 + }, + { + "name": "b", + "size": 1 + } ], "out": [ - "c" + { + "name": "c", + "size": 1 + } ] } }, @@ -177,7 +180,15 @@ "id": "18c2ebc7-5152-439c-9b3f-851c59bac834", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -188,7 +199,15 @@ "id": "664caf9e-5f40-4df4-800a-b626af702e62", "type": "basic.output", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 752, @@ -199,7 +218,15 @@ "id": "97b51945-d716-4b6c-9db9-970d08541249", "type": "basic.input", "data": { - "label": "" + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true }, "position": { "x": 64, @@ -246,7 +273,7 @@ "x": 0, "y": 0 }, - "zoom": 0.9999999784900666 + "zoom": 1 } } } diff --git a/app/scripts/services/compiler.service.js b/app/scripts/services/compiler.service.js index 828ef6f88..c01e911b0 100644 --- a/app/scripts/services/compiler.service.js +++ b/app/scripts/services/compiler.service.js @@ -44,7 +44,7 @@ angular.module('icestudio') return 'v' + nodeSha1(id).toString().substring(0, 6); } else { - return id.replace('.', '_'); + return id.replace(/\./g, '_'); } } @@ -242,7 +242,6 @@ angular.module('icestudio') block.type !== 'basic.info') { // Header - instance += name; if (block.type === 'basic.code') { instance += '_' + digestId(block.id);