⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s2p-count.vhd

📁 design compile synthesis user guide
💻 VHD
字号:
use WORK.TYPES.ALL;     -- Use the TYPES packageentity SER_PAR is       -- Declare the interface  port(SERIAL_IN, CLOCK, RESET: in BIT;       PARALLEL_OUT: out PARALLEL_TYPE;       PARITY_ERROR, READ_ENABLE: out BIT);end;architecture BEHAVIOR of SER_PAR is  -- Signals for stored values  signal CURRENT_STATE, NEXT_STATE: STATE_TYPE;  signal CURRENT_PARITY, NEXT_PARITY: BIT;  signal CURRENT_BIT_POSITION, NEXT_BIT_POSITION:      INTEGER range PARALLEL_BIT_COUNT downto 0;  signal CURRENT_PARALLEL_OUT, NEXT_PARALLEL_OUT:      PARALLEL_TYPE;beginNEXT_ST: process(SERIAL_IN, CURRENT_STATE, RESET,                 CURRENT_BIT_POSITION, CURRENT_PARITY,                 CURRENT_PARALLEL_OUT)  -- This process computes all outputs, the next  --   state, and the next value of all stored values  begin    PARITY_ERROR <= '0'; -- Default values for all    READ_ENABLE <= '0';  --  outputs and stored values    NEXT_STATE <= CURRENT_STATE;    NEXT_BIT_POSITION <= 0;    NEXT_PARITY <= '0';    NEXT_PARALLEL_OUT <= CURRENT_PARALLEL_OUT;    if (RESET = '1') then      -- Synchronous reset      NEXT_STATE <= WAIT_FOR_START;    else      case CURRENT_STATE is   -- State processing        when WAIT_FOR_START =>          if (SERIAL_IN = '1') then            NEXT_STATE <= READ_BITS;            NEXT_PARALLEL_OUT <=                PARALLEL_TYPE'(others=>'0');          end if;        when READ_BITS =>          if (CURRENT_BIT_POSITION =              PARALLEL_BIT_COUNT) then            if (CURRENT_PARITY = SERIAL_IN) then              NEXT_STATE <= ALLOW_READ;              READ_ENABLE <= '1';            else              NEXT_STATE <= PARITY_ERROR_DETECTED;            end if;          else            NEXT_PARALLEL_OUT(CURRENT_BIT_POSITION) <=                SERIAL_IN;            NEXT_BIT_POSITION <=                CURRENT_BIT_POSITION + 1;            NEXT_PARITY <= CURRENT_PARITY xor                           SERIAL_IN;          end if;        when PARITY_ERROR_DETECTED =>          PARITY_ERROR <= '1';        when ALLOW_READ =>          NEXT_STATE <= WAIT_FOR_START;      end case;    end if;  end process;  SYNCH: process    -- This process remembers the stored values    --    across clock cycles  begin    wait until CLOCK'event and CLOCK = '1';    CURRENT_STATE <= NEXT_STATE;    CURRENT_BIT_POSITION <= NEXT_BIT_POSITION;    CURRENT_PARITY <= NEXT_PARITY;    CURRENT_PARALLEL_OUT <= NEXT_PARALLEL_OUT;  end process;  PARALLEL_OUT <= CURRENT_PARALLEL_OUT;end BEHAVIOR;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -