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

Subversion Repositories w11

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 wfjm
-- $Id: pdp11_lunit.vhd 641 2015-02-01 22:12:15Z mueller $
2 2 wfjm
--
3 27 wfjm
-- Copyright 2006-2014 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 29 wfjm
-- Tool versions:  ise 8.2-14.7; viv 2014.4; ghdl 0.18-0.31
22 2 wfjm
-- Revision History: 
23
-- Date         Rev Version  Comment
24 27 wfjm
-- 2014-08-10   581   1.1.2  use c_cc_f_*
25 13 wfjm
-- 2011-11-18   427   1.1.1  now numeric_std clean
26 8 wfjm
-- 2010-09-18   300   1.1    renamed from lbox
27 2 wfjm
-- 2008-03-30   131   1.0.2  BUGFIX: SXT clears V condition code
28
-- 2007-06-14    56   1.0.1  Use slvtypes.all
29
-- 2007-05-12    26   1.0    Initial version 
30
------------------------------------------------------------------------------
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34 13 wfjm
use ieee.numeric_std.all;
35 2 wfjm
 
36
use work.slvtypes.all;
37
use work.pdp11.all;
38
 
39
-- ----------------------------------------------------------------------------
40
 
41 8 wfjm
entity pdp11_lunit is                   -- logic unit for data (lunit)
42 2 wfjm
  port (
43
    DSRC : in slv16;                    -- 'src' data in
44
    DDST : in slv16;                    -- 'dst' data in
45
    CCIN : in slv4;                     -- condition codes in
46
    FUNC : in slv4;                     -- function
47
    BYTOP : in slbit;                   -- byte operation
48
    DOUT : out slv16;                   -- data output
49
    CCOUT : out slv4                    -- condition codes out
50
  );
51 8 wfjm
end pdp11_lunit;
52 2 wfjm
 
53 8 wfjm
architecture syn of pdp11_lunit is
54 2 wfjm
 
55
-- --------------------------------------
56
 
57
begin
58
 
59
  process (DSRC, DDST, CCIN, FUNC, BYTOP)
60
    variable iout : slv16 := (others=>'0');
61
    variable inzstd : slbit := '0';
62
    variable ino : slbit := '0';
63
    variable izo : slbit := '0';
64
    variable ivo : slbit := '0';
65
    variable ico : slbit := '0';
66
 
67
    alias DSRC_L : slv8 is DSRC(7 downto 0);
68
    alias DSRC_H : slv8 is DSRC(15 downto 8);
69
    alias DDST_L : slv8 is DDST(7 downto 0);
70
    alias DDST_H : slv8 is DDST(15 downto 8);
71 27 wfjm
    alias NI : slbit is CCIN(c_cc_f_n);
72
    alias ZI : slbit is CCIN(c_cc_f_z);
73
    alias VI : slbit is CCIN(c_cc_f_v);
74
    alias CI : slbit is CCIN(c_cc_f_c);
75 2 wfjm
    alias iout_l : slv8 is iout(7 downto 0);
76
    alias iout_h : slv8 is iout(15 downto 8);
77
 
78
  begin
79
 
80
    iout := (others=>'0');
81
    inzstd := '1';                      -- use standard logic by default
82
    ino := '0';
83
    izo := '0';
84
    ivo := '0';
85
    ico := '0';
86
 
87
--
88
-- the decoding of FUNC is done "manually" to get a structure based on
89
-- a 8->1 pattern. This matches the opcode structure and seems most
90
-- efficient.
91
--
92
 
93
    if FUNC(3) = '0' then
94
      if BYTOP = '0' then
95
 
96
        case FUNC(2 downto 0) is
97
          when "000" =>                 -- ASR
98
            iout := DDST(15) & DDST(15 downto 1);
99
            ico := DDST(0);
100
            ivo := iout(15) xor ico;
101
 
102
          when "001"  =>                -- ASL
103
            iout := DDST(14 downto 0) & '0';
104
            ico := DDST(15);
105
            ivo := iout(15) xor ico;
106
 
107
          when "010" =>                 -- ROR
108
            iout := CI & DDST(15 downto 1);
109
            ico := DDST(0);
110
            ivo := iout(15) xor ico;
111
 
112
          when "011"  =>                -- ROL
113
            iout := DDST(14 downto 0) & CI;
114
            ico := DDST(15);
115
            ivo := iout(15) xor ico;
116
 
117
          when "100" =>                 -- BIS
118
            iout := DDST or DSRC;
119
            ico := CI;
120
 
121
          when "101" =>                 -- BIC
122
            iout := DDST and not DSRC;
123
            ico := CI;
124
 
125
          when "110" =>                 -- BIT
126
            iout := DDST and DSRC;
127
            ico := CI;
128
 
129
          when "111" =>                 -- MOV
130
            iout := DSRC;
131
            ico := CI;
132
          when others => null;
133
        end case;
134
 
135
      else
136
 
137
        case FUNC(2 downto 0) is
138
          when "000" =>                 -- ASRB
139
            iout_l := DDST_L(7) & DDST_L(7 downto 1);
140
            ico := DDST_L(0);
141
            ivo := iout_l(7) xor ico;
142
 
143
          when "001"  =>                -- ASLB
144
            iout_l := DDST(6 downto 0) & '0';
145
            ico := DDST(7);
146
            ivo := iout_l(7) xor ico;
147
 
148
          when "010" =>                 -- RORB
149
            iout_l := CI & DDST_L(7 downto 1);
150
            ico := DDST_L(0);
151
            ivo := iout_l(7) xor ico;
152
 
153
          when "011"  =>                -- ROLB
154
            iout_l := DDST_L(6 downto 0) & CI;
155
            ico := DDST_L(7);
156
            ivo := iout_l(7) xor ico;
157
 
158
          when "100" =>                 -- BISB
159
            iout_l := DDST_L or DSRC_L;
160
            ico := CI;
161
 
162
          when "101" =>                 -- BICB
163
            iout_l := DDST_L and not DSRC_L;
164
            ico := CI;
165
 
166
          when "110" =>                 -- BITB
167
            iout_l := DDST_L and DSRC_L;
168
            ico := CI;
169
 
170
          when "111" =>                 -- MOVB
171
            iout_l := DSRC_L;
172
            iout_h := (others=>DSRC_L(7));
173
            ico := CI;
174
          when others => null;
175
        end case;
176
      end if;
177
 
178
    else
179
      case FUNC(2 downto 0) is
180
        when "000" =>                   -- SXT
181
          iout := (others=>NI);
182
          inzstd := '0';
183
          ino := NI;
184
          izo := not NI;
185
          ivo := '0';
186
          ico := CI;
187
 
188
        when "001" =>                   -- SWAP
189
          iout := DDST_L & DDST_H;
190
          inzstd := '0';
191
          ino := iout(7);
192
          if unsigned(iout(7 downto 0)) = 0 then
193
            izo := '1';
194
          else
195
            izo := '0';
196
          end if;
197
 
198
        when "010" =>                   -- XOR
199
          iout := DDST xor DSRC;
200
          ico := CI;
201
 
202
        when others => null;
203
 
204
      end case;
205
    end if;
206
 
207
    DOUT <= iout;
208
 
209
    if inzstd = '1' then
210
      if BYTOP = '1' then
211
        ino := iout(7);
212
        if unsigned(iout(7 downto 0)) = 0 then
213
          izo := '1';
214
        else
215
          izo := '0';
216
        end if;
217
      else
218
        ino := iout(15);
219
        if unsigned(iout) = 0 then
220
          izo := '1';
221
        else
222
          izo := '0';
223
        end if;
224
      end if;
225
    end if;
226
 
227
    CCOUT(3) <= ino;
228
    CCOUT(2) <= izo;
229
    CCOUT(1) <= ivo;
230
    CCOUT(0) <= ico;
231
 
232
  end process;
233
 
234
end syn;

powered by: WebSVN 2.1.0

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