-- $Id: pdp11_lbox.vhd 314 2010-07-09 17:38:41Z mueller $
|
-- $Id: pdp11_lbox.vhd 314 2010-07-09 17:38:41Z mueller $
|
--
|
--
|
-- Copyright 2006-2008 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
-- Copyright 2006-2008 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
--
|
--
|
-- This program is free software; you may redistribute and/or modify it under
|
-- This program is free software; you may redistribute and/or modify it under
|
-- the terms of the GNU General Public License as published by the Free
|
-- the terms of the GNU General Public License as published by the Free
|
-- Software Foundation, either version 2, or at your option any later version.
|
-- Software Foundation, either version 2, or at your option any later version.
|
--
|
--
|
-- This program is distributed in the hope that it will be useful, but
|
-- This program is distributed in the hope that it will be useful, but
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
-- for complete details.
|
-- for complete details.
|
--
|
--
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- Module Name: pdp11_lbox - syn
|
-- Module Name: pdp11_lbox - syn
|
-- Description: pdp11: logic unit for data (lbox)
|
-- Description: pdp11: logic unit for data (lbox)
|
--
|
--
|
-- Dependencies: -
|
-- Dependencies: -
|
-- Test bench: tb/tb_pdp11_core (implicit)
|
-- Test bench: tb/tb_pdp11_core (implicit)
|
-- Target Devices: generic
|
-- Target Devices: generic
|
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
|
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
|
-- Revision History:
|
-- Revision History:
|
-- Date Rev Version Comment
|
-- Date Rev Version Comment
|
-- 2008-03-30 131 1.0.2 BUGFIX: SXT clears V condition code
|
-- 2008-03-30 131 1.0.2 BUGFIX: SXT clears V condition code
|
-- 2007-06-14 56 1.0.1 Use slvtypes.all
|
-- 2007-06-14 56 1.0.1 Use slvtypes.all
|
-- 2007-05-12 26 1.0 Initial version
|
-- 2007-05-12 26 1.0 Initial version
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
|
|
use work.slvtypes.all;
|
use work.slvtypes.all;
|
use work.pdp11.all;
|
use work.pdp11.all;
|
|
|
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
|
|
entity pdp11_lbox is -- logic unit for data (lbox)
|
entity pdp11_lbox is -- logic unit for data (lbox)
|
port (
|
port (
|
DSRC : in slv16; -- 'src' data in
|
DSRC : in slv16; -- 'src' data in
|
DDST : in slv16; -- 'dst' data in
|
DDST : in slv16; -- 'dst' data in
|
CCIN : in slv4; -- condition codes in
|
CCIN : in slv4; -- condition codes in
|
FUNC : in slv4; -- function
|
FUNC : in slv4; -- function
|
BYTOP : in slbit; -- byte operation
|
BYTOP : in slbit; -- byte operation
|
DOUT : out slv16; -- data output
|
DOUT : out slv16; -- data output
|
CCOUT : out slv4 -- condition codes out
|
CCOUT : out slv4 -- condition codes out
|
);
|
);
|
end pdp11_lbox;
|
end pdp11_lbox;
|
|
|
architecture syn of pdp11_lbox is
|
architecture syn of pdp11_lbox is
|
|
|
-- --------------------------------------
|
-- --------------------------------------
|
|
|
begin
|
begin
|
|
|
process (DSRC, DDST, CCIN, FUNC, BYTOP)
|
process (DSRC, DDST, CCIN, FUNC, BYTOP)
|
variable iout : slv16 := (others=>'0');
|
variable iout : slv16 := (others=>'0');
|
variable inzstd : slbit := '0';
|
variable inzstd : slbit := '0';
|
variable ino : slbit := '0';
|
variable ino : slbit := '0';
|
variable izo : slbit := '0';
|
variable izo : slbit := '0';
|
variable ivo : slbit := '0';
|
variable ivo : slbit := '0';
|
variable ico : slbit := '0';
|
variable ico : slbit := '0';
|
|
|
alias DSRC_L : slv8 is DSRC(7 downto 0);
|
alias DSRC_L : slv8 is DSRC(7 downto 0);
|
alias DSRC_H : slv8 is DSRC(15 downto 8);
|
alias DSRC_H : slv8 is DSRC(15 downto 8);
|
alias DDST_L : slv8 is DDST(7 downto 0);
|
alias DDST_L : slv8 is DDST(7 downto 0);
|
alias DDST_H : slv8 is DDST(15 downto 8);
|
alias DDST_H : slv8 is DDST(15 downto 8);
|
alias NI : slbit is CCIN(3);
|
alias NI : slbit is CCIN(3);
|
alias ZI : slbit is CCIN(2);
|
alias ZI : slbit is CCIN(2);
|
alias VI : slbit is CCIN(1);
|
alias VI : slbit is CCIN(1);
|
alias CI : slbit is CCIN(0);
|
alias CI : slbit is CCIN(0);
|
alias iout_l : slv8 is iout(7 downto 0);
|
alias iout_l : slv8 is iout(7 downto 0);
|
alias iout_h : slv8 is iout(15 downto 8);
|
alias iout_h : slv8 is iout(15 downto 8);
|
|
|
begin
|
begin
|
|
|
iout := (others=>'0');
|
iout := (others=>'0');
|
inzstd := '1'; -- use standard logic by default
|
inzstd := '1'; -- use standard logic by default
|
ino := '0';
|
ino := '0';
|
izo := '0';
|
izo := '0';
|
ivo := '0';
|
ivo := '0';
|
ico := '0';
|
ico := '0';
|
|
|
--
|
--
|
-- the decoding of FUNC is done "manually" to get a structure based on
|
-- the decoding of FUNC is done "manually" to get a structure based on
|
-- a 8->1 pattern. This matches the opcode structure and seems most
|
-- a 8->1 pattern. This matches the opcode structure and seems most
|
-- efficient.
|
-- efficient.
|
--
|
--
|
|
|
if FUNC(3) = '0' then
|
if FUNC(3) = '0' then
|
if BYTOP = '0' then
|
if BYTOP = '0' then
|
|
|
case FUNC(2 downto 0) is
|
case FUNC(2 downto 0) is
|
when "000" => -- ASR
|
when "000" => -- ASR
|
iout := DDST(15) & DDST(15 downto 1);
|
iout := DDST(15) & DDST(15 downto 1);
|
ico := DDST(0);
|
ico := DDST(0);
|
ivo := iout(15) xor ico;
|
ivo := iout(15) xor ico;
|
|
|
when "001" => -- ASL
|
when "001" => -- ASL
|
iout := DDST(14 downto 0) & '0';
|
iout := DDST(14 downto 0) & '0';
|
ico := DDST(15);
|
ico := DDST(15);
|
ivo := iout(15) xor ico;
|
ivo := iout(15) xor ico;
|
|
|
when "010" => -- ROR
|
when "010" => -- ROR
|
iout := CI & DDST(15 downto 1);
|
iout := CI & DDST(15 downto 1);
|
ico := DDST(0);
|
ico := DDST(0);
|
ivo := iout(15) xor ico;
|
ivo := iout(15) xor ico;
|
|
|
when "011" => -- ROL
|
when "011" => -- ROL
|
iout := DDST(14 downto 0) & CI;
|
iout := DDST(14 downto 0) & CI;
|
ico := DDST(15);
|
ico := DDST(15);
|
ivo := iout(15) xor ico;
|
ivo := iout(15) xor ico;
|
|
|
when "100" => -- BIS
|
when "100" => -- BIS
|
iout := DDST or DSRC;
|
iout := DDST or DSRC;
|
ico := CI;
|
ico := CI;
|
|
|
when "101" => -- BIC
|
when "101" => -- BIC
|
iout := DDST and not DSRC;
|
iout := DDST and not DSRC;
|
ico := CI;
|
ico := CI;
|
|
|
when "110" => -- BIT
|
when "110" => -- BIT
|
iout := DDST and DSRC;
|
iout := DDST and DSRC;
|
ico := CI;
|
ico := CI;
|
|
|
when "111" => -- MOV
|
when "111" => -- MOV
|
iout := DSRC;
|
iout := DSRC;
|
ico := CI;
|
ico := CI;
|
when others => null;
|
when others => null;
|
end case;
|
end case;
|
|
|
else
|
else
|
|
|
case FUNC(2 downto 0) is
|
case FUNC(2 downto 0) is
|
when "000" => -- ASRB
|
when "000" => -- ASRB
|
iout_l := DDST_L(7) & DDST_L(7 downto 1);
|
iout_l := DDST_L(7) & DDST_L(7 downto 1);
|
ico := DDST_L(0);
|
ico := DDST_L(0);
|
ivo := iout_l(7) xor ico;
|
ivo := iout_l(7) xor ico;
|
|
|
when "001" => -- ASLB
|
when "001" => -- ASLB
|
iout_l := DDST(6 downto 0) & '0';
|
iout_l := DDST(6 downto 0) & '0';
|
ico := DDST(7);
|
ico := DDST(7);
|
ivo := iout_l(7) xor ico;
|
ivo := iout_l(7) xor ico;
|
|
|
when "010" => -- RORB
|
when "010" => -- RORB
|
iout_l := CI & DDST_L(7 downto 1);
|
iout_l := CI & DDST_L(7 downto 1);
|
ico := DDST_L(0);
|
ico := DDST_L(0);
|
ivo := iout_l(7) xor ico;
|
ivo := iout_l(7) xor ico;
|
|
|
when "011" => -- ROLB
|
when "011" => -- ROLB
|
iout_l := DDST_L(6 downto 0) & CI;
|
iout_l := DDST_L(6 downto 0) & CI;
|
ico := DDST_L(7);
|
ico := DDST_L(7);
|
ivo := iout_l(7) xor ico;
|
ivo := iout_l(7) xor ico;
|
|
|
when "100" => -- BISB
|
when "100" => -- BISB
|
iout_l := DDST_L or DSRC_L;
|
iout_l := DDST_L or DSRC_L;
|
ico := CI;
|
ico := CI;
|
|
|
when "101" => -- BICB
|
when "101" => -- BICB
|
iout_l := DDST_L and not DSRC_L;
|
iout_l := DDST_L and not DSRC_L;
|
ico := CI;
|
ico := CI;
|
|
|
when "110" => -- BITB
|
when "110" => -- BITB
|
iout_l := DDST_L and DSRC_L;
|
iout_l := DDST_L and DSRC_L;
|
ico := CI;
|
ico := CI;
|
|
|
when "111" => -- MOVB
|
when "111" => -- MOVB
|
iout_l := DSRC_L;
|
iout_l := DSRC_L;
|
iout_h := (others=>DSRC_L(7));
|
iout_h := (others=>DSRC_L(7));
|
ico := CI;
|
ico := CI;
|
when others => null;
|
when others => null;
|
end case;
|
end case;
|
end if;
|
end if;
|
|
|
else
|
else
|
case FUNC(2 downto 0) is
|
case FUNC(2 downto 0) is
|
when "000" => -- SXT
|
when "000" => -- SXT
|
iout := (others=>NI);
|
iout := (others=>NI);
|
inzstd := '0';
|
inzstd := '0';
|
ino := NI;
|
ino := NI;
|
izo := not NI;
|
izo := not NI;
|
ivo := '0';
|
ivo := '0';
|
ico := CI;
|
ico := CI;
|
|
|
when "001" => -- SWAP
|
when "001" => -- SWAP
|
iout := DDST_L & DDST_H;
|
iout := DDST_L & DDST_H;
|
inzstd := '0';
|
inzstd := '0';
|
ino := iout(7);
|
ino := iout(7);
|
if unsigned(iout(7 downto 0)) = 0 then
|
if unsigned(iout(7 downto 0)) = 0 then
|
izo := '1';
|
izo := '1';
|
else
|
else
|
izo := '0';
|
izo := '0';
|
end if;
|
end if;
|
|
|
when "010" => -- XOR
|
when "010" => -- XOR
|
iout := DDST xor DSRC;
|
iout := DDST xor DSRC;
|
ico := CI;
|
ico := CI;
|
|
|
when others => null;
|
when others => null;
|
|
|
end case;
|
end case;
|
end if;
|
end if;
|
|
|
DOUT <= iout;
|
DOUT <= iout;
|
|
|
if inzstd = '1' then
|
if inzstd = '1' then
|
if BYTOP = '1' then
|
if BYTOP = '1' then
|
ino := iout(7);
|
ino := iout(7);
|
if unsigned(iout(7 downto 0)) = 0 then
|
if unsigned(iout(7 downto 0)) = 0 then
|
izo := '1';
|
izo := '1';
|
else
|
else
|
izo := '0';
|
izo := '0';
|
end if;
|
end if;
|
else
|
else
|
ino := iout(15);
|
ino := iout(15);
|
if unsigned(iout) = 0 then
|
if unsigned(iout) = 0 then
|
izo := '1';
|
izo := '1';
|
else
|
else
|
izo := '0';
|
izo := '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
CCOUT(3) <= ino;
|
CCOUT(3) <= ino;
|
CCOUT(2) <= izo;
|
CCOUT(2) <= izo;
|
CCOUT(1) <= ivo;
|
CCOUT(1) <= ivo;
|
CCOUT(0) <= ico;
|
CCOUT(0) <= ico;
|
|
|
end process;
|
end process;
|
|
|
end syn;
|
end syn;
|
|
|