Ok let's see if I can make your mood a bit better with this
FIRST OF ALL, I am *STILL* working on all this is UNFINISHED, UNTESTED, ETC.
So this IDE .. really challenging .. it would be "really easy" if RAS + address would be enough to understand what's going on, but it is not because you have to consider CAS into the equation, there could be CAS with no RAS ( ASPI ) and other stuff ..
However .. after much studying of this & that I come with this idea ..
The idea is to have "something" to generate the IDE /CS0 signal which goes '0' when CAS goes '0' and returns '1' when RAS goes '1' ( IDE /CS1 will be always at 1, nobody uses it ) .
At this point if I understood correctly PI goes '0' about 10ns after CAS goes '1' ( so CAS returns to '1' before PI does ).
Also, other important thing, if I read correctly between CAS going '1' and RAS going '1' too there are 10 ns of time.
Now to understand what I've done you have to compare those two things, this diagram :
With the one of the datasheet Figure A-2 page A-24
With the following VHDL ( which I repeat is still totally uncompleted and UNtested and such )
It synthesize anyway more or less as I tought it should have been.
I *THINK* doing this way it should all fit within "mode 6" but between this and "it works" I don't know yet.
The rest, has still to come.
Note : if I've done something completely crap it could well be, my mind is still grinding over all this ..
[edit] - it's that 't9' that I don't quite like much, I am thinking instead of using RAS for that to use a signal where I make RAS pass throught a couple of gates or stuff trying to delay it for 5 .. 10 ns more, that should be better, it could give me 20 ns of time extra I may need.
FIRST OF ALL, I am *STILL* working on all this is UNFINISHED, UNTESTED, ETC.
So this IDE .. really challenging .. it would be "really easy" if RAS + address would be enough to understand what's going on, but it is not because you have to consider CAS into the equation, there could be CAS with no RAS ( ASPI ) and other stuff ..
However .. after much studying of this & that I come with this idea ..
The idea is to have "something" to generate the IDE /CS0 signal which goes '0' when CAS goes '0' and returns '1' when RAS goes '1' ( IDE /CS1 will be always at 1, nobody uses it ) .
At this point if I understood correctly PI goes '0' about 10ns after CAS goes '1' ( so CAS returns to '1' before PI does ).
Also, other important thing, if I read correctly between CAS going '1' and RAS going '1' too there are 10 ns of time.
Now to understand what I've done you have to compare those two things, this diagram :
With the one of the datasheet Figure A-2 page A-24
With the following VHDL ( which I repeat is still totally uncompleted and UNtested and such )
It synthesize anyway more or less as I tought it should have been.
I *THINK* doing this way it should all fit within "mode 6" but between this and "it works" I don't know yet.
The rest, has still to come.
Code:
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 12:50:53 04/10/2011
-- Design Name:
-- Module Name: Main - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Main is
Port ( DAL : inout STD_LOGIC_VECTOR (15 downto 13);
ready : out STD_LOGIC;
bclr : in STD_LOGIC;
pup : in STD_LOGIC;
sel : in STD_LOGIC_VECTOR (1 downto 0);
pi : in STD_LOGIC;
x1_clock : in STD_LOGIC; -- 10 Mhz clock from the oscillator
cpu_clock : in STD_LOGIC; -- cpu clock "microcycle" style
negRas : in STD_LOGIC;
negCas : in STD_LOGIC;
rNegWLB : in STD_LOGIC;
rNegWHB : in STD_LOGIC;
AI : in STD_LOGIC_VECTOR (4 downto 1);
dal11 : inout STD_LOGIC;
dal8 : inout STD_LOGIC;
dal2 : inout STD_LOGIC;
dal1 : inout STD_LOGIC;
ADLatch : out STD_LOGIC;
romOE : out STD_LOGIC;
ramWEH : out STD_LOGIC;
ramOEH : out STD_LOGIC;
ramWEL : out STD_LOGIC;
ramOEL : out STD_LOGIC;
IDE_AD : in STD_LOGIC_VECTOR (2 downto 0);
IDE_CS0 : out STD_LOGIC;
IDE_WR : out STD_LOGIC;
IDE_RD : out STD_LOGIC;
SPI_SS : out STD_LOGIC;
SPI_MISO : in STD_LOGIC;
SPI_MOSI : out STD_LOGIC;
SPI_CLK : out STD_LOGIC);
end Main;
architecture Behavioral of Main is
-- for coherence with the T11 architecture we'll use the OCTAL notation
signal l_add : STD_LOGIC;
signal rom_sel : STD_LOGIC; -- when active at '0' means ROM address space is selected
signal io_sel : STD_LOGIC; -- when active at '0' means I/O address space is selected
signal ram_sel : STD_LOGIC; -- when active at '0' means RAM is selected
signal mode_read : STD_LOGIC; -- when active at '0' means the CPU is reading the MODE register
signal word_read : STD_LOGIC; -- when '0' means both lines rNegWLB,rNegWHB are at '1'
signal word_write : STD_LOGIC; -- when '0' means both lines rNegWLB,rNegWHB are at '0'
signal negPi : STD_LOGIC; -- not PI used for the IDE cycle
signal ideEnable : STD_LOGIC;
signal ide_read : STD_LOGIC;
signal ide_write : STD_LOGIC;
signal ide_inuse : STD_LOGIC;
signal MAD : STD_LOGIC_VECTOR (15 downto 11);
begin
l_add <= NOT ( negRas ); -- trivial, just to latch the addresses with those 574
ADLatch <= l_add;
-- let's not forget the CPLD too has RAISING EDGE sensitive FFs
LATCH_ADDR: process ( l_add )
begin
if ( l_add'event and l_add='1') then
MAD <= DAL(15 downto 13)&dal2&dal1;
end if;
end process;
-- we add the condition of the mode_read as well so to avoid I/O or mem selected
-- while the CPU is reading the mode register
io_sel <= '0' when MAD(15 downto 13) = "111" and mode_read = '1' else '1'; -- last 8K of address space is I/O, 160000 - 177777
rom_sel <= '0' when MAD(15 downto 13) = "110" and mode_read = '1' else '1'; -- 140000 - 157777 ROM
ram_sel <= '0' when io_sel = '1' and rom_sel = '1' and mode_read = '1'; -- anything else is RAM
-- with the selection above there's only one choice for the mode register
mode_read <= ( pup OR bclr ); -- it has to be a PUP low and BCLR low
-- restart address at 140000, 16 bits bus, normal R/W, constant clock nah bananez
DAL <= "000" when mode_read = '0' else "ZZZ";
dal11 <= '0' when mode_read = '0' else 'Z';
dal8 <= '0' when mode_read = '0' else 'Z';
--dal0 <= '0' when mode_read = '0' else "Z"; let's leave the other clock
-- ROM output enable, just as a paranoia we could include word_read
word_read <= NOT ( rNegWLB AND rNegWHB ); -- no write to ROM allowed
romOE <= '0' when rom_sel = '0' and word_read = '0' and negCas = '0' else '1'; -- plain and simple
-- RAM, just lightly more complex but nothing too weird here
-- this fundamentally means that he "ram cycle" is the duration of negCAS only because it HAS
-- to be the condition RAS = '0' AND CAS = '0' for a valid access, SEL lines are of no help
ramOEH <= '0' when ram_sel = '0' and rNegWHB = '1' and negCas = '0' else '1';
ramWEH <= '0' when ram_sel = '0' and rNegWHB = '0' and negCas = '0' else '1';
ramOEL <= '0' when ram_sel = '0' and rNegWLB = '1' and negCas = '0' else '1';
ramWEL <= '0' when ram_sel = '0' and rNegWLB = '0' and negCas = '0' else '1';
-- IDE stuff, let's see if it gets somewhere
negPi <= NOT ( pi );
-- this is a D type flip flop with preset and clear and an '1' stuck into 'd'
PR_CS0 : process ( bclr, negCas, negRas )
begin
if bclr = '0' then ideEnable <= '1'; -- '1' at reset
elsif negCas = '0' then ideEnable <= '0'; -- '0' when CAS = '0'
elsif negRas'event and negRas = '1' then ideEnable <= '1'; -- '1' at the rising edge of RAS
end if;
end process;
word_write <= rNegWLB OR rNegWHB;
ide_read <= io_sel or MAD(12) or MAD (11) or word_read;
ide_write <= io_sel or MAD(12) or NOT MAD (11) or word_write;
ide_inuse <= ide_read and ide_write; -- '0' when some I/O is in the ide
-- and there is the magic
IDE_CS0 <= ideEnable or negRas or ide_inuse;
IDE_WR <= ideEnable or negPi or ide_write or negCas;
IDE_RD <= ideEnable or negPi or ide_read or negCas;
end Behavioral;
Note : if I've done something completely crap it could well be, my mind is still grinding over all this ..
[edit] - it's that 't9' that I don't quite like much, I am thinking instead of using RAS for that to use a signal where I make RAS pass throught a couple of gates or stuff trying to delay it for 5 .. 10 ns more, that should be better, it could give me 20 ns of time extra I may need.
Last edited: