diff --git a/FPGA_by_Fredi/FPGA_DATE.bsf b/FPGA_by_Fredi/FPGA_DATE.bsf
index fd5ac89..a6c809a 100644
--- a/FPGA_by_Fredi/FPGA_DATE.bsf
+++ b/FPGA_by_Fredi/FPGA_DATE.bsf
@@ -31,7 +31,7 @@ applicable agreement for further details.
(line (pt 88 24)(pt 72 24)(line_width 3))
)
(drawing
- (text "319037463" (rect 27 18 72 30)(font "Arial" ))
+ (text "402923543" (rect 27 18 72 30)(font "Arial" ))
(text "32" (rect 77 25 87 37)(font "Arial" ))
(line (pt 16 16)(pt 72 16)(line_width 1))
(line (pt 72 16)(pt 72 32)(line_width 1))
diff --git a/FPGA_by_Fredi/FPGA_DATE.tdf b/FPGA_by_Fredi/FPGA_DATE.tdf
index 6769853..49f319c 100644
--- a/FPGA_by_Fredi/FPGA_DATE.tdf
+++ b/FPGA_by_Fredi/FPGA_DATE.tdf
@@ -33,7 +33,7 @@
--applicable agreement for further details.
-- Clearbox generated function header
-FUNCTION FPGA_DATE_lpm_constant_d19 ()
+FUNCTION FPGA_DATE_lpm_constant_i19 ()
RETURNS ( result[31..0]);
@@ -46,11 +46,11 @@ SUBDESIGN FPGA_DATE
VARIABLE
- FPGA_DATE_lpm_constant_d19_component : FPGA_DATE_lpm_constant_d19;
+ FPGA_DATE_lpm_constant_i19_component : FPGA_DATE_lpm_constant_i19;
BEGIN
- result[31..0] = FPGA_DATE_lpm_constant_d19_component.result[31..0];
+ result[31..0] = FPGA_DATE_lpm_constant_i19_component.result[31..0];
END;
@@ -63,9 +63,9 @@ END;
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: Radix NUMERIC "16"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
--- Retrieval info: PRIVATE: Value NUMERIC "319037463"
+-- Retrieval info: PRIVATE: Value NUMERIC "402923543"
-- Retrieval info: PRIVATE: nBit NUMERIC "32"
--- Retrieval info: CONSTANT: LPM_CVALUE NUMERIC "319037463"
+-- Retrieval info: CONSTANT: LPM_CVALUE NUMERIC "402923543"
-- Retrieval info: CONSTANT: LPM_HINT STRING "ENABLE_RUNTIME_MOD=NO"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "LPM_CONSTANT"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
diff --git a/FPGA_by_Fredi/FPGA_DATE_lpm_constant_i19.tdf b/FPGA_by_Fredi/FPGA_DATE_lpm_constant_i19.tdf
new file mode 100644
index 0000000..4ae1da6
--- /dev/null
+++ b/FPGA_by_Fredi/FPGA_DATE_lpm_constant_i19.tdf
@@ -0,0 +1,30 @@
+--lpm_constant CBX_AUTO_BLACKBOX="ALL" ENABLE_RUNTIME_MOD="NO" LPM_CVALUE=18042017 LPM_WIDTH=32 result
+--VERSION_BEGIN 9.1SP2 cbx_lpm_constant 2010:03:24:20:43:43:SJ cbx_mgl 2010:03:24:21:01:05:SJ VERSION_END
+
+
+-- Copyright (C) 1991-2010 Altera Corporation
+-- Your use of Altera Corporation's design tools, logic functions
+-- and other software and tools, and its AMPP partner logic
+-- functions, and any output files from any of the foregoing
+-- (including device programming or simulation files), and any
+-- associated documentation or information are expressly subject
+-- to the terms and conditions of the Altera Program License
+-- Subscription Agreement, Altera MegaCore Function License
+-- Agreement, or other applicable license agreement, including,
+-- without limitation, that your use is for the sole purpose of
+-- programming logic devices manufactured by Altera and sold by
+-- Altera or its authorized distributors. Please refer to the
+-- applicable agreement for further details.
+
+
+
+--synthesis_resources =
+SUBDESIGN FPGA_DATE_lpm_constant_i19
+(
+ result[31..0] : output;
+)
+
+BEGIN
+ result[] = B"00011000000001000010000000010111";
+END;
+--VALID FILE
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_MFP68901_IP/wf68901ip_interrupts.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_MFP68901_IP/wf68901ip_interrupts.vhd.bak
deleted file mode 100644
index 915c271..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_MFP68901_IP/wf68901ip_interrupts.vhd.bak
+++ /dev/null
@@ -1,391 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- ATARI MFP compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- MC68901 compatible multi function port core. ----
----- ----
----- This is the SUSKA MFP IP core interrupt logic file. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Revision 2K8A 2008/06/03 WF
--- Fixed Pending register logic.
--- Revision 2K9A 2009/06/20 WF
--- Fixed interrupt polarity for TA_I and TB_I.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF68901IP_INTERRUPTS is
- port ( -- System control:
- CLK : in bit;
- RESETn : in bit;
-
- -- Asynchronous bus control:
- DSn : in bit;
- CSn : in bit;
- RWn : in bit;
-
- -- Data and Adresses:
- RS : in bit_vector(5 downto 1);
- DATA_IN : in bit_vector(7 downto 0);
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_OUT_EN : out bit;
-
- -- Interrupt control:
- IACKn : in bit;
- IEIn : in bit;
- IEOn : out bit;
- IRQn : out bit;
-
- -- Interrupt sources:
- GP_INT : in bit_vector(7 downto 0);
-
- AER_4 : in bit;
- AER_3 : in bit;
- TAI : in bit;
- TBI : in bit;
- TA_PWM : in bit;
- TB_PWM : in bit;
- TIMER_A_INT : in bit;
- TIMER_B_INT : in bit;
- TIMER_C_INT : in bit;
- TIMER_D_INT : in bit;
-
- RCV_ERR : in bit;
- TRM_ERR : in bit;
- RCV_BUF_F : in bit;
- TRM_BUF_E : in bit
- );
-end entity WF68901IP_INTERRUPTS;
-
-architecture BEHAVIOR of WF68901IP_INTERRUPTS is
--- Interrupt state machine:
-type INT_STATES is (SCAN, REQUEST, VECTOR_OUT);
-signal INT_STATE : INT_STATES;
--- The registers:
-signal IERA : bit_vector(7 downto 0);
-signal IERB : bit_vector(7 downto 0);
-signal IPRA : bit_vector(7 downto 0);
-signal IPRB : bit_vector(7 downto 0);
-signal ISRA : bit_vector(7 downto 0);
-signal ISRB : bit_vector(7 downto 0);
-signal IMRA : bit_vector(7 downto 0);
-signal IMRB : bit_vector(7 downto 0);
-signal VR : bit_vector(7 downto 3);
--- Interconnect:
-signal VECT_NUMBER : bit_vector(7 downto 0);
-signal INT_SRC : bit_vector(15 downto 0);
-signal INT_SRC_EDGE : bit_vector(15 downto 0);
-signal INT_ENA : bit_vector(15 downto 0);
-signal INT_MASK : bit_vector(15 downto 0);
-signal INT_PENDING : bit_vector(15 downto 0);
-signal INT_SERVICE : bit_vector(15 downto 0);
-signal INT_PASS : bit_vector(15 downto 0);
-signal INT_OUT : bit_vector(15 downto 0);
-signal GP_INT_4 : bit;
-signal GP_INT_3 : bit;
-begin
- -- Interrupt source for the GPI_4 and GPI_3 is normally the respective port pin.
- -- But when the timers operate in their PWM modes, the GPI_4 and GPI_3 are associated
- -- to timer A and timer B.
- -- The xor logic provides polarity control for the interrupt transition. Be aware,
- -- that the PWM signals cause an interrupt on the opposite transition like the
- -- respective GPIP port pins (with the same AER settings).
- --GP_INT_4 <= GP_INT(4) when TA_PWM = '0' else TAI xor AER_4;
- --GP_INT_3 <= GP_INT(3) when TB_PWM = '0' else TBI xor AER_3;
- GP_INT_4 <= GP_INT(4) when TA_PWM = '0' else TAI xnor AER_4; -- This should be correct.
- GP_INT_3 <= GP_INT(3) when TB_PWM = '0' else TBI xnor AER_3;
-
-
- -- Interrupt source priority sorted (15 = highest):
- INT_SRC <= GP_INT(7 downto 6) & TIMER_A_INT & RCV_BUF_F & RCV_ERR & TRM_BUF_E & TRM_ERR & TIMER_B_INT &
- GP_INT(5) & GP_INT_4 & TIMER_C_INT & TIMER_D_INT & GP_INT_3 & GP_INT(2 downto 0);
-
- INT_ENA <= IERA & IERB;
- INT_MASK <= IMRA & IMRB;
- INT_PENDING <= IPRA & IPRB;
- INT_SERVICE <= ISRA & ISRB;
- INT_OUT <= INT_PENDING and INT_MASK; -- Masking:
-
- -- Enable the daisy chain, if there is no pending interrupt and
- -- the interrupt state machine is not in service.
- IEOn <= '0' when INT_OUT = x"0000" and INT_STATE = SCAN else '1';
-
- -- Interrupt request:
- IRQn <= '0' when INT_OUT /= x"0000" and INT_STATE = REQUEST else '1';
-
- EDGE_ENA: process(RESETn, CLK)
- -- These are the 16 edge detectors of the 16 interrupt input sources. This
- -- process also provides the disabling or enabling via the IERA and IERB registers.
- variable LOCK : bit_vector(15 downto 0);
- begin
- if RESETn = '0' then
- INT_SRC_EDGE <= x"0000";
- LOCK := x"0000";
- elsif CLK = '0' and CLK' event then
- for i in 15 downto 0 loop
- if INT_SRC(i) = '1' and INT_ENA(i) = '1' and LOCK(i) = '0' then
- LOCK(i) := '1';
- INT_SRC_EDGE(i) <= '1';
- elsif INT_SRC(i) = '0' then
- LOCK(i) := '0';
- INT_SRC_EDGE(i) <= '0';
- else
- INT_SRC_EDGE(i) <= '0';
- end if;
- end loop;
- end if;
- end process EDGE_ENA;
-
- INT_REGISTERS: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- IERA <= (others => '0');
- IERB <= (others => '0');
- IPRA <= (others => '0');
- IPRB <= (others => '0');
- ISRA <= (others => '0');
- ISRB <= (others => '0');
- IMRA <= (others => '0');
- IMRB <= (others => '0');
- elsif CLK = '1' and CLK' event then
- if CSn = '0' and DSn = '0' and RWn = '0' then
- case RS is
- when "00011" => IERA <= DATA_IN; -- Enable A.
- when "00100" => IERB <= DATA_IN; -- Enable B.
- when "00101" =>
- -- Only a '0' can be written to the pending register.
- for i in 7 downto 0 loop
- if DATA_IN(i) = '0' then
- IPRA(i) <= '0'; -- Pending A.
- end if;
- end loop;
- when "00110" =>
- -- Only a '0' can be written to the pending register.
- for i in 7 downto 0 loop
- if DATA_IN(i) = '0' then
- IPRB(i) <= '0'; -- Pending B.
- end if;
- end loop;
- when "00111" =>
- -- Only a '0' can be written to the in service register.
- for i in 7 downto 0 loop
- if DATA_IN(i) = '0' then
- ISRA(i) <= '0'; -- In Service A.
- end if;
- end loop;
- when "01000" =>
- -- Only a '0' can be written to the in service register.
- for i in 7 downto 0 loop
- if DATA_IN(i) = '0' then
- ISRB(i) <= '0'; -- In Service B.
- end if;
- end loop;
- when "01001" => IMRA <= DATA_IN; -- Mask A.
- when "01010" => IMRB <= DATA_IN; -- Mask B.
- when "01011" => VR <= DATA_IN(7 downto 3); -- Vector register.
- when others => null;
- end case;
- end if;
-
- -- Pending register:
- -- set and clear bit logic.
- for i in 15 downto 8 loop
- if INT_SRC_EDGE(i) = '1' then
- IPRA(i-8) <= '1';
- elsif INT_ENA(i) = '0' then
- IPRA(i-8) <= '0'; -- Clear by disabling the channel.
- elsif INT_PASS(i) = '1' then
- IPRA(i-8) <= '0'; -- Clear by passing the interrupt.
- end if;
- end loop;
- for i in 7 downto 0 loop
- if INT_SRC_EDGE(i) = '1' then
- IPRB(i) <= '1';
- elsif INT_ENA(i) = '0' then
- IPRB(i) <= '0'; -- Clear by disabling the channel.
- elsif INT_PASS(i) = '1' then
- IPRB(i) <= '0'; -- Clear by passing the interrupt.
- end if;
- end loop;
-
- -- In-Service register:
- -- Set bit logic, VR(3) is the service register enable.
- for i in 15 downto 8 loop
- if INT_OUT(i) = '1' and INT_PASS(i) = '1' and VR(3) = '1' then
- ISRA(i-8) <= '1';
- end if;
- end loop;
- for i in 7 downto 0 loop
- if INT_OUT(i) = '1' and INT_PASS(i) = '1' and VR(3) = '1' then
- ISRB(i) <= '1';
- end if;
- end loop;
- end if;
- end process INT_REGISTERS;
- DATA_OUT_EN <= '1' when CSn = '0' and DSn = '0' and RWn = '1' and RS > "00010" and RS <= "01011" else '1' when INT_STATE = VECTOR_OUT else '0';
-
- DATA_OUT <= IERA when CSn = '0' and DSn = '0' and RWn = '1' and RS = "00011" else
- IERB when CSn = '0' and DSn = '0' and RWn = '1' and RS = "00100" else
- IPRA when CSn = '0' and DSn = '0' and RWn = '1' and RS = "00101" else
- IPRB when CSn = '0' and DSn = '0' and RWn = '1' and RS = "00110" else
- ISRA when CSn = '0' and DSn = '0' and RWn = '1' and RS = "00111" else
- ISRB when CSn = '0' and DSn = '0' and RWn = '1' and RS = "01000" else
- IMRA when CSn = '0' and DSn = '0' and RWn = '1' and RS = "01001" else
- IMRB when CSn = '0' and DSn = '0' and RWn = '1' and RS = "01010" else
- VR & "000" when CSn = '0' and DSn = '0' and RWn = '1' and RS = "01011" else
- VECT_NUMBER when INT_STATE = VECTOR_OUT else x"00";
-
- P_INT_STATE : process(RESETn, CLK)
- begin
- if RESETn = '0' then
- INT_STATE <= SCAN;
- elsif CLK = '1' and CLK' event then
- case INT_STATE is
- when SCAN =>
- INT_PASS <= x"0000";
- -- Automatic End of Interrupt mode. Service register disabled.
- -- The MFP does not respond for an interrupt acknowledge cycle for an uninitialized
- -- vector number (VR(7 downto 4) = x"0").
- if INT_OUT /= x"0000" and VR(7 downto 4) /= x"0" and VR(3) = '0' and IEIn = '0' then
- INT_STATE <= REQUEST; -- Non masked interrupt is pending.
- -- The following 16 are the Software end of interrupt mode. Service register enabled.
- -- The MFP does not respond for an interrupt acknowledge cycle for an uninitialized
- -- vector number (VR(7 downto 4) = x"0"). The interrupts are prioritized.
- elsif INT_OUT /= x"0000" and VR(7 downto 4) /= x"0" and VR(3) = '1' and IEIn = '0' then
- if INT_OUT (15) = '1' and INT_SERVICE(15) = '0' then
- INT_STATE <= REQUEST;
- elsif INT_OUT (14) = '1' and INT_SERVICE(15 downto 14) = "00" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (13) = '1' and INT_SERVICE(15 downto 13) = "000" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (12) = '1' and INT_SERVICE(15 downto 12) = x"0" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (11) = '1' and INT_SERVICE(15 downto 11) = x"0" & '0' then
- INT_STATE <= REQUEST;
- elsif INT_OUT (10) = '1' and INT_SERVICE(15 downto 10) = x"0" & "00" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (9) = '1' and INT_SERVICE(15 downto 9) = x"0" & "000" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (8) = '1' and INT_SERVICE(15 downto 8) = x"00" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (7) = '1' and INT_SERVICE(15 downto 7) = x"00" & '0' then
- INT_STATE <= REQUEST;
- elsif INT_OUT (6) = '1' and INT_SERVICE(15 downto 6) = x"00" & "00" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (5) = '1' and INT_SERVICE(15 downto 5) = x"00" & "000" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (4) = '1' and INT_SERVICE(15 downto 4) = x"000" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (3) = '1' and INT_SERVICE(15 downto 3) = x"000" & '0' then
- INT_STATE <= REQUEST;
- elsif INT_OUT (2) = '1' and INT_SERVICE(15 downto 2) = x"000" & "00" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (1) = '1' and INT_SERVICE(15 downto 1) = x"000" & "000" then
- INT_STATE <= REQUEST;
- elsif INT_OUT (0) = '1' and INT_SERVICE(15 downto 0) = x"0000" then
- INT_STATE <= REQUEST;
- else
- INT_STATE <= SCAN; -- Wait for interrupt.
- end if;
- else
- INT_STATE <= SCAN;
- end if;
- when REQUEST =>
- if IACKn = '0' and DSn = '0' then -- Vectored interrupt mode.
- INT_STATE <= VECTOR_OUT; -- Non masked interrupt is pending.
- if INT_OUT(15) = '1' then
- INT_PASS(15) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"F"; -- GPI 7.
- elsif INT_OUT(14) = '1' then
- INT_PASS(14) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"E"; -- GPI 6.
- elsif INT_OUT(13) = '1' then
- INT_PASS(13) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"D"; -- TIMER A.
- elsif INT_OUT(12) = '1' then
- INT_PASS(12) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"C"; -- Receive buffer full.
- elsif INT_OUT(11) = '1' then
- INT_PASS(11) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"B"; -- Receiver error.
- elsif INT_OUT(10) = '1' then
- INT_PASS(10) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"A"; -- Transmit buffer empty.
- elsif INT_OUT(9) = '1' then
- INT_PASS(9) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"9"; -- Transmit error.
- elsif INT_OUT(8) = '1' then
- INT_PASS(8) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"8"; -- Timer B.
- elsif INT_OUT(7) = '1' then
- INT_PASS(7) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"7"; -- GPI 5.
- elsif INT_OUT(6) = '1' then
- INT_PASS(6) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"6"; -- GPI 4.
- elsif INT_OUT(5) = '1' then
- INT_PASS(5) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"5"; -- Timer C.
- elsif INT_OUT(4) = '1' then
- INT_PASS(4) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"4"; -- Timer D.
- elsif INT_OUT(3) = '1' then
- INT_PASS(3) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"3"; -- GPI 3.
- elsif INT_OUT(2) = '1' then
- INT_PASS(2) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"2"; -- GPI 2.
- elsif INT_OUT(1) = '1' then
- INT_PASS(1) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"1"; -- GPI 1.
- elsif INT_OUT(0) = '1' then
- INT_PASS(0) <= '1'; VECT_NUMBER <= VR(7 downto 4) & x"0"; -- GPI 0.
- end if;
- -- Polled interrupt mode: End of interrupt by writing to the pending registers.
- elsif CSn = '0' and DSn = '0' and RWn = '0' and (RS = "00101" or RS = "00110") then
- INT_STATE <= SCAN;
- else
- INT_STATE <= REQUEST; -- Wait.
- end if;
- when VECTOR_OUT =>
- INT_PASS <= x"0000";
- if DSn = '1' or IACKn = '1' then
- INT_STATE <= SCAN; -- Finished.
- else
- INT_STATE <= VECTOR_OUT; -- Wait for processor to read the vector.
- end if;
- end case;
- end if;
- end process P_INT_STATE;
-end architecture BEHAVIOR;
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_SDC_IF/sd-card-interface_soc.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_SDC_IF/sd-card-interface_soc.vhd.bak
deleted file mode 100644
index 0200dea..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_SDC_IF/sd-card-interface_soc.vhd.bak
+++ /dev/null
@@ -1,239 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- ATARI IP Core peripheral Add-On ----
----- ----
----- This file is part of the FPGA-ATARI project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- This hardware provides an interface to connect to a SD-Card. ----
----- ----
----- This interface is based on the project 'SatanDisk' of ----
----- Miroslav Nohaj 'Jookie'. The code is an interpretation of ----
----- the original code, written in VERILOG. It is provided for ----
----- the use in a system on programmable chips (SOPC). ----
----- ----
----- Timing: Use a clock frequency of 16MHz for this component. ----
----- Use the same clock frequency for the connected AVR ----
----- microcontroller. ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2007 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
----- This hardware works with the original ATARI ----
----- hard dik driver. ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K7A 2007/01/05 WF
--- Initial Release.
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
---
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF_SD_CARD is
- port (
- -- System:
- RESETn : in bit;
- CLK : in bit; -- 16MHz, see above.
-
- -- ACSI section:
- ACSI_A1 : in bit;
- ACSI_CSn : in bit;
- ACSI_ACKn : in bit;
- ACSI_INTn : out bit;
- ACSI_DRQn : out bit;
- ACSI_D_IN : in std_logic_vector(7 downto 0);
- ACSI_D_OUT : out std_logic_vector(7 downto 0);
- ACSI_D_EN : out bit;
-
- -- Microcontroller interface:
- MC_DO : in bit;
- MC_PIO_DMAn : in bit;
- MC_RWn : in bit;
- MC_CLR_CMD : in bit;
- MC_DONE : out bit;
- MC_GOT_CMD : out bit;
- MC_D_IN : in std_logic_vector(7 downto 0);
- MC_D_OUT : out std_logic_vector(7 downto 0);
- MC_D_EN : out bit
- );
-end WF_SD_CARD;
-
-architecture BEHAVIOR of WF_SD_CARD is
-signal DATA_REG : std_logic_vector(7 downto 0);
-signal D0_REG : bit;
-signal INT_REG : bit;
-signal DRQ_REG : bit;
-signal DONE_REG : bit;
-signal GOT_CMD_REG : bit;
-signal HOLD : bit;
-signal PREV_CSn : bit;
-signal PREV_ACKn : bit;
-begin
- MC_D_OUT <= DATA_REG when MC_RWn = '0' and DONE_REG = '1' else (others => '0');
- MC_D_EN <= '1' when MC_RWn = '0' and DONE_REG = '1' else '0';
- ACSI_D_OUT <= DATA_REG when MC_RWn = '1' and (ACSI_CSn = '0' or ACSI_ACKn = '0' or HOLD = '1') else (others => '0');
--- ???:
---ACSI_D_EN <= '1' when MC_RWn = '1' and (ACSI_CSn = '0' or ACSI_ACKn = '0' or HOLD = '1') else '0';
-ACSI_D_EN <= '0';
- ACSI_INTn <= INT_REG;
- ACSI_DRQn <= DRQ_REG;
- MC_DONE <= DONE_REG;
- MC_GOT_CMD <= GOT_CMD_REG;
-
- P_DATA: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- DATA_REG <= (others => '0');
- elsif CLK = '1' and CLK' event then
- if D0_REG = '0' and MC_DO = '1' and MC_RWn = '1' then
- DATA_REG <= MC_D_IN; -- Read from AVR to ACSI.
- end if;
- --
- if PREV_CSn = '0' and ACSI_CSn = '0' and MC_RWn = '0' and DONE_REG = '0' then
- DATA_REG <= ACSI_D_IN; -- Write from ACSI to AVR.
- elsif PREV_ACKn = '0' and ACSI_ACKn = '0' and MC_RWn = '0' and DONE_REG = '0' then
- DATA_REG <= ACSI_D_IN; -- Write from ACSI to AVR.
- end if;
- end if;
- end process P_DATA;
-
- P_SYNC: process
- begin
- wait until CLK = '1' and CLK' event;
- PREV_CSn <= ACSI_CSn;
- PREV_ACKn <= ACSI_ACKn;
- end process P_SYNC;
-
- P_INT_DRQ: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- INT_REG <= '1'; -- No interrupt.
- DRQ_REG <= '1'; -- No data request.
- elsif CLK = '1' and CLK' event then
- if D0_REG = '0' and MC_DO = '1' and MC_PIO_DMAn = '1' then -- Positive MC_DO edge.
- INT_REG <= '0'; -- Release an interrupt.
- DRQ_REG <= '1';
- elsif D0_REG = '0' and MC_DO = '1' then
- INT_REG <= '1';
- DRQ_REG <= '0'; -- Release a data request.
- end if;
- --
- if MC_CLR_CMD = '1' then -- Clear done.
- INT_REG <= '1'; -- Restore INT_REG.
- DRQ_REG <= '1'; -- Restore DRQ_REG.
- end if;
- --
- if (PREV_CSn = '0' and ACSI_CSn = '0') or (PREV_ACKn = '0' and ACSI_ACKn = '0') then
- if ACSI_CSn = '0' then
- INT_REG <= '1';
- end if;
- --
- if ACSI_ACKn = '0' then
- DRQ_REG <= '1';
- end if;
- end if;
- end if;
- end process P_INT_DRQ;
-
- P_HOLD: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- HOLD <= '0';
- elsif CLK = '1' and CLK' event then
- if (PREV_CSn = '0' and ACSI_CSn = '0') or (PREV_ACKn = '0' and ACSI_ACKn = '0') then
- HOLD <= '1';
- elsif PREV_CSn = '1' and ACSI_CSn = '1' then -- If signal is high.
- HOLD <= '0';
- elsif PREV_ACKn = '1' and ACSI_ACKn = '1' then -- If signal is high.
- HOLD <= '0';
- elsif PREV_CSn = '0' and ACSI_CSn = '1' then -- Rising edge.
- HOLD <= '1';
- elsif PREV_ACKn = '0' and ACSI_ACKn = '1' then -- Rising edge.
- HOLD <= '1';
- elsif MC_CLR_CMD = '1' then -- Clear done.
- HOLD <= '0';
- end if;
- end if;
- end process P_HOLD;
-
- P_DONE: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- DONE_REG <= '0';
- elsif CLK = '1' and CLK' event then
- if (PREV_CSn = '0' and ACSI_CSn = '0') or (PREV_ACKn = '0' and ACSI_ACKn = '0') then
- DONE_REG <= '1';
- elsif MC_CLR_CMD = '1' then -- Clear done.
- DONE_REG <= '0';
- elsif D0_REG = '0' and MC_DO = '1' then -- Positive MC_DO edge.
- DONE_REG <= '0';
- elsif D0_REG = '1' and MC_DO = '0' then -- Negative MC_DO edge.
- DONE_REG <= '0';
- end if;
- end if;
- end process P_DONE;
-
- P_DO_REG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- D0_REG <= '0';
- elsif CLK = '1' and CLK' event then
- if D0_REG = '0' and MC_DO = '1' then -- Positive MC_DO edge.
- D0_REG <= MC_DO;
- elsif D0_REG = '1' and MC_DO = '0' then -- Negative MC_DO edge.
- D0_REG <= MC_DO;
- end if;
- end if;
- end process P_DO_REG;
-
- P_GOT_CMD: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- GOT_CMD_REG <= '0';
- elsif CLK = '1' and CLK' event then
--- ?? ACSI_CSn doppelt!
---if PREV_CSn = '0' and ACSI_CSn = '0' and ACSI_CSn = '0' and ACSI_A1 = '0' then
- GOT_CMD_REG <= '1'; -- If command was received.
- elsif PREV_ACKn = '0' and ACSI_ACKn = '0' and ACSI_CSn = '0' and ACSI_A1 = '0' then
- GOT_CMD_REG <= '1'; -- If command was received.
- elsif MC_CLR_CMD = '1' then -- Clear done.
- GOT_CMD_REG <= '0';
- end if;
- end if;
- end process P_GOT_CMD;
-end architecture BEHAVIOR;
\ No newline at end of file
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_ctrl_status.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_ctrl_status.vhd.bak
deleted file mode 100644
index 2e85cdd..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_ctrl_status.vhd.bak
+++ /dev/null
@@ -1,214 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- 6850 compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- UART 6850 compatible IP core ----
----- ----
----- Control unit and status logic. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
--- Revision 2K9A 2009/06/20 WF
--- CTRL_REG has now synchronous reset to meet preset requirements.
--- Process P_DCD has now synchronous reset to meet preset requirements.
--- IRQ_In has now synchronous reset to meet preset requirement.
--- Revision 2K9B 2009/12/24 WF
--- Fixed the interrupt logic.
--- Introduced a minor RTSn correction.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF6850IP_CTRL_STATUS is
- port (
- CLK : in std_logic;
- RESETn : in bit;
-
- CS : in bit_vector(2 downto 0); -- Active if "011".
- E : in bit;
- RWn : in bit;
- RS : in bit;
-
- DATA_IN : in bit_vector(7 downto 0);
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_EN : out bit;
-
- -- Status register stuff:
- RDRF : in bit; -- Receive data register full.
- TDRE : in bit; -- Transmit data register empty.
- DCDn : in bit; -- Data carrier detect.
- CTSn : in bit; -- Clear to send.
- FE : in bit; -- Framing error.
- OVR : in bit; -- Overrun error.
- PE : in bit; -- Parity error.
-
- -- Control register stuff:
- MCLR : buffer bit; -- Master clear (high active).
- RTSn : out bit; -- Request to send.
- CDS : out bit_vector(1 downto 0); -- Clock control.
- WS : out bit_vector(2 downto 0); -- Word select.
- TC : out bit_vector(1 downto 0); -- Transmit control.
- IRQn : buffer bit -- Interrupt request.
- );
-end entity WF6850IP_CTRL_STATUS;
-
-architecture BEHAVIOR of WF6850IP_CTRL_STATUS is
-signal CTRL_REG : bit_vector(7 downto 0);
-signal STATUS_REG : bit_vector(7 downto 0);
-signal RIE : bit;
-signal CTS_In : bit;
-signal DCD_In : bit;
-signal DCD_FLAGn : bit;
-begin
- CTS_In <= CTSn;
- DCD_In <= DCDn; -- immer 0
-
- STATUS_REG(7) <= not IRQn;
- STATUS_REG(6) <= PE;
- STATUS_REG(5) <= OVR;
- STATUS_REG(4) <= FE;
- STATUS_REG(3) <= CTS_In; -- Reflexion of the input pin.
- STATUS_REG(2) <= DCD_FLAGn;
- STATUS_REG(1) <= TDRE and not CTS_In; -- No TDRE for CTSn = '1'.
- STATUS_REG(0) <= RDRF and not DCD_In; -- DCDn = '1' indicates empty.
-
- DATA_OUT <= STATUS_REG when CS = "011" and RWn = '1' and RS = '0' else (others => '0');
- DATA_EN <= '1' when CS = "011" and RWn = '1' and RS = '0' else '0';
-
- MCLR <= '1' when CTRL_REG(1 downto 0) = "11" else '0';
- RTSn <= '0' when CTRL_REG(6 downto 5) /= "10" else '1';
-
- CDS <= CTRL_REG(1 downto 0);
- WS <= CTRL_REG(4 downto 2);
- TC <= CTRL_REG(6 downto 5);
- RIE <= CTRL_REG(7);
-
- P_IRQ: process(CLK)
- variable irq_v : std_logic_vector(3 downto 0);
- begin
- if rising_edge(CLK) then
- if RESETn = '0' or MCLR = '1' then
- irq_v := x"0";
- IRQn <= '1';
- else
- -- Transmitter interrupt:
- if TDRE = '1' and CTRL_REG(6 downto 5) = "01" then
- if irq_v = x"F" then
- irq_v := irq_v + 1;
- end if;
- -- Receiver interrupts:
- elsif RDRF = '1' and RIE = '1' then
- if irq_v < 15 then
- irq_v := irq_v + 1;
- end if;
- -- Overrun
- elsif OVR = '1' and RIE = '1' then
- if irq_v < 15 then
- irq_v := irq_v + 1;
- end if;
- else
- if irq_v > 0 then
- irq_v := irq_v - 1;
- end if;
- end if;
- if irq_v < 8 then
- IRQn <= '1';
- else
- IRQn <= '0';
- end if;
- -- The reset of the IRQ status flag:
- -- Clear by writing to the transmit data register.
- -- Clear by reading the receive data register.
- end if;
- end if;
- end process P_IRQ;
-
- CONTROL: process(CLK)
- begin
- if rising_edge(CLK) then
- if RESETn = '0' then
- CTRL_REG <= "01000000";
- elsif CS = "011" and RWn = '0' and RS = '0' then
- CTRL_REG <= DATA_IN;
- end if;
- end if;
- end process CONTROL;
-
- P_DCD: process(CLK)
- -- This process is some kind of tricky. Refer to the MC6850 data
- -- sheet for more information.
- variable READ_LOCK : boolean;
- variable DCD_RELEASE : boolean;
- begin
- if rising_edge(CLK) then
- if RESETn = '0' then
- DCD_FLAGn <= '0'; -- This interrupt source must initialise low.
- READ_LOCK := true;
- DCD_RELEASE := false;
- elsif MCLR = '1' then
- DCD_FLAGn <= DCD_In;
- READ_LOCK := true;
- elsif DCD_In = '1' then
- DCD_FLAGn <= '1';
- elsif CS = "011" and RWn = '1' and RS = '0' then
- READ_LOCK := false; -- Un-READ_LOCK if receiver data register is read.
- elsif CS = "011" and RWn = '1' and RS = '1' and READ_LOCK = false then
- -- Clear if receiver status register read access.
- -- After data register has ben read and READ_LOCK again.
- DCD_RELEASE := true;
- READ_LOCK := true;
- DCD_FLAGn <= DCD_In;
- elsif DCD_In = '0' and DCD_RELEASE = true then
- DCD_FLAGn <= '0';
- DCD_RELEASE := false;
- end if;
- end if;
- end process P_DCD;
-end architecture BEHAVIOR;
-
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive - Kopie.vhd b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive - Kopie.vhd
deleted file mode 100644
index c6626df..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive - Kopie.vhd
+++ /dev/null
@@ -1,419 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- 6850 compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- UART 6850 compatible IP core ----
----- ----
----- 6850's receiver unit. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF6850IP_RECEIVE is
- port (
- CLK : in bit;
- RESETn : in bit;
- MCLR : in bit;
-
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
-
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_EN : out bit;
-
- WS : in bit_vector(2 downto 0);
- CDS : in bit_vector(1 downto 0);
-
- RXCLK : in bit;
- RXDATA : in bit;
-
- RDRF : buffer bit;
- OVR : out bit;
- PE : out bit;
- FE : out bit
- );
-end entity WF6850IP_RECEIVE;
-
-architecture BEHAVIOR of WF6850IP_RECEIVE is
-type RCV_STATES is (IDLE, WAIT_START, SAMPLE, PARITY, STOP1, STOP2, SYNC);
-signal RCV_STATE, RCV_NEXT_STATE : RCV_STATES;
-signal RXDATA_I : bit;
-signal RXDATA_S : bit;
-signal DATA_REG : bit_vector(7 downto 0);
-signal SHIFT_REG : bit_vector(7 downto 0);
-signal CLK_STRB : bit;
-signal BITCNT : std_logic_vector(2 downto 0);
-begin
- P_SAMPLE: process
- -- This filter provides a synchronisation to the system
- -- clock, even for random baud rates of the received data
- -- stream.
- variable FLT_TMP : integer range 0 to 2;
- begin
- wait until CLK = '1' and CLK' event;
- --
- RXDATA_I <= RXDATA;
- --
- if RXDATA_I = '1' and FLT_TMP < 2 then
- FLT_TMP := FLT_TMP + 1;
- elsif RXDATA_I = '1' then
- RXDATA_S <= '1';
- elsif RXDATA_I = '0' and FLT_TMP > 0 then
- FLT_TMP := FLT_TMP - 1;
- elsif RXDATA_I = '0' then
- RXDATA_S <= '0';
- end if;
- end process P_SAMPLE;
-
- CLKDIV: process
- variable CLK_LOCK : boolean;
- variable STRB_LOCK : boolean;
- variable CLK_DIVCNT : std_logic_vector(6 downto 0);
- begin
- wait until CLK = '1' and CLK' event;
- if CDS = "00" then -- Divider off.
- if RXCLK = '1' and STRB_LOCK = false then
- CLK_STRB <= '1';
- STRB_LOCK := true;
- elsif RXCLK = '0' then
- CLK_STRB <= '0';
- STRB_LOCK := false;
- else
- CLK_STRB <= '0';
- end if;
- elsif RCV_STATE = IDLE then
- -- Preset the CLKDIV with the start delays.
- if CDS = "01" then
- CLK_DIVCNT := "0001000"; -- Half of div by 16 mode.
- elsif CDS = "10" then
- CLK_DIVCNT := "0100000"; -- Half of div by 64 mode.
- end if;
- CLK_STRB <= '0';
- else
- if CLK_DIVCNT > "0000000" and RXCLK = '1' and CLK_LOCK = false then
- CLK_DIVCNT := CLK_DIVCNT - '1';
- CLK_STRB <= '0';
- CLK_LOCK := true;
- elsif CDS = "01" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "0010000"; -- Div by 16 mode.
- --
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif CDS = "10" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "1000000"; -- Div by 64 mode.
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif RXCLK = '0' then
- CLK_LOCK := false;
- STRB_LOCK := false;
- CLK_STRB <= '0';
- else
- CLK_STRB <= '0';
- end if;
- end if;
- end process CLKDIV;
-
- DATAREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- DATA_REG <= x"00";
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- DATA_REG <= x"00";
- elsif RCV_STATE = SYNC and WS(2) = '0' and RDRF = '0' then -- 7 bit data.
- -- Transfer from shift- to data register only if
- -- data register is empty (RDRF = '0').
- DATA_REG <= '0' & SHIFT_REG(7 downto 1);
- elsif RCV_STATE = SYNC and WS(2) = '1' and RDRF = '0' then -- 8 bit data.
- -- Transfer from shift- to data register only if
- -- data register is empty (RDRF = '0').
- DATA_REG <= SHIFT_REG;
- end if;
- end if;
- end process DATAREG;
- DATA_OUT <= DATA_REG when CS = "011" and RWn = '1' and RS = '1' and E = '1' else (others => '0');
- DATA_EN <= '1' when CS = "011" and RWn = '1' and RS = '1' and E = '1' else '0';
-
- SHIFTREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- SHIFT_REG <= x"00";
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- SHIFT_REG <= x"00";
- elsif RCV_STATE = SAMPLE and CLK_STRB = '1' then
- SHIFT_REG <= RXDATA_S & SHIFT_REG(7 downto 1); -- Shift right.
- end if;
- end if;
- end process SHIFTREG;
-
- P_BITCNT: process
- begin
- wait until CLK = '1' and CLK' event;
- if RCV_STATE = SAMPLE and CLK_STRB = '1' then
- BITCNT <= BITCNT + '1';
- elsif RCV_STATE /= SAMPLE then
- BITCNT <= (others => '0');
- end if;
- end process P_BITCNT;
-
- FRAME_ERR: process(RESETn, CLK)
- -- This module detects a framing error
- -- during stop bit 1 and stop bit 2.
- variable FE_I: bit;
- begin
- if RESETn = '0' then
- FE_I := '0';
- FE <= '0';
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- FE_I := '0';
- FE <= '0';
- elsif CLK_STRB = '1' then
- if RCV_STATE = STOP1 and RXDATA_S = '0' then
- FE_I := '1';
- elsif RCV_STATE = STOP2 and RXDATA_S = '0' then
- FE_I := '1';
- elsif RCV_STATE = STOP1 or RCV_STATE = STOP2 then
- FE_I := '0'; -- Error resets when correct data appears.
- end if;
- end if;
- if RCV_STATE = SYNC then
- FE <= FE_I; -- Update the FE every SYNC time.
- end if;
- end if;
- end process FRAME_ERR;
-
- OVERRUN: process(RESETn, CLK)
- variable OVR_I : bit;
- variable FIRST_READ : boolean;
- begin
- if RESETn = '0' then
- OVR_I := '0';
- OVR <= '0';
- FIRST_READ := false;
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- OVR_I := '0';
- OVR <= '0';
- FIRST_READ := false;
- elsif CLK_STRB = '1' and RCV_STATE = STOP1 then
- -- Overrun appears if RDRF is '1' in this state.
- OVR_I := RDRF;
- end if;
- if CS = "011" and RWn = '1' and RS = '1' then
- -- If an overrun was detected, the concerning flag is
- -- set when the valid data word in the receiver data
- -- register is read. Thereafter the RDRF flag is reset
- -- and the overrun disappears (OVR_I goes low) after
- -- a second read (in time) of the receiver data register.
- if FIRST_READ = false then
- if OVR_I = '1' then
- OVR <= '1';
- OVR_I := '0';
- FIRST_READ := true;
- else
- OVR <= '0';
- end if;
- end if;
- else
- FIRST_READ := false;
- end if;
- end if;
- end process OVERRUN;
-
- PARITY_TEST: process(RESETn, CLK)
- variable PAR_TMP : bit;
- variable PE_I : bit;
- begin
- if RESETn = '0' then
- PE <= '0';
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- PE <= '0';
- elsif CLK_STRB = '1' then -- Sample parity on clock strobe.
- PE_I := '0'; -- Initialise.
- if RCV_STATE = PARITY then
- for i in 1 to 7 loop
- if i = 1 then
- PAR_TMP := SHIFT_REG(i-1) xor SHIFT_REG(i);
- else
- PAR_TMP := PAR_TMP xor SHIFT_REG(i);
- end if;
- end loop;
- if WS = "000" or WS = "010" or WS = "110" then -- Even parity.
- PE_I := PAR_TMP xor RXDATA_S;
- elsif WS = "001" or WS = "011" or WS = "111" then -- Odd parity.
- PE_I := not PAR_TMP xor RXDATA_S;
- else -- No parity for WS = "100" and WS = "101".
- PE_I := '0';
- end if;
- end if;
- end if;
- -- Transmit the parity flag together with the data
- -- In other words: no parity to the status register
- -- when RDRF inhibits the data transfer to the
- -- receiver data register.
- if RCV_STATE = SYNC and RDRF = '0' then
- PE <= PE_I;
- elsif CS = "011" and RWn = '1' and RS = '1' then
- PE <= '0'; -- Clear when reading the data register.
- end if;
- end if;
- end process PARITY_TEST;
-
- P_RDRF: process(RESETn, CLK)
- -- Receive data register full flag.
- begin
- if RESETn = '0' then
- RDRF <= '0';
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- RDRF <= '0';
- elsif RCV_STATE = SYNC then
- RDRF <= '1'; -- Data register is full until now!
- elsif CS = "011" and RWn = '1' and RS = '1' then
- RDRF <= '0'; -- After reading the data register ...
- end if;
- end if;
- end process P_RDRF;
-
- RCV_STATEREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- RCV_STATE <= IDLE;
- elsif CLK = '1' and CLK' event then
- if MCLR = '1' then
- RCV_STATE <= IDLE;
- else
- RCV_STATE <= RCV_NEXT_STATE;
- end if;
- end if;
- end process RCV_STATEREG;
-
- RCV_STATEDEC: process(RCV_STATE, RXDATA_S, CDS, WS, BITCNT, CLK_STRB)
- begin
- case RCV_STATE is
- when IDLE =>
- if RXDATA_S = '0' and CDS = "00" then
- RCV_NEXT_STATE <= SAMPLE; -- Startbit detected in div by 1 mode.
- elsif RXDATA_S = '0' and CDS = "01" then
- RCV_NEXT_STATE <= WAIT_START; -- Startbit detected in div by 16 mode.
- elsif RXDATA_S = '0' and CDS = "10" then
- RCV_NEXT_STATE <= WAIT_START; -- Startbit detected in div by 64 mode.
- else
- RCV_NEXT_STATE <= IDLE; -- No startbit; sleep well :-)
- end if;
- when WAIT_START =>
- if CLK_STRB = '1' then
- if RXDATA_S = '0' then
- RCV_NEXT_STATE <= SAMPLE; -- Start condition in no div by 1 modes.
- else
- RCV_NEXT_STATE <= IDLE; -- No valid start condition, go back.
- end if;
- else
- RCV_NEXT_STATE <= WAIT_START; -- Stay.
- end if;
- when SAMPLE =>
- if CLK_STRB = '1' then
- if BITCNT < "110" and WS(2) = '0' then
- RCV_NEXT_STATE <= SAMPLE; -- Go on sampling 7 data bits.
- elsif BITCNT < "111" and WS(2) = '1' then
- RCV_NEXT_STATE <= SAMPLE; -- Go on sampling 8 data bits.
- elsif WS = "100" or WS = "101" then
- RCV_NEXT_STATE <= STOP1; -- No parity check enabled.
- else
- RCV_NEXT_STATE <= PARITY; -- Parity enabled.
- end if;
- else
- RCV_NEXT_STATE <= SAMPLE; -- Stay in sample mode.
- end if;
- when PARITY =>
- if CLK_STRB = '1' then
- RCV_NEXT_STATE <= STOP1;
- else
- RCV_NEXT_STATE <= PARITY;
- end if;
- when STOP1 =>
- if CLK_STRB = '1' then
- if RXDATA_S = '0' then
- RCV_NEXT_STATE <= SYNC; -- Framing error detected.
- elsif WS = "000" or WS = "001" or WS = "100" then
- RCV_NEXT_STATE <= STOP2; -- Two stop bits selected.
- else
- RCV_NEXT_STATE <= SYNC; -- One stop bit selected.
- end if;
- else
- RCV_NEXT_STATE <= STOP1;
- end if;
- when STOP2 =>
- if CLK_STRB = '1' then
- RCV_NEXT_STATE <= SYNC;
- else
- RCV_NEXT_STATE <= STOP2;
- end if;
- when SYNC =>
- RCV_NEXT_STATE <= IDLE;
- end case;
- end process RCV_STATEDEC;
-end architecture BEHAVIOR;
-
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive.vhd.bak
deleted file mode 100644
index 8877e05..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_receive.vhd.bak
+++ /dev/null
@@ -1,425 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- 6850 compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- UART 6850 compatible IP core ----
----- ----
----- 6850's receiver unit. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF6850IP_RECEIVE is
- port (
- CLK : in std_logic;
- RESETn : in bit;
- MCLR : in bit;
-
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
-
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_EN : out bit;
-
- WS : in bit_vector(2 downto 0);
- CDS : in bit_vector(1 downto 0);
-
- RXCLK : in bit;
- RXDATA : in bit;
-
- RDRF : buffer bit;
- OVR : out bit;
- PE : out bit;
- FE : out bit
- );
-end entity WF6850IP_RECEIVE;
-
-architecture BEHAVIOR of WF6850IP_RECEIVE is
-type RCV_STATES is (IDLE, WAIT_START, SAMPLE, PARITY, STOP1, STOP2, SYNC);
-signal RCV_STATE, RCV_NEXT_STATE : RCV_STATES;
-signal RXDATA_I : bit;
-signal RXDATA_S : bit;
-signal DATA_REG : bit_vector(7 downto 0);
-signal SHIFT_REG : bit_vector(7 downto 0);
-signal CLK_STRB : bit;
-signal BITCNT : std_logic_vector(2 downto 0);
-begin
- P_SAMPLE: process(CLK)
- -- This filter provides a synchronisation to the system
- -- clock, even for random baud rates of the received data
- -- stream.
- variable FLT_TMP : integer range 0 to 2;
- begin
- if rising_edge(CLK) then
- --
- RXDATA_I <= RXDATA;
- --
- if RXDATA_I = '1' and FLT_TMP < 2 then
- FLT_TMP := FLT_TMP + 1;
- elsif RXDATA_I = '1' then
- RXDATA_S <= '1';
- elsif RXDATA_I = '0' and FLT_TMP > 0 then
- FLT_TMP := FLT_TMP - 1;
- elsif RXDATA_I = '0' then
- RXDATA_S <= '0';
- end if;
- end if;
- end process P_SAMPLE;
-
- CLKDIV: process(CLK)
- variable CLK_LOCK : boolean;
- variable STRB_LOCK : boolean;
- variable CLK_DIVCNT : std_logic_vector(6 downto 0);
- begin
- if rising_edge(CLK) then
- if CDS = "00" then -- Divider off.
- if RXCLK = '1' and STRB_LOCK = false then
- CLK_STRB <= '1';
- STRB_LOCK := true;
- elsif RXCLK = '0' then
- CLK_STRB <= '0';
- STRB_LOCK := false;
- else
- CLK_STRB <= '0';
- end if;
- elsif RCV_STATE = IDLE then
- -- Preset the CLKDIV with the start delays.
- if CDS = "01" then
- CLK_DIVCNT := "0001000"; -- Half of div by 16 mode.
- elsif CDS = "10" then
- CLK_DIVCNT := "0100000"; -- Half of div by 64 mode.
- end if;
- CLK_STRB <= '0';
- else
- if CLK_DIVCNT > "0000000" and RXCLK = '1' and CLK_LOCK = false then
- CLK_DIVCNT := CLK_DIVCNT - '1';
- CLK_STRB <= '0';
- CLK_LOCK := true;
- elsif CDS = "01" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "0010000"; -- Div by 16 mode.
- --
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif CDS = "10" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "1000000"; -- Div by 64 mode.
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif RXCLK = '0' then
- CLK_LOCK := false;
- STRB_LOCK := false;
- CLK_STRB <= '0';
- else
- CLK_STRB <= '0';
- end if;
- end if;
- end if;
- end process CLKDIV;
-
- DATAREG: process(RESETn, CLK)
- begin
- if RESETn = '0' or MCLR = '1' then
- DATA_REG <= x"00";
- else
- if rising_edge(CLK) then
- if RCV_STATE = SYNC and WS(2) = '0' and RDRF = '0' then -- 7 bit data.
- -- Transfer from shift- to data register only if
- -- data register is empty (RDRF = '0').
- DATA_REG <= '0' & SHIFT_REG(7 downto 1);
- elsif RCV_STATE = SYNC and WS(2) = '1' and RDRF = '0' then -- 8 bit data.
- -- Transfer from shift- to data register only if
- -- data register is empty (RDRF = '0').
- DATA_REG <= SHIFT_REG;
- end if;
- end if;
- end if;
- end process DATAREG;
- DATA_OUT <= DATA_REG when CS = "011" and RWn = '1' and RS = '1' else (others => '0');
- DATA_EN <= '1' when CS = "011" and RWn = '1' and RS = '1' else '0';
-
- SHIFTREG: process(RESETn, CLK)
- begin
- if RESETn = '0' or MCLR = '1' then
- SHIFT_REG <= x"00";
- else
- if rising_edge(CLK) then
- if RCV_STATE = SAMPLE and CLK_STRB = '1' then
- SHIFT_REG <= RXDATA_S & SHIFT_REG(7 downto 1); -- Shift right.
- end if;
- end if;
- end if;
- end process SHIFTREG;
-
- P_BITCNT: process(CLK)
- begin
- if rising_edge(CLK) then
- if RCV_STATE = SAMPLE and CLK_STRB = '1' then
- BITCNT <= BITCNT + '1';
- elsif RCV_STATE /= SAMPLE then
- BITCNT <= (others => '0');
- end if;
- end if;
- end process P_BITCNT;
-
- FRAME_ERR: process(RESETn, CLK)
- -- This module detects a framing error
- -- during stop bit 1 and stop bit 2.
- variable FE_I: bit;
- begin
- if RESETn = '0' then
- FE_I := '0';
- FE <= '0';
- else
- if rising_edge(CLK) then
- if MCLR = '1' then
- FE_I := '0';
- FE <= '0';
- elsif CLK_STRB = '1' then
- if RCV_STATE = STOP1 and RXDATA_S = '0' then
- FE_I := '1';
- elsif RCV_STATE = STOP2 and RXDATA_S = '0' then
- FE_I := '1';
- elsif RCV_STATE = STOP1 or RCV_STATE = STOP2 then
- FE_I := '0'; -- Error resets when correct data appears.
- end if;
- end if;
- if RCV_STATE = SYNC then
- FE <= FE_I; -- Update the FE every SYNC time.
- end if;
- end if;
- end if;
- end process FRAME_ERR;
-
- OVERRUN: process(RESETn, CLK)
- variable OVR_I : bit;
- variable FIRST_READ : boolean;
- begin
- if rising_edge(CLK) then
- if RESETn = '0' or MCLR = '1' then
- OVR_I := '0';
- OVR <= '0';
- FIRST_READ := false;
- else
- if CLK_STRB = '1' and RCV_STATE = STOP1 then
- -- Overrun appears if RDRF is '1' in this state.
- OVR_I := RDRF;
- end if;
- if CS = "011" and RWn = '1' and RS = '1' then
- -- If an overrun was detected, the concerning flag is
- -- set when the valid data word in the receiver data
- -- register is read. Thereafter the RDRF flag is reset
- -- and the overrun disappears (OVR_I goes low) after
- -- a second read (in time) of the receiver data register.
- if FIRST_READ = false then
- if OVR_I = '1' then
- OVR <= '1';
- OVR_I := '0';
- FIRST_READ := true;
- else
- OVR <= '0';
- end if;
- end if;
- else
- FIRST_READ := false;
- end if;
- end if;
- end if;
- end process OVERRUN;
-
- PARITY_TEST: process(RESETn,MCLR,CLK)
- variable PAR_TMP : bit;
- variable PE_I : bit;
- begin
- if RESETn = '0' or MCRL = '1' then
- PE <= '0';
- else
- if rising_edge(CLK) then
- if CLK_STRB = '1' then -- Sample parity on clock strobe.
- PE_I := '0'; -- Initialise.
- if RCV_STATE = PARITY then
- for i in 1 to 7 loop
- if i = 1 then
- PAR_TMP := SHIFT_REG(i-1) xor SHIFT_REG(i);
- else
- PAR_TMP := PAR_TMP xor SHIFT_REG(i);
- end if;
- end loop;
- if WS = "000" or WS = "010" or WS = "110" then -- Even parity.
- PE_I := PAR_TMP xor RXDATA_S;
- elsif WS = "001" or WS = "011" or WS = "111" then -- Odd parity.
- PE_I := not PAR_TMP xor RXDATA_S;
- else -- No parity for WS = "100" and WS = "101".
- PE_I := '0';
- end if;
- end if;
- end if;
- end if;
- -- Transmit the parity flag together with the data
- -- In other words: no parity to the status register
- -- when RDRF inhibits the data transfer to the
- -- receiver data register.
- if RCV_STATE = SYNC and RDRF = '0' then
- PE <= PE_I;
- elsif CS = "011" and RWn = '1' and RS = '1' then
- PE <= '0'; -- Clear when reading the data register.
- end if;
- end if;
- end process PARITY_TEST;
-
- P_RDRF: process(RESETn, CLK)
- -- Receive data register full flag.
- begin
- if rising_edge(CLK) then
- if RESETn = '0' or MCLR = '1' then
- RDRF <= '0';
- else
- if RCV_STATE = SYNC then
- RDRF <= '1'; -- Data register is full until now!
- end if;
- if CS = "011" and RWn = '1' and RS = '1' then
- RDRF <= '0'; -- when reading the data register ...
- end if;
- end if;
- end if;
- end process P_RDRF;
-
- RCV_STATEREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- RCV_STATE <= IDLE;
- else
- if rising_edge(CLK) then
- if MCLR = '1' then
- RCV_STATE <= IDLE;
- else
- RCV_STATE <= RCV_NEXT_STATE;
- end if;
- end if;
- end if;
- end process RCV_STATEREG;
-
- RCV_STATEDEC: process(RCV_STATE, RXDATA_S, CDS, WS, BITCNT, CLK_STRB)
- begin
- case RCV_STATE is
- when IDLE =>
- if RXDATA_S = '0' and CDS = "00" then
- RCV_NEXT_STATE <= SAMPLE; -- Startbit detected in div by 1 mode.
- elsif RXDATA_S = '0' and CDS = "01" then
- RCV_NEXT_STATE <= WAIT_START; -- Startbit detected in div by 16 mode.
- elsif RXDATA_S = '0' and CDS = "10" then
- RCV_NEXT_STATE <= WAIT_START; -- Startbit detected in div by 64 mode.
- else
- RCV_NEXT_STATE <= IDLE; -- No startbit; sleep well :-)
- end if;
- when WAIT_START =>
- if CLK_STRB = '1' then
- if RXDATA_S = '0' then
- RCV_NEXT_STATE <= SAMPLE; -- Start condition in no div by 1 modes.
- else
- RCV_NEXT_STATE <= IDLE; -- No valid start condition, go back.
- end if;
- else
- RCV_NEXT_STATE <= WAIT_START; -- Stay.
- end if;
- when SAMPLE =>
- if CLK_STRB = '1' then
- if BITCNT < "110" and WS(2) = '0' then
- RCV_NEXT_STATE <= SAMPLE; -- Go on sampling 7 data bits.
- elsif BITCNT < "111" and WS(2) = '1' then
- RCV_NEXT_STATE <= SAMPLE; -- Go on sampling 8 data bits.
- elsif WS = "100" or WS = "101" then
- RCV_NEXT_STATE <= STOP1; -- No parity check enabled.
- else
- RCV_NEXT_STATE <= PARITY; -- Parity enabled.
- end if;
- else
- RCV_NEXT_STATE <= SAMPLE; -- Stay in sample mode.
- end if;
- when PARITY =>
- if CLK_STRB = '1' then
- RCV_NEXT_STATE <= STOP1;
- else
- RCV_NEXT_STATE <= PARITY;
- end if;
- when STOP1 =>
- if CLK_STRB = '1' then
- if RXDATA_S = '0' then
- RCV_NEXT_STATE <= SYNC; -- Framing error detected.
- elsif WS = "000" or WS = "001" or WS = "100" then
- RCV_NEXT_STATE <= STOP2; -- Two stop bits selected.
- else
- RCV_NEXT_STATE <= SYNC; -- One stop bit selected.
- end if;
- else
- RCV_NEXT_STATE <= STOP1;
- end if;
- when STOP2 =>
- if CLK_STRB = '1' then
- RCV_NEXT_STATE <= SYNC;
- else
- RCV_NEXT_STATE <= STOP2;
- end if;
- when SYNC =>
- RCV_NEXT_STATE <= IDLE;
- end case;
- end process RCV_STATEDEC;
-end architecture BEHAVIOR;
-
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_top_soc.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_top_soc.vhd.bak
deleted file mode 100644
index 6f80a67..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_top_soc.vhd.bak
+++ /dev/null
@@ -1,252 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- 6850 compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- UART 6850 compatible IP core ----
----- ----
----- This is the top level file. ----
----- Top level file for use in systems on programmable chips. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Top level file provided for SOC (systems on programmable chips).
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF6850IP_TOP_SOC is
- port (
- CLK : in bit;
- RESETn : in bit;
-
- CS2n, CS1, CS0 : in bit;
- E : in bit;
- RWn : in bit;
- RS : in bit;
-
- DATA_IN : in std_logic_vector(7 downto 0);
- DATA_OUT : out std_logic_vector(7 downto 0);
- DATA_EN : out bit;
-
- TXCLK : in bit;
- RXCLK : in bit;
- RXDATA : in bit;
- CTSn : in bit;
- DCDn : in bit;
-
- IRQn : out bit;
- TXDATA : out bit;
- RTSn : out bit
- );
-end entity WF6850IP_TOP_SOC;
-
-architecture STRUCTURE of WF6850IP_TOP_SOC is
-component WF6850IP_CTRL_STATUS
- port (
- CLK : in bit;
- RESETn : in bit;
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
- DATA_IN : in bit_vector(7 downto 0);
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_EN : out bit;
- RDRF : in bit;
- TDRE : in bit;
- DCDn : in bit;
- CTSn : in bit;
- FE : in bit;
- OVR : in bit;
- PE : in bit;
- MCLR : out bit;
- RTSn : out bit;
- CDS : out bit_vector(1 downto 0);
- WS : out bit_vector(2 downto 0);
- TC : out bit_vector(1 downto 0);
- IRQn : out bit
- );
-end component;
-
-component WF6850IP_RECEIVE
- port (
- CLK : in bit;
- RESETn : in bit;
- MCLR : in bit;
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
- DATA_OUT : out bit_vector(7 downto 0);
- DATA_EN : out bit;
- WS : in bit_vector(2 downto 0);
- CDS : in bit_vector(1 downto 0);
- RXCLK : in bit;
- RXDATA : in bit;
- RDRF : out bit;
- OVR : out bit;
- PE : out bit;
- FE : out bit
- );
-end component;
-
-component WF6850IP_TRANSMIT
- port (
- CLK : in bit;
- RESETn : in bit;
- MCLR : in bit;
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
- DATA_IN : in bit_vector(7 downto 0);
- CTSn : in bit;
- TC : in bit_vector(1 downto 0);
- WS : in bit_vector(2 downto 0);
- CDS : in bit_vector(1 downto 0);
- TXCLK : in bit;
- TDRE : out bit;
- TXDATA : out bit
- );
-end component;
-signal DATA_IN_I : bit_vector(7 downto 0);
-signal DATA_RX : bit_vector(7 downto 0);
-signal DATA_RX_EN : bit;
-signal DATA_CTRL : bit_vector(7 downto 0);
-signal DATA_CTRL_EN : bit;
-signal RDRF_I : bit;
-signal TDRE_I : bit;
-signal FE_I : bit;
-signal OVR_I : bit;
-signal PE_I : bit;
-signal MCLR_I : bit;
-signal CDS_I : bit_vector(1 downto 0);
-signal WS_I : bit_vector(2 downto 0);
-signal TC_I : bit_vector(1 downto 0);
-signal IRQ_In : bit;
-begin
- DATA_IN_I <= To_BitVector(DATA_IN);
- DATA_EN <= DATA_RX_EN or DATA_CTRL_EN;
- DATA_OUT <= To_StdLogicVector(DATA_RX) when DATA_RX_EN = '1' else
- To_StdLogicVector(DATA_CTRL) when DATA_CTRL_EN = '1' else (others => '0');
-
- IRQn <= '0' when IRQ_In = '0' else '1';
-
- I_UART_CTRL_STATUS: WF6850IP_CTRL_STATUS
- port map(
- CLK => CLK,
- RESETn => RESETn,
- CS(2) => CS2n,
- CS(1) => CS1,
- CS(0) => CS0,
- E => E,
- RWn => RWn,
- RS => RS,
- DATA_IN => DATA_IN_I,
- DATA_OUT => DATA_CTRL,
- DATA_EN => DATA_CTRL_EN,
- RDRF => RDRF_I,
- TDRE => TDRE_I,
- DCDn => DCDn,
- CTSn => CTSn,
- FE => FE_I,
- OVR => OVR_I,
- PE => PE_I,
- MCLR => MCLR_I,
- RTSn => RTSn,
- CDS => CDS_I,
- WS => WS_I,
- TC => TC_I,
- IRQn => IRQ_In
- );
-
- I_UART_RECEIVE: WF6850IP_RECEIVE
- port map (
- CLK => CLK,
- RESETn => RESETn,
- MCLR => MCLR_I,
- CS(2) => CS2n,
- CS(1) => CS1,
- CS(0) => CS0,
- E => E,
- RWn => RWn,
- RS => RS,
- DATA_OUT => DATA_RX,
- DATA_EN => DATA_RX_EN,
- WS => WS_I,
- CDS => CDS_I,
- RXCLK => RXCLK,
- RXDATA => RXDATA,
- RDRF => RDRF_I,
- OVR => OVR_I,
- PE => PE_I,
- FE => FE_I
- );
-
- I_UART_TRANSMIT: WF6850IP_TRANSMIT
- port map (
- CLK => CLK,
- RESETn => RESETn,
- MCLR => MCLR_I,
- CS(2) => CS2n,
- CS(1) => CS1,
- CS(0) => CS0,
- E => E,
- RWn => RWn,
- RS => RS,
- DATA_IN => DATA_IN_I,
- CTSn => CTSn,
- TC => TC_I,
- WS => WS_I,
- CDS => CDS_I,
- TDRE => TDRE_I,
- TXCLK => TXCLK,
- TXDATA => TXDATA
- );
-end architecture STRUCTURE;
\ No newline at end of file
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_transmit.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_transmit.vhd.bak
deleted file mode 100644
index d6953d5..0000000
--- a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/WF_UART6850_IP/wf6850ip_transmit.vhd.bak
+++ /dev/null
@@ -1,338 +0,0 @@
-----------------------------------------------------------------------
----- ----
----- 6850 compatible IP Core ----
----- ----
----- This file is part of the SUSKA ATARI clone project. ----
----- http://www.experiment-s.de ----
----- ----
----- Description: ----
----- UART 6850 compatible IP core ----
----- ----
----- 6850's transmitter unit. ----
----- ----
----- ----
----- To Do: ----
----- - ----
----- ----
----- Author(s): ----
----- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
----- ----
-----------------------------------------------------------------------
----- ----
----- Copyright (C) 2006 - 2008 Wolfgang Foerster ----
----- ----
----- This source file may be used and distributed without ----
----- restriction provided that this copyright statement is not ----
----- removed from the file and that any derivative work contains ----
----- the original copyright notice and the associated disclaimer. ----
----- ----
----- This source file is free software; you can redistribute it ----
----- and/or modify it under the terms of the GNU Lesser General ----
----- Public License as published by the Free Software Foundation; ----
----- either version 2.1 of the License, or (at your option) any ----
----- later version. ----
----- ----
----- This source is distributed in the hope that it will be ----
----- useful, but WITHOUT ANY WARRANTY; without even the implied ----
----- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
----- PURPOSE. See the GNU Lesser General Public License for more ----
----- details. ----
----- ----
----- You should have received a copy of the GNU Lesser General ----
----- Public License along with this source; if not, download it ----
----- from http://www.gnu.org/licenses/lgpl.html ----
----- ----
-----------------------------------------------------------------------
---
--- Revision History
---
--- Revision 2K6A 2006/06/03 WF
--- Initial Release.
--- Revision 2K6B 2006/11/07 WF
--- Modified Source to compile with the Xilinx ISE.
--- Revision 2K8A 2008/07/14 WF
--- Minor changes.
--- Revision 2K8B 2008/11/01 WF
--- Fixed the T_DRE process concerning the TDRE <= '1' setting.
--- Thanks to Lyndon Amsdon finding the bug.
---
-
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-
-entity WF6850IP_TRANSMIT is
- port (
- CLK : in std_logic;
- RESETn : in bit;
- MCLR : in bit;
-
- CS : in bit_vector(2 downto 0);
- E : in bit;
- RWn : in bit;
- RS : in bit;
-
- DATA_IN : in bit_vector(7 downto 0);
-
- CTSn : in bit;
-
- TC : in bit_vector(1 downto 0);
- WS : in bit_vector(2 downto 0);
- CDS : in bit_vector(1 downto 0);
-
- TXCLK : in bit;
-
- TDRE : buffer bit;
- TXDATA : out bit
- );
-end entity WF6850IP_TRANSMIT;
-
-architecture BEHAVIOR of WF6850IP_TRANSMIT is
-type TR_STATES is (IDLE, LOAD_SHFT, START, SHIFTOUT, PARITY, STOP1, STOP2);
-signal TR_STATE, TR_NEXT_STATE : TR_STATES;
-signal CLK_STRB : bit;
-signal DATA_REG : bit_vector(7 downto 0);
-signal SHIFT_REG : bit_vector(7 downto 0);
-signal BITCNT : std_logic_vector(2 downto 0);
-signal PARITY_I : bit;
-begin
- -- The default condition in this statement is to ensure
- -- to cover all possibilities for example if there is a
- -- one hot decoding of the state machine with wrong states
- -- (e.g. not one of the given here).
- TXDATA <= '1' when TR_STATE = IDLE else
- '1' when TR_STATE = LOAD_SHFT else
- '0' when TR_STATE = START else
- SHIFT_REG(0) when TR_STATE = SHIFTOUT else
- PARITY_I when TR_STATE = PARITY else
- '1' when TR_STATE = STOP1 else
- '1' when TR_STATE = STOP2 else '1';
-
- CLKDIV: process
- variable CLK_LOCK : boolean;
- variable STRB_LOCK : boolean;
- variable CLK_DIVCNT : std_logic_vector(6 downto 0);
- begin
- if rising_edge(CLK) then
- if CDS = "00" then -- divider off
- if TXCLK = '0' and STRB_LOCK = false then -- Works on negative TXCLK edge.
- CLK_STRB <= '1';
- STRB_LOCK := true;
- elsif TXCLK = '1' then
- CLK_STRB <= '0';
- STRB_LOCK := false;
- else
- CLK_STRB <= '0';
- end if;
- elsif TR_STATE = IDLE then
- -- preset the CLKDIV with the start delays
- if CDS = "01" then
- CLK_DIVCNT := "0010000"; -- div by 16 mode
- elsif CDS = "10" then
- CLK_DIVCNT := "1000000"; -- div by 64 mode
- end if;
- CLK_STRB <= '0';
- else
- -- Works on negative TXCLK edge:
- if CLK_DIVCNT > "0000000" and TXCLK = '0' and CLK_LOCK = false then
- CLK_DIVCNT := CLK_DIVCNT - '1';
- CLK_STRB <= '0';
- CLK_LOCK := true;
- elsif CDS = "01" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "0010000"; -- Div by 16 mode.
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif CDS = "10" and CLK_DIVCNT = "0000000" then
- CLK_DIVCNT := "1000000"; -- Div by 64 mode.
- if STRB_LOCK = false then
- STRB_LOCK := true;
- CLK_STRB <= '1';
- else
- CLK_STRB <= '0';
- end if;
- elsif TXCLK = '1' then
- CLK_LOCK := false;
- STRB_LOCK := false;
- CLK_STRB <= '0';
- else
- CLK_STRB <= '0';
- end if;
- end if;
- end if;
- end process CLKDIV;
-
- DATAREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- DATA_REG <= x"00";
- elsif rising_edge(CLK) then
- if MCLR = '1' then
- DATA_REG <= x"00";
- elsif WS(2) = '0' and CS = "011" and RWn = '0' and RS = '1' and E = '1' then
- DATA_REG <= '0' & DATA_IN(6 downto 0); -- 7 bit data mode.
- elsif WS(2) = '1' and CS = "011" and RWn = '0' and RS = '1' and E = '1' then
- DATA_REG <= DATA_IN; -- 8 bit data mode.
- end if;
- end if;
- end process DATAREG;
-
- SHIFTREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- SHIFT_REG <= x"00";
- elsif rising_edge(CLK) then
- if MCLR = '1' then
- SHIFT_REG <= x"00";
- elsif TR_STATE = LOAD_SHFT and TDRE = '0' then
- -- If during LOAD_SHIFT the transmitter data register
- -- is empty (TDRE = '1') the shift register will not
- -- be loaded. When additionally TC = "11", the break
- -- character (zero data and no stop bits) is sent.
- SHIFT_REG <= DATA_REG;
- elsif TR_STATE = SHIFTOUT and CLK_STRB = '1' then
- SHIFT_REG <= '0' & SHIFT_REG(7 downto 1); -- Shift right.
- end if;
- end if;
- end process SHIFTREG;
-
- P_BITCNT: process(CLK)
- -- Counter for the data bits transmitted.
- begin
- if rising_edge(CLK) then
- if TR_STATE = SHIFTOUT and CLK_STRB = '1' then
- BITCNT <= BITCNT + '1';
- elsif TR_STATE /= SHIFTOUT then
- BITCNT <= "000";
- end if;
- end if;
- end process P_BITCNT;
-
- P_TDRE: process(RESETn, CLK)
- -- Transmit data register empty flag.
- begin
- if rising_edge(CLK) then
- if RESETn = '0' or MCLR = '1' then
- TDRE <= '1';
- else
- if TR_NEXT_STATE = START and TR_STATE /= START then
- -- Data has been loaded to shift register, thus data register is free again.
- -- Thanks to Lyndon Amsdon for finding a bug here. The TDRE is set to one once
- -- entering the state now.
- TDRE <= '1';
- end if;
- if CS = "011" and RWn = '0' and RS = '1' then
- TDRE <= '0';
- end if;
- end if;
- end if;
- end process P_TDRE;
-
- PARITY_GEN: process(CLK)
- variable PAR_TMP : bit;
- begin
- if rising_edge(CLK) then
- if TR_STATE = START then -- Calculate the parity during the start phase.
- for i in 1 to 7 loop
- if i = 1 then
- PAR_TMP := SHIFT_REG(i-1) xor SHIFT_REG(i);
- else
- PAR_TMP := PAR_TMP xor SHIFT_REG(i);
- end if;
- end loop;
- if WS = "000" or WS = "010" or WS = "110" then -- Even parity.
- PARITY_I <= PAR_TMP;
- elsif WS = "001" or WS = "011" or WS = "111" then -- Odd parity.
- PARITY_I <= not PAR_TMP;
- else -- No parity for WS = "100" and WS = "101".
- PARITY_I <= '0';
- end if;
- end if;
- end if;
- end process PARITY_GEN;
-
- TR_STATEREG: process(RESETn, CLK)
- begin
- if RESETn = '0' then
- TR_STATE <= IDLE;
- else
- if rising_edge(CLK) then
- if MCLR = '1' then
- TR_STATE <= IDLE;
- else
- TR_STATE <= TR_NEXT_STATE;
- end if;
- end if;
- end if;
- end process TR_STATEREG;
-
- TR_STATEDEC: process(TR_STATE, CLK_STRB, TC, BITCNT, WS, TDRE, CTSn)
- begin
- case TR_STATE is
- when IDLE =>
- if TDRE = '1' and TC = "11" then
- TR_NEXT_STATE <= LOAD_SHFT;
- elsif TDRE = '0' and CTSn = '0' then -- Start if data register is not empty.
- TR_NEXT_STATE <= LOAD_SHFT;
- else
- TR_NEXT_STATE <= IDLE;
- end if;
- when LOAD_SHFT =>
- TR_NEXT_STATE <= START;
- when START =>
- if CLK_STRB = '1' then
- TR_NEXT_STATE <= SHIFTOUT;
- else
- TR_NEXT_STATE <= START;
- end if;
- when SHIFTOUT =>
- if CLK_STRB = '1' then
- if BITCNT < "110" and WS(2) = '0' then
- TR_NEXT_STATE <= SHIFTOUT; -- Transmit 7 data bits.
- elsif BITCNT < "111" and WS(2) = '1' then
- TR_NEXT_STATE <= SHIFTOUT; -- Transmit 8 data bits.
- elsif WS = "100" or WS = "101" then
- if TDRE = '1' and TC = "11" then
- -- Break condition, do not send a stop bit.
- TR_NEXT_STATE <= IDLE;
- else
- TR_NEXT_STATE <= STOP1; -- No parity check enabled.
- end if;
- else
- TR_NEXT_STATE <= PARITY; -- Parity enabled.
- end if;
- else
- TR_NEXT_STATE <= SHIFTOUT;
- end if;
- when PARITY =>
- if CLK_STRB = '1' then
- if TDRE = '1' and TC = "11" then
- -- Break condition, do not send a stop bit.
- TR_NEXT_STATE <= IDLE;
- else
- TR_NEXT_STATE <= STOP1; -- No parity check enabled.
- end if;
- else
- TR_NEXT_STATE <= PARITY;
- end if;
- when STOP1 =>
- if CLK_STRB = '1' and (WS = "000" or WS = "001" or WS = "100") then
- TR_NEXT_STATE <= STOP2; -- Two stop bits selected.
- elsif CLK_STRB = '1' then
- TR_NEXT_STATE <= IDLE; -- One stop bits selected.
- else
- TR_NEXT_STATE <= STOP1;
- end if;
- when STOP2 =>
- if CLK_STRB = '1' then
- TR_NEXT_STATE <= IDLE;
- else
- TR_NEXT_STATE <= STOP2;
- end if;
- end case;
- end process TR_STATEDEC;
-end architecture BEHAVIOR;
-
diff --git a/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/dcfifo1.vhd.bak b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/dcfifo1.vhd.bak
new file mode 100644
index 0000000..e7c6ae6
--- /dev/null
+++ b/FPGA_by_Fredi/FalconIO_SDCard_IDE_CF/dcfifo1.vhd.bak
@@ -0,0 +1,202 @@
+-- megafunction wizard: %LPM_FIFO+%
+-- GENERATION: STANDARD
+-- VERSION: WM1.0
+-- MODULE: dcfifo_mixed_widths
+
+-- ============================================================
+-- File Name: dcfifo1.vhd
+-- Megafunction Name(s):
+-- dcfifo_mixed_widths
+--
+-- Simulation Library Files(s):
+-- altera_mf
+-- ============================================================
+-- ************************************************************
+-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
+--
+-- 9.1 Build 222 10/21/2009 SJ Web Edition
+-- ************************************************************
+
+
+--Copyright (C) 1991-2009 Altera Corporation
+--Your use of Altera Corporation's design tools, logic functions
+--and other software and tools, and its AMPP partner logic
+--functions, and any output files from any of the foregoing
+--(including device programming or simulation files), and any
+--associated documentation or information are expressly subject
+--to the terms and conditions of the Altera Program License
+--Subscription Agreement, Altera MegaCore Function License
+--Agreement, or other applicable license agreement, including,
+--without limitation, that your use is for the sole purpose of
+--programming logic devices manufactured by Altera and sold by
+--Altera or its authorized distributors. Please refer to the
+--applicable agreement for further details.
+
+
+LIBRARY ieee;
+USE ieee.std_logic_1164.all;
+
+LIBRARY altera_mf;
+USE altera_mf.all;
+
+ENTITY dcfifo1 IS
+ PORT
+ (
+ aclr : IN STD_LOGIC := '0';
+ data : IN STD_LOGIC_VECTOR (15 DOWNTO 0);
+ rdclk : IN STD_LOGIC ;
+ rdreq : IN STD_LOGIC ;
+ wrclk : IN STD_LOGIC ;
+ wrreq : IN STD_LOGIC ;
+ q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0);
+ wrusedw : OUT STD_LOGIC_VECTOR (3 DOWNTO 0)
+ );
+END dcfifo1;
+
+
+ARCHITECTURE SYN OF dcfifo1 IS
+
+ SIGNAL sub_wire0 : STD_LOGIC_VECTOR (3 DOWNTO 0);
+ SIGNAL sub_wire1 : STD_LOGIC_VECTOR (7 DOWNTO 0);
+
+
+
+ COMPONENT dcfifo_mixed_widths
+ GENERIC (
+ intended_device_family : STRING;
+ lpm_numwords : NATURAL;
+ lpm_showahead : STRING;
+ lpm_type : STRING;
+ lpm_width : NATURAL;
+ lpm_widthu : NATURAL;
+ lpm_widthu_r : NATURAL;
+ lpm_width_r : NATURAL;
+ overflow_checking : STRING;
+ rdsync_delaypipe : NATURAL;
+ underflow_checking : STRING;
+ use_eab : STRING;
+ write_aclr_synch : STRING;
+ wrsync_delaypipe : NATURAL
+ );
+ PORT (
+ wrclk : IN STD_LOGIC ;
+ rdreq : IN STD_LOGIC ;
+ wrusedw : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
+ aclr : IN STD_LOGIC ;
+ rdclk : IN STD_LOGIC ;
+ q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0);
+ wrreq : IN STD_LOGIC ;
+ data : IN STD_LOGIC_VECTOR (15 DOWNTO 0)
+ );
+ END COMPONENT;
+
+BEGIN
+ wrusedw <= sub_wire0(3 DOWNTO 0);
+ q <= sub_wire1(7 DOWNTO 0);
+
+ dcfifo_mixed_widths_component : dcfifo_mixed_widths
+ GENERIC MAP (
+ intended_device_family => "Cyclone III",
+ lpm_numwords => 16,
+ lpm_showahead => "OFF",
+ lpm_type => "dcfifo",
+ lpm_width => 16,
+ lpm_widthu => 4,
+ lpm_widthu_r => 5,
+ lpm_width_r => 8,
+ overflow_checking => "ON",
+ rdsync_delaypipe => 5,
+ underflow_checking => "ON",
+ use_eab => "ON",
+ write_aclr_synch => "OFF",
+ wrsync_delaypipe => 5
+ )
+ PORT MAP (
+ wrclk => wrclk,
+ rdreq => rdreq,
+ aclr => aclr,
+ rdclk => rdclk,
+ wrreq => wrreq,
+ data => data,
+ wrusedw => sub_wire0,
+ q => sub_wire1
+ );
+
+
+
+END SYN;
+
+-- ============================================================
+-- CNX file retrieval info
+-- ============================================================
+-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
+-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
+-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
+-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
+-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
+-- Retrieval info: PRIVATE: Clock NUMERIC "4"
+-- Retrieval info: PRIVATE: Depth NUMERIC "16"
+-- Retrieval info: PRIVATE: Empty NUMERIC "1"
+-- Retrieval info: PRIVATE: Full NUMERIC "1"
+-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
+-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
+-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
+-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
+-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
+-- Retrieval info: PRIVATE: Optimize NUMERIC "1"
+-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
+-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
+-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
+-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
+-- Retrieval info: PRIVATE: Width NUMERIC "16"
+-- Retrieval info: PRIVATE: dc_aclr NUMERIC "1"
+-- Retrieval info: PRIVATE: diff_widths NUMERIC "1"
+-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
+-- Retrieval info: PRIVATE: output_width NUMERIC "8"
+-- Retrieval info: PRIVATE: rsEmpty NUMERIC "0"
+-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
+-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
+-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
+-- Retrieval info: PRIVATE: sc_sclr NUMERIC "0"
+-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
+-- Retrieval info: PRIVATE: wsFull NUMERIC "0"
+-- Retrieval info: PRIVATE: wsUsedW NUMERIC "1"
+-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
+-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "16"
+-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
+-- Retrieval info: CONSTANT: LPM_TYPE STRING "dcfifo"
+-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "16"
+-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "4"
+-- Retrieval info: CONSTANT: LPM_WIDTHU_R NUMERIC "5"
+-- Retrieval info: CONSTANT: LPM_WIDTH_R NUMERIC "8"
+-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
+-- Retrieval info: CONSTANT: RDSYNC_DELAYPIPE NUMERIC "5"
+-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
+-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
+-- Retrieval info: CONSTANT: WRITE_ACLR_SYNCH STRING "OFF"
+-- Retrieval info: CONSTANT: WRSYNC_DELAYPIPE NUMERIC "5"
+-- Retrieval info: USED_PORT: aclr 0 0 0 0 INPUT GND aclr
+-- Retrieval info: USED_PORT: data 0 0 16 0 INPUT NODEFVAL data[15..0]
+-- Retrieval info: USED_PORT: q 0 0 8 0 OUTPUT NODEFVAL q[7..0]
+-- Retrieval info: USED_PORT: rdclk 0 0 0 0 INPUT NODEFVAL rdclk
+-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL rdreq
+-- Retrieval info: USED_PORT: wrclk 0 0 0 0 INPUT NODEFVAL wrclk
+-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL wrreq
+-- Retrieval info: USED_PORT: wrusedw 0 0 4 0 OUTPUT NODEFVAL wrusedw[3..0]
+-- Retrieval info: CONNECT: @data 0 0 16 0 data 0 0 16 0
+-- Retrieval info: CONNECT: q 0 0 8 0 @q 0 0 8 0
+-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
+-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
+-- Retrieval info: CONNECT: @rdclk 0 0 0 0 rdclk 0 0 0 0
+-- Retrieval info: CONNECT: @wrclk 0 0 0 0 wrclk 0 0 0 0
+-- Retrieval info: CONNECT: wrusedw 0 0 4 0 @wrusedw 0 0 4 0
+-- Retrieval info: CONNECT: @aclr 0 0 0 0 aclr 0 0 0 0
+-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1.vhd TRUE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1.inc FALSE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1.cmp TRUE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1.bsf TRUE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1_inst.vhd FALSE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1_waveforms.html FALSE
+-- Retrieval info: GEN_FILE: TYPE_NORMAL dcfifo1_wave*.jpg FALSE
+-- Retrieval info: LIB_FILE: altera_mf
diff --git a/FPGA_by_Fredi/Interrupt_Handler/interrupt_handler.tdf.bak b/FPGA_by_Fredi/Interrupt_Handler/interrupt_handler.tdf.bak
new file mode 100644
index 0000000..7e4aa32
--- /dev/null
+++ b/FPGA_by_Fredi/Interrupt_Handler/interrupt_handler.tdf.bak
@@ -0,0 +1,391 @@
+TITLE "INTERRUPT HANDLER UND C1287";
+
+-- CREATED BY FREDI ASCHWANDEN
+
+INCLUDE "lpm_bustri_LONG.inc";
+INCLUDE "lpm_bustri_BYT.inc";
+
+
+-- Parameters Statement (optional)
+
+-- {{ALTERA_PARAMETERS_BEGIN}} DO NOT REMOVE THIS LINE!
+-- {{ALTERA_PARAMETERS_END}} DO NOT REMOVE THIS LINE!
+
+
+-- Subdesign Section
+
+SUBDESIGN interrupt_handler
+(
+ -- {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
+ MAIN_CLK : INPUT;
+ nFB_WR : INPUT;
+ nFB_CS1 : INPUT;
+ nFB_CS2 : INPUT;
+ FB_SIZE0 : INPUT;
+ FB_SIZE1 : INPUT;
+ FB_ADR[31..0] : INPUT;
+ FPGA_DATE[31..0] : INPUT;
+ PIC_INT : INPUT;
+ E0_INT : INPUT;
+ DVI_INT : INPUT;
+ nPCI_INTA : INPUT;
+ nPCI_INTB : INPUT;
+ nPCI_INTC : INPUT;
+ nPCI_INTD : INPUT;
+ nMFP_INT : INPUT;
+ nFB_OE : INPUT;
+ DSP_INT : INPUT;
+ VSYNC : INPUT;
+ HSYNC : INPUT;
+ DMA_DRQ : INPUT;
+ nRSTO : INPUT;
+ nIRQ[7..2] : OUTPUT;
+ INT_HANDLER_TA : OUTPUT;
+ ACP_CONF[31..0] : OUTPUT;
+ TIN0 : OUTPUT;
+ FB_AD[31..0] : BIDIR;
+ -- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
+)
+
+VARIABLE
+ FB_B[3..0] :NODE;
+ INT_CTR[31..0] :DFFE;
+ INT_CTR_CS :NODE;
+ INT_LATCH[31..0] :DFF;
+ INT_LATCH_CS :NODE;
+ INT_CLEAR[31..0] :DFF;
+ INT_CLEAR_CS :NODE;
+ INT_IN[31..0] :NODE;
+ INT_ENA[31..0] :DFFE;
+ INT_ENA_CS :NODE;
+ INT_L[9..0] :DFF;
+ INT_LA[9..0][3..0] :DFF;
+ ACP_CONF[31..0] :DFFE;
+ ACP_CONF_CS :NODE;
+ FPGA_DATE_CS :NODE;
+ PSEUDO_BUS_ERROR :NODE;
+ UHR_AS :NODE;
+ UHR_DS :NODE;
+ RTC_ADR[5..0] :DFFE;
+ ACHTELSEKUNDEN[2..0] :DFFE;
+ WERTE[7..0][63..0] :DFFE; -- WERTE REGISTER 0-63
+ PIC_INT_SYNC[2..0] :DFF;
+ INC_SEC :NODE;
+ INC_MIN :NODE;
+ INC_STD :NODE;
+ INC_TAG :NODE;
+ ANZAHL_TAGE_DES_MONATS[7..0]:NODE;
+ WINTERZEIT :NODE;
+ SOMMERZEIT :NODE;
+ INC_MONAT :NODE;
+ INC_JAHR :NODE;
+ UPDATE_ON :NODE;
+
+BEGIN
+-- BYT SELECT
+ FB_B0 = FB_SIZE1 & !FB_SIZE0 & !FB_ADR1 -- HWORD
+ # !FB_SIZE1 & FB_SIZE0 & !FB_ADR1 & !FB_ADR0 -- HHBYT
+ # !FB_SIZE1 & !FB_SIZE0 # FB_SIZE1 & FB_SIZE0; -- LONG UND LINE
+ FB_B1 = FB_SIZE1 & !FB_SIZE0 & !FB_ADR1 -- HWORD
+ # !FB_SIZE1 & FB_SIZE0 & !FB_ADR1 & FB_ADR0 -- HLBYT
+ # !FB_SIZE1 & !FB_SIZE0 # FB_SIZE1 & FB_SIZE0; -- LONG UND LINE
+ FB_B2 = FB_SIZE1 & !FB_SIZE0 & FB_ADR1 -- LWORD
+ # !FB_SIZE1 & FB_SIZE0 & FB_ADR1 & !FB_ADR0 -- LHBYT
+ # !FB_SIZE1 & !FB_SIZE0 # FB_SIZE1 & FB_SIZE0; -- LONG UND LINE
+ FB_B3 = FB_SIZE1 & !FB_SIZE0 & FB_ADR1 -- LWORD
+ # !FB_SIZE1 & FB_SIZE0 & FB_ADR1 & FB_ADR0 -- LLBYT
+ # !FB_SIZE1 & !FB_SIZE0 # FB_SIZE1 & FB_SIZE0; -- LONG UND LINE
+
+-- INTERRUPT CONTROL REGISTER: BIT0=INT5 AUSLÖSEN, 1=INT7 AUSLÖSEN
+ INT_CTR[].CLK = MAIN_CLK;
+ INT_CTR_CS = !nFB_CS2 & FB_ADR[27..2]==H"4000"; -- $10000/4
+ INT_CTR[] = FB_AD[];
+ INT_CTR[31..24].ENA = INT_CTR_CS & FB_B0 & !nFB_WR;
+ INT_CTR[23..16].ENA = INT_CTR_CS & FB_B1 & !nFB_WR;
+ INT_CTR[15..8].ENA = INT_CTR_CS & FB_B2 & !nFB_WR;
+ INT_CTR[7..0].ENA = INT_CTR_CS & FB_B3 & !nFB_WR;
+-- INTERRUPT ENABLE REGISTER BIT31=INT7,30=INT6,29=INT5,28=INT4,27=INT3,26=INT2
+ INT_ENA[].CLK = MAIN_CLK;
+ INT_ENA[].CLRN = nRSTO;
+ INT_ENA_CS = !nFB_CS2 & FB_ADR[27..2]==H"4001"; -- $10004/4
+ INT_ENA[] = FB_AD[];
+ INT_ENA[31..24].ENA = INT_ENA_CS & FB_B0 & !nFB_WR;
+ INT_ENA[23..16].ENA = INT_ENA_CS & FB_B1 & !nFB_WR;
+ INT_ENA[15..8].ENA = INT_ENA_CS & FB_B2 & !nFB_WR;
+ INT_ENA[7..0].ENA = INT_ENA_CS & FB_B3 & !nFB_WR;
+-- INTERRUPT CLEAR REGISTER WRITE ONLY 1=INTERRUPT CLEAR
+ INT_CLEAR[].CLK = MAIN_CLK;
+ INT_CLEAR_CS = !nFB_CS2 & FB_ADR[27..2]==H"4002"; -- $10008/4
+ INT_CLEAR[31..24] = FB_AD[31..24] & INT_CLEAR_CS & FB_B0 & !nFB_WR;
+ INT_CLEAR[23..16] = FB_AD[23..16] & INT_CLEAR_CS & FB_B1 & !nFB_WR;
+ INT_CLEAR[15..8] = FB_AD[15..8] & INT_CLEAR_CS & FB_B2 & !nFB_WR;
+ INT_CLEAR[7..0] = FB_AD[7..0] & INT_CLEAR_CS & FB_B3 & !nFB_WR;
+-- INTERRUPT LATCH REGISTER READ ONLY
+ INT_LATCH_CS = !nFB_CS2 & FB_ADR[27..2]==H"4003"; -- $1000C/4
+-- INTERRUPT
+ !nIRQ2 = HSYNC & INT_ENA[26];
+ !nIRQ3 = INT_CTR0 & INT_ENA[27];
+ !nIRQ4 = VSYNC & INT_ENA[28];
+ !nIRQ5 = INT_LATCH[]!=H"00000000" & INT_ENA[29];
+ !nIRQ6 = !nMFP_INT & INT_ENA[30];
+ !nIRQ7 = PSEUDO_BUS_ERROR & INT_ENA[31];
+
+PSEUDO_BUS_ERROR = !nFB_CS1 & (FB_ADR[19..4]==H"F8C8" -- SCC
+ # FB_ADR[19..4]==H"F8E0" -- VME
+-- # FB_ADR[19..4]==H"F920" -- PADDLE
+-- # FB_ADR[19..4]==H"F921" -- PADDLE
+-- # FB_ADR[19..4]==H"F922" -- PADDLE
+ # FB_ADR[19..4]==H"FFA8" -- MFP2
+ # FB_ADR[19..4]==H"FFA9" -- MFP2
+ # FB_ADR[19..4]==H"FFAA" -- MFP2
+ # FB_ADR[19..4]==H"FFA8" -- MFP2
+ # FB_ADR[19..8]==H"F87" -- TT SCSI
+ # FB_ADR[19..4]==H"FFC2" -- ST UHR
+ # FB_ADR[19..4]==H"FFC3" -- ST UHR
+-- # FB_ADR[19..4]==H"F890" -- DMA SOUND
+-- # FB_ADR[19..4]==H"F891" -- DMA SOUND
+-- # FB_ADR[19..4]==H"F892" -- DMA SOUND
+ );
+-- IF VIDEO ADR CHANGE
+TIN0 = !nFB_CS1 & FB_ADR[19..1]==H"7C100" & !nFB_WR; -- WRITE VIDEO BASE ADR HIGH 0xFFFF8201/2
+
+-- INTERRUPT LATCH
+ INT_L[].CLK = MAIN_CLK;
+ INT_L[].CLRN = nRSTO;
+ INT_L0 = PIC_INT & INT_ENA[0];
+ INT_L1 = E0_INT & INT_ENA[1];
+ INT_L2 = DVI_INT & INT_ENA[2];
+ INT_L3 = !nPCI_INTA & INT_ENA[3];
+ INT_L4 = !nPCI_INTB & INT_ENA[4];
+ INT_L5 = !nPCI_INTC & INT_ENA[5];
+ INT_L6 = !nPCI_INTD & INT_ENA[6];
+ INT_L7 = DSP_INT & INT_ENA[7];
+ INT_L8 = VSYNC & INT_ENA[8];
+ INT_L9 = HSYNC & INT_ENA[9];
+
+ INT_LA[][].CLK = MAIN_CLK;
+ INT_LATCH[] = H"FFFFFFFF";
+ INT_LATCH[].CLRN = !INT_CLEAR[] & nRSTO;
+ FOR I IN 0 TO 9 GENERATE
+ INT_LA[I][].CLRN = INT_ENA[I] & nRSTO;
+ INT_LA[I][] = INT_LA[I][]+1 & INT_L[I] & INT_LA[I][]<7
+ # INT_LA[I][]-1 & !INT_L[I] & INT_LA[I][]>8
+ # 15 & INT_L[I] & INT_LA[I][]>6
+ # 0 & !INT_L[I] & INT_LA[I][]<9;
+ INT_LATCH[I].CLK = INT_LA[I][3];
+ END GENERATE;
+
+-- INT_IN
+ INT_IN0 = PIC_INT;
+ INT_IN1 = E0_INT;
+ INT_IN2 = DVI_INT;
+ INT_IN3 = !nPCI_INTA;
+ INT_IN4 = !nPCI_INTB;
+ INT_IN5 = !nPCI_INTC;
+ INT_IN6 = !nPCI_INTD;
+ INT_IN7 = DSP_INT;
+ INT_IN8 = VSYNC;
+ INT_IN9 = HSYNC;
+ INT_IN[25..10] = H"0";
+ INT_IN26 = HSYNC;
+ INT_IN27 = INT_CTR0;
+ INT_IN28 = VSYNC;
+ INT_IN29 = INT_LATCH[]!=H"00000000";
+ INT_IN30 = !nMFP_INT;
+ INT_IN31 = DMA_DRQ;
+--***************************************************************************************
+-- ACP CONFIG REGISTER: BIT 31-> 0=CF 1=IDE
+ ACP_CONF[].CLK = MAIN_CLK;
+ ACP_CONF_CS = !nFB_CS2 & FB_ADR[27..2]==H"10000"; -- $4'0000/4
+ ACP_CONF[] = FB_AD[];
+ ACP_CONF[31..24].ENA = ACP_CONF_CS & FB_B0 & !nFB_WR;
+ ACP_CONF[23..16].ENA = ACP_CONF_CS & FB_B1 & !nFB_WR;
+ ACP_CONF[15..8].ENA = ACP_CONF_CS & FB_B2 & !nFB_WR;
+ ACP_CONF[7..0].ENA = ACP_CONF_CS & FB_B3 & !nFB_WR;
+--***************************************************************************************
+-- FPGA DATE HEX (ddmmyyyy)
+ FPGA_DATE_CS = !nFB_CS2 & FB_ADR[27..2]==H"10040"; -- $4'0000/4
+--***************************************************************************************
+
+--------------------------------------------------------------
+-- C1287 0=SEK 2=MIN 4=STD 6=WOCHENTAG 7=TAG 8=MONAT 9=JAHR
+----------------------------------------------------------
+ RTC_ADR[].CLK = MAIN_CLK;
+ RTC_ADR[] = FB_AD[21..16];
+ UHR_AS = !nFB_CS1 & FB_ADR[19..1]==H"7C4B0" & FB_B1; -- FFFF8961
+ UHR_DS = !nFB_CS1 & FB_ADR[19..1]==H"7C4B1" & FB_B3; -- FFFF8963
+ RTC_ADR[].ENA = UHR_AS & !nFB_WR;
+ WERTE[][].CLK = MAIN_CLK;
+ WERTE[7..0][0] = FB_AD[23..16] & RTC_ADR[]==0 & UHR_DS & !nFB_WR;
+ WERTE[7..0][1] = FB_AD[23..16];
+ WERTE[7..0][2] = FB_AD[23..16] & RTC_ADR[]==2 & UHR_DS & !nFB_WR;
+ WERTE[7..0][3] = FB_AD[23..16];
+ WERTE[7..0][4] = FB_AD[23..16] & RTC_ADR[]==4 & UHR_DS & !nFB_WR;
+ WERTE[7..0][5] = FB_AD[23..16];
+ WERTE[7..0][6] = FB_AD[23..16] & RTC_ADR[]==6 & UHR_DS & !nFB_WR;
+ WERTE[7..0][7] = FB_AD[23..16] & RTC_ADR[]==7 & UHR_DS & !nFB_WR;
+ WERTE[7..0][8] = FB_AD[23..16] & RTC_ADR[]==8 & UHR_DS & !nFB_WR;
+ WERTE[7..0][9] = FB_AD[23..16] & RTC_ADR[]==9 & UHR_DS & !nFB_WR;
+ FOR I IN 10 TO 63 GENERATE
+ WERTE[7..0][I] = FB_AD[23..16];
+ END GENERATE;
+ FOR I IN 0 TO 63 GENERATE
+ WERTE[][I].ENA = RTC_ADR[]==I & UHR_DS & !nFB_WR;
+ END GENERATE;
+ PIC_INT_SYNC[].CLK = MAIN_CLK;
+ PIC_INT_SYNC[0] = PIC_INT;
+ PIC_INT_SYNC[1] = PIC_INT_SYNC[0];
+ PIC_INT_SYNC[2] = !PIC_INT_SYNC[1] & PIC_INT_SYNC[0];
+ UPDATE_ON = !WERTE[7][11];
+ WERTE[6][10].CLRN = GND; -- KEIN UIP
+ UPDATE_ON = !WERTE[7][11]; -- UPDATE ON OFF
+ WERTE[2][11] = VCC; -- IMMER BINARY
+ WERTE[1][11] = VCC; -- IMMER 24H FORMAT
+ WERTE[0][11] = VCC; -- IMMER SOMMERZEITKORREKTUR
+ WERTE[7][13] = VCC; -- IMMER RICHTIG
+-- SOMMER WINTERZEIT: BIT 0 IM REGISTER D IST DIE INFORMATION OB SOMMERZEIT IST (BRAUCHT MAN FÜR RÜCKSCHALTUNG)
+ SOMMERZEIT = WERTE[][6]==1 & WERTE[][4]==1 & WERTE[][8]==4 & WERTE[][7]>23; --LETZTER SONNTAG IM APRIL
+ WERTE[0][13] = SOMMERZEIT;
+ WERTE[0][13].ENA = INC_STD & (SOMMERZEIT # WINTERZEIT);
+ WINTERZEIT = WERTE[][6]==1 & WERTE[][4]==1 & WERTE[][8]==10 & WERTE[][7]>24 & WERTE[0][13]; --LETZTER SONNTAG IM OKTOBER
+-- ACHTELSEKUNDEN
+ ACHTELSEKUNDEN[].CLK = MAIN_CLK;
+ ACHTELSEKUNDEN[] = ACHTELSEKUNDEN[]+1;
+ ACHTELSEKUNDEN[].ENA = PIC_INT_SYNC[2] & UPDATE_ON;
+-- SEKUNDEN
+ INC_SEC = ACHTELSEKUNDEN[]==7 & PIC_INT_SYNC[2] & UPDATE_ON;
+ WERTE[][0] = (WERTE[][0]+1) & WERTE[][0]!=59 & !(RTC_ADR[]==0 & UHR_DS & !nFB_WR); -- SEKUNDEN ZÄHLEN BIS 59
+ WERTE[][0].ENA = INC_SEC & !(RTC_ADR[]==0 & UHR_DS & !nFB_WR);
+-- MINUTEN
+ INC_MIN = INC_SEC & WERTE[][0]==59; --
+ WERTE[][2] = (WERTE[][2]+1) & WERTE[][2]!=59 & !(RTC_ADR[]==2 & UHR_DS & !nFB_WR); -- MINUTEN ZÄHLEN BIS 59
+ WERTE[][2].ENA = INC_MIN & !(RTC_ADR[]==2 & UHR_DS & !nFB_WR); --
+-- STUNDEN
+ INC_STD = INC_MIN & WERTE[][2]==59;
+ WERTE[][4] = (WERTE[][4]+1+(1 & SOMMERZEIT)) & WERTE[][4]!=23 & !(RTC_ADR[]==4 & UHR_DS & !nFB_WR); -- STUNDEN ZÄHLEN BIS 23
+ WERTE[][4].ENA = INC_STD & !(WINTERZEIT & WERTE[0][12]) & !(RTC_ADR[]==4 & UHR_DS & !nFB_WR); -- EINE STUNDE AUSLASSEN WENN WINTERZEITUMSCHALTUNG UND NOCH SOMMERZEIT
+-- WOCHENTAG UND TAG
+ INC_TAG = INC_STD & WERTE[][2]==23;
+ WERTE[][6] = (WERTE[][6]+1) & WERTE[][6]!=7 & !(RTC_ADR[]==6 & UHR_DS & !nFB_WR) -- WOCHENTAG ZÄHLEN BIS 7
+ # 1 & WERTE[][6]==7 & !(RTC_ADR[]==6 & UHR_DS & !nFB_WR); -- DANN BEI 1 WEITER
+ WERTE[][6].ENA = INC_TAG & !(RTC_ADR[]==6 & UHR_DS & !nFB_WR);
+ ANZAHL_TAGE_DES_MONATS[] = 31 & (WERTE[][8]==1 # WERTE[][8]==3 # WERTE[][8]==5 # WERTE[][8]==7 # WERTE[][8]==8 # WERTE[][8]==10 # WERTE[][8]==12)
+ # 30 & (WERTE[][8]==4 # WERTE[][8]==6 # WERTE[][8]==9 # WERTE[][8]==11)
+ # 29 & WERTE[][8]==2 & WERTE[1..0][9]==0
+ # 28 & WERTE[][8]==2 & WERTE[1..0][9]!=0;
+ WERTE[][7] = (WERTE[][7]+1) & WERTE[][7]!=ANZAHL_TAGE_DES_MONATS[] & !(RTC_ADR[]==7 & UHR_DS & !nFB_WR) -- TAG ZÄHLEN BIS MONATSENDE
+ # 1 & WERTE[][7]==ANZAHL_TAGE_DES_MONATS[] & !(RTC_ADR[]==7 & UHR_DS & !nFB_WR); -- DANN BEI 1 WEITER
+ WERTE[][7].ENA = INC_TAG & !(RTC_ADR[]==7 & UHR_DS & !nFB_WR); --
+-- MONATE
+ INC_MONAT = INC_TAG & WERTE[][7]==ANZAHL_TAGE_DES_MONATS[]; --
+ WERTE[][8] = (WERTE[][8]+1) & WERTE[][8]!=12 & !(RTC_ADR[]==8 & UHR_DS & !nFB_WR) -- MONATE ZÄHLEN BIS 12
+ # 1 & WERTE[][8]==12 & !(RTC_ADR[]==8 & UHR_DS & !nFB_WR); -- DANN BEI 1 WEITER
+ WERTE[][8].ENA = INC_MONAT & !(RTC_ADR[]==8 & UHR_DS & !nFB_WR);
+-- JAHR
+ INC_JAHR = INC_MONAT & WERTE[][8]==12; --
+ WERTE[][9] = (WERTE[][9]+1) & WERTE[][9]!=99 & !(RTC_ADR[]==9 & UHR_DS & !nFB_WR); -- JAHRE ZÄHLEN BIS 99
+ WERTE[][9].ENA = INC_JAHR & !(RTC_ADR[]==9 & UHR_DS & !nFB_WR);
+-- TRISTATE OUTPUT
+
+ FB_AD[31..24] = lpm_bustri_BYT(
+ INT_CTR_CS & INT_CTR[31..24]
+ # INT_ENA_CS & INT_ENA[31..24]
+ # INT_LATCH_CS & INT_LATCH[31..24]
+ # INT_CLEAR_CS & INT_IN[31..24]
+ # ACP_CONF_CS & ACP_CONF[31..24]
+ # FPGA_DATE_CS & FPGA_DATE[31..24]
+ ,(INT_CTR_CS # INT_ENA_CS # INT_LATCH_CS # INT_CLEAR_CS # ACP_CONF_CS) & !nFB_OE);
+ FB_AD[23..16] = lpm_bustri_BYT(
+ WERTE[][0] & RTC_ADR[]==0 & UHR_DS
+ # WERTE[][1] & RTC_ADR[]==1 & UHR_DS
+ # WERTE[][2] & RTC_ADR[]==2 & UHR_DS
+ # WERTE[][3] & RTC_ADR[]==3 & UHR_DS
+ # WERTE[][4] & RTC_ADR[]==4 & UHR_DS
+ # WERTE[][5] & RTC_ADR[]==5 & UHR_DS
+ # WERTE[][6] & RTC_ADR[]==6 & UHR_DS
+ # WERTE[][7] & RTC_ADR[]==7 & UHR_DS
+ # WERTE[][8] & RTC_ADR[]==8 & UHR_DS
+ # WERTE[][9] & RTC_ADR[]==9 & UHR_DS
+ # WERTE[][10] & RTC_ADR[]==10 & UHR_DS
+ # WERTE[][11] & RTC_ADR[]==11 & UHR_DS
+ # WERTE[][12] & RTC_ADR[]==12 & UHR_DS
+ # WERTE[][13] & RTC_ADR[]==13 & UHR_DS
+ # WERTE[][14] & RTC_ADR[]==14 & UHR_DS
+ # WERTE[][15] & RTC_ADR[]==15 & UHR_DS
+ # WERTE[][16] & RTC_ADR[]==16 & UHR_DS
+ # WERTE[][17] & RTC_ADR[]==17 & UHR_DS
+ # WERTE[][18] & RTC_ADR[]==18 & UHR_DS
+ # WERTE[][19] & RTC_ADR[]==19 & UHR_DS
+ # WERTE[][20] & RTC_ADR[]==20 & UHR_DS
+ # WERTE[][21] & RTC_ADR[]==21 & UHR_DS
+ # WERTE[][22] & RTC_ADR[]==22 & UHR_DS
+ # WERTE[][23] & RTC_ADR[]==23 & UHR_DS
+ # WERTE[][24] & RTC_ADR[]==24 & UHR_DS
+ # WERTE[][25] & RTC_ADR[]==25 & UHR_DS
+ # WERTE[][26] & RTC_ADR[]==26 & UHR_DS
+ # WERTE[][27] & RTC_ADR[]==27 & UHR_DS
+ # WERTE[][28] & RTC_ADR[]==28 & UHR_DS
+ # WERTE[][29] & RTC_ADR[]==29 & UHR_DS
+ # WERTE[][30] & RTC_ADR[]==30 & UHR_DS
+ # WERTE[][31] & RTC_ADR[]==31 & UHR_DS
+ # WERTE[][32] & RTC_ADR[]==32 & UHR_DS
+ # WERTE[][33] & RTC_ADR[]==33 & UHR_DS
+ # WERTE[][34] & RTC_ADR[]==34 & UHR_DS
+ # WERTE[][35] & RTC_ADR[]==35 & UHR_DS
+ # WERTE[][36] & RTC_ADR[]==36 & UHR_DS
+ # WERTE[][37] & RTC_ADR[]==37 & UHR_DS
+ # WERTE[][38] & RTC_ADR[]==38 & UHR_DS
+ # WERTE[][39] & RTC_ADR[]==39 & UHR_DS
+ # WERTE[][40] & RTC_ADR[]==40 & UHR_DS
+ # WERTE[][41] & RTC_ADR[]==41 & UHR_DS
+ # WERTE[][42] & RTC_ADR[]==42 & UHR_DS
+ # WERTE[][43] & RTC_ADR[]==43 & UHR_DS
+ # WERTE[][44] & RTC_ADR[]==44 & UHR_DS
+ # WERTE[][45] & RTC_ADR[]==45 & UHR_DS
+ # WERTE[][46] & RTC_ADR[]==46 & UHR_DS
+ # WERTE[][47] & RTC_ADR[]==47 & UHR_DS
+ # WERTE[][48] & RTC_ADR[]==48 & UHR_DS
+ # WERTE[][49] & RTC_ADR[]==49 & UHR_DS
+ # WERTE[][50] & RTC_ADR[]==50 & UHR_DS
+ # WERTE[][51] & RTC_ADR[]==51 & UHR_DS
+ # WERTE[][52] & RTC_ADR[]==52 & UHR_DS
+ # WERTE[][53] & RTC_ADR[]==53 & UHR_DS
+ # WERTE[][54] & RTC_ADR[]==54 & UHR_DS
+ # WERTE[][55] & RTC_ADR[]==55 & UHR_DS
+ # WERTE[][56] & RTC_ADR[]==56 & UHR_DS
+ # WERTE[][57] & RTC_ADR[]==57 & UHR_DS
+ # WERTE[][58] & RTC_ADR[]==58 & UHR_DS
+ # WERTE[][59] & RTC_ADR[]==59 & UHR_DS
+ # WERTE[][60] & RTC_ADR[]==60 & UHR_DS
+ # WERTE[][61] & RTC_ADR[]==61 & UHR_DS
+ # WERTE[][62] & RTC_ADR[]==62 & UHR_DS
+ # WERTE[][63] & RTC_ADR[]==63 & UHR_DS
+ # (0,RTC_ADR[]) & UHR_AS
+ # INT_CTR_CS & INT_CTR[23..16]
+ # INT_ENA_CS & INT_ENA[23..16]
+ # INT_LATCH_CS & INT_LATCH[23..16]
+ # INT_CLEAR_CS & INT_IN[23..16]
+ # ACP_CONF_CS & ACP_CONF[23..16]
+ # FPGA_DATE_CS & FPGA_DATE[23..16]
+ ,(UHR_DS # UHR_AS # INT_CTR_CS # INT_ENA_CS # INT_LATCH_CS # INT_CLEAR_CS # ACP_CONF_CS) & !nFB_OE);
+ FB_AD[15..8] = lpm_bustri_BYT(
+ INT_CTR_CS & INT_CTR[15..8]
+ # INT_ENA_CS & INT_ENA[15..8]
+ # INT_LATCH_CS & INT_LATCH[15..8]
+ # INT_CLEAR_CS & INT_IN[15..8]
+ # ACP_CONF_CS & ACP_CONF[15..8]
+ # FPGA_DATE_CS & FPGA_DATE[15..8]
+ ,(INT_CTR_CS # INT_ENA_CS # INT_LATCH_CS # INT_CLEAR_CS # ACP_CONF_CS) & !nFB_OE);
+ FB_AD[7..0] = lpm_bustri_BYT(
+ INT_CTR_CS & INT_CTR[7..0]
+ # INT_ENA_CS & INT_ENA[7..0]
+ # INT_LATCH_CS & INT_LATCH[7..0]
+ # INT_CLEAR_CS & INT_IN[7..0]
+ # ACP_CONF_CS & ACP_CONF[7..0]
+ # FPGA_DATE_CS & FPGA_DATE[7..0]
+ ,(INT_CTR_CS # INT_ENA_CS # INT_LATCH_CS # INT_CLEAR_CS # ACP_CONF_CS) & !nFB_OE);
+
+ INT_HANDLER_TA = INT_CTR_CS # INT_ENA_CS # INT_LATCH_CS # INT_CLEAR_CS;
+END;
+
+
diff --git a/FPGA_by_Fredi/PLLJ_PLLSPE_INFO.txt b/FPGA_by_Fredi/PLLJ_PLLSPE_INFO.txt
new file mode 100644
index 0000000..797d4f8
--- /dev/null
+++ b/FPGA_by_Fredi/PLLJ_PLLSPE_INFO.txt
@@ -0,0 +1,20 @@
+PLL_Name altpll1:inst|altpll:altpll_component|altpll_3vp2:auto_generated|pll1
+PLLJITTER 36
+PLLSPEmax 84
+PLLSPEmin -53
+
+PLL_Name altpll2:inst12|altpll:altpll_component|altpll_1r33:auto_generated|pll1
+PLLJITTER 43
+PLLSPEmax 84
+PLLSPEmin -53
+
+PLL_Name altpll3:inst13|altpll:altpll_component|altpll_aus2:auto_generated|pll1
+PLLJITTER NA
+PLLSPEmax 84
+PLLSPEmin -53
+
+PLL_Name altpll4:inst22|altpll:altpll_component|altpll_r4n2:auto_generated|pll1
+PLLJITTER 31
+PLLSPEmax 84
+PLLSPEmin -53
+
diff --git a/FPGA_by_Fredi/UNUSED b/FPGA_by_Fredi/UNUSED
new file mode 100644
index 0000000..3a7d9e6
--- /dev/null
+++ b/FPGA_by_Fredi/UNUSED
@@ -0,0 +1,27 @@
+
+-- Clearbox generated Memory Initialization File (.mif)
+
+WIDTH=3;
+DEPTH=16;
+
+ADDRESS_RADIX=HEX;
+DATA_RADIX=HEX;
+
+CONTENT BEGIN
+ 00 : 7;
+ 01 : 6;
+ 02 : 5;
+ 03 : 4;
+ 04 : 3;
+ 05 : 2;
+ 06 : 1;
+ 07 : 0;
+ 08 : 7;
+ 09 : 6;
+ 0a : 5;
+ 0b : 4;
+ 0c : 3;
+ 0d : 2;
+ 0e : 1;
+ 0f : 0;
+END;
diff --git a/FPGA_by_Fredi/Video/DDR_CTR.tdf.bak b/FPGA_by_Fredi/Video/DDR_CTR.tdf.bak
new file mode 100644
index 0000000..c688f97
--- /dev/null
+++ b/FPGA_by_Fredi/Video/DDR_CTR.tdf.bak
@@ -0,0 +1,659 @@
+TITLE "DDR_CTR";
+
+-- CREATED BY FREDI ASCHWANDEN
+
+INCLUDE "lpm_bustri_BYT.inc";
+
+-- FIFO WATER MARK
+CONSTANT FIFO_LWM = 0;
+CONSTANT FIFO_MWM = 1000;
+CONSTANT FIFO_HWM = 2000;
+
+-- {{ALTERA_PARAMETERS_BEGIN}} DO NOT REMOVE THIS LINE!
+-- {{ALTERA_PARAMETERS_END}} DO NOT REMOVE THIS LINE!
+
+SUBDESIGN DDR_CTR
+(
+ -- {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
+ FB_ADR[31..0] : INPUT;
+ nFB_CS1 : INPUT;
+ nFB_CS2 : INPUT;
+ nFB_CS3 : INPUT;
+ nFB_OE : INPUT;
+ FB_SIZE0 : INPUT;
+ FB_SIZE1 : INPUT;
+ nRSTO : INPUT;
+ MAIN_CLK : INPUT;
+ FB_ALE : INPUT;
+ nFB_WR : INPUT;
+ DDR_SYNC_66M : INPUT;
+ CLR_FIFO : INPUT;
+ VIDEO_RAM_CTR[15..0] : INPUT;
+ BLITTER_ADR[31..0] : INPUT;
+ BLITTER_SIG : INPUT;
+ BLITTER_WR : INPUT;
+ DDRCLK0 : INPUT;
+ CLK33M : INPUT;
+ FIFO_MW[10..0] : INPUT;
+ VA[12..0] : OUTPUT;
+ nVWE : OUTPUT;
+ nVRAS : OUTPUT;
+ nVCS : OUTPUT;
+ VCKE : OUTPUT;
+ nVCAS : OUTPUT;
+ FB_LE[3..0] : OUTPUT;
+ FB_VDOE[3..0] : OUTPUT;
+ SR_FIFO_WRE : OUTPUT;
+ SR_DDR_FB : OUTPUT;
+ SR_DDR_WR : OUTPUT;
+ SR_DDRWR_D_SEL : OUTPUT;
+ SR_VDMP[7..0] : OUTPUT;
+ VIDEO_DDR_TA : OUTPUT;
+ SR_BLITTER_DACK : OUTPUT;
+ BA[1..0] : OUTPUT;
+ DDRWR_D_SEL1 : OUTPUT;
+ VDM_SEL[3..0] : OUTPUT;
+ FB_AD[31..0] : BIDIR;
+ -- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
+)
+
+VARIABLE
+ FB_REGDDR :MACHINE WITH STATES(FR_WAIT,FR_S0,FR_S1,FR_S2,FR_S3);
+ DDR_SM :MACHINE WITH STATES(DS_T1,DS_T2A,DS_T2B,DS_T3,DS_N5,DS_N6, DS_N7, DS_N8, -- START (NORMAL 8 CYCLES TOTAL = 60ns)
+ DS_C2,DS_C3,DS_C4, DS_C5, DS_C6, DS_C7, -- CONFIG
+ DS_T4R,DS_T5R, -- READ CPU UND BLITTER,
+ DS_T4W,DS_T5W,DS_T6W,DS_T7W,DS_T8W,DS_T9W, -- WRITE CPU UND BLITTER
+ DS_T4F,DS_T5F,DS_T6F,DS_T7F,DS_T8F,DS_T9F,DS_T10F, -- READ FIFO
+ DS_CB6, DS_CB8, -- CLOSE FIFO BANK
+ DS_R2,DS_R3,DS_R4, DS_R5, DS_R6); -- REFRESH 10X7.5NS=75NS
+ LINE :NODE;
+ FB_B[3..0] :NODE;
+ VCAS :NODE;
+ VRAS :NODE;
+ VWE :NODE;
+ VA_P[12..0] :DFF;
+ BA_P[1..0] :DFF;
+ VA_S[12..0] :DFF;
+ BA_S[1..0] :DFF;
+ MCS[1..0] :DFF;
+ CPU_DDR_SYNC :DFF;
+ DDR_SEL :NODE;
+ DDR_CS :DFFE;
+ DDR_CONFIG :NODE;
+ SR_DDR_WR :DFF;
+ SR_DDRWR_D_SEL :DFF;
+ SR_VDMP[7..0] :DFF;
+ CPU_ROW_ADR[12..0] :NODE;
+ CPU_BA[1..0] :NODE;
+ CPU_COL_ADR[9..0] :NODE;
+ CPU_SIG :NODE;
+ CPU_REQ :DFF;
+ CPU_AC :DFF;
+ BUS_CYC :DFF;
+ BUS_CYC_END :NODE;
+ BLITTER_REQ :DFF;
+ BLITTER_AC :DFF;
+ BLITTER_ROW_ADR[12..0] :NODE;
+ BLITTER_BA[1..0] :NODE;
+ BLITTER_COL_ADR[9..0] :NODE;
+ FIFO_REQ :DFF;
+ FIFO_AC :DFF;
+ FIFO_ROW_ADR[12..0] :NODE;
+ FIFO_BA[1..0] :NODE;
+ FIFO_COL_ADR[9..0] :NODE;
+ FIFO_ACTIVE :NODE;
+ CLR_FIFO_SYNC :DFF;
+ CLEAR_FIFO_CNT :DFF;
+ STOP :DFF;
+ SR_FIFO_WRE :DFF;
+ FIFO_BANK_OK :DFF;
+ FIFO_BANK_NOT_OK :NODE;
+ DDR_REFRESH_ON :NODE;
+ DDR_REFRESH_CNT[10..0] :DFF;
+ DDR_REFRESH_REQ :DFF;
+ DDR_REFRESH_SIG[3..0] :DFFE;
+ REFRESH_TIME :DFF;
+ VIDEO_BASE_L_D[7..0] :DFFE;
+ VIDEO_BASE_L :NODE;
+ VIDEO_BASE_M_D[7..0] :DFFE;
+ VIDEO_BASE_M :NODE;
+ VIDEO_BASE_H_D[7..0] :DFFE;
+ VIDEO_BASE_H :NODE;
+ VIDEO_BASE_X_D[2..0] :DFFE;
+ VIDEO_ADR_CNT[22..0] :DFFE;
+ VIDEO_CNT_L :NODE;
+ VIDEO_CNT_M :NODE;
+ VIDEO_CNT_H :NODE;
+ VIDEO_BASE_ADR[22..0] :NODE;
+ VIDEO_ACT_ADR[26..0] :NODE;
+
+BEGIN
+ LINE = FB_SIZE0 & FB_SIZE1;
+-- BYT SELECT
+ FB_B0 = FB_ADR[1..0]==0 -- ADR==0
+ # FB_SIZE1 & FB_SIZE0 # !FB_SIZE1 & !FB_SIZE0; -- LONG UND LINE
+ FB_B1 = FB_ADR[1..0]==1 -- ADR==1
+ # FB_SIZE1 & !FB_SIZE0 & !FB_ADR1 -- HIGH WORD
+ # FB_SIZE1 & FB_SIZE0 # !FB_SIZE1 & !FB_SIZE0; -- LONG UND LINE
+ FB_B2 = FB_ADR[1..0]==2 -- ADR==2
+ # FB_SIZE1 & FB_SIZE0 # !FB_SIZE1 & !FB_SIZE0; -- LONG UND LINE
+ FB_B3 = FB_ADR[1..0]==3 -- ADR==3
+ # FB_SIZE1 & !FB_SIZE0 & FB_ADR1 -- LOW WORD
+ # FB_SIZE1 & FB_SIZE0 # !FB_SIZE1 & !FB_SIZE0; -- LONG UND LINE
+-- CPU READ (REG DDR => CPU) AND WRITE (CPU => REG DDR) --------------------------------------------------
+ FB_REGDDR.CLK = MAIN_CLK;
+ CASE FB_REGDDR IS
+ WHEN FR_WAIT =>
+ FB_LE0 = !nFB_WR;
+ IF BUS_CYC # DDR_SEL & LINE & !nFB_WR THEN -- LOS WENN BEREIT ODER IMMER BEI LINE WRITE
+ FB_REGDDR = FR_S0;
+ ELSE
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ WHEN FR_S0 =>
+ IF DDR_CS THEN
+ FB_LE0 = !nFB_WR;
+ VIDEO_DDR_TA = VCC;
+ IF LINE THEN
+ FB_VDOE0 = !nFB_OE & !DDR_CONFIG;
+ FB_REGDDR = FR_S1;
+ ELSE
+ BUS_CYC_END = VCC;
+ FB_VDOE0 = !nFB_OE & !MAIN_CLK & !DDR_CONFIG;
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ ELSE
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ WHEN FR_S1 =>
+ IF DDR_CS THEN
+ FB_VDOE1 = !nFB_OE & !DDR_CONFIG;
+ FB_LE1 = !nFB_WR;
+ VIDEO_DDR_TA = VCC;
+ FB_REGDDR = FR_S2;
+ ELSE
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ WHEN FR_S2 =>
+ IF DDR_CS THEN
+ FB_VDOE2 = !nFB_OE & !DDR_CONFIG;
+ FB_LE2 = !nFB_WR;
+ IF !BUS_CYC & LINE & !nFB_WR THEN -- BEI LINE WRITE EVT. WARTEN
+ FB_REGDDR = FR_S2;
+ ELSE
+ VIDEO_DDR_TA = VCC;
+ FB_REGDDR = FR_S3;
+ END IF;
+ ELSE
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ WHEN FR_S3 =>
+ IF DDR_CS THEN
+ FB_VDOE3 = !nFB_OE & !MAIN_CLK & !DDR_CONFIG;
+ FB_LE3 = !nFB_WR;
+ VIDEO_DDR_TA = VCC;
+ BUS_CYC_END = VCC;
+ FB_REGDDR = FR_WAIT;
+ ELSE
+ FB_REGDDR = FR_WAIT;
+ END IF;
+ END CASE;
+-- DDR STEUERUNG -----------------------------------------------------
+-- VIDEO RAM CONTROL REGISTER (IST IN VIDEO_MUX_CTR) $F0000400: BIT 0: VCKE; 1: !nVCS ;2:REFRESH ON , (0=FIFO UND CNT CLEAR); 3: CONFIG; 8: FIFO_ACTIVE;
+ VCKE = VIDEO_RAM_CTR0;
+ nVCS = !VIDEO_RAM_CTR1;
+ DDR_REFRESH_ON = VIDEO_RAM_CTR2;
+ DDR_CONFIG = VIDEO_RAM_CTR3;
+ FIFO_ACTIVE = VIDEO_RAM_CTR8;
+--------------------------------
+ CPU_ROW_ADR[] = FB_ADR[26..14];
+ CPU_BA[] = FB_ADR[13..12];
+ CPU_COL_ADR[] = FB_ADR[11..2];
+ nVRAS = !VRAS;
+ nVCAS = !VCAS;
+ nVWE = !VWE;
+ SR_DDR_WR.CLK = DDRCLK0;
+ SR_DDRWR_D_SEL.CLK = DDRCLK0;
+ SR_VDMP[7..0].CLK = DDRCLK0;
+ SR_FIFO_WRE.CLK = DDRCLK0;
+ CPU_AC.CLK = DDRCLK0;
+ FIFO_AC.CLK = DDRCLK0;
+ BLITTER_AC.CLK = DDRCLK0;
+ DDRWR_D_SEL1 = BLITTER_AC;
+-- SELECT LOGIC
+ DDR_SEL = FB_ALE & FB_AD[31..30]==B"01";
+ DDR_CS.CLK = MAIN_CLK;
+ DDR_CS.ENA = FB_ALE;
+ DDR_CS = DDR_SEL;
+-- WENN READ ODER WRITE B,W,L DDR SOFORT ANFORDERN, BEI WRITE LINE SPÄTER
+ CPU_SIG = DDR_SEL & (nFB_WR # !LINE) & !DDR_CONFIG -- NICHT LINE ODER READ SOFORT LOS WENN NICHT CONFIG
+ # DDR_SEL & DDR_CONFIG -- CONFIG SOFORT LOS
+ # FB_REGDDR==FR_S1 & !nFB_WR; -- LINE WRITE SPÄTER
+ CPU_REQ.CLK = DDR_SYNC_66M;
+ CPU_REQ = CPU_SIG
+ # CPU_REQ & FB_REGDDR!=FR_S1 & FB_REGDDR!=FR_S3 & !BUS_CYC_END & !BUS_CYC; -- HALTEN BUS CYC BEGONNEN ODER FERTIG
+ BUS_CYC.CLK = DDRCLK0;
+ BUS_CYC = BUS_CYC & !BUS_CYC_END;
+ -- STATE MACHINE SYNCHRONISIEREN -----------------
+ MCS[].CLK = DDRCLK0;
+ MCS0 = MAIN_CLK;
+ MCS1 = MCS0;
+ CPU_DDR_SYNC.CLK = DDRCLK0;
+ CPU_DDR_SYNC = MCS[]==2 & VCKE & !nVCS; -- NUR 1 WENN EIN
+ ---------------------------------------------------
+ VA_S[].CLK = DDRCLK0;
+ BA_S[].CLK = DDRCLK0;
+ VA[] = VA_S[];
+ BA[] = BA_S[];
+ VA_P[].CLK = DDRCLK0;
+ BA_P[].CLK = DDRCLK0;
+-- DDR STATE MACHINE -----------------------------------------------
+ DDR_SM.CLK = DDRCLK0;
+ CASE DDR_SM IS
+ WHEN DS_T1 =>
+ IF DDR_REFRESH_REQ THEN
+ DDR_SM = DS_R2;
+ ELSE
+ IF CPU_DDR_SYNC THEN -- SYNCHRON UND EIN?
+ IF DDR_CONFIG THEN -- JA
+ DDR_SM = DS_C2;
+ ELSE
+ IF CPU_REQ THEN -- BEI WAIT UND LINE WRITE
+ VA_S[] = CPU_ROW_ADR[];
+ BA_S[] = CPU_BA[];
+ CPU_AC = VCC;
+ BUS_CYC = VCC;
+ DDR_SM = DS_T2B;
+ ELSE
+ IF FIFO_REQ # !BLITTER_REQ THEN -- FIFO IST DEFAULT
+ VA_P[] = FIFO_ROW_ADR[];
+ BA_P[] = FIFO_BA[];
+ FIFO_AC = VCC; -- VORBESETZEN
+ ELSE
+ VA_P[] = BLITTER_ROW_ADR[];
+ BA_P[] = BLITTER_BA[];
+ BLITTER_AC = VCC; -- VORBESETZEN
+ END IF;
+ DDR_SM = DS_T2A;
+ END IF;
+ END IF;
+ ELSE
+ DDR_SM = DS_T1; -- NEIN ->SYNCHRONISIEREN
+ END IF;
+ END IF;
+
+ WHEN DS_T2A => -- SCHNELLZUGRIFF *** HIER IST PAGE IMMER NOT OK ***
+ IF DDR_SEL & (nFB_WR # !LINE) THEN
+ VRAS = VCC;
+ VA[] = FB_AD[26..14];
+ BA[] = FB_AD[13..12];
+ VA_S[10] = VCC; -- AUTO PRECHARGE DA NICHT FIFO PAGE
+ CPU_AC = VCC;
+ BUS_CYC = VCC; -- BUS CYCLUS LOSTRETEN
+ ELSE
+ VRAS = FIFO_AC & FIFO_REQ # BLITTER_AC & BLITTER_REQ;
+ VA[] = VA_P[];
+ BA[] = BA_P[];
+ VA_S[10] = !(FIFO_AC & FIFO_REQ);
+ FIFO_BANK_OK = FIFO_AC & FIFO_REQ;
+ FIFO_AC = FIFO_AC & FIFO_REQ;
+ BLITTER_AC = BLITTER_AC & BLITTER_REQ;
+ END IF;
+ DDR_SM = DS_T3;
+
+ WHEN DS_T2B =>
+ VRAS = VCC;
+ FIFO_BANK_NOT_OK = VCC;
+ CPU_AC = VCC;
+ BUS_CYC = VCC; -- BUS CYCLUS LOSTRETEN
+ DDR_SM = DS_T3;
+
+ WHEN DS_T3 =>
+ CPU_AC = CPU_AC;
+ FIFO_AC = FIFO_AC;
+ BLITTER_AC = BLITTER_AC;
+ VA_S[10] = VA_S[10]; -- AUTO PRECHARGE WENN NICHT FIFO PAGE
+ IF !nFB_WR & CPU_AC # BLITTER_WR & BLITTER_AC THEN
+ DDR_SM = DS_T4W;
+ ELSE
+ IF CPU_AC THEN -- CPU?
+ VA_S[9..0] = CPU_COL_ADR[];
+ BA_S[] = CPU_BA[];
+ DDR_SM = DS_T4R;
+ ELSE
+ IF FIFO_AC THEN -- FIFO?
+ VA_S[9..0] = FIFO_COL_ADR[];
+ BA_S[] = FIFO_BA[];
+ DDR_SM = DS_T4F;
+ ELSE
+ IF BLITTER_AC THEN
+ VA_S[9..0] = BLITTER_COL_ADR[];
+ BA_S[] = BLITTER_BA[];
+ DDR_SM = DS_T4R;
+ ELSE
+ DDR_SM = DS_N8;
+ END IF;
+ END IF;
+ END IF;
+ END IF;
+-- READ
+ WHEN DS_T4R =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ VCAS = VCC;
+ SR_DDR_FB = CPU_AC; -- READ DATEN FÜR CPU
+ SR_BLITTER_DACK = BLITTER_AC; -- BLITTER DACK AND BLITTER LATCH DATEN
+ DDR_SM = DS_T5R;
+
+ WHEN DS_T5R =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ IF FIFO_REQ & FIFO_BANK_OK THEN -- FIFO READ EINSCHIEBEN WENN BANK OK
+ VA_S[9..0] = FIFO_COL_ADR[];
+ VA_S[10] = GND; -- MANUEL PRECHARGE
+ BA_S[] = FIFO_BA[];
+ DDR_SM = DS_T6F;
+ ELSE
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESSEN
+ DDR_SM = DS_CB6;
+ END IF;
+-- WRITE
+ WHEN DS_T4W =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ SR_BLITTER_DACK = BLITTER_AC; -- BLITTER ACK AND BLITTER LATCH DATEN
+ VA_S[10] = VA_S[10]; -- AUTO PRECHARGE WENN NICHT FIFO PAGE
+ DDR_SM = DS_T5W;
+
+ WHEN DS_T5W =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ VA_S[9..0] = CPU_AC & CPU_COL_ADR[]
+ # BLITTER_AC & BLITTER_COL_ADR[];
+ VA_S[10] = VA_S[10]; -- AUTO PRECHARGE WENN NICHT FIFO PAGE
+ BA_S[] = CPU_AC & CPU_BA[]
+ # BLITTER_AC & BLITTER_BA[];
+ SR_VDMP[7..4] = FB_B[] # BLITTER_AC & B"1111"; -- BYTE ENABLE WRITE, BEI BLITTER IMMER LINE
+ SR_VDMP[3..0] = (LINE # BLITTER_AC) & B"1111"; -- LINE ENABLE WRITE, BEI BLITTER IMMER LINE
+ DDR_SM = DS_T6W;
+
+ WHEN DS_T6W =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ VCAS = VCC;
+ VWE = VCC;
+ SR_DDR_WR = VCC; -- WRITE COMMAND CPU UND BLITTER IF WRITER
+ SR_DDRWR_D_SEL = VCC; -- 2. HÄLFTE WRITE DATEN SELEKTIEREN
+ SR_VDMP[] = (LINE # BLITTER_AC) & B"11111111"; -- WENN LINE DANN ACTIV
+ DDR_SM = DS_T7W;
+
+ WHEN DS_T7W =>
+ CPU_AC = CPU_AC;
+ BLITTER_AC = BLITTER_AC;
+ SR_DDR_WR = VCC; -- WRITE COMMAND CPU UND BLITTER IF WRITE
+ SR_DDRWR_D_SEL = VCC; -- 2. HÄLFTE WRITE DATEN SELEKTIEREN
+ DDR_SM = DS_T8W;
+
+ WHEN DS_T8W =>
+ DDR_SM = DS_T9W;
+
+ WHEN DS_T9W =>
+ IF FIFO_REQ & FIFO_BANK_OK THEN
+ VA_S[9..0] = FIFO_COL_ADR[];
+ VA_S[10] = GND; -- NON AUTO PRECHARGE
+ BA_S[] = FIFO_BA[];
+ DDR_SM = DS_T6F;
+ ELSE
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESSEN
+ DDR_SM = DS_CB6;
+ END IF;
+-- FIFO READ
+ WHEN DS_T4F =>
+ VCAS = VCC;
+ SR_FIFO_WRE = VCC; -- DATEN WRITE FIFO
+ DDR_SM = DS_T5F;
+
+ WHEN DS_T5F =>
+ IF FIFO_REQ THEN
+ IF VIDEO_ADR_CNT[7..0]==H"FF" THEN -- NEUE PAGE?
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESSEN
+ DDR_SM = DS_CB6; -- BANK SCHLIESSEN
+ ELSE
+ VA_S[9..0] = FIFO_COL_ADR[]+4;
+ VA_S[10] = GND; -- NON AUTO PRECHARGE
+ BA_S[] = FIFO_BA[];
+ DDR_SM = DS_T6F;
+ END IF;
+ ELSE
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESSEN
+ DDR_SM = DS_CB6; -- NOCH OFFEN LASSEN
+ END IF;
+
+ WHEN DS_T6F =>
+ VCAS = VCC;
+ SR_FIFO_WRE = VCC; -- DATEN WRITE FIFO
+ DDR_SM = DS_T7F;
+
+ WHEN DS_T7F =>
+ IF CPU_REQ & FIFO_MW[]>FIFO_LWM THEN
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESEN
+ DDR_SM = DS_CB8; -- BANK SCHLIESSEN
+ ELSE
+ IF FIFO_REQ THEN
+ IF VIDEO_ADR_CNT[7..0]==H"FF" THEN -- NEUE PAGE?
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESSEN
+ DDR_SM = DS_CB8; -- BANK SCHLIESSEN
+ ELSE
+ VA_S[9..0] = FIFO_COL_ADR[]+4;
+ VA_S[10] = GND; -- NON AUTO PRECHARGE
+ BA_S[] = FIFO_BA[];
+ DDR_SM = DS_T8F;
+ END IF;
+ ELSE
+ VA_S[10] = VCC; -- ALLE PAGES SCHLIESEN
+ DDR_SM = DS_CB8; -- BANK SCHLIESSEN
+ END IF;
+ END IF;
+
+ WHEN DS_T8F =>
+ VCAS = VCC;
+ SR_FIFO_WRE = VCC; -- DATEN WRITE FIFO
+ IF FIFO_MW[] The following waveforms show the behavior of altsyncram megafunction for the chosen set of parameters in design altdpram0.vhd. For the purpose of this simulation, the contents of the memory at the start of the sample waveforms is assumed to be ( 7, 6, 5, 4, ...). The design altdpram0.vhd has two read/write ports. Read/write port A has 16 words of 3 bits each and Read/write port B has 16 words of 3 bits each. The output of the read/write port A is registered by clock_a. The output of the read/write port B is registered by clock_b.
+
The above waveform shows the behavior of the design under normal read conditions. The read happens at the rising edge of the enabled clock cycle. The output from the RAM is undefined until after the first rising edge of the read clock. The clock enable on the read side input registers are disabled. The clock enable on the output registers are disabled.
+
The above waveform shows the behavior of the design under normal write conditions. The write cycle is assumed to be from the rising edge of the enabled clock in which wren is high till the rising edge of the next clock cycle. In BIDIR_DUAL_PORT mode, when the write happens at the same address as the one being read in the other port, the read output is unknown. Actual write into the RAM happens at the rising edge of the write clock. The clock enable on the write side input registers are disabled. The clock enable on the output registers are disabled. For the A port, When a write happens, the output of the port is the old data at the address. For the B port, When a write happens, the output of the port is the old data at the address.
+ + +