2014-01-06 4 views
0

자일링스 (VHDL)를 코딩하는 법을 배우고 있습니다. 다음으로 간단한 마이크로 프로세서/마이크로 컨트롤러를 만들고 슬라이스 구성 요소에 대해 조금 배우고 싶습니다. 그래서 제 목표는 AMD 2901 (4 비트 슬라이스)을 사용하여 8 비트 마이크로 프로세서를 코딩하는 것입니다. (나는 이미 2901의 코드와 그 입출력 신호에 대한 모든 정보를 가지고있다.)VHDL 마이크로 프로세서/마이크로 컨트롤러

나는 마이크로 프로세서의 아키텍처를 만들 것 인 첫 번째 단계를 알고 있으므로 이런 식으로 끝났다. 버스의 대역폭은 내가 찾고있는 것과 매우 다를 것입니다.) 내가 그림 같은 중앙 버스를 코딩 어떻게

  1. :

    http://www.cs.binghamton.edu/~reckert/wk15fig1.JPG 그래서 여기

    을 지키는 질문입니다 (기본적으로 모든 나는 http://www.cs.binghamton.edu/~reckert/hardwire3new.html 여기에서 그것을 얻을 마이크로 프로세서 및 마이크로 컨트롤러에 대해 알고) 보여 주었다? 다이어그램처럼 중앙의 큰 버스를 사용하여 내 기억과 구성 요소를 "듣고"쓸 수있는 방법은 무엇입니까?

  2. 2901 ALU (두 개)를 사용하여 8 비트 마이크로 프로세서를 사용하고 싶습니다. 질문 : 내 opcode가 xxxxx001 (여기서 x는 제어 신호이고 001은 ALU에 대한 추가를 의미 함)를 사용한다고 가정 해 봅시다. 슬라이스 ALU가있는 경우 opcode는 xxxxx001001이어야합니다. 두 ALU 모두에게 명령을 내릴 수 있습니까? 또는 ALU가 동일한 "001"명령을 공유해야합니까? (VHDL에서 버스를 사용하는 방법을 알고 두 포트를 "듣거나"만드는 방법을 알 수 있습니다.)

  3. 내 목표와 함께 도움이되는 정보가 담긴 튜토리얼이나 링크를 나와 공유 할 수 있다면 그것은 굉장 할 것이다. 나는 많은 것을 수색했으며 매우 적은 정보를 발견했다.

답변

3

이 답변은 질문의 세 번째 부분입니다.

the MCPU project을 살펴 보는 것이 도움이 될 수 있습니다. 그것은 77 라인의 VHDL 코드에서 8 비트 CPU입니다. 제작자가 전체 디자인을 32 개의 매크로 셀에 집어 넣었으므로 코드는 약간의 까다로운 부분이 있지만 the design document이 도움이됩니다.

또한 아래에 포함 된 코드 가독성을 목표로 리팩터링 버전을 만들었습니다. 저는 프로젝트의 원작자는 아니며, 모든 명성은 Tim Böscke에게 있습니다.

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all; 

entity mcpu is 
    port (
     data_bus: inout std_logic_vector(7 downto 0); 
     address: out std_logic_vector(5 downto 0); 
     n_oe: out std_logic; 
     -- Asynchronous memory interface 
     n_we: out std_logic;  
     n_reset: in std_logic; 
     clock: in std_logic 
    ); 
end; 

architecture refactored of mcpu is 
    signal accumulator: std_logic_vector(8 downto 0); 
    alias carry is accumulator(8); 
    alias result is accumulator(7 downto 0); 
    alias opcode is data_bus(7 downto 6); 

    signal address_register: std_logic_vector(5 downto 0); 
    signal pc: std_logic_vector(5 downto 0); 
    signal states: std_logic_vector(2 downto 0); 

    type cpu_state_type is (FETCH, WRITE, ALU_ADD, ALU_NOR, BRANCH_NOT_TAKEN); 
    signal cpu_state: cpu_state_type; 

    type state_encoding_type is array (cpu_state_type) of std_logic_vector(2 downto 0); 
    constant STATE_ENCODING: state_encoding_type := (
     FETCH => "000", 
     WRITE => "001", 
     ALU_ADD => "010", 
     ALU_NOR => "011", 
     BRANCH_NOT_TAKEN => "101" 
); 

begin 
    process (clock, n_reset) 
    begin 
     if not n_reset then 
      -- start execution at memory location 0 
      address_register <= (others => '0'); 
      states <= "000"; 
      cpu_state <= FETCH; 
      accumulator <= (others => '0'); 
      pc <= (others => '0'); 
     elsif rising_edge(clock) then 

      -- PC/Adress path 
      if cpu_state = FETCH then 
       pc <= address_register + 1; 
       address_register <= data_bus(5 downto 0); 
      else 
       address_register <= pc; 
      end if; 

      -- ALU/Data Path 
      case cpu_state is 
       when ALU_ADD => 
        accumulator <= ('0' & result) + ('0' & data_bus); 
       when ALU_NOR => 
        result <= result nor data_bus; 
       when BRANCH_NOT_TAKEN => 
        carry <= '0'; 
       when others => null; 
      end case; 

      -- State machine 
      if cpu_state /= FETCH then 
       cpu_state <= FETCH; 
      elsif opcode ?= "11" and carry then 
       cpu_state <= BRANCH_NOT_TAKEN; 
      else 
       states <= "0" & not opcode;  -- execute instruction 
       case opcode is 
        when "00" => cpu_state <= ALU_NOR; -- 011 
        when "01" => cpu_state <= ALU_ADD; -- 010      
        when "10" => cpu_state <= WRITE; -- 001 
        when "11" => cpu_state <= FETCH; -- 000 
        when others => null;      
       end case; 
      end if; 
     end if; 
    end process; 

    -- output 
    address <= address_register;  
    data_bus <= result when (cpu_state = WRITE) else (others => 'Z'); 

    -- output enable is active low, asserted only when 
    -- rst=1, clk=0, and state!=001(wr_acc) and state!=101(read_pc) 
    n_oe <= '1' when (clock='1' or cpu_state = WRITE or n_reset = '0' or cpu_state = BRANCH_NOT_TAKEN) else '0'; 

    -- write enable is active low, asserted only when 
    -- rst=1, clk=0, and state=001(wr_acc) 
    n_we <= '1' when (clock = '1' or cpu_state /= WRITE or n_reset = '0') else '0'; 

end; 
관련 문제