Processador
master
8 bits de dados e 16 bits de endereço
slave
ROM
constant mem : mem_type := (
-- load increment
LDCi, 1,
-- store it at 0x4000
STAi, 64, 0,
-- show on 7-segment
STAi, 128, ADDR_SEG,
-- increment with value at 0x4000
ADDi, 64, 0,
-- if no carry out repeat at address 5
JNCi, 0, 5,
-- turn on LED(7)
LDCi, 128,
STAi, 128, ADDR_LED,
-- endless loop to address 19
JMPi, 0, 19,
others => 0);
slave
RAM
slave
I/O
STAi, 128, ADDR_SEG,
STAi, 128, ADDR_LED,
------------------------------------------------------------------------------ Memory mapped addresses
----------------------------------------------------------------------------constant ADDR_LED
: addr_type := 0;
constant ADDR_SEG
: addr_type := 1;
constant ADDR_SWITCH : addr_type := 2;
-- Load and store
constant LDAi : data_type := 1;
constant LDCi : data_type := 2;
constant STAi : data_type := 3;
-- load from address to accu
-- load constant to accu
-- store accu to address
constant LDXi : data_type := 8;
-- load index register with constant
constant INCXi : data_type := 9;
-- increment index register
constant DECXi : data_type := 10; -- decrement index register
-- Arithmetic
constant ADDi : data_type := 16;
constant SUBi : data_type := 17;
constant NOTi : data_type := 18;
constant ANDi : data_type := 19;
constant ORi : data_type := 20;
constant XORi : data_type := 21;
-- add data from address to accu
-- sub data from address from accu
-- sub data from address from accu
-- AND data from address with accu
-- OR data from address with accu
-- XOR data from address with accu
-- Shift
constant SLLi : data_type := 24;
constant SLRi : data_type := 25;
constant ROLi : data_type := 26;
constant RORi : data_type := 27;
-- Jump
constant JMPi : data_type := 32;
constant JCi : data_type := 33;
constant JNCi : data_type := 34;
constant JZi : data_type := 35;
constant JNZi : data_type := 36;
-- shift logical left
-- shift logical right
-- rotate left
-- rotate right
-- jump to address
-- jump when carry flag is set
-- jump when carry flag is not set
-- jump when zero flag is set
-- jump when zero flag is not set
constant mem : mem_type := (
-- load increment
LDCi, 1,
-- store it at 0x4000
STAi, 64, 0,
-- show on 7-segment
STAi, 128, ADDR_SEG,
-- increment with value at 0x4000
ADDi, 64, 0,
-- if no carry out repeat at address 5
JNCi, 0, 5,
-- turn on LED(7)
LDCi, 128,
STAi, 128, ADDR_LED,
-- endless loop to address 19
JMPi, 0, 19,
others => 0);
-- load constant to accu
constant LDCi : data_type := 2;;
Acumulador
-- store accu to address
constant STAi : data_type := 3;
RAM
x”40”x”00”
x”4000”
Acumulador
-- show on 7-segment
STAi, 128, ADDR_SEG,
x”80”x”00”
-- add data from address to accu
constant ADDi : data_type := 16;
< x”40”x”00”> +
Acumulador
-- jump when carry flag is not set
constant JNCi : data_type := 34;
constant mem : mem_type := (
-- load increment
LDCi, 1,
-- endereço 0,1
-- store it at 0x4000
STAi, 64, 0,
-- endereço 2,3,4
-- show on 7-segment
STAi, 128, ADDR_SEG, -- endereço 5,6,7
-- increment with value at 0x4000
ADDi, 64, 0,
-- endereço 8,9,10
-- if no carry out repeat at address 5
JNCi, 0, 5,
-- endereço 11,12,13
-- turn on LED(7)
LDCi, 128,
-- endereço 14, 15
STAi, 128, ADDR_LED, -- endereço 16,17,18
-- endless loop to address 19
JMPi, 0, 19,
-- endereço 19,20,21
others => 0);
Preparar um programa utilizando instruções de processador para fazer tarefas 1-3.
Todas as tarefas devem ser acabadas durante a aula
Tarefa 1.
Contar até 10 e depois terminar a execução. Utilize leds para mostrar a sequência
seguinte de códigos 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1001, 1010
Tarefa 2.
Utilizar leds para mostrar códigos seguintes: 1010, 1001, 1000, 0111, 0110, 0101,
0100, 0011, 0010, 0001. Depois terminar a execução do projecto
Tarefa 3.
Implementar multiplicação de dois inteiros com valores possíveis 0,...,9. Apresente o
resultado em código binário
Download

Aula teórica: parte 2