Skip to content

Commit

Permalink
libraries and signal generation
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephAbbey committed Oct 24, 2022
1 parent cc09a5c commit e979380
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 50 deletions.
38 changes: 20 additions & 18 deletions examples/binary_counter.vhdl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std_unsigned.all;

entity binary_counter is
port(
Expand All @@ -14,34 +15,35 @@ end entity;

architecture scratch of binary_counter is

signal run : std_logic;
signal cnt : integer range 0 to 15;
signal run : std_logic;

begin

leds <= to_stdulogicvector(cnt);

process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
run <= '0';
cnt <= 0;
else
if buttons(0) = '1' then
run <= '1';
elsif buttons(1) = '1' then
if rising_edge(clk) then
if reset = '1' then
run <= '0';
end if;
if (run = '1') and (incr = '1') then
-- to prevent natural overflow
if cnt = 15 then
cnt <= 0;
else
cnt <= cnt;
cnt <= 0;
else
if buttons(0) = '1' then
run <= '1';
elsif buttons(1) = '1' then
run <= '0';
end if;
if (run = '1') and (incr = '1') then
-- to prevent natural overflow
if cnt = 15 then
cnt <= 0;
else
cnt <= cnt;
end if;
end if;
end if;
end if;
end if;

end process;

end architecture;
2 changes: 1 addition & 1 deletion examples/binary_counter.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":-12,"y":13,"extraState":{"depCount":1},"fields":{"1":{"id":"5Y9_SLHF8Bd4|n|ymNgJ"}},"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":"5Y9_SLHF8Bd4|n|ymNgJ"}}}},"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":"2G:Z~BB|CAam0[(.o??k"}}}},"B":{"block":{"type":"value_std_logic","id":"HV[(76@,1o#o|NIyg{4L","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":")~8k1(;U?4ft4XPFi{@o","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"Xxc}cOExM?./jx~mV8*O","fields":{"VALUE":0}}}},"next":{"block":{"type":"variables_set","id":"Cf-SgU0h/|v-!Q^9k-b6","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"VALUE":{"block":{"type":"math_number","id":"ma#QQ4qfMTB$a6#(=M?p","fields":{"NUM":0}}}}}}}},"ELSE":{"block":{"type":"controls_if","id":"f-,*:@2#uyD21rpE2f)f","extraState":{"elseIfCount":1},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"2nY3KBpnFQ.2yXV[x68L","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"list_index","id":"B[/K_[ezcB2Qx~37R4M-","fields":{"INDEX":0},"inputs":{"LIST":{"block":{"type":"variables_get","id":",Yo/8Lf=M*CmYrw_OUj(","fields":{"VAR":{"id":"N;q[+Y+(ah3cQgJ:uCc]"}}}}}}},"B":{"block":{"type":"value_std_logic","id":"~(@!41XyTF6o`q~PKqdq","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":"}K[KHLm0?`E~d/(XP1vh","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"UV9mO#P,pc?1F+kN-|~]","fields":{"VALUE":1}}}}}},"IF1":{"block":{"type":"logic_compare","id":"u1MTJoP`db#/(ia?gQFr","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"list_index","id":"ZUV!0KG40./|gDHaQ1dI","fields":{"INDEX":1},"inputs":{"LIST":{"block":{"type":"variables_get","id":"?}{8%#9qAKe{QptQ%H3[","fields":{"VAR":{"id":"N;q[+Y+(ah3cQgJ:uCc]"}}}}}}},"B":{"block":{"type":"value_std_logic","id":":/K-oZGH+Df@l|.cNM7W","fields":{"VALUE":1}}}}}},"DO1":{"block":{"type":"variables_set","id":":2}zwaU/+0U_^^X6SdVZ","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"j]v$V?;+-|3c6IA86}%b","fields":{"VALUE":0}}}}}}},"next":{"block":{"type":"controls_if","id":"+w#Q=H/Nwo|sX*WnGu_7","inputs":{"IF0":{"block":{"type":"logic_operation","id":"ct^,b/*0mfrz)hZ96%SR","fields":{"OPERATION":"and"},"inputs":{"A":{"block":{"type":"logic_compare","id":"ar033LzB:8~Asbfhqc1G","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"14Nh=)5qx3Kp7CnM{_3Q","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}}}},"B":{"block":{"type":"value_std_logic","id":"`Z:vS*c~|rDt;H^|*;6/","fields":{"VALUE":1}}}}}},"B":{"block":{"type":"logic_compare","id":"wjWT^X5D+m=*SCJgao1i","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"w%M}[tqe1tZ~$hGT{Auh","fields":{"VAR":{"id":"vLZ;k9sxoNVKVc?I}kk|"}}}},"B":{"block":{"type":"value_std_logic","id":"ivUlYk}vMq%}C_o|+hpe","fields":{"VALUE":1}}}}}}}}},"DO0":{"block":{"type":"controls_if","id":"02fAV_-?A;IM5h+kf{B4","extraState":{"hasElse":true},"icons":{"comment":{"text":"to prevent natural overflow","pinned":true,"height":80,"width":160}},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"RzN!wxca#NjI~DODa)C=","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"%@),sr{`cx-V9bcvV48S","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}}}},"B":{"block":{"type":"math_number","id":"[BHDfT^}`|fQA`/=mn}5","fields":{"NUM":15}}}}}},"DO0":{"block":{"type":"variables_set","id":":uxhh-O5/%w=;qFRPM3e","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"VALUE":{"block":{"type":"math_number","id":"d7`j(wM,Ck,x#R.h4hX+","fields":{"NUM":0}}}}}},"ELSE":{"block":{"type":"math_change","id":"q$0[C|3apsd3w^;44!%{","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"DELTA":{"shadow":{"type":"math_number","id":"N][!U{H/z_@V-SvgJBKp","fields":{"NUM":1}}}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"cnt","id":"gWcVR:~_ouWxb9@{IwGa"},{"name":"run","id":"E0tQW(i(Up||M4R4RYG["},{"name":"clk","id":"5Y9_SLHF8Bd4|n|ymNgJ"},{"name":"reset","id":"2G:Z~BB|CAam0[(.o??k"},{"name":"incr","id":"vLZ;k9sxoNVKVc?I}kk|"},{"name":"buttons","id":"N;q[+Y+(ah3cQgJ:uCc]"},{"name":"leds","id":"zZ.FFw)dey[B4Vwn^yh`"}],"signals":{"run":"std_logic","cnt":"integer range 0 to 15"}}
{"blocks":{"languageVersion":0,"blocks":[{"type":"process","id":"avqozk~ylO6~9`OoO-tF","x":463,"y":13,"extraState":{"depCount":1},"fields":{"1":{"id":"5Y9_SLHF8Bd4|n|ymNgJ"}},"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":"5Y9_SLHF8Bd4|n|ymNgJ"}}}},"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":"2G:Z~BB|CAam0[(.o??k"}}}},"B":{"block":{"type":"value_std_logic","id":"HV[(76@,1o#o|NIyg{4L","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":")~8k1(;U?4ft4XPFi{@o","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"Xxc}cOExM?./jx~mV8*O","fields":{"VALUE":0}}}},"next":{"block":{"type":"variables_set","id":"Cf-SgU0h/|v-!Q^9k-b6","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"VALUE":{"block":{"type":"math_number","id":"ma#QQ4qfMTB$a6#(=M?p","fields":{"NUM":0}}}}}}}},"ELSE":{"block":{"type":"controls_if","id":"f-,*:@2#uyD21rpE2f)f","extraState":{"elseIfCount":1},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"2nY3KBpnFQ.2yXV[x68L","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"list_index","id":"B[/K_[ezcB2Qx~37R4M-","fields":{"INDEX":0},"inputs":{"LIST":{"block":{"type":"variables_get","id":",Yo/8Lf=M*CmYrw_OUj(","fields":{"VAR":{"id":"N;q[+Y+(ah3cQgJ:uCc]"}}}}}}},"B":{"block":{"type":"value_std_logic","id":"~(@!41XyTF6o`q~PKqdq","fields":{"VALUE":1}}}}}},"DO0":{"block":{"type":"variables_set","id":"}K[KHLm0?`E~d/(XP1vh","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"UV9mO#P,pc?1F+kN-|~]","fields":{"VALUE":1}}}}}},"IF1":{"block":{"type":"logic_compare","id":"u1MTJoP`db#/(ia?gQFr","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"list_index","id":"ZUV!0KG40./|gDHaQ1dI","fields":{"INDEX":1},"inputs":{"LIST":{"block":{"type":"variables_get","id":"?}{8%#9qAKe{QptQ%H3[","fields":{"VAR":{"id":"N;q[+Y+(ah3cQgJ:uCc]"}}}}}}},"B":{"block":{"type":"value_std_logic","id":":/K-oZGH+Df@l|.cNM7W","fields":{"VALUE":1}}}}}},"DO1":{"block":{"type":"variables_set","id":":2}zwaU/+0U_^^X6SdVZ","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}},"inputs":{"VALUE":{"block":{"type":"value_std_logic","id":"j]v$V?;+-|3c6IA86}%b","fields":{"VALUE":0}}}}}}},"next":{"block":{"type":"controls_if","id":"+w#Q=H/Nwo|sX*WnGu_7","inputs":{"IF0":{"block":{"type":"logic_operation","id":"ct^,b/*0mfrz)hZ96%SR","fields":{"OPERATION":"and"},"inputs":{"A":{"block":{"type":"logic_compare","id":"ar033LzB:8~Asbfhqc1G","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"14Nh=)5qx3Kp7CnM{_3Q","fields":{"VAR":{"id":"E0tQW(i(Up||M4R4RYG["}}}},"B":{"block":{"type":"value_std_logic","id":"`Z:vS*c~|rDt;H^|*;6/","fields":{"VALUE":1}}}}}},"B":{"block":{"type":"logic_compare","id":"wjWT^X5D+m=*SCJgao1i","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"w%M}[tqe1tZ~$hGT{Auh","fields":{"VAR":{"id":"vLZ;k9sxoNVKVc?I}kk|"}}}},"B":{"block":{"type":"value_std_logic","id":"ivUlYk}vMq%}C_o|+hpe","fields":{"VALUE":1}}}}}}}}},"DO0":{"block":{"type":"controls_if","id":"02fAV_-?A;IM5h+kf{B4","extraState":{"hasElse":true},"icons":{"comment":{"text":"to prevent natural overflow","pinned":true,"height":80,"width":160}},"inputs":{"IF0":{"block":{"type":"logic_compare","id":"RzN!wxca#NjI~DODa)C=","fields":{"OP":"EQ"},"inputs":{"A":{"block":{"type":"variables_get","id":"%@),sr{`cx-V9bcvV48S","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}}}},"B":{"block":{"type":"math_number","id":"[BHDfT^}`|fQA`/=mn}5","fields":{"NUM":15}}}}}},"DO0":{"block":{"type":"variables_set","id":":uxhh-O5/%w=;qFRPM3e","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"VALUE":{"block":{"type":"math_number","id":"d7`j(wM,Ck,x#R.h4hX+","fields":{"NUM":0}}}}}},"ELSE":{"block":{"type":"math_change","id":"q$0[C|3apsd3w^;44!%{","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}},"inputs":{"DELTA":{"shadow":{"type":"math_number","id":"N][!U{H/z_@V-SvgJBKp","fields":{"NUM":1}}}}}}}}}}}}}}}}}}}}}},{"type":"process_direct_set","id":"2WV_x^9Fn^K5~HN@?IpG","x":-12,"y":13,"fields":{"VAR":{"id":"zZ.FFw)dey[B4Vwn^yh`"}},"inputs":{"VALUE":{"block":{"type":"ieee.numeric_std_unsigned_to_stdulogicvector","id":")LdWhR+dpy:CwuP0dPr@","inputs":{"NUM":{"block":{"type":"variables_get","id":"+]QX^TgSSU{H:QQ1jOID","fields":{"VAR":{"id":"gWcVR:~_ouWxb9@{IwGa"}}}}}}}}}]},"variables":[{"name":"cnt","id":"gWcVR:~_ouWxb9@{IwGa"},{"name":"run","id":"E0tQW(i(Up||M4R4RYG["},{"name":"clk","id":"5Y9_SLHF8Bd4|n|ymNgJ"},{"name":"reset","id":"2G:Z~BB|CAam0[(.o??k"},{"name":"incr","id":"vLZ;k9sxoNVKVc?I}kk|"},{"name":"buttons","id":"N;q[+Y+(ah3cQgJ:uCc]"},{"name":"leds","id":"zZ.FFw)dey[B4Vwn^yh`"}],"signals":{"cnt":"integer range 0 to 15","run":"std_logic"}}
7 changes: 6 additions & 1 deletion examples/binary_counter.vhdl.sbe
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"reset" : ["in", "std_logic"],
"incr" : ["in", "std_logic"],
"buttons" : ["in", "std_logic_vector(3 downto 0)"],
"leds" : ["out", "std_logic_vector(3 downto 0)", "0000"]
"leds" : ["out", "std_logic_vector(3 downto 0)"]
},
"libraries": {
"ieee": {
"numeric_std_unsigned": "ieee.numeric_std_unsigned.sbi"
}
}
}
2 changes: 1 addition & 1 deletion examples/button_driven.vhdl.sbe
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"reset" : ["in", "std_logic"],
"incr" : ["in", "std_logic"],
"buttons" : ["in", "std_logic_vector(3 downto 0)"],
"leds" : ["out", "std_logic_vector(3 downto 0)", "0000"]
"leds" : ["out", "std_logic_vector(3 downto 0)"]
},
"name": "led4_button4"
}
20 changes: 20 additions & 0 deletions examples/ieee.numeric_std_unsigned.sbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
([
{
"block": {
"kind": "block",
"type": "ieee.numeric_std_unsigned_to_stdulogicvector",
"message0": "to_stdulogicvector %1",
colour,
"args0": [
{
"type": "input_value",
"name": "NUM"
}
],
"output": null,
},
"generator": function (block) {
return ["to_stdulogicvector(" + generator.valueToCode(block, "NUM", generator.ORDER_NONE) + ")", generator.ORDER_FUNCTION_CALL]
}
}
])
Empty file removed examples/library.vhdl
Empty file.
Empty file removed examples/library.vhdl.sbi
Empty file.
Loading

0 comments on commit e979380

Please sign in to comment.