J
jacko
Guest
hi
my first vhdl project is underway. here it is so far, does anyone have
any comments on style or problems i am not seeing?
-- indi16 vhdl first version --
-- indi16.4.0
-- (C)2007 K Ring Technologies Semiconductor
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY indi16 IS
PORT
(
Clk, Reset, Halt, Cin, ACin : IN STD_LOGIC;
DataIn : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
DataOut : OUT STD_LOGIC_VECTOR(15 DOWNTO 0);
Fetch, BusFree, OE, RW, CS0, CS1: OUT STD_LOGIC;
Cout, ACout, Hilo, RW16 : OUT STD_LOGIC;
Video : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
Address : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END indi16;
ARCHITECTURE a OF indi16 IS
-- the sequence clock (256 pixels)
SIGNAL Seq : STD_LOGIC_VECTOR(10 DOWNTO 0);
-- the register set
SIGNAL P, Q, R, S, A: STD_LOGIC_VECTOR(15 DOWNTO 0);
-- other hidden registers
SIGNAL IR, ALUin : STD_LOGIC_VECTOR(15 DOWNTO 0);
-- flags
SIGNAL C : STD_LOGIC;
BEGIN
Main:
PROCESS (Clk, Reset)
-- ALU process
VARIABLE F0, F1, F2, F3 : STD_LOGIC_VECTOR(15 DOWNTO 0);
VARIABLE FA, FC, ALUout : STD_LOGIC_VECTOR(16 DOWNTO 0);
VARIABLE C0, ID, OD, PNul : STD_LOGIC;
VARIABLE LMB : STD_LOGIC;
VARIABLE Ins : STD_LOGIC_VECTOR(7 DOWNTO 0);
VARIABLE Op, Rin, Rout : STD_LOGIC_VECTOR(1 DOWNTO 0);
BEGIN
IF Reset = '1' THEN
-- reset happening
P = 0;
Q = 0;
R = 0;
S = 0;
A = 0;
ELSE IF Clk'EVENT AND Clk = '1' AND Halt = '0' THEN
-- instruction loop
IF LMB = '1' THEN
Ins = IR[7..0];
ELSE
Ins = IR[15..8];
END IF;
Op = Ins[7..6];
ID = Ins[5];
Rin = Ins[4..3];
OD = Ins[2];
Rout = Ins[1..0];
PNul = (Ins[2..0] == '000');
-- register decode
-- ALU operation
F1 = A AND ALUin;
F2 = A XOR ALUin;
F3 = ALUin;
-- full adder
F0 = F2 XOR (FC, C);
FA = F2 AND (FC, C)
C0, FC = F1 OR FA;
-- mux alu out
CASE Op IS
WHEN '00' =>
ALUout = F0;
WHEN '01' =>
ALUout = F1;
WHEN '10' =>
ALUout = F2;
WHEN '11' =>
ALUout = F3;
END CASE;
-- memory access
CASE Seq[3..1] IS
WHEN '000' =>
-- 0 Instruction Fetch
Address <= P;
Hilo <= '1';
RW <= '1';
OE <= '0';
Data <= 'ZZZZZZZZ';
WHEN '001' =>
-- 1
IR[15..8] <= Data;
Hilo <= '0';
WHEN '010' =>
-- 2
IR[7..0] <= Data;
WHEN '011' =>
-- 3
__statement;
__statement;
WHEN '100' =>
-- 4
__statement;
__statement;
WHEN '101' =>
-- 5
__statement;
__statement;
WHEN '110' =>
-- 6
__statement;
__statement;
WHEN '111' =>
-- 7
__statement;
__statement;
END CASE;
Hilo <= Seq[0];
-- 8 bit bus
-- clock next cycle
Seq <= Seq+1;
END IF;
END PROCESS Main;
END a;
cheers
my first vhdl project is underway. here it is so far, does anyone have
any comments on style or problems i am not seeing?
-- indi16 vhdl first version --
-- indi16.4.0
-- (C)2007 K Ring Technologies Semiconductor
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY indi16 IS
PORT
(
Clk, Reset, Halt, Cin, ACin : IN STD_LOGIC;
DataIn : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
DataOut : OUT STD_LOGIC_VECTOR(15 DOWNTO 0);
Fetch, BusFree, OE, RW, CS0, CS1: OUT STD_LOGIC;
Cout, ACout, Hilo, RW16 : OUT STD_LOGIC;
Video : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
Address : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END indi16;
ARCHITECTURE a OF indi16 IS
-- the sequence clock (256 pixels)
SIGNAL Seq : STD_LOGIC_VECTOR(10 DOWNTO 0);
-- the register set
SIGNAL P, Q, R, S, A: STD_LOGIC_VECTOR(15 DOWNTO 0);
-- other hidden registers
SIGNAL IR, ALUin : STD_LOGIC_VECTOR(15 DOWNTO 0);
-- flags
SIGNAL C : STD_LOGIC;
BEGIN
Main:
PROCESS (Clk, Reset)
-- ALU process
VARIABLE F0, F1, F2, F3 : STD_LOGIC_VECTOR(15 DOWNTO 0);
VARIABLE FA, FC, ALUout : STD_LOGIC_VECTOR(16 DOWNTO 0);
VARIABLE C0, ID, OD, PNul : STD_LOGIC;
VARIABLE LMB : STD_LOGIC;
VARIABLE Ins : STD_LOGIC_VECTOR(7 DOWNTO 0);
VARIABLE Op, Rin, Rout : STD_LOGIC_VECTOR(1 DOWNTO 0);
BEGIN
IF Reset = '1' THEN
-- reset happening
P = 0;
Q = 0;
R = 0;
S = 0;
A = 0;
ELSE IF Clk'EVENT AND Clk = '1' AND Halt = '0' THEN
-- instruction loop
IF LMB = '1' THEN
Ins = IR[7..0];
ELSE
Ins = IR[15..8];
END IF;
Op = Ins[7..6];
ID = Ins[5];
Rin = Ins[4..3];
OD = Ins[2];
Rout = Ins[1..0];
PNul = (Ins[2..0] == '000');
-- register decode
-- ALU operation
F1 = A AND ALUin;
F2 = A XOR ALUin;
F3 = ALUin;
-- full adder
F0 = F2 XOR (FC, C);
FA = F2 AND (FC, C)
C0, FC = F1 OR FA;
-- mux alu out
CASE Op IS
WHEN '00' =>
ALUout = F0;
WHEN '01' =>
ALUout = F1;
WHEN '10' =>
ALUout = F2;
WHEN '11' =>
ALUout = F3;
END CASE;
-- memory access
CASE Seq[3..1] IS
WHEN '000' =>
-- 0 Instruction Fetch
Address <= P;
Hilo <= '1';
RW <= '1';
OE <= '0';
Data <= 'ZZZZZZZZ';
WHEN '001' =>
-- 1
IR[15..8] <= Data;
Hilo <= '0';
WHEN '010' =>
-- 2
IR[7..0] <= Data;
WHEN '011' =>
-- 3
__statement;
__statement;
WHEN '100' =>
-- 4
__statement;
__statement;
WHEN '101' =>
-- 5
__statement;
__statement;
WHEN '110' =>
-- 6
__statement;
__statement;
WHEN '111' =>
-- 7
__statement;
__statement;
END CASE;
Hilo <= Seq[0];
-- 8 bit bus
-- clock next cycle
Seq <= Seq+1;
END IF;
END PROCESS Main;
END a;
cheers