Курсовая работа: Моделирование процессора (операционного и управляющего автоматов) для выполнения набора машинных команд
begin
process (CLK, RST)
begin
if CLK='0' and CLK'event and RIn='1'and C='1' then regist<=DataIN;
end if;
if CLK='0' and CLK'event and ROut='1'and C='1' then DataOut<=regist after 3 ns;
end if;
if CLK='0' and CLK'event and ROut='0' then DataOut<= «ZZZZZZZZ» after 3 ns;
end if;
if RST='1' then regist<= «00000000»;
end if;
end process;
end R0;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RDC is
port (Number: in std_logic_vector (7 downto 0);
RDCIn: in std_logic;
R1: out std_logic;
R2: out std_logic;
R3: out std_logic;
R4: out std_logic);
end RDC;
architecture RDC of RDC is
begin
process(RDCIn)
begin
if RDCIn='1' and RDCIn'event then
R1<='0';
R2<='0';
R3<='0';
R4<='0';
if Number= «00000001» then R1<='1'after 2ns;
end if;
if Number= «00000010» then R2<='1'after 2ns;
end if;
if Number= «00000011» then R3<='1'after 2ns;
end if;
if Number= «00000100» then R4<='1'after 2ns;
end if;
end if;
end process;
end RDC;
Временная диаграмма работы выбора регистров РОН RDC:
Описание памяти RAM:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_signed.all;
entity RAM is
port (RdWr: in std_logic;
CS: in std_logic;
Adr: in std_logic_vector (7 downto 0);
Data: inout std_logic_vector (7 downto 0));
end RAM;
architecture RAM of RAM is
type MemoryType is array (0 to 8) of std_logic_vector (7 downto 0);
signal Memory: MemoryType:=(
«00000000», mov A,#d
«00110011», #d
«00000001», mov R,#d
«00000001», number R
«11110110», #d
«00000010», add A, Rn
«00000001», number R
«00000100», JBC bit, rel
«00000000»); restart
begin
process (RdWr, CS, Adr)
begin
if RdWr='1' and CS='1' then Data<=Memory (CONV_INTEGER ('0'& Adr)) after 3ns;
end if;
if RdWr='0' and CS='1' then Memory (CONV_INTEGER ('0'& Adr))<=Data;
end if;
end process;
end RAM;
Описание регистра в один бит:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity R_1bit is
port (reg_in, IE: in std_logic;
CLK, Zero:in std_logic;
reg_out: out std_logic);
end R_1bit;
architecture R_1bit of R_1bit is
signal regist: std_logic;
begin
process(CLK)
begin
reg_out<= regist;
if CLK='0' and CLK'event and IE='1' then regist<=reg_in after 2ns;
elsif Zero='1' then regist<='0' after 2ns;
end if;
end process;
end R_1bit;
–
Временная диаграмма работы памяти МПА RAM:
Описание регистра-аккумулятора RA:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RA is
port (
CLK: in std_logic;
RAIn: in std_logic;
DIn: in std_logic_vector (7 downto 0);
DOut: out std_logic_vector (7 downto 0)
);
end RA;
architecture RA of RA is
signal reg: std_logic_vector (7 downto 0):= «00000000»;
begin
process (CLK, RAIn)
begin
DOut<=reg after 3 ns;
if CLK='0' and CLK'event and RAIn='1' then
reg<=DIn;
end if;
end process;
end RA;
Временная диаграмма работы регистра-аккумулятора RA:
Описание узла памяти Memory:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_signed.all;
entity Memory is
port (Adr: in std_logic_vector (5 downto 0);
RD: in std_logic;
MrOut: out std_logic;
InstrCom: out std_logic_vector (0 to 27));
end Memory;
architecture Memory of Memory is
type MemoryType is array (0 to 59) of std_logic_vector (0 to 27);
signal Memory: MemoryType;
begin
Memory(0)<= «000»& «000000»& «0000000»& «0000000»& «0000»& «0»;
Memory(1)<= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; – MarIn
Memory(2)<= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; – RdWr, CS
Memory(3)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(4)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; – MbrOut
Memory(5)<= «000»& «000000»& «0010000»& «0000000»& «0000»& «0»; – IrIn
Memory(6)<= «100»& «000000»& «0000000»& «0000000»& «0000»& «0»; – Instr0
– mov A,#d
Memory(7) <= «000»& «000000»& «0100000»& «0000000»& «0000»& «0»; IncPC
Memory(8) <= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; MarIn
Memory(9) <= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; RdWr, CS
Memory(10)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(11)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; MbrOut
Memory(12)<= «000»& «000000»& «0000000»& «0000001»& «0000»& «0»; – RAin
Memory(13)<= «001»& «000000»& «0100000»& «0000000»& «0000»& «0»; – Instr2, IncPC
– mov Rn,#d
Memory(14)<= «000»& «000000»& «0100000»& «0000000»& «0000»& «0»; – IncPC
Memory(15)<= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; – MarIn
Memory(16)<= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; – RdWr, CS
Memory(17)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(18)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; – MbrOut
Memory(19)<= «000»& «000000»& «0000000»& «0000000»& «0010»& «0»; – RDCIn
Memory(20)<= «000»& «000000»& «0100000»& «0000000»& «0000»& «0»; – IncPC
Memory(21)<= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; – MarIn
Memory(22)<= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; – RdWr, CS
Memory(23)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(24)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; – MbrOut
Memory(25)<= «000»& «000000»& «0000000»& «0000000»& «1000»& «0»; – RIn
Memory(26)<= «001»& «000000»& «0100000»& «0000000»& «0000»& «0»; – Instr2, IncPC
– add A, Rn
Memory(27)<= «000»& «000000»& «0100000»& «0000000»& «0000»& «0»; – IncPC
Memory(28)<= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; – MarIn
Memory(29)<= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; – RdWr, CS
Memory(30)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(31)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; – MbrOut
Memory(32)<= «000»& «000000»& «0000000»& «0000000»& «0010»& «0»; – RDCIn
Memory(33)<= «000»& «000000»& «0000000»& «0000000»& «0100»& «0»; – ROut
Memory(34)<= «000»& «000000»& «0000000»& «0000000»& «0001»& «0»; – SADD
Memory(35)<= «000»& «000000»& «0000000»& «0001000»& «0000»& «0»; – RZin
Memory(36)<= «000»& «000000»& «0000000»& «0000100»& «0000»& «0»; – RZout
Memory(37)<= «000»& «000000»& «0000000»& «0000001»& «0000»& «0»; – RAin
Memory(38)<= «001»& «000000»& «0100000»& «0000000»& «0000»& «0»; – Instr2, IncPC
– JBC
Memory(51)<= «010»& «110110»& «0000000»& «0000000»& «0000»& «0»; – perexod na adres 36H ili 54 v dec s/s
Memory(52)<= «000»& «000000»& «0000000»& «0000000»& «0000»& «0»; – any value
Memory(53)<= «000»& «000000»& «0000000»& «0000000»& «0000»& «0»; – any value
Memory(54)<= «000»& «000000»& «0100000»& «0000000»& «0000»& «0»; – IncPC
Memory(55)<= «000»& «000000»& «0001000»& «0000000»& «0000»& «0»; – MarIn
Memory(56)<= «000»& «000000»& «0000110»& «0000000»& «0000»& «0»; – RdWr, CS
Memory(57)<= «000»& «000000»& «0000001»& «0000000»& «0000»& «0»; – MbrIn
Memory(58)<= «000»& «000000»& «0000000»& «1000000»& «0000»& «0»; – MbrOut
Memory(59)<= «001»& «000000»& «1000000»& «0000000»& «0000»& «0»; – Instr2, PCIn
process(RD)
begin
if RD='1' and RD'event then
InstrCom<=Memory (CONV_INTEGER ('0'& Adr));
MrOut<='1';
end if;
if RD='0' and RD'event then MrOut<='0';
end if;
end process;
end Memory;
Временная диаграмма работы памяти УУ Memory:
VHDL – описание остальных элементов схемы (регистра CAR и регистра СBR, регистра инструкций, мультиплексора, декодера, простых логических элементов, регистров MAR и MBR):
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity CAR is
port (D: in std_logic_vector (5 downto 0);
CarIn: in std_logic;
CarOut: out std_logic;
Q: out std_logic_vector (5 downto 0));
end CAR;
architecture CAR of CAR is
begin
process(CarIn)
begin
if CarIn='0' and CarIn'event then
Q<=D;
CarOut<='1';
end if;
if CarIn='1' and CarIn'event then CarOut<='0';
end if;
end process;
end CAR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity CBR is
port (InstrCom: in std_logic_vector (0 to 27);
CbrIn: in std_logic;
Adr: out std_logic_vector (5 downto 0);
Instr0: out std_logic;
Instr1: out std_logic;
Instr2: out std_logic;
PCIn: out std_logic;
IncPC: out std_logic;
IrIn: out std_logic;
MarIn:out std_logic;
RdWr:out std_logic;
CS:out std_logic;
MbrIn:out std_logic;
MbrOut:out std_logic;
MbrInD:out std_logic;
MbrOutD:out std_logic;
RzIn:out std_logic;
RzOut:out std_logic;
Inv:out std_logic;
RAIn:out std_logic;
RIn:out std_logic;
ROut:out std_logic;
RDCIn:out std_logic;
SADD:out std_logic;
InvZ: out std_logic);
end CBR;
architecture CBR of CBR is
begin
process(CbrIN)
begin
if CbrIN='1' and CbrIN'event then
Instr0<=InstrCom(2) after 1ns;
Instr1<=InstrCom(1) after 1ns;
Instr2<=InstrCom(0) after 1ns;
ADR<=InstrCom (3 to 8) after 1ns;
PCIn <=InstrCom(9) after 1ns;
IncPC<=InstrCom(10) after 1ns;
IrIn <=InstrCom(11) after 1ns;
MarIn <=InstrCom(12) after 1ns;
RdWr <=InstrCom(13) after 1ns;
CS <=InstrCom(14) after 1ns;
MbrIn<=InstrCom(15) after 1ns;
MbrOut<=InstrCom(16) after 1ns;
MbrInD<=InstrCom(17) after 1ns;
MbrOutD<=InstrCom(18) after 1ns;
RzIn <=InstrCom(19) after 1ns;
RzOut<=InstrCom(20) after 1ns;
Inv<=InstrCom(21) after 1ns;
RAIn<=InstrCom(22) after 1ns;
RIn <=InstrCom(23) after 1ns;
ROut<=InstrCom(24) after 1ns;
RDCIn <=InstrCom(25) after 1ns;
SADD<=InstrCom(26) after 1ns;
InvZ<=InstrCom(27) after 1ns;
end if;
end process;
end CBR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity IR is
port (Command: in std_logic_vector (7 downto 0);
IRin: in std_logic;
Reset: in std_logic;
IrOut: out std_logic;
Com: out std_logic_vector (7 downto 0));
end IR;
architecture IR of IR is
begin
process (IrIn, Reset)
begin
if IrIn='1' and Irin'event then
Com<=Command after 2ns;
IrOut<='1'after 2ns;
end if;
if IrIn='0' and Irin'event then IrOut<='0';
end if;
if Reset='1' then
Com<= «00000000»;
IrOut<='1';
end if;
end process;
end IR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity DC1 is
port (Ale:in std_logic;
Com: in std_logic_vector (7 downto 0);
ComAdr: out std_logic_vector (5 downto 0));
end DC1;
architecture DC1 of DC1 is
begin
process(Ale)
begin
if Ale='1' and Ale'event then
if Com= «00000000» then ComAdr <= «000111»;
elsif Com= «00000001» then ComAdr <= «001110»;
elsif Com= «00000010» then ComAdr <= «011011»;
elsif Com= «00000011» then ComAdr <= «100111»;
elsif Com= «00000100» then ComAdr <= «110011»;
else ComAdr <= «000000»;
end if;
end if;
end process;
end DC1;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity INV is
port (DIn: in std_logic_vector (7 downto 0);
Inv: in std_logic;
DOut: out std_logic_vector (7 downto 0));
end INV;
architecture INV of INV is
begin
DOut<=not DIn when Inv='1'else DIn;
end INV;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity LogAnd is
port (in1: in std_logic;
in2: in std_logic;
Sout: out std_logic);
end LogAnd;
architecture LogAnd of LogAnd is
begin
Sout<=in1 and in2 after 1ns;
end LogAnd;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity LogOR is
port (in1: in std_logic;
in2: in std_logic;
SOut: out std_logic);
end LogOR;
architecture LogOR of LogOR is
begin
SOut<=in1 or in2 after 1ns;
end LogOR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity MUX is
port (IN1: in std_logic_vector (5 downto 0);
IN2: in std_logic_vector (5 downto 0);
IN3: in std_logic_vector (5 downto 0);
Adr0: in std_logic;
Adr1: in std_logic;
CLK: in std_logic;
MuxOut: out std_logic;
OUT1: out std_logic_vector (5 downto 0));
end MUX;
architecture MUX of MUX is
begin
process(CLK)
begin
if CLK='1' and CLK'event then
if Adr1='0' and Adr0='0' then OUT1 <= IN1;
elsif Adr1='1' then OUT1 <= IN2;
elsif Adr1='0' and Adr0='1' then OUT1 <= IN3;
else Out1<= «000000»;
end if;
MuxOut<='1';
end if;
if CLK='0' and CLK'event then MuxOut<='0';
end if;
end process;
end MUX;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity MAR is
port (RST: in std_logic;
CLK: in std_logic;
MarIn: in std_logic;
AdrIn: in std_logic_vector (7 downto 0);
AdrOut: out std_logic_vector (7 downto 0));
end MAR;
architecture MAR of MAR is
signal reg: std_logic_vector (7 downto 0):= «00000000»;
begin
process (CLK, RST)
begin
if CLK='0' and CLK'event and MarIn='1' then reg<=AdrIn;
end if;
if CLK='1' and CLK'event then AdrOut<=reg;
end if;
if RST='1' then reg<= «00000000»;
end if;
end process;
end MAR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity MBR is
port (RST: in std_logic;
CLK: in std_logic;
MbrIn: in std_logic;
MbrOut: in std_logic;
MbrInD: in std_logic;
MbrOutD: in std_logic;
DataIn: inout std_logic_vector (7 downto 0);
DataOut: inout std_logic_vector (7 downto 0));
end MBR;
architecture MBR of MBR is
signal reg: std_logic_vector (7 downto 0);
begin
Process (CLK, RST)
begin
if CLK='0' and CLK'event then
if MbrIn='1' then reg<=DataIn;
elsif MbrOut='1' then DataOut<=reg;
elsif MbrInD='1' then reg<=DataOut;
elsif MbrOutD='1' then DataIn<=reg;
end if;
if MbrIn='0' and MbrOutD='0' then DataIn<= «ZZZZZZZZ»;
end if;
if MbrOut='0' and MbrInD='0' then DataOut<= «ZZZZZZZZ»;
end if;
end if;
if RST='1' then reg<= «00000000»;
end if;
end process;
end MBR;
–
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RZ is
port (DIn: in std_logic_vector (7 downto 0);
CLK: in std_logic;
RST: in std_logic;
RZOut: in std_logic;
RZIn: in std_logic;
InvZ: in std_logic;
DOut: out std_logic_vector (7 downto 0));
end RZ;
architecture RZ of RZ is
signal regist: std_logic_vector (7 downto 0);
begin
process (CLK, RST)
begin
if CLK='0' and CLK'event and RZIn='1' then regist<=DIN;
end if;
if CLK='0' and CLK'event and RZOut='1' then
if InvZ='1'then DOut<=not regist after 3 ns;
else DOut<=regist after 3 ns;
end if;
end if;
if CLK='0' and CLK'event and RZOut='0' then DOut<= «ZZZZZZZZ» after 3 ns;
end if;
if RST='1' then regist<= «00000000»;
end if;
end process;
end RZ;
7. Тестирование процессора и подтверждение правильности его работы с помощью временных диаграмм
Описание процессора на языке Active VHDL:
library IEEE;
use IEEE.std_logic_1164.all;
entity MPA is
port (CLK: in STD_LOGIC;
Reset: in std_logic;
FC, bit_out: out std_logic;
DataBus: inout std_logic_vector (7 downto 0));
end MPA;
architecture MPA of MPA is
–
component Add
port (Inc: in STD_LOGIC;
Reset: in STD_LOGIC;
SIn: in std_logic_vector (5 downto 0);
SOut: out std_logic_vector (5 downto 0));
end component;
–
component ALU
port (A: in std_logic_vector (7 downto 0);
B: in std_logic_vector (7 downto 0);
CLK: in std_logic;
SADD: in std_logic;
FC: out std_logic;
FZ: out std_logic;
Q: out std_logic_vector (7 downto 0));
end component;
–
component CAR
port (CarIn: in std_logic;
D: in std_logic_vector (5 downto 0);
CarOut: out STD_LOGIC;
Q: out std_logic_vector (5 downto 0));
end component;
–
component CBR
port (CbrIn: in std_logic;
InstrCom: in std_logic_vector (0 to 27);
Adr: out std_logic_vector (5 downto 0);
CS: out STD_LOGIC;
IncPC: out STD_LOGIC;
Instr0: out std_logic;
Instr1: out std_logic;
Instr2: out std_logic;
Inv: out STD_LOGIC;
InvZ: out STD_LOGIC;
IrIn: out std_logic;
MarIn: out STD_LOGIC;
MbrIn: out STD_LOGIC;
MbrInD: out STD_LOGIC;
MbrOut: out STD_LOGIC;
MbrOutD: out STD_LOGIC;
PCin: out STD_LOGIC;
RAIn: out STD_LOGIC;
RDCIn: out STD_LOGIC;
RIn: out STD_LOGIC;
ROut: out STD_LOGIC;
RdWr: out STD_LOGIC;
RzIn: out STD_LOGIC;
RzOut: out STD_LOGIC;
SADD: out STD_LOGIC);
end component;
–
component DC1
port (Ale: in STD_LOGIC;
Com: in std_logic_vector (7 downto 0);
ComAdr: out std_logic_vector (5 downto 0));
end component;
–
component INV
port (DIn: in std_logic_vector (7 downto 0);
Inv: in std_logic;
DOut: out std_logic_vector (7 downto 0));
end component;
–
component IR
port (Command: in std_logic_vector (7 downto 0);
IRin: in std_logic;
Reset: in std_logic;
Com: out std_logic_vector (7 downto 0);
IrOut: out STD_LOGIC);
end component;
–
component LogAnd
port (in1: in std_logic;
in2: in std_logic;
Sout: out std_logic);
end component;
–
component LogOR
port (in1: in std_logic;
in2: in std_logic;
SOut: out std_logic);
end component;
–
component MAR
port (AdrIn: in std_logic_vector (7 downto 0);
CLK: in std_logic;
MarIn: in std_logic;
RST: in std_logic;
AdrOut: out std_logic_vector (7 downto 0));
end component;
–
component MBR
port (CLK: in STD_LOGIC;
MbrIn: in STD_LOGIC;
MbrInD: in STD_LOGIC;
MbrOut: in STD_LOGIC;
MbrOutD: in STD_LOGIC;
RST: in STD_LOGIC;
DataIn: inout STD_LOGIC_VECTOR (7 downto 0);
DataOut: inout STD_LOGIC_VECTOR (7 downto 0));
end component;
–
component Memory
port (Adr: in std_logic_vector (5 downto 0);
RD: in std_logic;
InstrCom: out std_logic_vector (0 to 27);
MrOut: out STD_LOGIC);
end component;
–
component MUX
port (Adr0: in std_logic;
Adr1: in std_logic;
CLK: in STD_LOGIC;
IN1: in std_logic_vector (5 downto 0);
IN2: in std_logic_vector (5 downto 0);
IN3: in std_logic_vector (5 downto 0);
MuxOut: out STD_LOGIC;
OUT1: out std_logic_vector (5 downto 0));
end component;
–
component PC
port (AdrIn: in STD_LOGIC_VECTOR (7 downto 0);
CLK: in STD_LOGIC;
IncPC: in STD_LOGIC;
PCIn: in STD_LOGIC;
RST: in STD_LOGIC;
AdrOut: out STD_LOGIC_VECTOR (7 downto 0));
end component;
–
component R0
port (C: in STD_LOGIC;
CLK: in std_logic;
DataIn: in std_logic_vector (7 downto 0);
RIn: in std_logic;
ROut: in std_logic;
RST: in std_logic;
DataOut: out std_logic_vector (7 downto 0));
end component;
–
component RA
port (
CLK: in STD_LOGIC;
DIn: in std_logic_vector (7 downto 0);
RAIn: in std_logic;
DOut: out std_logic_vector (7 downto 0));
end component;
–
component RAM
port (Adr: in STD_LOGIC_VECTOR (7 downto 0);
CS: in STD_LOGIC;
RdWr: in STD_LOGIC;
Data: inout STD_LOGIC_VECTOR (7 downto 0));
end component;
–
component RDC
port (Number: in std_logic_vector (7 downto 0);
RDCIn: in std_logic;
R1: out std_logic;
R2: out std_logic;
R3: out std_logic;
R4: out std_logic);
end component;
–
component RZ
port (CLK: in STD_LOGIC;
DIn: in STD_LOGIC_VECTOR (7 downto 0);
InvZ: in STD_LOGIC;
RST: in STD_LOGIC;
RZIn: in STD_LOGIC;
RZOut: in STD_LOGIC;
DOut: out STD_LOGIC_VECTOR (7 downto 0));
end component;
–
component R_1bit is
port (reg_in, IE: in std_logic;
CLK, Zero:in std_logic;
reg_out: out std_logic);
end component;
–
signal CS, IncPC, IrIn, MarIn, MbrIn, MbrOut, JB: STD_LOGIC;
signal S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, SR1, SR2, SR3, SR4: STD_LOGIC;
signal N1, N2, N3, FC_sig, bit_outs: STD_LOGIC;
signal PCIN, RaIn, RDCIn, RdWr, RIn, ROut, RzIn, RzOut, SADD: STD_LOGIC;
signal Adr: std_logic_vector (7 downto 0);
signal BUS2, BUS6, BUS7, BUS8, BUS11: std_logic_vector (5 downto 0);
signal BUS10: std_logic_vector (27 downto 0);
signal BUS0, BUS1, BUS3, BUS4, BUS5: std_logic_vector (7 downto 0);
signal MemOut: STD_LOGIC_VECTOR (7 downto 0);
–
begin
DD0: IR port map (Com => BUS1, Command => DataBus, IRin => IrIn, IrOut => S3,
Reset => Reset);
DD1: LogAnd port map (Sout => S5, in1 => bit_outs, in2 =>S4);
DD2: MAR port map (AdrIn => BUS0, AdrOut => Adr, CLK => CLK, MarIn => MarIn,
RST => Reset);
DD3: RAM port map (Adr => Adr, CS => CS, Data => MemOut, RdWr => RdWr);
DD4: MBR port map (CLK => CLK, DataIn => MemOut, DataOut => DataBus,
MbrIn => MbrIn, MbrInD => S6, MbrOut => MbrOut,
MbrOutD => S7, RST => Reset);
DD5: R0 port map (C => SR1, CLK => CLK, DataIn => DataBus, DataOut => DataBus,
RIn => RIn, ROut => ROut, RST => Reset);
DD6: R0 port map (C => SR2, CLK => CLK, DataIn => DataBus, DataOut => DataBus,
RIn => RIn, ROut => ROut, RST => Reset);
DD7: R0 port map (C => SR3, CLK => CLK, DataIn => DataBus, DataOut => DataBus,
RIn => RIn, ROut => ROut, RST => Reset);
DD8: R0 port map (C => SR4, CLK => CLK, DataIn => DataBus, DataOut => DataBus,
RIn => RIn, ROut => ROut, RST => Reset);
DD9: RA port map (CLK => CLK, DIn => DataBus, DOut => BUS3, RAIn => RaIn);
DD10: ALU port map (A => BUS4, B => DataBus, CLK => CLK, FC => FC_sig, FZ => S1,
Q => BUS5, SADD => SADD);
DD11: DC1 port map (Ale => S3, Com => BUS1, ComAdr => BUS2);
DD12: RZ port map (CLK => CLK, DIn => BUS5, DOut => DataBus, InvZ => JB,
RST => Reset, RZIn => RzIn, RZOut => RzOut);
DD13: INV port map (DIn => BUS3, DOut => BUS4, Inv => S2);
DD14: RDC port map (Number => DataBus, R1 => SR1, R2 => SR2, R3 => SR3,
R4 => SR4, RDCIn => RDCIn);
DD15: MUX port map (Adr0 => S9, Adr1 => S10, CLK => CLK, IN1 => BUS11,
IN2 => BUS2, IN3 => BUS6, MuxOut => N2, OUT1 => BUS7);
DD16: Add port map (Inc => N2, Reset => Reset, SIn => BUS7, SOut => BUS11);
DD17: CAR port map (CarIn => CLK, CarOut => N3, D => BUS7, Q => BUS8);
DD18: Memory port map (Adr => BUS8, InstrCom => BUS10, MrOut => N1, RD => N3);
DD19: CBR port map (Adr => BUS6, CS => CS, CbrIn => N1, IncPC => IncPC, Instr0 => S8,
Instr1 => S4, Instr2 => S10, InstrCom => BUS10, Inv => S2, InvZ => JB, IrIn => IrIn,
MarIn => MarIn, MbrIn => MbrIn, MbrInD => S6, MbrOut => MbrOut, MbrOutD => S7,
PCin => PCIN, RAIn => RaIn, RDCIn => RDCIn, Rin => RIn, ROut => ROut,
RdWr => RdWr,
RzIn => RzIn, RzOut => RzOut, SADD => SADD);
DD20: PC port map (AdrIn => DataBus, AdrOut => BUS0, CLK => CLK, IncPC => IncPC,
PCIn => PCIN, RST => Reset);
DD21: LogOR port map (SOut => S9, in1 => S5, in2 => S8);
DD22: R_1bit port map (CLK => CLK, reg_in =>FC_sig, reg_out => bit_outs, IE =>RzIn,
Zero=>S5);
FC<=FC_sig;
bit_out<=bit_outs;
end MPA;
Выводы
При выполнении работы было произведено моделирование процессора с устройством управления на основе памяти с одним полем адреса, имеющего ряд специальных регистров, а также четыре регистра общего назначения. Тестовая программа была успешно выполнена, что вполне свидетельствует о его корректной работе.
Структурная схема, разработанная в этой работе, естественно, не является единственно возможной. Но на ее примере можно усвоить основные принципы построения цифровых вычислительных систем, такие как микропрограммное управление, совместное использование шин процессора различными устройствами со всеми вытекающими отсюда требованиями к организации работы этих устройств: синхронизации, сингулярности передач информации и другими.
Данная схема обладает одной магистралью, она достаточно проста в исполнении, хотя одномагистральная система не всегда позволяет просто реализовать некоторые операции, а именно такая система занимает намного меньше места на печатной плате, чем двухмагистральная (и тем более трехмагистральная), что и дает ей преимущества при конструировании небольших устройств.
По диаграмме работы процессора видно, что выполнение команды JBC занимает в среднем 90 ns, команда сложения немного больше 183 ns, команд пересылки – 140ns. Полное выполнение всех команд по очереди производится за 630 ns. Начальная задержка работы процессора с четом всех задержек на всех элементах составила всего 1 ns, что очень мало.