mirror of
https://github.com/mist-devel/mist-board.git
synced 2026-02-05 15:44:40 +00:00
@@ -57,7 +57,7 @@ assign enable=~cs&cs_prev; // cs falling edge detection
|
||||
assign data_out=(~cs)?data:8'hff;
|
||||
|
||||
initial begin
|
||||
$readmemh("basic.hex",basic);
|
||||
$readmemh("roms/basic.hex",basic);
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
@@ -122,7 +122,8 @@ begin
|
||||
if count(4 downto 0) = "01000" then
|
||||
clk_1M_pulse <= '1';
|
||||
end if;
|
||||
if count = "000100000" then -- DAR divide by 33 (otherwise real c64 miss EOI acknowledge)
|
||||
-- if count = "000100000" then -- DAR divide by 33 (otherwise real c64 miss EOI acknowledge)
|
||||
if count = "000011111" then -- TH divide by 32
|
||||
count := (others => '0'); -- DAR
|
||||
else -- DAR
|
||||
count := std_logic_vector(unsigned(count) + 1);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,8 @@ derive_clock_uncertainty
|
||||
|
||||
# Clock groups
|
||||
set_clock_groups -asynchronous -group [get_clocks {SPI_SCK}] -group [get_clocks {pll_pal|altpll_component|auto_generated|pll1|clk[*]}]
|
||||
set_clock_groups -asynchronous -group [get_clocks {pll_pal|altpll_component|auto_generated|pll1|clk[1]}] -group [get_clocks {pll_pal|altpll_component|auto_generated|pll1|clk[0]}]
|
||||
set_clock_groups -asynchronous -group [get_clocks {pll_pal|altpll_component|auto_generated|pll1|clk[1]}] -group [get_clocks {pll_ntsc|altpll_component|auto_generated|pll1|clk[0]}]
|
||||
|
||||
|
||||
# Some relaxed constrain to the VGA pins. The signals should arrive together, the delay is not really important.
|
||||
|
||||
@@ -230,6 +230,7 @@ user_io #(.STRLEN(CONF_STR_LEN)) user_io (
|
||||
.conf_str ( CONF_STR ),
|
||||
|
||||
.clk_sys ( clk28 ),
|
||||
.clk_sd ( clk32 ),
|
||||
|
||||
.SPI_CLK ( SPI_SCK ),
|
||||
.SPI_SS_IO ( CONF_DATA0 ),
|
||||
@@ -587,8 +588,8 @@ pll_ntsc pll_ntsc (
|
||||
// ----------------------------------- floppy 1541 ---------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
wire [7:0] led_disk;
|
||||
assign LED = !led_disk[6];
|
||||
wire led_disk;
|
||||
assign LED = !led_disk;
|
||||
|
||||
wire c16_iec_atn_o;
|
||||
wire c16_iec_data_o;
|
||||
@@ -607,7 +608,7 @@ wire c1541_iec_data_i = c16_iec_data_i;
|
||||
wire c1541_iec_clk_i = c16_iec_clk_i;
|
||||
|
||||
c1541_sd c1541_sd (
|
||||
.clk32 ( clk28 ),
|
||||
.clk32 ( clk32 ),
|
||||
.reset ( reset ),
|
||||
|
||||
.disk_change ( img_mounted ),
|
||||
@@ -630,7 +631,7 @@ c1541_sd c1541_sd (
|
||||
.sd_buff_wr ( sd_dout_strobe ),
|
||||
.sd_buff_addr ( sd_buff_addr ),
|
||||
|
||||
// .led ( led_disk )
|
||||
.led ( led_disk )
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
1010
cores/c16/t65/T65.vhd
Normal file → Executable file
1010
cores/c16/t65/T65.vhd
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
397
cores/c16/t65/T65_ALU.vhd
Normal file → Executable file
397
cores/c16/t65/T65_ALU.vhd
Normal file → Executable file
@@ -1,18 +1,18 @@
|
||||
-- ****
|
||||
-- T65(b) core. In an effort to merge and maintain bug fixes ....
|
||||
--
|
||||
--
|
||||
-- Ver 300 Bugfixes by ehenciak added
|
||||
-- MikeJ March 2005
|
||||
-- Latest version from www.fpgaarcade.com (original www.opencores.org)
|
||||
-- See list of changes in T65 top file (T65.vhd)...
|
||||
--
|
||||
-- ****
|
||||
-- 65xx compatible microprocessor core
|
||||
--
|
||||
-- 6502 compatible microprocessor core
|
||||
-- FPGAARCADE SVN: $Id: T65_ALU.vhd 1234 2015-02-28 20:14:50Z wolfgang.scherr $
|
||||
--
|
||||
-- Version : 0245
|
||||
--
|
||||
-- Copyright (c) 2002 Daniel Wallner (jesus@opencores.org)
|
||||
-- Copyright (c) 2002...2015
|
||||
-- Daniel Wallner (jesus <at> opencores <dot> org)
|
||||
-- Mike Johnson (mikej <at> fpgaarcade <dot> com)
|
||||
-- Wolfgang Scherr (WoS <at> pin4 <dot> at>
|
||||
-- Morten Leikvoll ()
|
||||
--
|
||||
-- All rights reserved
|
||||
--
|
||||
@@ -42,19 +42,12 @@
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
--
|
||||
-- Please report bugs to the author, but before you do so, please
|
||||
-- Please report bugs to the author(s), but before you do so, please
|
||||
-- make sure that this is not a derivative work and that
|
||||
-- you have the latest version of this file.
|
||||
--
|
||||
-- The latest version of this file can be found at:
|
||||
-- http://www.opencores.org/cvsweb.shtml/t65/
|
||||
--
|
||||
-- Limitations :
|
||||
--
|
||||
-- File history :
|
||||
--
|
||||
-- 0245 : First version
|
||||
--
|
||||
-- See in T65 top file (T65.vhd)...
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
@@ -62,199 +55,239 @@ use IEEE.numeric_std.all;
|
||||
use work.T65_Pack.all;
|
||||
|
||||
entity T65_ALU is
|
||||
port(
|
||||
Mode : in std_logic_vector(1 downto 0); -- "00" => 6502, "01" => 65C02, "10" => 65816
|
||||
Op : in std_logic_vector(3 downto 0);
|
||||
BusA : in std_logic_vector(7 downto 0);
|
||||
BusB : in std_logic_vector(7 downto 0);
|
||||
P_In : in std_logic_vector(7 downto 0);
|
||||
P_Out : out std_logic_vector(7 downto 0);
|
||||
Q : out std_logic_vector(7 downto 0)
|
||||
);
|
||||
port(
|
||||
Mode : in std_logic_vector(1 downto 0); -- "00" => 6502, "01" => 65C02, "10" => 65816
|
||||
Op : in T_ALU_OP;
|
||||
BusA : in std_logic_vector(7 downto 0);
|
||||
BusB : in std_logic_vector(7 downto 0);
|
||||
P_In : in std_logic_vector(7 downto 0);
|
||||
P_Out : out std_logic_vector(7 downto 0);
|
||||
Q : out std_logic_vector(7 downto 0)
|
||||
);
|
||||
end T65_ALU;
|
||||
|
||||
architecture rtl of T65_ALU is
|
||||
|
||||
-- AddSub variables (temporary signals)
|
||||
signal ADC_Z : std_logic;
|
||||
signal ADC_C : std_logic;
|
||||
signal ADC_V : std_logic;
|
||||
signal ADC_N : std_logic;
|
||||
signal ADC_Q : std_logic_vector(7 downto 0);
|
||||
signal SBC_Z : std_logic;
|
||||
signal SBC_C : std_logic;
|
||||
signal SBC_V : std_logic;
|
||||
signal SBC_N : std_logic;
|
||||
signal SBC_Q : std_logic_vector(7 downto 0);
|
||||
-- AddSub variables (temporary signals)
|
||||
signal ADC_Z : std_logic;
|
||||
signal ADC_C : std_logic;
|
||||
signal ADC_V : std_logic;
|
||||
signal ADC_N : std_logic;
|
||||
signal ADC_Q : std_logic_vector(7 downto 0);
|
||||
signal SBC_Z : std_logic;
|
||||
signal SBC_C : std_logic;
|
||||
signal SBC_V : std_logic;
|
||||
signal SBC_N : std_logic;
|
||||
signal SBC_Q : std_logic_vector(7 downto 0);
|
||||
signal SBX_Q : std_logic_vector(7 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
process (P_In, BusA, BusB)
|
||||
variable AL : unsigned(6 downto 0);
|
||||
variable AH : unsigned(6 downto 0);
|
||||
variable C : std_logic;
|
||||
begin
|
||||
AL := resize(unsigned(BusA(3 downto 0) & P_In(Flag_C)), 7) + resize(unsigned(BusB(3 downto 0) & "1"), 7);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & AL(5)), 7) + resize(unsigned(BusB(7 downto 4) & "1"), 7);
|
||||
process (P_In, BusA, BusB)
|
||||
variable AL : unsigned(6 downto 0);
|
||||
variable AH : unsigned(6 downto 0);
|
||||
variable C : std_logic;
|
||||
begin
|
||||
AL := resize(unsigned(BusA(3 downto 0) & P_In(Flag_C)), 7) + resize(unsigned(BusB(3 downto 0) & "1"), 7);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & AL(5)), 7) + resize(unsigned(BusB(7 downto 4) & "1"), 7);
|
||||
|
||||
-- pragma translate_off
|
||||
if is_x(std_logic_vector(AL)) then AL := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AH)) then AH := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AL)) then AL := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AH)) then AH := "0000000"; end if;
|
||||
-- pragma translate_on
|
||||
|
||||
if AL(4 downto 1) = 0 and AH(4 downto 1) = 0 then
|
||||
ADC_Z <= '1';
|
||||
else
|
||||
ADC_Z <= '0';
|
||||
end if;
|
||||
if AL(4 downto 1) = 0 and AH(4 downto 1) = 0 then
|
||||
ADC_Z <= '1';
|
||||
else
|
||||
ADC_Z <= '0';
|
||||
end if;
|
||||
|
||||
if AL(5 downto 1) > 9 and P_In(Flag_D) = '1' then
|
||||
AL(6 downto 1) := AL(6 downto 1) + 6;
|
||||
end if;
|
||||
if AL(5 downto 1) > 9 and P_In(Flag_D) = '1' then
|
||||
AL(6 downto 1) := AL(6 downto 1) + 6;
|
||||
end if;
|
||||
|
||||
C := AL(6) or AL(5);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & C), 7) + resize(unsigned(BusB(7 downto 4) & "1"), 7);
|
||||
C := AL(6) or AL(5);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & C), 7) + resize(unsigned(BusB(7 downto 4) & "1"), 7);
|
||||
|
||||
ADC_N <= AH(4);
|
||||
ADC_V <= (AH(4) xor BusA(7)) and not (BusA(7) xor BusB(7));
|
||||
ADC_N <= AH(4);
|
||||
ADC_V <= (AH(4) xor BusA(7)) and not (BusA(7) xor BusB(7));
|
||||
|
||||
-- pragma translate_off
|
||||
if is_x(std_logic_vector(AH)) then AH := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AH)) then AH := "0000000"; end if;
|
||||
-- pragma translate_on
|
||||
|
||||
if AH(5 downto 1) > 9 and P_In(Flag_D) = '1' then
|
||||
AH(6 downto 1) := AH(6 downto 1) + 6;
|
||||
end if;
|
||||
if AH(5 downto 1) > 9 and P_In(Flag_D) = '1' then
|
||||
AH(6 downto 1) := AH(6 downto 1) + 6;
|
||||
end if;
|
||||
|
||||
ADC_C <= AH(6) or AH(5);
|
||||
ADC_C <= AH(6) or AH(5);
|
||||
|
||||
ADC_Q <= std_logic_vector(AH(4 downto 1) & AL(4 downto 1));
|
||||
end process;
|
||||
ADC_Q <= std_logic_vector(AH(4 downto 1) & AL(4 downto 1));
|
||||
end process;
|
||||
|
||||
process (Op, P_In, BusA, BusB)
|
||||
variable AL : unsigned(6 downto 0);
|
||||
variable AH : unsigned(5 downto 0);
|
||||
variable C : std_logic;
|
||||
begin
|
||||
C := P_In(Flag_C) or not Op(0);
|
||||
AL := resize(unsigned(BusA(3 downto 0) & C), 7) - resize(unsigned(BusB(3 downto 0) & "1"), 6);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & "0"), 6) - resize(unsigned(BusB(7 downto 4) & AL(5)), 6);
|
||||
process (Op, P_In, BusA, BusB)
|
||||
variable AL : unsigned(6 downto 0);
|
||||
variable AH : unsigned(5 downto 0);
|
||||
variable C : std_logic;
|
||||
variable CT : std_logic;
|
||||
begin
|
||||
CT:='0';
|
||||
if( Op=ALU_OP_AND or --"0001" These OpCodes used to have LSB set
|
||||
Op=ALU_OP_ADC or --"0011"
|
||||
Op=ALU_OP_EQ2 or --"0101"
|
||||
Op=ALU_OP_SBC or --"0111"
|
||||
Op=ALU_OP_ROL or --"1001"
|
||||
Op=ALU_OP_ROR or --"1011"
|
||||
-- Op=ALU_OP_EQ3 or --"1101"
|
||||
Op=ALU_OP_INC --"1111"
|
||||
) then
|
||||
CT:='1';
|
||||
end if;
|
||||
|
||||
-- pragma translate_off
|
||||
if is_x(std_logic_vector(AL)) then AL := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AH)) then AH := "000000"; end if;
|
||||
-- pragma translate_on
|
||||
C := P_In(Flag_C) or not CT;--was: or not Op(0);
|
||||
AL := resize(unsigned(BusA(3 downto 0) & C), 7) - resize(unsigned(BusB(3 downto 0) & "1"), 6);
|
||||
AH := resize(unsigned(BusA(7 downto 4) & "0"), 6) - resize(unsigned(BusB(7 downto 4) & AL(5)), 6);
|
||||
|
||||
if AL(4 downto 1) = 0 and AH(4 downto 1) = 0 then
|
||||
SBC_Z <= '1';
|
||||
else
|
||||
SBC_Z <= '0';
|
||||
end if;
|
||||
-- pragma translate_off
|
||||
if is_x(std_logic_vector(AL)) then AL := "0000000"; end if;
|
||||
if is_x(std_logic_vector(AH)) then AH := "000000"; end if;
|
||||
-- pragma translate_on
|
||||
|
||||
SBC_C <= not AH(5);
|
||||
SBC_V <= (AH(4) xor BusA(7)) and (BusA(7) xor BusB(7));
|
||||
SBC_N <= AH(4);
|
||||
if AL(4 downto 1) = 0 and AH(4 downto 1) = 0 then
|
||||
SBC_Z <= '1';
|
||||
else
|
||||
SBC_Z <= '0';
|
||||
end if;
|
||||
|
||||
if P_In(Flag_D) = '1' then
|
||||
if AL(5) = '1' then
|
||||
AL(5 downto 1) := AL(5 downto 1) - 6;
|
||||
end if;
|
||||
AH := resize(unsigned(BusA(7 downto 4) & "0"), 6) - resize(unsigned(BusB(7 downto 4) & AL(6)), 6);
|
||||
if AH(5) = '1' then
|
||||
AH(5 downto 1) := AH(5 downto 1) - 6;
|
||||
end if;
|
||||
end if;
|
||||
SBC_C <= not AH(5);
|
||||
SBC_V <= (AH(4) xor BusA(7)) and (BusA(7) xor BusB(7));
|
||||
SBC_N <= AH(4);
|
||||
|
||||
SBC_Q <= std_logic_vector(AH(4 downto 1) & AL(4 downto 1));
|
||||
end process;
|
||||
SBX_Q <= std_logic_vector(AH(4 downto 1) & AL(4 downto 1));
|
||||
|
||||
process (Op, P_In, BusA, BusB,
|
||||
ADC_Z, ADC_C, ADC_V, ADC_N, ADC_Q,
|
||||
SBC_Z, SBC_C, SBC_V, SBC_N, SBC_Q)
|
||||
variable Q_t : std_logic_vector(7 downto 0);
|
||||
begin
|
||||
-- ORA, AND, EOR, ADC, NOP, LD, CMP, SBC
|
||||
-- ASL, ROL, LSR, ROR, BIT, LD, DEC, INC
|
||||
P_Out <= P_In;
|
||||
Q_t := BusA;
|
||||
case Op(3 downto 0) is
|
||||
when "0000" =>
|
||||
-- ORA
|
||||
Q_t := BusA or BusB;
|
||||
when "0001" =>
|
||||
-- AND
|
||||
Q_t := BusA and BusB;
|
||||
when "0010" =>
|
||||
-- EOR
|
||||
Q_t := BusA xor BusB;
|
||||
when "0011" =>
|
||||
-- ADC
|
||||
P_Out(Flag_V) <= ADC_V;
|
||||
P_Out(Flag_C) <= ADC_C;
|
||||
Q_t := ADC_Q;
|
||||
when "0101" | "1101" =>
|
||||
-- LDA
|
||||
when "0110" =>
|
||||
-- CMP
|
||||
P_Out(Flag_C) <= SBC_C;
|
||||
when "0111" =>
|
||||
-- SBC
|
||||
P_Out(Flag_V) <= SBC_V;
|
||||
P_Out(Flag_C) <= SBC_C;
|
||||
Q_t := SBC_Q;
|
||||
when "1000" =>
|
||||
-- ASL
|
||||
Q_t := BusA(6 downto 0) & "0";
|
||||
P_Out(Flag_C) <= BusA(7);
|
||||
when "1001" =>
|
||||
-- ROL
|
||||
Q_t := BusA(6 downto 0) & P_In(Flag_C);
|
||||
P_Out(Flag_C) <= BusA(7);
|
||||
when "1010" =>
|
||||
-- LSR
|
||||
Q_t := "0" & BusA(7 downto 1);
|
||||
P_Out(Flag_C) <= BusA(0);
|
||||
when "1011" =>
|
||||
-- ROR
|
||||
Q_t := P_In(Flag_C) & BusA(7 downto 1);
|
||||
P_Out(Flag_C) <= BusA(0);
|
||||
when "1100" =>
|
||||
-- BIT
|
||||
P_Out(Flag_V) <= BusB(6);
|
||||
when "1110" =>
|
||||
-- DEC
|
||||
Q_t := std_logic_vector(unsigned(BusA) - 1);
|
||||
when "1111" =>
|
||||
-- INC
|
||||
Q_t := std_logic_vector(unsigned(BusA) + 1);
|
||||
when others =>
|
||||
end case;
|
||||
if P_In(Flag_D) = '1' then
|
||||
if AL(5) = '1' then
|
||||
AL(5 downto 1) := AL(5 downto 1) - 6;
|
||||
end if;
|
||||
AH := resize(unsigned(BusA(7 downto 4) & "0"), 6) - resize(unsigned(BusB(7 downto 4) & AL(6)), 6);
|
||||
if AH(5) = '1' then
|
||||
AH(5 downto 1) := AH(5 downto 1) - 6;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
case Op(3 downto 0) is
|
||||
when "0011" =>
|
||||
P_Out(Flag_N) <= ADC_N;
|
||||
P_Out(Flag_Z) <= ADC_Z;
|
||||
when "0110" | "0111" =>
|
||||
P_Out(Flag_N) <= SBC_N;
|
||||
P_Out(Flag_Z) <= SBC_Z;
|
||||
when "0100" =>
|
||||
when "1100" =>
|
||||
P_Out(Flag_N) <= BusB(7);
|
||||
if (BusA and BusB) = "00000000" then
|
||||
P_Out(Flag_Z) <= '1';
|
||||
else
|
||||
P_Out(Flag_Z) <= '0';
|
||||
end if;
|
||||
when others =>
|
||||
P_Out(Flag_N) <= Q_t(7);
|
||||
if Q_t = "00000000" then
|
||||
P_Out(Flag_Z) <= '1';
|
||||
else
|
||||
P_Out(Flag_Z) <= '0';
|
||||
end if;
|
||||
end case;
|
||||
SBC_Q <= std_logic_vector(AH(4 downto 1) & AL(4 downto 1));
|
||||
end process;
|
||||
|
||||
Q <= Q_t;
|
||||
end process;
|
||||
process (Op, P_In, BusA, BusB,
|
||||
ADC_Z, ADC_C, ADC_V, ADC_N, ADC_Q,
|
||||
SBC_Z, SBC_C, SBC_V, SBC_N, SBC_Q,
|
||||
SBX_Q)
|
||||
variable Q_t : std_logic_vector(7 downto 0);
|
||||
variable Q2_t : std_logic_vector(7 downto 0);
|
||||
begin
|
||||
-- ORA, AND, EOR, ADC, NOP, LD, CMP, SBC
|
||||
-- ASL, ROL, LSR, ROR, BIT, LD, DEC, INC
|
||||
P_Out <= P_In;
|
||||
Q_t := BusA;
|
||||
Q2_t := BusA;
|
||||
case Op is
|
||||
when ALU_OP_OR=>
|
||||
Q_t := BusA or BusB;
|
||||
when ALU_OP_AND=>
|
||||
Q_t := BusA and BusB;
|
||||
when ALU_OP_EOR=>
|
||||
Q_t := BusA xor BusB;
|
||||
when ALU_OP_ADC=>
|
||||
P_Out(Flag_V) <= ADC_V;
|
||||
P_Out(Flag_C) <= ADC_C;
|
||||
Q_t := ADC_Q;
|
||||
when ALU_OP_CMP=>
|
||||
P_Out(Flag_C) <= SBC_C;
|
||||
when ALU_OP_SAX=>
|
||||
P_Out(Flag_C) <= SBC_C;
|
||||
Q_t := SBX_Q; -- undoc: subtract (A & X) - (immediate)
|
||||
when ALU_OP_SBC=>
|
||||
P_Out(Flag_V) <= SBC_V;
|
||||
P_Out(Flag_C) <= SBC_C;
|
||||
Q_t := SBC_Q; -- undoc: subtract (A & X) - (immediate), then decimal correction
|
||||
when ALU_OP_ASL=>
|
||||
Q_t := BusA(6 downto 0) & "0";
|
||||
P_Out(Flag_C) <= BusA(7);
|
||||
when ALU_OP_ROL=>
|
||||
Q_t := BusA(6 downto 0) & P_In(Flag_C);
|
||||
P_Out(Flag_C) <= BusA(7);
|
||||
when ALU_OP_LSR=>
|
||||
Q_t := "0" & BusA(7 downto 1);
|
||||
P_Out(Flag_C) <= BusA(0);
|
||||
when ALU_OP_ROR=>
|
||||
Q_t := P_In(Flag_C) & BusA(7 downto 1);
|
||||
P_Out(Flag_C) <= BusA(0);
|
||||
when ALU_OP_ARR=>
|
||||
Q_t := P_In(Flag_C) & (BusA(7 downto 1) and BusB(7 downto 1));
|
||||
P_Out(Flag_V) <= Q_t(5) xor Q_t(6);
|
||||
Q2_t := Q_t;
|
||||
if P_In(Flag_D)='1' then
|
||||
if (BusA(3 downto 0) and BusB(3 downto 0)) > "0100" then
|
||||
Q2_t(3 downto 0) := std_logic_vector(unsigned(Q_t(3 downto 0)) + x"6");
|
||||
end if;
|
||||
if (BusA(7 downto 4) and BusB(7 downto 4)) > "0100" then
|
||||
Q2_t(7 downto 4) := std_logic_vector(unsigned(Q_t(7 downto 4)) + x"6");
|
||||
P_Out(Flag_C) <= '1';
|
||||
else
|
||||
P_Out(Flag_C) <= '0';
|
||||
end if;
|
||||
else
|
||||
P_Out(Flag_C) <= Q_t(6);
|
||||
end if;
|
||||
when ALU_OP_BIT=>
|
||||
P_Out(Flag_V) <= BusB(6);
|
||||
when ALU_OP_DEC=>
|
||||
Q_t := std_logic_vector(unsigned(BusA) - 1);
|
||||
when ALU_OP_INC=>
|
||||
Q_t := std_logic_vector(unsigned(BusA) + 1);
|
||||
when others =>
|
||||
null;
|
||||
--EQ1,EQ2,EQ3 passes BusA to Q_t and P_in to P_out
|
||||
end case;
|
||||
|
||||
case Op is
|
||||
when ALU_OP_ADC=>
|
||||
P_Out(Flag_N) <= ADC_N;
|
||||
P_Out(Flag_Z) <= ADC_Z;
|
||||
when ALU_OP_CMP|ALU_OP_SBC|ALU_OP_SAX=>
|
||||
P_Out(Flag_N) <= SBC_N;
|
||||
P_Out(Flag_Z) <= SBC_Z;
|
||||
when ALU_OP_EQ1=>--dont touch P
|
||||
when ALU_OP_BIT=>
|
||||
P_Out(Flag_N) <= BusB(7);
|
||||
if (BusA and BusB) = "00000000" then
|
||||
P_Out(Flag_Z) <= '1';
|
||||
else
|
||||
P_Out(Flag_Z) <= '0';
|
||||
end if;
|
||||
when ALU_OP_ANC=>
|
||||
P_Out(Flag_N) <= Q_t(7);
|
||||
P_Out(Flag_C) <= Q_t(7);
|
||||
if Q_t = "00000000" then
|
||||
P_Out(Flag_Z) <= '1';
|
||||
else
|
||||
P_Out(Flag_Z) <= '0';
|
||||
end if;
|
||||
when others =>
|
||||
P_Out(Flag_N) <= Q_t(7);
|
||||
if Q_t = "00000000" then
|
||||
P_Out(Flag_Z) <= '1';
|
||||
else
|
||||
P_Out(Flag_Z) <= '0';
|
||||
end if;
|
||||
end case;
|
||||
|
||||
if Op=ALU_OP_ARR then
|
||||
-- handled above in ARR code
|
||||
Q <= Q2_t;
|
||||
else
|
||||
Q <= Q_t;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
end;
|
||||
|
||||
2127
cores/c16/t65/T65_MCode.vhd
Normal file → Executable file
2127
cores/c16/t65/T65_MCode.vhd
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
195
cores/c16/t65/T65_Pack.vhd
Normal file → Executable file
195
cores/c16/t65/T65_Pack.vhd
Normal file → Executable file
@@ -1,18 +1,18 @@
|
||||
-- ****
|
||||
-- T65(b) core. In an effort to merge and maintain bug fixes ....
|
||||
--
|
||||
--
|
||||
-- Ver 300 Bugfixes by ehenciak added
|
||||
-- MikeJ March 2005
|
||||
-- Latest version from www.fpgaarcade.com (original www.opencores.org)
|
||||
-- See list of changes in T65 top file (T65.vhd)...
|
||||
--
|
||||
-- ****
|
||||
--
|
||||
-- 65xx compatible microprocessor core
|
||||
--
|
||||
-- Version : 0246
|
||||
-- FPGAARCADE SVN: $Id: T65_Pack.vhd 1234 2015-02-28 20:14:50Z wolfgang.scherr $
|
||||
--
|
||||
-- Copyright (c) 2002 Daniel Wallner (jesus@opencores.org)
|
||||
-- Copyright (c) 2002...2015
|
||||
-- Daniel Wallner (jesus <at> opencores <dot> org)
|
||||
-- Mike Johnson (mikej <at> fpgaarcade <dot> com)
|
||||
-- Wolfgang Scherr (WoS <at> pin4 <dot> at>
|
||||
-- Morten Leikvoll ()
|
||||
--
|
||||
-- All rights reserved
|
||||
--
|
||||
@@ -42,76 +42,139 @@
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
--
|
||||
-- Please report bugs to the author, but before you do so, please
|
||||
-- Please report bugs to the author(s), but before you do so, please
|
||||
-- make sure that this is not a derivative work and that
|
||||
-- you have the latest version of this file.
|
||||
--
|
||||
-- The latest version of this file can be found at:
|
||||
-- http://www.opencores.org/cvsweb.shtml/t65/
|
||||
--
|
||||
-- Limitations :
|
||||
--
|
||||
-- File history :
|
||||
--
|
||||
-- See in T65 top file (T65.vhd)...
|
||||
|
||||
library IEEE;
|
||||
use IEEE.std_logic_1164.all;
|
||||
|
||||
package T65_Pack is
|
||||
|
||||
constant Flag_C : integer := 0;
|
||||
constant Flag_Z : integer := 1;
|
||||
constant Flag_I : integer := 2;
|
||||
constant Flag_D : integer := 3;
|
||||
constant Flag_B : integer := 4;
|
||||
constant Flag_1 : integer := 5;
|
||||
constant Flag_V : integer := 6;
|
||||
constant Flag_N : integer := 7;
|
||||
constant Flag_C : integer := 0;
|
||||
constant Flag_Z : integer := 1;
|
||||
constant Flag_I : integer := 2;
|
||||
constant Flag_D : integer := 3;
|
||||
constant Flag_B : integer := 4;
|
||||
constant Flag_1 : integer := 5;
|
||||
constant Flag_V : integer := 6;
|
||||
constant Flag_N : integer := 7;
|
||||
|
||||
component T65_MCode
|
||||
port(
|
||||
Mode : in std_logic_vector(1 downto 0); -- "00" => 6502, "01" => 65C02, "10" => 65816
|
||||
IR : in std_logic_vector(7 downto 0);
|
||||
MCycle : in std_logic_vector(2 downto 0);
|
||||
P : in std_logic_vector(7 downto 0);
|
||||
LCycle : out std_logic_vector(2 downto 0);
|
||||
ALU_Op : out std_logic_vector(3 downto 0);
|
||||
Set_BusA_To : out std_logic_vector(2 downto 0); -- DI,A,X,Y,S,P
|
||||
Set_Addr_To : out std_logic_vector(1 downto 0); -- PC Adder,S,AD,BA
|
||||
Write_Data : out std_logic_vector(2 downto 0); -- DL,A,X,Y,S,P,PCL,PCH
|
||||
Jump : out std_logic_vector(1 downto 0); -- PC,++,DIDL,Rel
|
||||
BAAdd : out std_logic_vector(1 downto 0); -- None,DB Inc,BA Add,BA Adj
|
||||
BreakAtNA : out std_logic;
|
||||
ADAdd : out std_logic;
|
||||
AddY : out std_logic;
|
||||
PCAdd : out std_logic;
|
||||
Inc_S : out std_logic;
|
||||
Dec_S : out std_logic;
|
||||
LDA : out std_logic;
|
||||
LDP : out std_logic;
|
||||
LDX : out std_logic;
|
||||
LDY : out std_logic;
|
||||
LDS : out std_logic;
|
||||
LDDI : out std_logic;
|
||||
LDALU : out std_logic;
|
||||
LDAD : out std_logic;
|
||||
LDBAL : out std_logic;
|
||||
LDBAH : out std_logic;
|
||||
SaveP : out std_logic;
|
||||
Write : out std_logic
|
||||
);
|
||||
end component;
|
||||
subtype T_Lcycle is std_logic_vector(2 downto 0);
|
||||
constant Cycle_sync :T_Lcycle:="000";
|
||||
constant Cycle_1 :T_Lcycle:="001";
|
||||
constant Cycle_2 :T_Lcycle:="010";
|
||||
constant Cycle_3 :T_Lcycle:="011";
|
||||
constant Cycle_4 :T_Lcycle:="100";
|
||||
constant Cycle_5 :T_Lcycle:="101";
|
||||
constant Cycle_6 :T_Lcycle:="110";
|
||||
constant Cycle_7 :T_Lcycle:="111";
|
||||
|
||||
component T65_ALU
|
||||
port(
|
||||
Mode : in std_logic_vector(1 downto 0); -- "00" => 6502, "01" => 65C02, "10" => 65C816
|
||||
Op : in std_logic_vector(3 downto 0);
|
||||
BusA : in std_logic_vector(7 downto 0);
|
||||
BusB : in std_logic_vector(7 downto 0);
|
||||
P_In : in std_logic_vector(7 downto 0);
|
||||
P_Out : out std_logic_vector(7 downto 0);
|
||||
Q : out std_logic_vector(7 downto 0)
|
||||
);
|
||||
end component;
|
||||
function CycleNext(c:T_Lcycle) return T_Lcycle;
|
||||
|
||||
type T_Set_BusA_To is
|
||||
(
|
||||
Set_BusA_To_DI,
|
||||
Set_BusA_To_ABC,
|
||||
Set_BusA_To_X,
|
||||
Set_BusA_To_Y,
|
||||
Set_BusA_To_S,
|
||||
Set_BusA_To_P,
|
||||
Set_BusA_To_DA,
|
||||
Set_BusA_To_DAO,
|
||||
Set_BusA_To_DAX,
|
||||
Set_BusA_To_AAX,
|
||||
Set_BusA_To_DONTCARE
|
||||
);
|
||||
|
||||
type T_Set_Addr_To is
|
||||
(
|
||||
Set_Addr_To_PBR,
|
||||
Set_Addr_To_SP,
|
||||
Set_Addr_To_ZPG,
|
||||
Set_Addr_To_BA
|
||||
);
|
||||
|
||||
type T_Write_Data is
|
||||
(
|
||||
Write_Data_DL,
|
||||
Write_Data_ABC,
|
||||
Write_Data_X,
|
||||
Write_Data_Y,
|
||||
Write_Data_S,
|
||||
Write_Data_P,
|
||||
Write_Data_PCL,
|
||||
Write_Data_PCH,
|
||||
Write_Data_AX,
|
||||
Write_Data_AXB,
|
||||
Write_Data_XB,
|
||||
Write_Data_YB,
|
||||
Write_Data_DONTCARE
|
||||
);
|
||||
|
||||
type T_ALU_OP is
|
||||
(
|
||||
ALU_OP_OR, --"0000"
|
||||
ALU_OP_AND, --"0001"
|
||||
ALU_OP_EOR, --"0010"
|
||||
ALU_OP_ADC, --"0011"
|
||||
ALU_OP_EQ1, --"0100" EQ1 does not change N,Z flags, EQ2/3 does.
|
||||
ALU_OP_EQ2, --"0101" Not sure yet whats the difference between EQ2&3. They seem to do the same ALU op
|
||||
ALU_OP_CMP, --"0110"
|
||||
ALU_OP_SBC, --"0111"
|
||||
ALU_OP_ASL, --"1000"
|
||||
ALU_OP_ROL, --"1001"
|
||||
ALU_OP_LSR, --"1010"
|
||||
ALU_OP_ROR, --"1011"
|
||||
ALU_OP_BIT, --"1100"
|
||||
-- ALU_OP_EQ3, --"1101"
|
||||
ALU_OP_DEC, --"1110"
|
||||
ALU_OP_INC, --"1111"
|
||||
ALU_OP_ARR,
|
||||
ALU_OP_ANC,
|
||||
ALU_OP_SAX,
|
||||
ALU_OP_XAA
|
||||
-- ALU_OP_UNDEF--"----"--may be replaced with any?
|
||||
);
|
||||
|
||||
type T_t65_dbg is record
|
||||
I : std_logic_vector(7 downto 0); -- instruction
|
||||
A : std_logic_vector(7 downto 0); -- A reg
|
||||
X : std_logic_vector(7 downto 0); -- X reg
|
||||
Y : std_logic_vector(7 downto 0); -- Y reg
|
||||
S : std_logic_vector(7 downto 0); -- stack pointer
|
||||
P : std_logic_vector(7 downto 0); -- processor flags
|
||||
end record;
|
||||
|
||||
end;
|
||||
|
||||
package body T65_Pack is
|
||||
|
||||
function CycleNext(c:T_Lcycle) return T_Lcycle is
|
||||
begin
|
||||
case(c) is
|
||||
when Cycle_sync=>
|
||||
return Cycle_1;
|
||||
when Cycle_1=>
|
||||
return Cycle_2;
|
||||
when Cycle_2=>
|
||||
return Cycle_3;
|
||||
when Cycle_3=>
|
||||
return Cycle_4;
|
||||
when Cycle_4=>
|
||||
return Cycle_5;
|
||||
when Cycle_5=>
|
||||
return Cycle_6;
|
||||
when Cycle_6=>
|
||||
return Cycle_7;
|
||||
when Cycle_7=>
|
||||
return Cycle_sync;
|
||||
when others=>
|
||||
return Cycle_sync;
|
||||
end case;
|
||||
end CycleNext;
|
||||
|
||||
end T65_Pack;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
module user_io #(parameter STRLEN=0) (
|
||||
input [(8*STRLEN)-1:0] conf_str,
|
||||
|
||||
input clk_sys,
|
||||
input clk_sys, // clock for system-related messages (kbd, joy, etc...)
|
||||
input clk_sd, // clock for SD-card related messages
|
||||
|
||||
input SPI_CLK,
|
||||
input SPI_SS_IO,
|
||||
output reg SPI_MISO,
|
||||
@@ -88,9 +90,6 @@ wire [7:0] core_type = 8'ha4;
|
||||
// command byte read by the io controller
|
||||
wire [7:0] sd_cmd = { 4'h5, sd_conf, sd_sdhc, sd_wr, sd_rd };
|
||||
|
||||
// filter spi clock. the 8 bit gate delay is ~2.5ns in total
|
||||
//wire [7:0] spi_sck_D = { spi_sck_D[6:0], SPI_CLK } /* synthesis keep */;
|
||||
//wire spi_sck = (spi_sck && spi_sck_D != 8'h00) || (!spi_sck && spi_sck_D == 8'hff);
|
||||
wire spi_sck = SPI_CLK;
|
||||
|
||||
// ---------------- PS2 ---------------------
|
||||
@@ -368,6 +367,78 @@ always @(posedge clk_sys) begin
|
||||
spi_byte_inD <= spi_byte_in_r;
|
||||
spi_byte_in <= spi_byte_inD;
|
||||
|
||||
if (~spi_transfer_endD & spi_transfer_end) begin
|
||||
abyte_cnt <= 8'd0;
|
||||
end else if (~spi_receiver_strobeD & spi_receiver_strobe) begin
|
||||
|
||||
if(abyte_cnt != 8'd255)
|
||||
abyte_cnt <= byte_cnt + 8'd1;
|
||||
|
||||
if(abyte_cnt == 0) begin
|
||||
acmd <= spi_byte_in;
|
||||
end else begin
|
||||
case(acmd)
|
||||
// buttons and switches
|
||||
8'h01: but_sw <= spi_byte_in;
|
||||
8'h02: joystick_0 <= spi_byte_in;
|
||||
8'h03: joystick_1 <= spi_byte_in;
|
||||
8'h04: begin
|
||||
// store incoming ps2 mouse bytes
|
||||
ps2_mouse_fifo[ps2_mouse_wptr] <= spi_byte_in;
|
||||
ps2_mouse_wptr <= ps2_mouse_wptr + 1;
|
||||
end
|
||||
8'h05: begin
|
||||
// store incoming ps2 keyboard bytes
|
||||
ps2_kbd_fifo[ps2_kbd_wptr] <= spi_byte_in;
|
||||
ps2_kbd_wptr <= ps2_kbd_wptr + 1;
|
||||
end
|
||||
|
||||
8'h15: status <= spi_byte_in;
|
||||
|
||||
// joystick analog
|
||||
8'h1a: begin
|
||||
// first byte is joystick indes
|
||||
if(abyte_cnt == 1)
|
||||
stick_idx <= spi_byte_in[2:0];
|
||||
else if(abyte_cnt == 2) begin
|
||||
// second byte is x axis
|
||||
if(stick_idx == 0)
|
||||
joystick_analog_0[15:8] <= spi_byte_in;
|
||||
else if(stick_idx == 1)
|
||||
joystick_analog_1[15:8] <= spi_byte_in;
|
||||
end else if(abyte_cnt == 3) begin
|
||||
// third byte is y axis
|
||||
if(stick_idx == 0)
|
||||
joystick_analog_0[7:0] <= spi_byte_in;
|
||||
else if(stick_idx == 1)
|
||||
joystick_analog_1[7:0] <= spi_byte_in;
|
||||
end
|
||||
end
|
||||
endcase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
// Process SD-card related bytes from SPI at the clk_sd domain
|
||||
always @(posedge clk_sd) begin
|
||||
|
||||
reg spi_receiver_strobe;
|
||||
reg spi_transfer_end;
|
||||
reg [7:0] spi_byte_in;
|
||||
reg spi_receiver_strobeD;
|
||||
reg spi_transfer_endD;
|
||||
reg [7:0] spi_byte_inD;
|
||||
reg [7:0] acmd;
|
||||
reg [7:0] abyte_cnt; // counts bytes
|
||||
|
||||
//synchronize between SPI and sd clock domains
|
||||
spi_receiver_strobeD <= spi_receiver_strobe_r;
|
||||
spi_receiver_strobe <= spi_receiver_strobeD;
|
||||
spi_transfer_endD <= spi_transfer_end_r;
|
||||
spi_transfer_end <= spi_transfer_endD;
|
||||
spi_byte_inD <= spi_byte_in_r;
|
||||
spi_byte_in <= spi_byte_inD;
|
||||
|
||||
if(sd_dout_strobe) begin
|
||||
sd_dout_strobe<= 0;
|
||||
if(~&sd_buff_addr) sd_buff_addr <= sd_buff_addr + 1'b1;
|
||||
@@ -404,22 +475,6 @@ always @(posedge clk_sys) begin
|
||||
|
||||
end else begin
|
||||
case(acmd)
|
||||
// buttons and switches
|
||||
8'h01: but_sw <= spi_byte_in;
|
||||
8'h02: joystick_0 <= spi_byte_in;
|
||||
8'h03: joystick_1 <= spi_byte_in;
|
||||
8'h04: begin
|
||||
// store incoming ps2 mouse bytes
|
||||
ps2_mouse_fifo[ps2_mouse_wptr] <= spi_byte_in;
|
||||
ps2_mouse_wptr <= ps2_mouse_wptr + 1;
|
||||
end
|
||||
8'h05: begin
|
||||
// store incoming ps2 keyboard bytes
|
||||
ps2_kbd_fifo[ps2_kbd_wptr] <= spi_byte_in;
|
||||
ps2_kbd_wptr <= ps2_kbd_wptr + 1;
|
||||
end
|
||||
|
||||
8'h15: status <= spi_byte_in;
|
||||
|
||||
// send sector IO -> FPGA
|
||||
8'h17: begin
|
||||
@@ -438,26 +493,6 @@ always @(posedge clk_sys) begin
|
||||
sd_ack_conf <= 1'b1;
|
||||
sd_dout <= spi_byte_in;
|
||||
end
|
||||
|
||||
// joystick analog
|
||||
8'h1a: begin
|
||||
// first byte is joystick indes
|
||||
if(abyte_cnt == 1)
|
||||
stick_idx <= spi_byte_in[2:0];
|
||||
else if(abyte_cnt == 2) begin
|
||||
// second byte is x axis
|
||||
if(stick_idx == 0)
|
||||
joystick_analog_0[15:8] <= spi_byte_in;
|
||||
else if(stick_idx == 1)
|
||||
joystick_analog_1[15:8] <= spi_byte_in;
|
||||
end else if(abyte_cnt == 3) begin
|
||||
// third byte is y axis
|
||||
if(stick_idx == 0)
|
||||
joystick_analog_0[7:0] <= spi_byte_in;
|
||||
else if(stick_idx == 1)
|
||||
joystick_analog_1[7:0] <= spi_byte_in;
|
||||
end
|
||||
end
|
||||
|
||||
8'h1c: img_mounted <= 1;
|
||||
endcase
|
||||
|
||||
Reference in New Issue
Block a user