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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [pdp8/] [cpu/] [mq.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 trurl
------------------------------------------------------------------
2
--!
3
--! PDP-8 Processor
4
--!
5
--! \brief
6
--!      CPU Multiplier Quotient (MQ) Register
7
--!
8
--! \details
9
--!      The Multiplier Quotient (MQ) Register is used during
10
--!      certain EAE instructions.   Many times is is just used
11
--!      as a temporary register.
12
--!
13
--!      The MQ register is modified as follows:
14
--!      -# The MQ reqister is set to 0000 when the Front Panel
15
--!         CLEAR switch is asserted, and
16
--!      -# The MQ reqister is set to 0000 when a Clear AC and MQ
17
--!         (CAM) instruction is executed, and 
18
--!      -# The MQ reqister is set to 0000 when a CLA SWP
19
--!         instruction is executed, and 
20
--!      -# The MQ is loaded with the contents of the AC register
21
--!         when a MQ Register Load (MQL) instruction is
22
--!         executed, and
23
--!      -# The MQ is loaded with the contents of the AC register
24
--!         when a Swap AC and MQ (SWP) instruction is
25
--!         executed, and
26
--!      -# The MQ register is updated during each of the
27
--!         following EAE instructions:
28
--!          -# the Double Precision Increment (DPIC)
29
--!             instruction, or
30
--!          -# the Double Precision Complement (DCM)
31
--!             instruction, or
32
--!          -# the Double Precision Add (DAD) instruction, or
33
--!          -# the Double Precision Divide (DVI) instruction, or
34
--!          -# the Double Precision Multiply (MUY) instruction, or
35
--!          -# the Arithmetic Shift Right (ASR) instruction, or
36
--!          -# the Logical Shift Right (LSR) instruction, or
37
--!          -# the Shift Left (SHL) instruction, or
38
--!
39
--! \file
40
--!      mq.vhd
41
--!
42
--! \author
43
--!      Rob Doyle - doyle (at) cox (dot) net
44
--!
45
--------------------------------------------------------------------
46
--
47
--  Copyright (C) 2009, 2010, 2011, 2012 Rob Doyle
48
--
49
-- This source file may be used and distributed without
50
-- restriction provided that this copyright statement is not
51
-- removed from the file and that any derivative work contains
52
-- the original copyright notice and the associated disclaimer.
53
--
54
-- This source file is free software; you can redistribute it
55
-- and/or modify it under the terms of the GNU Lesser General
56
-- Public License as published by the Free Software Foundation;
57
-- version 2.1 of the License.
58
--
59
-- This source is distributed in the hope that it will be
60
-- useful, but WITHOUT ANY WARRANTY; without even the implied
61
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
62
-- PURPOSE. See the GNU Lesser General Public License for more
63
-- details.
64
--
65
-- You should have received a copy of the GNU Lesser General
66
-- Public License along with this source; if not, download it
67
-- from http://www.gnu.org/licenses/lgpl.txt
68
--
69
--------------------------------------------------------------------
70
--
71
-- Comments are formatted for doxygen
72
--
73
 
74
library ieee;                                   --! IEEE Library
75
use ieee.std_logic_1164.all;                    --! IEEE 1164
76
use ieee.numeric_std.all;                       --! IEEE Numeric Standard
77
use work.cpu_types.all;                         --! Types
78
 
79
--
80
--! CPU Multiplier Quotient (MQ) Register Entity
81
--
82
 
83
entity eMQ is port (
84
    sys   : in  sys_t;                          --! Clock/Reset
85
    mqOP  : in  mqop_t;                         --! MQ Operation
86
    AC    : in  data_t;                         --! AC Register
87
    MD    : in  data_t;                         --! MD Register
88
    EAE   : in  eae_t;                          --! EAE Register
89
    MQ    : out data_t                          --! MQ Output
90
);
91
end eMQ;
92
 
93
--
94
--! CPU Multiplier Quotient (MQ) Register RTL
95
--
96
 
97
architecture rtl of eMQ is
98
 
99
    signal mqREG   : data_t;                    --! Multiplier Quotient Register
100
    signal addMUX1 : data_t;                    --! Adder Multiplexer #1 input
101
    signal addMUX2 : data_t;                    --! Adder Multiplexer #2 input
102
    signal shl0    : data_t;                    --! MQ <- (MQ << 1) + 0
103
    signal shl1    : data_t;                    --! MQ <- (MQ << 1) + 1
104
    signal shr0    : data_t;                    --! MQ <- 0 & (MQ >> 1)
105
    signal shr1    : data_t;                    --! MQ <- 1 & (MQ >> 1)
106
    signal eael    : data_t;                    --! EAE (low word)
107
 
108
begin
109
 
110
    --
111
    -- Shifts and Rotates
112
    --
113
 
114
    shl0 <= mqREG(1 to 11) & '0';               -- SHL0 <= (MQ << 1) & '0'
115
    shl1 <= mqREG(1 to 11) & '1';               -- SHL1 <= (MQ << 1) & '1'
116
    shr0 <= '0' & mqREG(0 to 10);               -- SHR0 <= '0' & MQ(0 to 10)
117
    shr1 <= '1' & mqREG(0 to 10);               -- SHR1 <= '1' & MQ(0 to 10)
118
    eael <= EAE(13 to 24);                      -- EAEL <= EAE(13 to 24)
119
 
120
    --
121
    -- Adder input #1 mux.
122
    --
123
 
124
    with mqOP select
125
        addMUX1 <= o"0000" when mqopNOP,        -- MQ <- MQ
126
                   o"0000" when mqopCLR,        -- MQ <- "0000"
127
                   o"0000" when mqopSET,        -- MQ <- "7777"
128
                   o"0000" when mqopSHL0,       -- MQ <- (MQ << 1) & '0'
129
                   o"0000" when mqopSHL1,       -- MQ <- (MQ << 1) & '1'
130
                   o"0000" when mqopAC,         -- MQ <- AC
131
                   o"0000" when mqopMD,         -- MQ <- MD
132
                   MD      when mqopADDMD,      -- MQ <- MQ + MD
133
                   o"0001" when mqopACP1,       -- MQ <- AC + 1
134
                   o"0001" when mqopNEGAC,      -- MQ <- -AC
135
                   o"0000" when mqopEAE,        -- MQ <- EAE(13 to 24)
136
                   o"0000" when mqopSHR0,       -- MQ <- '0' & MQ(0 to 10)
137
                   o"0000" when mqopSHR1;       -- MQ <- '1' & MQ(0 to 10)
138
 
139
    --
140
    -- Adder input #2 mux.
141
    --
142
 
143
    with mqOP select
144
        addMUX2 <= mqREG   when mqopNOP,        -- MQ <- MQ
145
                   o"0000" when mqopCLR,        -- MQ <- "0000"
146
                   o"7777" when mqopSET,        -- MQ <- "7777"
147
                   shl0    when mqopSHL0,       -- MQ <- (MQ << 1) + 0
148
                   shl1    when mqopSHL1,       -- MQ <- (MQ << 1) + 1
149
                   AC      when mqopAC,         -- MQ <- AC
150
                   MD      when mqopMD,         -- MQ <- MD
151
                   mqREG   when mqopADDMD,      -- MQ <- MQ + MD
152
                   AC      when mqopACP1,       -- MQ <- AC + 1
153
                   not(AC) when mqopNEGAC,      -- MQ <- -AC
154
                   eael    when mqopEAE,        -- MQ <- EAE(13 to 24)
155
                   shr0    when mqopSHR0,       -- MQ <- '0' & MQ(0 to 10)
156
                   shr1    when mqopSHR1;       -- MQ <- '1' & MQ(0 to 10)
157
 
158
    --
159
    --! MQ Register
160
    --
161
 
162
    REG_MQ : process(sys)
163
    begin
164
        if sys.rst = '1' then
165
            mqREG <= o"0000";
166
        elsif rising_edge(sys.clk) then
167
            mqREG <= std_logic_vector(unsigned(addMUX2) + unsigned(addMUX1));
168
        end if;
169
    end process REG_MQ;
170
 
171
    MQ <= mqREG;
172
 
173
end rtl;

powered by: WebSVN 2.1.0

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