OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [w11a/] [pdp11_lunit.vhd] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: pdp11_lunit.vhd 427 2011-11-19 21:04:11Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15 8 wfjm
-- Module Name:    pdp11_lunit - syn
16
-- Description:    pdp11: logic unit for data (lunit)
17 2 wfjm
--
18
-- Dependencies:   -
19
-- Test bench:     tb/tb_pdp11_core (implicit)
20
-- Target Devices: generic
21 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 12.1, 13.1; ghdl 0.18-0.29
22 2 wfjm
-- Revision History: 
23
-- Date         Rev Version  Comment
24 13 wfjm
-- 2011-11-18   427   1.1.1  now numeric_std clean
25 8 wfjm
-- 2010-09-18   300   1.1    renamed from lbox
26 2 wfjm
-- 2008-03-30   131   1.0.2  BUGFIX: SXT clears V condition code
27
-- 2007-06-14    56   1.0.1  Use slvtypes.all
28
-- 2007-05-12    26   1.0    Initial version 
29
------------------------------------------------------------------------------
30
 
31
library ieee;
32
use ieee.std_logic_1164.all;
33 13 wfjm
use ieee.numeric_std.all;
34 2 wfjm
 
35
use work.slvtypes.all;
36
use work.pdp11.all;
37
 
38
-- ----------------------------------------------------------------------------
39
 
40 8 wfjm
entity pdp11_lunit is                   -- logic unit for data (lunit)
41 2 wfjm
  port (
42
    DSRC : in slv16;                    -- 'src' data in
43
    DDST : in slv16;                    -- 'dst' data in
44
    CCIN : in slv4;                     -- condition codes in
45
    FUNC : in slv4;                     -- function
46
    BYTOP : in slbit;                   -- byte operation
47
    DOUT : out slv16;                   -- data output
48
    CCOUT : out slv4                    -- condition codes out
49
  );
50 8 wfjm
end pdp11_lunit;
51 2 wfjm
 
52 8 wfjm
architecture syn of pdp11_lunit is
53 2 wfjm
 
54
-- --------------------------------------
55
 
56
begin
57
 
58
  process (DSRC, DDST, CCIN, FUNC, BYTOP)
59
    variable iout : slv16 := (others=>'0');
60
    variable inzstd : slbit := '0';
61
    variable ino : slbit := '0';
62
    variable izo : slbit := '0';
63
    variable ivo : slbit := '0';
64
    variable ico : slbit := '0';
65
 
66
    alias DSRC_L : slv8 is DSRC(7 downto 0);
67
    alias DSRC_H : slv8 is DSRC(15 downto 8);
68
    alias DDST_L : slv8 is DDST(7 downto 0);
69
    alias DDST_H : slv8 is DDST(15 downto 8);
70
    alias NI : slbit is CCIN(3);
71
    alias ZI : slbit is CCIN(2);
72
    alias VI : slbit is CCIN(1);
73
    alias CI : slbit is CCIN(0);
74
    alias iout_l : slv8 is iout(7 downto 0);
75
    alias iout_h : slv8 is iout(15 downto 8);
76
 
77
  begin
78
 
79
    iout := (others=>'0');
80
    inzstd := '1';                      -- use standard logic by default
81
    ino := '0';
82
    izo := '0';
83
    ivo := '0';
84
    ico := '0';
85
 
86
--
87
-- the decoding of FUNC is done "manually" to get a structure based on
88
-- a 8->1 pattern. This matches the opcode structure and seems most
89
-- efficient.
90
--
91
 
92
    if FUNC(3) = '0' then
93
      if BYTOP = '0' then
94
 
95
        case FUNC(2 downto 0) is
96
          when "000" =>                 -- ASR
97
            iout := DDST(15) & DDST(15 downto 1);
98
            ico := DDST(0);
99
            ivo := iout(15) xor ico;
100
 
101
          when "001"  =>                -- ASL
102
            iout := DDST(14 downto 0) & '0';
103
            ico := DDST(15);
104
            ivo := iout(15) xor ico;
105
 
106
          when "010" =>                 -- ROR
107
            iout := CI & DDST(15 downto 1);
108
            ico := DDST(0);
109
            ivo := iout(15) xor ico;
110
 
111
          when "011"  =>                -- ROL
112
            iout := DDST(14 downto 0) & CI;
113
            ico := DDST(15);
114
            ivo := iout(15) xor ico;
115
 
116
          when "100" =>                 -- BIS
117
            iout := DDST or DSRC;
118
            ico := CI;
119
 
120
          when "101" =>                 -- BIC
121
            iout := DDST and not DSRC;
122
            ico := CI;
123
 
124
          when "110" =>                 -- BIT
125
            iout := DDST and DSRC;
126
            ico := CI;
127
 
128
          when "111" =>                 -- MOV
129
            iout := DSRC;
130
            ico := CI;
131
          when others => null;
132
        end case;
133
 
134
      else
135
 
136
        case FUNC(2 downto 0) is
137
          when "000" =>                 -- ASRB
138
            iout_l := DDST_L(7) & DDST_L(7 downto 1);
139
            ico := DDST_L(0);
140
            ivo := iout_l(7) xor ico;
141
 
142
          when "001"  =>                -- ASLB
143
            iout_l := DDST(6 downto 0) & '0';
144
            ico := DDST(7);
145
            ivo := iout_l(7) xor ico;
146
 
147
          when "010" =>                 -- RORB
148
            iout_l := CI & DDST_L(7 downto 1);
149
            ico := DDST_L(0);
150
            ivo := iout_l(7) xor ico;
151
 
152
          when "011"  =>                -- ROLB
153
            iout_l := DDST_L(6 downto 0) & CI;
154
            ico := DDST_L(7);
155
            ivo := iout_l(7) xor ico;
156
 
157
          when "100" =>                 -- BISB
158
            iout_l := DDST_L or DSRC_L;
159
            ico := CI;
160
 
161
          when "101" =>                 -- BICB
162
            iout_l := DDST_L and not DSRC_L;
163
            ico := CI;
164
 
165
          when "110" =>                 -- BITB
166
            iout_l := DDST_L and DSRC_L;
167
            ico := CI;
168
 
169
          when "111" =>                 -- MOVB
170
            iout_l := DSRC_L;
171
            iout_h := (others=>DSRC_L(7));
172
            ico := CI;
173
          when others => null;
174
        end case;
175
      end if;
176
 
177
    else
178
      case FUNC(2 downto 0) is
179
        when "000" =>                   -- SXT
180
          iout := (others=>NI);
181
          inzstd := '0';
182
          ino := NI;
183
          izo := not NI;
184
          ivo := '0';
185
          ico := CI;
186
 
187
        when "001" =>                   -- SWAP
188
          iout := DDST_L & DDST_H;
189
          inzstd := '0';
190
          ino := iout(7);
191
          if unsigned(iout(7 downto 0)) = 0 then
192
            izo := '1';
193
          else
194
            izo := '0';
195
          end if;
196
 
197
        when "010" =>                   -- XOR
198
          iout := DDST xor DSRC;
199
          ico := CI;
200
 
201
        when others => null;
202
 
203
      end case;
204
    end if;
205
 
206
    DOUT <= iout;
207
 
208
    if inzstd = '1' then
209
      if BYTOP = '1' then
210
        ino := iout(7);
211
        if unsigned(iout(7 downto 0)) = 0 then
212
          izo := '1';
213
        else
214
          izo := '0';
215
        end if;
216
      else
217
        ino := iout(15);
218
        if unsigned(iout) = 0 then
219
          izo := '1';
220
        else
221
          izo := '0';
222
        end if;
223
      end if;
224
    end if;
225
 
226
    CCOUT(3) <= ino;
227
    CCOUT(2) <= izo;
228
    CCOUT(1) <= ivo;
229
    CCOUT(0) <= ico;
230
 
231
  end process;
232
 
233
end syn;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.