FSM代码:
PROCESS(clk_153K) --时序逻辑
BEGIN
IF (clk_153K'EVENT AND clk_153K = '1')THEN
IF(reset = '0')THEN
CUR_STATE <= R_start;
ELSE
CUR_STATE <= NEXT_STATE;
...
END PROCESS;
PROCESS(CUR_STATE) --组合逻辑
BEGIN
CASE CUR_STATE IS
WHEN R_start =>
NEXT_STATE <= R_centre;
dalay_count <= "0000";
rxd_data <= "0000"&dalay_count;
WHEN R_centre =>
NEXT_STATE <= R_wait;
dalay_count <= dalay_count + 1; --问题所在,值不更新,望指点
rxd_data <= "0000"&dalay_count;
WHEN R_wait =>
dalay_count <= "0010";
rxd_data <= "0000"&dalay_count;
NEXT_STATE <= R_sample;
WHEN R_sample =>
dalay_count <= "0011";
rxd_data <= "0000"&dalay_count;
NEXT_STATE <= R_stop;
WHEN R_stop =>
dalay_count <= "0100";
rxd_data <= "0000"&dalay_count;
NEXT_STATE <= R_start;
WHEN OTHERS =>
NEXT_STATE <= R_start;
END CASE;
END PROCESS; |