📄 guibrain.tdf
字号:
FUNCTION debounce (left_button, right_button, clk)
RETURNS (debou_left, debou_right, reset, 1Hz, 12Mhz);
INCLUDE "lpm_counter.inc";
SUBDESIGN guibrain
(left, right, clk, y_valid : INPUT;
new, sel, cnt_out[4..0], toggle, reset, 12Mhz : OUTPUT;)
VARIABLE
io : debounce;
cnt[4..0] : dff;
brain : MACHINE WITH STATES (idle, sel_value, process1, process2, process3);
cnt_ena : NODE;
BEGIN
brain.clk = io.12Mhz;
brain.reset = io.reset;
reset = io.reset;
CASE brain IS
WHEN idle =>
IF io.debou_left THEN
brain = sel_value;
END IF;
sel = VCC; -- DISPLAY = RESULT
WHEN sel_value =>
cnt_ena = VCC;
-- wait until the right value is picked
IF io.debou_right THEN
brain = process1;
END IF;
sel = GND; -- DISPLAY = COUNTER input
WHEN process1 =>
-- start the process by setting the new =1
new = VCC;
brain = process2;
sel = GND; -- DISPLAY = RESULT
WHEN process2 =>
IF y_valid THEN -- confirm fir filter is ready for the next input
brain = process3;
END IF;
-- clear the new input
new = B"0";
sel = VCC; -- DISPLAY = RESULT
WHEN process3 =>
IF io.debou_left THEN
brain = sel_value;
END IF;
sel = VCC; -- DISPLAY = RESULT
END CASE;
-- counter from 0 to 16 for FIR filter input
cnt_out[] = cnt[].q;
cnt[].clrn = !io.reset;
cnt[].clk = io.12Mhz;
IF cnt_ena & io.debou_left THEN
IF (cnt[].q == B"10000") THEN
cnt[] = B"00000";
else
cnt[] = cnt[] + 1;
END IF;
else
cnt[] = cnt[];
END IF;
-- Connection to and from sub-design debounce.gdf
io.left_button = left;
io.right_button = right;
io.clk = clk;
12Mhz = io.12Mhz;
toggle = io.1hz;
END;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -