{"id":573,"date":"2015-10-15T08:27:38","date_gmt":"2015-10-15T08:27:38","guid":{"rendered":"http:\/\/coolt.ch\/notizen\/?p=573"},"modified":"2015-10-15T08:27:38","modified_gmt":"2015-10-15T08:27:38","slug":"state-machine-vhdl","status":"publish","type":"post","link":"https:\/\/coolt.ch\/notizen\/state-machine-vhdl\/","title":{"rendered":"State Machine VHDL"},"content":{"rendered":"<p><strong>states bitweise definieren<\/strong><\/p>\n<pre class=\"lang:sh decode:true\">constant s0         : std_logic_vector(2 downto 0) := \"000\";\r\nconstant s1         : std_logic_vector(2 downto 0) := \"100\";\r\nconstant s2         : std_logic_vector(2 downto 0) := \"110\";\r\nconstant s3         : std_logic_vector(2 downto 0) := \"011\";\r\nconstant s4         : std_logic_vector(2 downto 0) := \"001\";\r\nconstant s5         : std_logic_vector(2 downto 0) := \"111\";\r\n\r\nsignal state :        std_logic_vector(2 downto 0);\r\nsignal next_state:    std_logic_vector(2 downto 0);\r\n<\/pre>\n<p><strong>states als type<\/strong><\/p>\n<pre class=\"lang:sh decode:true\">type actual_state is (s0, s1, s2, s3, s4, s5, s6, s7);\r\n        \r\nsignal state:          actual_state  := s0;  \r\nsignal next_state:     actual_state  ;<\/pre>\n<p><strong><br \/>\nEnumeriter Type<\/strong><\/p>\n<pre class=\"lang:sh decode:true \">type actual_state is (s0, s1, s2, s3);\r\n\r\nattribute enum_encoding : string;\r\nattribute enum_encoding of actual_state: type is \"00 01 10 11\";  \r\n\r\n\/\/ nicht sicher:     \r\nsignal state:          actual_state  := s0;  \r\nsignal next_state:     actual_state  ;<\/pre>\n<p><strong><br \/>\nState-Zuweisung<\/strong><\/p>\n<pre class=\"lang:sh decode:true\">fsm: process (all)\r\n    begin\r\n        if (KEY_1 = '0') then\r\n            state &lt;= s0;\r\n        elsif (rising_edge(CLOCK_27)) then\r\n          state &lt;= next_state;\r\n        end if;\r\n    end process;<\/pre>\n<p><strong><br \/>\nLogik Events<\/strong><\/p>\n<pre class=\"lang:sh decode:true\">fsm_input: process (all)        \r\nbegin     \r\n    case state is\r\n       when s0 =&gt;\r\n          if(pulse ='1') then\r\n            next_state &lt;= s1;\r\n          else\r\n            next_state &lt;= s0;\r\n          end if;           \r\n       when s1 =&gt;    \r\n          if(pulse ='1') then\r\n             if SW_17 = '1' the\r\n                next_state &lt;= s2;  \r\n             else\r\n                next_state &lt;= s0;\r\n             end if;\r\n          else\r\n             next_state &lt;= s1;\r\n          end if;\r\n       when s2 =&gt;   next_state &lt;= s3;\r\n       when s3 =&gt;   next_state &lt;= s4;\r\n       when s4 =&gt;   next_state &lt;= s5;\r\n       when s5 =&gt;   next_state &lt;= s6;\r\n       when s6 =&gt;   next_state &lt;= s7\r\n       when s7 =&gt;   next_state &lt;= s7;    \r\n    end case;        \r\n end process;<\/pre>\n<p><strong>Output Action <\/strong><\/p>\n<pre class=\"lang:sh decode:true\">fsm_output: process (all)\r\nbegin   \r\n    case state is\r\n            when s0 =&gt;   out     &lt;= \"001\"; \r\n            when s1 =&gt;   out     &lt;= \"011\"; GPIO_0_0 &lt;= '1';\r\n            when s2 =&gt;   LEDR_2  &lt;= '1';\r\n            when s3 =&gt;   LEDR_3  &lt;= '1';\r\n   \r\n            when OTHERS =&gt;   NULL;\r\n      end case;\r\nend process;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>states bitweise definieren constant s0 : std_logic_vector(2 downto 0) := &#8222;000&#8220;; constant s1 : std_logic_vector(2 downto 0) := &#8222;100&#8220;; constant s2 : std_logic_vector(2 downto 0) := &#8222;110&#8220;; constant s3 : std_logic_vector(2 downto 0) := &#8222;011&#8220;; constant s4 : std_logic_vector(2 downto 0) := &#8222;001&#8220;; constant s5 : std_logic_vector(2 downto 0) := &#8222;111&#8220;; signal state : std_logic_vector(2 &hellip; <a href=\"https:\/\/coolt.ch\/notizen\/state-machine-vhdl\/\" class=\"more-link\"><span class=\"screen-reader-text\">State Machine VHDL<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[59],"tags":[10,3],"_links":{"self":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/573"}],"collection":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/comments?post=573"}],"version-history":[{"count":2,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":575,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/573\/revisions\/575"}],"wp:attachment":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/media?parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/categories?post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/tags?post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}