1. Trang chủ
  2. » Tất cả

socpartfinished

14 214 2
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

SOC homework 1 Hv: Nguyễn Trọng Trí Mshv: 12140051 Thiết kế 1 mạch tìm thấy giá trị nhập 8 bit X trong bộ nhớ 64 x 8 và trả về chỉ số của giá trị mà nó tìm thấy trong bộ nhớ (tìm từ địa chỉ 0) và khi không tìm thấy thì nó trả về trị –1. Mạch bắt đầu khi tín hiệu START là 1 và khi hoàn tất việc tìm kiếm thì nó cho tín hiệu DONE lên 1. 1) Vẽ giản đồ FSMD 2) Tạo ra datapath dùng các thành phần như: RAM, mạch cộng, mạch so sánh, mạch dồn kênh và thanh ghi. 3) Vẽ sơ đồ kết nối controller với datapath. 4) Vẽ giản đồ FSM của controller. 5) Viết mã VHDL để cài đặt mạch này và thử mô phỏng nó trên MaxplusII hay QuartusII 1. Vẽ giản đồ FSMD Hình 1.1 Flowing chart Hình 1.2 FSMD diagram 2. Tạo mạch datapath Hình 2.1 Datapath schematic 3. Sơ đồ kết nối controller với datapath 4. Vẽ giản đồ FSM của controller 5. Viết mã VHDL để cài đặt thiết kế và mô phỏng trên Quartus II Viết mã VHDL cho thiết kế: --*========================================================= -- File: ram_data_detector.vhd -- Project: SOC homework 1 -- Author: Nguyen Trong Tri -- Date: 2013/03/18 -- Version : v1.0 -- Description: Detect a 'X' value in ram 64 x 8 --*========================================================= -- Standard library LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; -- Declarations ENTITY ram_data_detection IS GENERIC( ADDRESS_WIDTH : integer := 6; DATA_WIDTH : integer := 8 ); PORT ( clock: IN std_logic; rst_n: IN std_logic; start: IN std_logic; din : IN std_logic_vector (DATA_WIDTH - 1 downto 0); done: OUT std_logic; indexout: OUT std_logic_vector (ADDRESS_WIDTH downto 0) ); END ENTITY ram_data_detection; -- architecture ARCHITECTURE bhv of ram_data_detection is -- components -- ram COMPONENT ram IS GENERIC( ADDRESS_WIDTH : integer := 6; DATA_WIDTH : integer := 8 ); PORT( clock : IN std_logic; data : IN std_logic_vector(DATA_WIDTH - 1 DOWNTO 0); write_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0); read_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0); we : IN std_logic; q : OUT std_logic_vector(DATA_WIDTH - 1 DOWNTO 0) ); END COMPONENT ; -- fsm control COMPONENT fsm IS PORT ( clock: IN std_logic; rst_n: IN std_logic; start: IN std_logic; finished: IN std_logic; found : IN std_logic; en_load:OUT std_logic; en_add: OUT std_logic; en_finished: OUT std_logic; done: OUT std_logic ); END COMPONENT fsm; --interconnecting wires, regs SIGNAL found : std_logic; SIGNAL finished : std_logic; SIGNAL en_load : std_logic; SIGNAL en_add : std_logic; SIGNAL en_finished: std_logic; SIGNAL reg_din: std_logic_vector(DATA_WIDTH - 1 downto 0); SIGNAL reg_ram_data: std_logic_vector(DATA_WIDTH - 1 downto 0); SIGNAL ram_data: std_logic_vector(DATA_WIDTH - 1 downto 0); SIGNAL reg_next_addr: unsigned(ADDRESS_WIDTH downto 0); SIGNAL reg_addr: unsigned(ADDRESS_WIDTH downto 0); BEGIN -- get data and address process(clock,rst_n) begin if (rst_n = '0') then reg_din <= (others=>'0'); reg_addr <= (others=>'0'); indexout <= (others=>'1'); elsif (clock'event and clock='1') then -- get data in if (en_load = '1') then reg_din <= din; end if; -- get ram address reg_addr <= reg_next_addr; -- get index out if en_finished = '1' and found = '1' then indexout <= std_logic_vector(reg_addr); else indexout <= (others=>'1'); end if; end if; end process; -- next addresss reg_next_addr <= reg_addr + 1 when en_add = '1' else reg_addr; -- ram data reg_ram_data <= ram_data; -- Read ram data syn_ram: ram PORT MAP( clock => clock, data => (others=>'0'), write_address => (others=>'0'), read_address => std_logic_vector(reg_addr(ADDRESS_WIDTH - 1 downto 0)), we => '0', q => ram_data ); fsmctl: fsm PORT MAP( clock => clock, rst_n => rst_n, start => start, finished => finished, found => found, en_add => en_add, en_load => en_load, en_finished => en_finished, done => done ); -- next-state logic found <= '1' when (reg_din = reg_ram_data) else '0'; finished <= '1' when (reg_addr = 63) else '0'; end bhv; --*========================================================= -- File: fsm.vhd -- Project: SOC homework 1 -- Author: Nguyen Trong Tri -- Date : 2013/03/18 -- Version : v1.0 -- Description: fsm machine for datapath of ram_data_detector --*========================================================= -- Standard library LIBRARY ieee; USE ieee.std_logic_1164.all; -- Declarations ENTITY fsm IS PORT ( rst_n: IN std_logic; clock: IN std_logic; start: IN std_logic; finished: IN std_logic; found : IN std_logic; en_load: OUT std_logic; en_add: OUT std_logic; en_finished: OUT std_logic; done: OUT std_logic ); END ENTITY fsm; -- architecture ARCHITECTURE fsm_arch of fsm is TYPE fsm_states IS (idle_state, load_state, cmp_state, finish_state); SIGNAL state_reg, state_next: fsm_states; SIGNAL en_out: std_logic_vector(2 downto 0); begin -- state register process (clock, rst_n) begin if (rst_n = '0') then state_reg <= idle_state; elsif (clock'event and clock='1') then state_reg <= state_next; end if; end process; -- next state logic process (state_reg, found, finished, start) begin case state_reg is when idle_state => if (start = '1')then state_next <= load_state; else state_next <= idle_state; end if; when load_state => state_next <= cmp_state; when cmp_state => if (finished = '1') or (found = '1') then

Ngày đăng: 01/04/2013, 09:32

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w