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

Subversion Repositories leros

[/] [leros/] [trunk/] [vhdl/] [core/] [leros_decode.vhd] - Blame information for rev 5

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

Line No. Rev Author Line
1 3 martin
--
2
--  Copyright 2011 Martin Schoeberl <masca@imm.dtu.dk>,
3
--                 Technical University of Denmark, DTU Informatics. 
4
--  All rights reserved.
5
--
6
-- Redistribution and use in source and binary forms, with or without
7
-- modification, are permitted provided that the following conditions are met:
8
-- 
9
--    1. Redistributions of source code must retain the above copyright notice,
10
--       this list of conditions and the following disclaimer.
11
-- 
12
--    2. Redistributions in binary form must reproduce the above copyright
13
--       notice, this list of conditions and the following disclaimer in the
14
--       documentation and/or other materials provided with the distribution.
15
-- 
16
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
17
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
-- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19
-- NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
-- 
27
-- The views and conclusions contained in the software and documentation are
28
-- those of the authors and should not be interpreted as representing official
29
-- policies, either expressed or implied, of the copyright holder.
30
-- 
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
use ieee.numeric_std.all;
35
 
36
use work.leros_types.all;
37
 
38
-- decode logic
39
 
40
entity leros_decode is
41
        port  (
42
                instr : in std_logic_vector(7 downto 0);
43
                dec : out decode_type
44
        );
45
end leros_decode;
46
 
47
architecture rtl of leros_decode is
48
 
49
begin
50
 
51
process(instr)
52
begin
53
        -- some defaults
54
        dec.op <= op_ld;
55
        dec.al_ena <= '0';
56
        dec.ah_ena <= '0';
57
        dec.log_add <= '0';
58
        dec.add_sub <= '0';
59
        dec.shr <= '0';
60
        dec.sel_imm <= '0';
61
        dec.store <= '0';
62
        dec.outp <= '0';
63
        dec.inp <= '0';
64
        -- used in decode, not in ex
65
        dec.br_op <= '0';
66
        dec.jal <= '0';
67
        dec.loadh <= '0';
68
        dec.indls<= '0';
69
 
70
        -- start decoding
71
        dec.add_sub <= instr(2);
72
        dec.sel_imm <= instr(0);
73
        -- bit 1 and 2 partially unused
74
        case instr(7 downto 3) is
75
                when "00000" =>         -- nop
76
                when "00001" =>         -- add, sub
77
                        dec.al_ena <= '1';
78
                        dec.ah_ena <= '1';
79
                        dec.log_add <= '1';
80
                when "00010" =>         -- shr
81
                        dec.al_ena <= '1';
82
                        dec.ah_ena <= '1';
83
                        dec.shr <= '1';
84
                when "00011" =>         -- reserved
85
                        null;
86
                when "00100" =>         -- alu
87
                        dec.al_ena <= '1';
88
                        dec.ah_ena <= '1';
89
                when "00101" =>         -- loadh
90
                        dec.loadh <= '1';
91
                        dec.ah_ena <= '1';
92
                when "00110" =>         -- store
93
                        dec.store <= '1';
94
                when "00111" =>         -- I/O
95
                        if instr(2)='0' then
96
                                dec.outp <= '1';
97
                        else
98
                                dec.al_ena <= '1';
99
                                dec.ah_ena <= '1';
100
                                dec.inp <= '1';
101
                        end if;
102
                when "01000" =>         -- jal
103
                        dec.jal <= '1';
104
                        dec.store <= '1';
105
                when "01001" =>         -- branch
106
                        dec.br_op <= '1';
107
                when "01010" =>         -- loadaddr
108
                        null;
109
                when "01100" =>         -- load indirect
110
                        dec.al_ena <= '1';
111
                        dec.ah_ena <= '1';
112
                        dec.indls <= '1';
113
                when "01110" =>         -- store indirect
114
                        dec.indls <= '1';
115
                        dec.store <= '1';
116
                when others =>
117
                        null;
118
        end case;
119
 
120
        case instr(2 downto 1) is
121
                when "00" =>
122
                        dec.op <= op_ld;
123
                when "01" =>
124
                        dec.op <= op_and;
125
                when "10" =>
126
                        dec.op <= op_or;
127
                when "11" =>
128
                        dec.op <= op_xor;
129
                when others =>
130
                        null;
131
        end case;
132
end process;
133
 
134
end rtl;

powered by: WebSVN 2.1.0

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