Skip to content

Commit

Permalink
built scratch for more demos
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephAbbey committed Oct 24, 2022
1 parent a293733 commit 9c28f09
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/binary_counter.vhdl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ begin
if cnt = 15 then
cnt <= 0;
else
cnt <= cnt;
cnt <= cnt + 1;
end if;
end if;
end if;
Expand Down
19 changes: 10 additions & 9 deletions examples/button_driven.vhdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ library ieee;

architecture scratch of led4_button4 is

constant button_tab_c : positive := 1;



begin

process(clk)
begin
if rising_edge(clk) then
if reset = '0' then
leds <= "0000";
else
-- If any buttons are pressed, set leds to buttons.
if or(buttons) then
leds <= buttons;
if rising_edge(clk) then
if reset = '0' then
leds <= "0000";
else
-- If any buttons are pressed, set leds to buttons.
if or(buttons) then
leds <= buttons;
end if;
end if;
end if;
end if;

end process;

end architecture;
2 changes: 1 addition & 1 deletion examples/button_driven.vhdl.sbd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"avqozk~ylO6~9`OoO-tF","x":388,"y":13,"extraState":{"depCount":1},"fields":{"1":{"id":"u;Fa!BiTi{j_018wO)36"}},"inputs":{"body":{"block":{"type":"controls_if","id":"7)2aH8jQ`CxLSWy}UAgr","inputs":{"IF0":{"block":{"type":"logic_rising_edge","id":"0QWfBso?I$XYQ8@mej5}","fields":{"dep":{"id":"u;Fa!BiTi{j_018wO)36"}}}},"DO0":{"block":{"type":"controls_if","id":"|iCK:,3?*n,e{^9zO]%y","extraState":{"hasElse":true},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"B=Og_Cm*AO)T}CKQAZXF","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"Db8Ohuaw7PUe(HOT?d:%","fields":{"VAR":{"id":"k={!]s@w*z5TAx~}`{9)"}}}},"B":{"block":{"type":"value_std_logic","id":"HV[(76@,1o#o|NIyg{4L","fields":{"VALUE":0}}}}}},"DO0":{"block":{"type":"variables_set","id":"#+9/+hoAZ#@$}Xj@UfWf","fields":{"VAR":{"id":"j]MA]3Vu=zr|cCG^O7mG"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":"e;wxzA`Gn*})l|hu!d,}","fields":{"VALUE":"0000"}}}}}},"ELSE":{"block":{"type":"controls_if","id":"G-`MW2Q19@O:3dI$@8i`","icons":{"comment":{"text":"If any buttons are pressed, set leds to buttons.","pinned":false,"height":107,"width":387}},"inputs":{"IF0":{"block":{"type":"logic_operation_vector","id":"16BmZIO|$qr(z+1]f618","fields":{"OPERATION":"or"},"inputs":{"LIST":{"block":{"type":"variables_get","id":".*yYPrudmb_BZ;n|H]a2","fields":{"VAR":{"id":"xiS/W8KC[SjitA9:_W,%"}}}}}}},"DO0":{"block":{"type":"variables_set","id":"@2+PU)j0,=F_cLpfwji{","fields":{"VAR":{"id":"j]MA]3Vu=zr|cCG^O7mG"}},"inputs":{"VALUE":{"block":{"type":"variables_get","id":".+(dqWRY[l/0K@ZwWi6E","fields":{"VAR":{"id":"xiS/W8KC[SjitA9:_W,%"}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"clk","id":"u;Fa!BiTi{j_018wO)36"},{"name":"reset","id":"k={!]s@w*z5TAx~}`{9)"},{"name":"incr","id":"-N/%|Yb*ua~LIYg|RDXz"},{"name":"buttons","id":"xiS/W8KC[SjitA9:_W,%"},{"name":"leds","id":"j]MA]3Vu=zr|cCG^O7mG"}]}
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"avqozk~ylO6~9`OoO-tF","x":388,"y":13,"extraState":{"depCount":1},"fields":{"1":{"id":"u;Fa!BiTi{j_018wO)36"}},"inputs":{"body":{"block":{"type":"controls_if","id":"7)2aH8jQ`CxLSWy}UAgr","inputs":{"IF0":{"block":{"type":"logic_rising_edge","id":"0QWfBso?I$XYQ8@mej5}","fields":{"dep":{"id":"u;Fa!BiTi{j_018wO)36"}}}},"DO0":{"block":{"type":"controls_if","id":"|iCK:,3?*n,e{^9zO]%y","extraState":{"hasElse":true},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"B=Og_Cm*AO)T}CKQAZXF","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"Db8Ohuaw7PUe(HOT?d:%","fields":{"VAR":{"id":"k={!]s@w*z5TAx~}`{9)"}}}},"B":{"block":{"type":"value_std_logic","id":"HV[(76@,1o#o|NIyg{4L","fields":{"VALUE":0}}}}}},"DO0":{"block":{"type":"variables_set","id":"#+9/+hoAZ#@$}Xj@UfWf","fields":{"VAR":{"id":"j]MA]3Vu=zr|cCG^O7mG"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":"e;wxzA`Gn*})l|hu!d,}","fields":{"VALUE":"0000"}}}}}},"ELSE":{"block":{"type":"controls_if","id":"G-`MW2Q19@O:3dI$@8i`","icons":{"comment":{"text":"If any buttons are pressed, set leds to buttons.","pinned":false,"height":107,"width":387}},"inputs":{"IF0":{"block":{"type":"logic_operation_vector","id":"16BmZIO|$qr(z+1]f618","fields":{"OPERATION":"or"},"inputs":{"LIST":{"block":{"type":"variables_get","id":".*yYPrudmb_BZ;n|H]a2","fields":{"VAR":{"id":"xiS/W8KC[SjitA9:_W,%"}}}}}}},"DO0":{"block":{"type":"variables_set","id":"@2+PU)j0,=F_cLpfwji{","fields":{"VAR":{"id":"j]MA]3Vu=zr|cCG^O7mG"}},"inputs":{"VALUE":{"block":{"type":"variables_get","id":".+(dqWRY[l/0K@ZwWi6E","fields":{"VAR":{"id":"xiS/W8KC[SjitA9:_W,%"}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"clk","id":"u;Fa!BiTi{j_018wO)36"},{"name":"reset","id":"k={!]s@w*z5TAx~}`{9)"},{"name":"incr","id":"-N/%|Yb*ua~LIYg|RDXz"},{"name":"buttons","id":"xiS/W8KC[SjitA9:_W,%"},{"name":"leds","id":"j]MA]3Vu=zr|cCG^O7mG"}],"signals":{}}
37 changes: 37 additions & 0 deletions examples/logic_gates.vhdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
library ieee;
use ieee.std_logic_1164.all;

entity logic_gates is
port(
clk : in std_logic;
reset : in std_logic;
incr : in std_logic;
buttons : in std_logic_vector(3 downto 0);
leds : out std_logic_vector(3 downto 0)
);
end entity;


architecture scratch of logic_gates is

constant button_tab_c : positive := 1;



begin

process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
leds <= "0000";
else
leds(0) <= and(buttons);
leds(1) <= or(buttons);
leds(2) <= xor(buttons);
leds(3) <= nor(buttons);
end if;
end if;
end process;

end architecture;
1 change: 1 addition & 0 deletions examples/logic_gates.vhdl.sbd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"}t~Mp@7Yk(@-IUxnI:JN","x":262,"y":138,"extraState":{"depCount":1},"fields":{"1":{"id":"#y0d_bv!$l,ehNj.:JUD"}},"inputs":{"body":{"block":{"type":"controls_if","id":"-I.[YM|^3k8yLi4d0|r-","inputs":{"IF0":{"block":{"type":"logic_rising_edge","id":"bNIE!Wo0z6?:blK`5rA_","fields":{"dep":{"id":"#y0d_bv!$l,ehNj.:JUD"}}}},"DO0":{"block":{"type":"controls_if","id":"zoncJ(=WWE/b7@r55PNs","extraState":{"hasElse":true},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"b!~JK!!By(Ydu84z,WgB","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"Rt`#3h]thgo/`~Bk-anM","fields":{"VAR":{"id":"iIi,2Y]z2^(5X-+n;+SG"}}}},"B":{"block":{"type":"value_std_logic","id":":[ActNE/ED==C8guvuB[","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":"(XYXC^[n|Saxk?3^Z?rr","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":")KmJ|`2)nHp]s~*^=%{6","fields":{"VALUE":"0000"}}}}}},"ELSE":{"block":{"type":"variables_set_index","id":"qxo=vdb)fa-RWF5$[r;|","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"},"INDEX":0},"inputs":{"VALUE":{"block":{"type":"logic_operation_vector","id":"JUc+D0H4]3++B-|yv-d`","fields":{"OPERATION":"and"},"inputs":{"LIST":{"block":{"type":"variables_get","id":"=/j9_KTVqPc#iD#$W@Xa","fields":{"VAR":{"id":"jE5^.ID*ZF!hr(+uZ)}e"}}}}}}}},"next":{"block":{"type":"variables_set_index","id":"#))8QPW?W%Z1J+=-u9UV","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"},"INDEX":1},"inputs":{"VALUE":{"block":{"type":"logic_operation_vector","id":"Nxo@*kC#cPk_`H2[ASQh","fields":{"OPERATION":"or"},"inputs":{"LIST":{"block":{"type":"variables_get","id":"apTT-hb5J)6n6T:(pGaq","fields":{"VAR":{"id":"jE5^.ID*ZF!hr(+uZ)}e"}}}}}}}},"next":{"block":{"type":"variables_set_index","id":"%*r|E/fBdKjTDTnBy5#$","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"},"INDEX":2},"inputs":{"VALUE":{"block":{"type":"logic_operation_vector","id":"XL2W`d:X264Wd8ZO#Q,M","fields":{"OPERATION":"xor"},"inputs":{"LIST":{"block":{"type":"variables_get","id":"ji]2vW^LjvI4!F$-d2g2","fields":{"VAR":{"id":"jE5^.ID*ZF!hr(+uZ)}e"}}}}}}}},"next":{"block":{"type":"variables_set_index","id":"{k#:jwX_K{@2?/4M~}A|","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"},"INDEX":3},"inputs":{"VALUE":{"block":{"type":"logic_operation_vector","id":"(eMAI4X|w7!pO4FYf}x`","fields":{"OPERATION":"nor"},"inputs":{"LIST":{"block":{"type":"variables_get","id":"nmN@*wDXS}4Pj+#{2./i","fields":{"VAR":{"id":"jE5^.ID*ZF!hr(+uZ)}e"}}}}}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"clk","id":"#y0d_bv!$l,ehNj.:JUD"},{"name":"reset","id":"iIi,2Y]z2^(5X-+n;+SG"},{"name":"incr","id":"R~UCvmz3J,zg*3rrG4k|"},{"name":"buttons","id":"jE5^.ID*ZF!hr(+uZ)}e"},{"name":"leds","id":"q/}!ERRTTj};N#huJxf{"}],"signals":{}}
12 changes: 12 additions & 0 deletions examples/logic_gates.vhdl.sbe
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entity": {
"clk" : ["in", "std_logic"],
"reset" : ["in", "std_logic"],
"incr" : ["in", "std_logic"],
"buttons" : ["in", "std_logic_vector(3 downto 0)"],
"leds" : ["out", "std_logic_vector(3 downto 0)"]
},
"constants": {
"button_tab_c": ["positive", "1"]
}
}
39 changes: 39 additions & 0 deletions examples/pulse_gen.vhdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
library ieee;
use ieee.std_logic_1164.all;

entity pulse_gen is
port(
clk : in std_logic;
reset : in std_logic;
incr : in std_logic;
buttons : in std_logic_vector(3 downto 0);
leds : out std_logic_vector(3 downto 0)
);
end entity;


architecture scratch of pulse_gen is

constant button_tab_c : positive := 1;

signal buttons_d : std_logic_vector(3 downto 0);


begin

process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
leds <= "0000";
buttons_d <= "0000";
else
if incr = '1' then
buttons_d <= buttons;
leds <= buttons and not buttons_d;
end if;
end if;
end if;
end process;

end architecture;
1 change: 1 addition & 0 deletions examples/pulse_gen.vhdl.sbd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"%4s:ha+GtEnOZS_M(i#i","x":337,"y":88,"extraState":{"depCount":1},"fields":{"1":{"id":",a_S_.gF7u?`a-0oI*:$"}},"inputs":{"body":{"block":{"type":"controls_if","id":"]YA3S%BjPzc-8z|v!3JU","inputs":{"IF0":{"block":{"type":"logic_rising_edge","id":"-TYEed^c~l1^0/JyP`9s","fields":{"dep":{"id":",a_S_.gF7u?`a-0oI*:$"}}}},"DO0":{"block":{"type":"controls_if","id":"vf}{~5SU!MtGtPJ#AtD,","extraState":{"hasElse":true},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"](aD5DWYu%3}3TMWg,N;","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"nf_n`+yLuZW$Cphe;$}:","fields":{"VAR":{"id":"O(Qv-dMB0/YDa(Ibn$=M"}}}},"B":{"block":{"type":"value_std_logic","id":"L$TbOcg%Y[~t2xI.38y(","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":";,~PJd;}5e}4X*$~Z=9X","fields":{"VAR":{"id":"65Uwc|kHQ*|7.w;SZp%U"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":"(ndpkgW1uXcx/,!#cdJ-","fields":{"VALUE":"0000"}}}},"next":{"block":{"type":"variables_set","id":"4cZ0|pbwr.qu]=2/a#R%","fields":{"VAR":{"id":"9tffOR6Ih^vqXGqjCllj"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":"m~{A=i@0i0{nM6ycQ+Wa","fields":{"VALUE":"0000"}}}}}}}},"ELSE":{"block":{"type":"controls_if","id":"^S|y{7,NHfP~2QM4D1Rr","inputs":{"IF0":{"block":{"type":"logic_compare","id":"jDRiDSIERg%:5cn^u1((","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"FzW:zipwf.S1%zC7L?H/","fields":{"VAR":{"id":":F)Ok#e)2*r0vo5+?6s2"}}}},"B":{"block":{"type":"value_std_logic","id":"X4#TNlJ;x7P@^2sLVj*U","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":"sN~Q3QZKJ9WKzjqV{;6l","fields":{"VAR":{"id":"9tffOR6Ih^vqXGqjCllj"}},"inputs":{"VALUE":{"block":{"type":"variables_get","id":"ijulpr#B!*LO`/ROD6xb","fields":{"VAR":{"id":"BB^`c|wJ8,3h8UNmAr+p"}}}}},"next":{"block":{"type":"variables_set","id":"J+oAnc_|e1|jIJ(c2]9a","fields":{"VAR":{"id":"65Uwc|kHQ*|7.w;SZp%U"}},"inputs":{"VALUE":{"block":{"type":"logic_operation","id":";f9AOi8y.Maq7NG?b8Kl","fields":{"OPERATION":"and"},"inputs":{"A":{"block":{"type":"variables_get","id":"$(EQe9:_c$VuQ31kd=Cu","fields":{"VAR":{"id":"BB^`c|wJ8,3h8UNmAr+p"}}}},"B":{"block":{"type":"logic_not","id":"e8t8?Shpfjq;u%/tXVAd","inputs":{"INPUT":{"block":{"type":"variables_get","id":"r}}V@Y;0(5jE*uqBS0n*","fields":{"VAR":{"id":"9tffOR6Ih^vqXGqjCllj"}}}}}}}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"clk","id":",a_S_.gF7u?`a-0oI*:$"},{"name":"reset","id":"O(Qv-dMB0/YDa(Ibn$=M"},{"name":"incr","id":":F)Ok#e)2*r0vo5+?6s2"},{"name":"buttons","id":"BB^`c|wJ8,3h8UNmAr+p"},{"name":"leds","id":"65Uwc|kHQ*|7.w;SZp%U"},{"name":"buttons_d","id":"9tffOR6Ih^vqXGqjCllj"}],"signals":{"buttons_d":"std_logic_vector(3 downto 0)"}}
12 changes: 12 additions & 0 deletions examples/pulse_gen.vhdl.sbe
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entity": {
"clk" : ["in", "std_logic"],
"reset" : ["in", "std_logic"],
"incr" : ["in", "std_logic"],
"buttons" : ["in", "std_logic_vector(3 downto 0)"],
"leds" : ["out", "std_logic_vector(3 downto 0)"]
},
"constants": {
"button_tab_c": ["positive", "1"]
}
}
34 changes: 34 additions & 0 deletions examples/toggle_driven.vhdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library ieee;
use ieee.std_logic_1164.all;

entity toggle_driven is
port(
clk : in std_logic;
reset : in std_logic;
incr : in std_logic;
buttons : in std_logic_vector(3 downto 0);
leds : out std_logic_vector(3 downto 0)
);
end entity;


architecture scratch of toggle_driven is

constant button_tab_c : positive := 2;



begin

process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
leds <= "0000";
else
leds <= buttons;
end if;
end if;
end process;

end architecture;
1 change: 1 addition & 0 deletions examples/toggle_driven.vhdl.sbd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"}t~Mp@7Yk(@-IUxnI:JN","x":262,"y":138,"extraState":{"depCount":1},"fields":{"1":{"id":"#y0d_bv!$l,ehNj.:JUD"}},"inputs":{"body":{"block":{"type":"controls_if","id":"-I.[YM|^3k8yLi4d0|r-","inputs":{"IF0":{"block":{"type":"logic_rising_edge","id":"bNIE!Wo0z6?:blK`5rA_","fields":{"dep":{"id":"#y0d_bv!$l,ehNj.:JUD"}}}},"DO0":{"block":{"type":"controls_if","id":"zoncJ(=WWE/b7@r55PNs","extraState":{"hasElse":true},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"b!~JK!!By(Ydu84z,WgB","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"Rt`#3h]thgo/`~Bk-anM","fields":{"VAR":{"id":"iIi,2Y]z2^(5X-+n;+SG"}}}},"B":{"block":{"type":"value_std_logic","id":":[ActNE/ED==C8guvuB[","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":"(XYXC^[n|Saxk?3^Z?rr","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"}},"inputs":{"VALUE":{"block":{"type":"value_std_logic_vector","id":")KmJ|`2)nHp]s~*^=%{6","fields":{"VALUE":"0000"}}}}}},"ELSE":{"block":{"type":"variables_set","id":"+dIy==8uPKBfFhuJ`OMm","fields":{"VAR":{"id":"q/}!ERRTTj};N#huJxf{"}},"inputs":{"VALUE":{"block":{"type":"variables_get","id":"#@;3b,L$efmCdPVYP,k-","fields":{"VAR":{"id":"jE5^.ID*ZF!hr(+uZ)}e"}}}}}}}}}}}}}}}]},"variables":[{"name":"clk","id":"#y0d_bv!$l,ehNj.:JUD"},{"name":"reset","id":"iIi,2Y]z2^(5X-+n;+SG"},{"name":"incr","id":"R~UCvmz3J,zg*3rrG4k|"},{"name":"buttons","id":"jE5^.ID*ZF!hr(+uZ)}e"},{"name":"leds","id":"q/}!ERRTTj};N#huJxf{"}],"signals":{}}
12 changes: 12 additions & 0 deletions examples/toggle_driven.vhdl.sbe
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entity": {
"clk" : ["in", "std_logic"],
"reset" : ["in", "std_logic"],
"incr" : ["in", "std_logic"],
"buttons" : ["in", "std_logic_vector(3 downto 0)"],
"leds" : ["out", "std_logic_vector(3 downto 0)"]
},
"constants": {
"button_tab_c": ["positive", "2"]
}
}
46 changes: 35 additions & 11 deletions scratch-vhdl-vscode/media/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ document.addEventListener('DOMContentLoaded', function () {
},
{
'kind': 'block',
'type': 'logic_negate',
'type': 'logic_not',
},
{
'kind': 'block',
Expand Down Expand Up @@ -442,6 +442,20 @@ document.addEventListener('DOMContentLoaded', function () {
"inputsInline": true,
"style": "logic_blocks",
},
{
"kind": "block",
"type": "logic_not",
"message0": "not %1",
"args0": [
{
"type": "input_value",
"name": "INPUT",
}
],
"output": "Boolean",
"inputsInline": true,
"style": "logic_blocks",
},
{
"kind": "block",
"type": "logic_operation",
Expand Down Expand Up @@ -750,16 +764,17 @@ document.addEventListener('DOMContentLoaded', function () {
const VHDLGenerator = new Blockly.Generator("VHDL");
// TODO: VHDL keyword list

VHDLGenerator.ORDER_ATOMIC = 0;
VHDLGenerator.ORDER_ATOMIC /**/ = 0;
VHDLGenerator.ORDER_FUNCTION_CALL = 1;
VHDLGenerator.ORDER_INDEX = 1.1;
VHDLGenerator.ORDER_MUL = 2;
VHDLGenerator.ORDER_DIV = 2;
VHDLGenerator.ORDER_ADD = 2.1;
VHDLGenerator.ORDER_SUB = 2.1;
VHDLGenerator.ORDER_LOGIC = 2.2;
VHDLGenerator.ORDER_COMPARE = 3;
VHDLGenerator.ORDER_NONE = 99;
VHDLGenerator.ORDER_INDEX /**/ = 1.1;
VHDLGenerator.ORDER_MUL /**/ = 2.0;
VHDLGenerator.ORDER_DIV /**/ = 2.1;
VHDLGenerator.ORDER_SUB /**/ = 3.1;
VHDLGenerator.ORDER_ADD /**/ = 3.2;
VHDLGenerator.ORDER_NOT /**/ = 4;
VHDLGenerator.ORDER_LOGIC /**/ = 5;
VHDLGenerator.ORDER_COMPARE /**/ = 6;
VHDLGenerator.ORDER_NONE /**/ = 99;


VHDLGenerator.finish = function (code) {
Expand Down Expand Up @@ -839,6 +854,10 @@ document.addEventListener('DOMContentLoaded', function () {
return ["rising_edge(" + block.getField("dep").getVariable().name + ")", VHDLGenerator.ORDER_FUNCTION_CALL]
}

VHDLGenerator.logic_not = function (block) {
return ["not " + VHDLGenerator.valueToCode(block, "INPUT", VHDLGenerator.ORDER_NOT), VHDLGenerator.ORDER_NOT]
}

VHDLGenerator.logic_operation = function (block) {
return [VHDLGenerator.valueToCode(block, "A", VHDLGenerator.ORDER_LOGIC) + " " + block.getFieldValue("OPERATION") + " " + VHDLGenerator.valueToCode(block, "B", VHDLGenerator.ORDER_LOGIC), VHDLGenerator.ORDER_LOGIC]
}
Expand All @@ -864,9 +883,14 @@ document.addEventListener('DOMContentLoaded', function () {
VHDLGenerator.valueToCode(block, 'VALUE', VHDLGenerator.ORDER_NONE) + ';\n';
}

VHDLGenerator.variables_set_index = function (block) {
return block.getField("VAR").getVariable().name + "(" + block.getFieldValue("INDEX") + ') <= ' +
VHDLGenerator.valueToCode(block, 'VALUE', VHDLGenerator.ORDER_NONE) + ';\n';
}

VHDLGenerator.math_change = function (block) {
return block.getField("VAR").getVariable().name + ' <= ' +
block.getField("VAR").getVariable().name + VHDLGenerator.valueToCode(block, 'BY', VHDLGenerator.ORDER_ADD) + ';\n';
block.getField("VAR").getVariable().name + " + " + VHDLGenerator.valueToCode(block, 'DELTA', VHDLGenerator.ORDER_ADD) + ';\n';
}

VHDLGenerator.value_std_logic = function (block) {
Expand Down
2 changes: 1 addition & 1 deletion scratch-vhdl-vscode/src/scratchVHDLEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ScratchVHDLDocument extends Disposable implements vscode.CustomDocument {
)) || '{}',
(await ScratchVHDLDocument.readFile(
vscode.Uri.parse(uri.toString() + '.sbe')
)) || '{entity:{}}',
)) || '{"entity":{}}',
delegate
);
}
Expand Down

0 comments on commit 9c28f09

Please sign in to comment.