Синтез схеми ПЛІС для інвертора
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
rr_carry,curr_zero,curr_ir)
BEGIN
-- set the default values for these signals to avoid synthesis
-- of implied latches
sel_data_ram <= 0;
read <= 0;
write <= 0;
ld_ir <= 0;
ld_ir_lsn <= 0;
inc_pc <= 0;
jump_pc <= 0;
alu_op <= "000";
CASE curr_st IS
WHEN FETCH =>
-- fetch an instruction from external RAM
sel_data_ram <= 0; -- select the instruction RAM
read <= 1; -- read from the RAM
ld_ir <= 1;-- load the instruction
-- register with the opcode
inc_pc <= 1; -- increment the PC
-- to the next instruction
next_st <= DECODE; -- then decode the
-- instruction that was just loaded
WHEN DECODE =>
-- decode the instruction. Actually, this state is used to
-- read a direct-address operand from the data section of the
-- external RAM and store it in the lower 4 bits of the IR.
IF curr_ir(7 DOWNTO 4)=LOAD_DIR THEN
sel_data_ram <= 1;
read <= 1;
ld_ir_lsn <= 1;
END IF;
IF curr_ir(7 DOWNTO 4)=ADD_DIR THEN
sel_data_ram <= 1;
read <= 1;
ld_ir_lsn <= 1;
END IF;
IF curr_ir(7 DOWNTO 4)=XOR_DIR THEN
sel_data_ram <= 1;
read <= 1;
ld_ir_lsn <= 1;
END IF;
IF curr_ir(7 DOWNTO 4)=TEST_DIR THEN
sel_data_ram <= 1;
read <= 1;
ld_ir_lsn <= 1;
END IF;
next_st <= EXECUTE;-- then execute the instruction
WHEN EXECUTE =>
-- execute the instruction.
IF curr_ir=CLEAR_C THEN
alu_op <= CLR_CARRY_OP;-- clear the carry flag
END IF;
IF curr_ir=SET_C THEN
alu_op <= SET_CARRY_OP;-- set the carry flag
END IF;
IF curr_ir=SKIP_C THEN-- skip the next instruction
inc_pc <= curr_carry; -- if the carry flag is set
END IF;
IF curr_ir=SKIP_Z THEN-- skip the next instruction
inc_pc <= curr_zero; -- if the zero flag is set
END IF;
IF curr_ir(7 DOWNTO 4)=LOAD_IMM THEN
-- load the ACC with immediate
alu_op <= PASS_OP;
-- data from the lower 4 bits of IR
END IF;
IF curr_ir(7 DOWNTO 4)=ADD_IMM THEN
-- add the lower 4 bits of the
alu_op <= ADD_OP;-- IR to the ACC
END IF;
IF curr_ir(7)=JUMP THEN
-- jump to the address stored in the
jump_pc <= 1;
-- lower 7 bits of the IR
END IF;
IF curr_ir(7 DOWNTO 4)=STORE_DIR THEN
-- write the ACC to RAM
sel_data_ram <= 1;
write <= 1;
END IF;
IF curr_ir(7 DOWNTO 4)=LOAD_DIR THEN
-- load the ACC with the
alu_op <= PASS_OP;
-- data read from RAM in the previous cycle
END IF;
IF curr_ir(7 DOWNTO 4)=ADD_DIR THEN
-- add the data read from RAM in
alu_op <= ADD_OP;
-- the previous cycle to the ACC
END IF;
IF curr_ir(7 DOWNTO 4)=XOR_DIR THEN
-- XOR the data read from RAM in
alu_op <= XOR_OP;
-- the previous cycle to the ACC
END IF;
IF curr_ir(7 DOWNTO 4)=TEST_DIR THEN
-- mask the ACC with the value
alu_op <= AND_OP;
-- read from RAM in the previous cycle and
END IF;
-- set the zero flag if all the bits are zero
next_st <= FETCH;
-- execution complete, so go fetch another instruction
WHEN others =>
END CASE;
END PROCESS;
-- this process makes the next value of all these signals into the
-- current value on the rising clock edge
PROCESS (clk,reset)
BEGIN
-- asynchronously reset the state of the GNOME microcomputer
IF reset=1 THEN
curr_st <= FETCH;-- start by fetching instructions
curr_pc <= "0000000";-- start at beginning of instruction RAM
curr_ir <= "00000000";
curr_acc <= "0000";-- clear accumulator
curr_carry <= 0; -- clear carry flag
curr_zero <= 0; -- clear zero flag
-- otherwise, update state on the rising clock edge
ELSIF (clkevent AND clk=1) THEN
curr_st <= next_st;
curr_pc <= next_pc;
curr_ir <= next_ir;
curr_acc <= next_acc;
curr_carry <= next_carry;
curr_zero <= next_zero;
END IF;
END PROCESS;
END gnome_arch;
В відповідному розділі записки потрібно подати:
-текст моделі з коментарями державною мовою;
-побудовану на основі VHDL моделі структурну схему процесора (це можна зробити за допомогою утиліти RTL schematic Viewer, що містить САПР WebPack);
-додаткові (поза коментарями) розяснення щодо семантики VHDL моделі;
-витяги з протоколів синтезу, імплементування, програмування, діаграму часового симулювання поведінки процесора як окремого проекту.
Розробка VHDL моделі памяті даних
Модель памяті даних складено так, аби VHDL синтезатор за стилем написання винайшов, що її треба реалізувати на вбудованих до цільової ПЛІС елементах RAM. Це покращує реалізацію проекту. Існує варіант прямого запису в тексті моделі бібліотечних посилань на вбудовані елементи. Проте така модель набуває рис непересувної, хоча і ефективної моделі низького рівня. Це не завжди є бажаним. Подамо текст моделі памяті даних.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ram is
port (clk : in std_logic;
oe : in std_logic;
we : in std_logic;
sel_ram : in std_logic;
address : in std_logic_vector(6 downto 0);
data : inout std_logic_vector(7 downto 0));
end ram;
architecture syn of ram is
type ram_type is array (15 downto 0)of std_logic_vector (3 downto 0);
signal RAM : ram_type;
begin
process (clk)
begin
if (clkevent and clk = 1) then
if ((sel_ram = 1)and (oe=1)and (we=0)) then
RAM(conv_integer(address(3 downto 0))) <= data (3 downto 0);
end if;
end if;
end process;
data <= "0000"& RAM(conv_integer(address(3 downto 0)))
when ((sel_ram=1) and (oe=0) and (we=1)) else
"ZZZZZZZZ";
end syn;
В відповідному розділі пояснювальної записки потрібно подати:
-текст моделі з коментарями державною мовою;
-побудовану на основі VHDL моделі структурну схему памяті;
-додаткові розяснення щодо семантики VHDL кодів;
-витяги з протоколів синтезу, імплементування, програмування і часову діаграму симулювання памяті даних як окремого проекту.
Розробка VHDL моделі памяті програм
Подамо VHDL модель постійної (так нам зручно) памяті програм. Ця память містить машинні коди тестової програми. За допомогою цієї моделі ми вбудовуємо програму до компютера. Ясно, що зміна програми вимагатиме пересинтезу і переімплементування проекту.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity rom is
port (
sel_ram : in std_logic;
oe : in std_logic;
ADDR : in std_logic_vector (6 downto 0);
DATA : inout STD_LOGIC_VECTOR (7 downto 0));
end rom;
architecture XILINX of rom is
subtype ROM_WORD is STD_LOGIC_VECTOR (7 downto 0);
type ROM_TABLE is array (0 to 19) of ROM_WORD;
constant ROM: ROM_TABLE := ROM_TABLE (
ROM_WORD (x"18"), -- start of test program
ROM_WORD (x"30"),
ROM_WORD (x"14"),
ROM_WORD (x"31"),
ROM_WORD (x"19"),
ROM_WORD (x"32"),
ROM_WORD (x"12"),
ROM_WORD (x"33"),
ROM_WORD (x"00"),
ROM_WORD (x"40"),
ROM_WORD (x"52"),
ROM_WORD (x"34"),
ROM_WORD (x"41&qu