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

Subversion Repositories tinyvliw8

[/] [tinyvliw8/] [trunk/] [src/] [vhdl/] [proc/] [instDecoder.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 steckol
-----------------------------------------------------------------
2
-- Project: Aeternitas
3
-- Author:  Oliver Stecklina <stecklina@ihp-microelectronics.com>
4
-- Date:    03.02.2014 
5
-- File:    instDecoder.vhd
6
-- Design:  AeternitasSWUR
7
-----------------------------------------------------------------
8
-- Description : This unit is the instruction set decoder of the
9
--               embedded 8-bit VLIW processor.
10
-----------------------------------------------------------------
11
-- $Log$
12
-----------------------------------------------------------------
13
 
14
library ieee;
15
 
16
use ieee.std_logic_1164.all;
17
use ieee.std_logic_arith.all;
18
 
19
entity vliwProc_instDecoder is
20
        port (
21
                clk        : in std_logic;
22
 
23
                instData   : in  std_logic_vector(31 downto 0);
24
 
25
                ldstOpCode : out std_logic;
26
                ldstAs     : out std_logic_vector(1 downto 0);
27
                ldstDstReg : out std_logic_vector(2 downto 0);
28
                ldstSrc    : out std_logic_vector(7 downto 0);
29
                ldstEn_n   : out std_logic;
30
 
31
                aluOpCode  : out std_logic_vector(2 downto 0);
32
                aluAs      : out std_logic_vector(1 downto 0);
33
                aluDstReg  : out std_logic_vector(2 downto 0);
34
                aluSrc     : out std_logic_vector(7 downto 0);
35
                aluEn_n    : out std_logic;
36
 
37
                jmpAs      : out std_logic_vector(1 downto 0);
38
                jmpDstReg  : out std_logic_vector(10 downto 0);
39
                jmpEn_n    : out std_logic;
40
 
41
                esb        : out std_logic_vector(3 downto 0);
42
 
43
                stalled_n  : out std_logic;
44
                stall_n    : in std_logic;
45
 
46
                rst_n      : in std_logic
47
        );
48
end vliwProc_instDecoder;
49
 
50
architecture behavior of vliwProc_instDecoder is
51
 
52
component gendelay
53
        generic (n: integer := 1);
54
        port (
55
                a_in    : in    std_logic;
56
                a_out   : out   std_logic
57
        );
58
end component;
59
 
60
        signal instWord0_s  : std_logic_vector(15 downto 0);
61
        signal instWord1_s  : std_logic_vector(15 downto 0);
62
 
63
        signal clk_s          : std_logic;
64
 
65
        signal esb_s           : std_logic_vector(3 downto 0);
66
 
67
        signal untSel0_n_s : std_logic_vector(2 downto 0);
68
        signal untSel1_n_s : std_logic_vector(2 downto 0);
69
 
70
        signal stalled_n_s : std_logic;
71
 
72
        signal ldstEn_n_s  : std_logic;
73
        signal aluEn_n_s   : std_logic;
74
        signal jmpEn_n_s   : std_logic;
75
 
76
        signal cnt_s      : std_logic_vector(1 downto 0);
77
begin
78
 
79
        clk_s     <= clk;
80
        stalled_n <= stalled_n_s;
81
 
82
        -- Note! use cnt_s instead of esb to be faster than esb
83
        --    otherwise we get a glitch on esb(0) in case of stall
84
        sync_Stall: process(rst_n, cnt_s(0))
85
        begin
86
                if (rst_n = '0') then
87
                        stalled_n_s <= '1';
88
                else
89
                        if (cnt_s(0)'event and cnt_s(0) = '1') then
90
                                stalled_n_s <= stall_n;
91
                        end if;
92
                end if;
93
        end process;
94
 
95
        ldstEn_n <= ldstEn_n_s;
96
        jmpEn_n <= jmpEn_n_s;
97
        aluEn_n <= aluEn_n_s;
98
 
99
        genState_p : process(rst_n, clk_s)
100
        begin
101
                if (rst_n = '0') then
102
                        cnt_s <= "01";
103
                else
104
                        if (clk_s'event and clk_s = '0') then
105
                                cnt_s(1) <= not(cnt_s(1));
106
                        end if;
107
 
108
                        if (clk_s'event and clk_s = '1') then
109
                                cnt_s(0) <= not(cnt_s(0));
110
                        end if;
111
                end if;
112
        end process;
113
 
114
        -- execution state bus
115
        esb_s <= "0001" when rst_n = '1' and cnt_s = "01" else
116
                 "0010" when rst_n = '1' and cnt_s = "11" else
117
                 "0100" when rst_n = '1' and cnt_s = "10" else
118
                 "1000" when rst_n = '1' and cnt_s = "00" else
119
                 "0000";
120
 
121
        esb <= esb_s when stalled_n_s = '1' else
122
               (others => '0');
123
 
124
        untSel1_n_s <= "111" when instWord0_s(15 downto 13) = instWord1_s(15 downto 13) else
125
                       "110" when instWord1_s(15 downto 13) = "111" else
126
                                   "101" when instWord1_s(15 downto 13) = "000" or instWord1_s(15 downto 13) = "001" else
127
                                   "011";
128
 
129
        untSel0_n_s <= "110" when instWord0_s(15 downto 13) = "111" else
130
                                   "101" when instWord0_s(15 downto 13) = "000" or instWord0_s(15 downto 13) = "001" else
131
                                   "011";
132
 
133
 
134
        jmpEn_n_s  <= '0' when (untSel0_n_s(0) = '0' or untSel1_n_s(0) = '0') and cnt_s(1) = '1' else
135
                      '1';
136
        ldstEn_n_s <= '0' when (untSel0_n_s(1) = '0' or untSel1_n_s(1) = '0') and cnt_s(1) = '1' else
137
                      '1';
138
        aluEn_n_s  <= '0' when (untSel0_n_s(2) = '0' or untSel1_n_s(2) = '0') and cnt_s(1) = '1' else
139
                      '1';
140
 
141
        instWord0_s <= instData(31 downto 16);
142
        instWord1_s <= instData(15 downto 0);
143
 
144
        aluOpCode  <= instWord0_s(15 downto 13)  when untSel0_n_s(2) = '0' else
145
                      instWord1_s(15 downto 13)  when untSel1_n_s(2) = '0' else
146
                      (others => '0');
147
        aluAs      <= instWord0_s(12 downto 11) when untSel0_n_s(2) = '0' else
148
                      instWord1_s(12 downto 11) when untSel1_n_s(2) = '0' else
149
                      (others => '0');
150
        aluDstReg  <= instWord0_s(10 downto 8)  when untSel0_n_s(2) = '0' else
151
                      instWord1_s(10 downto 8)  when untSel1_n_s(2) = '0' else
152
                      (others => '0');
153
        aluSrc     <= instWord0_s(7 downto 0)   when untSel0_n_s(2) = '0' else
154
                      instWord1_s(7 downto 0)   when untSel1_n_s(2) = '0' else
155
                      (others => '0');
156
 
157
        ldstOpCode  <= instWord0_s(13)           when untSel0_n_s(1) = '0' else
158
                       instWord1_s(13)           when untSel1_n_s(1) = '0' else
159
                       '0';
160
        ldstAs      <= instWord0_s(12 downto 11) when untSel0_n_s(1) = '0' else
161
                       instWord1_s(12 downto 11) when untSel1_n_s(1) = '0' else
162
                       (others => '0');
163
        ldstDstReg  <= instWord0_s(10 downto 8)  when untSel0_n_s(1) = '0' else
164
                       instWord1_s(10 downto 8)  when untSel1_n_s(1) = '0' else
165
                       (others => '0');
166
        ldstSrc     <= instWord0_s(7 downto 0)   when untSel0_n_s(1) = '0' else
167
                       instWord1_s(7 downto 0)   when untSel1_n_s(1) = '0' else
168
                       (others => '0');
169
 
170
        jmpAs      <= instWord0_s(12 downto 11) when untSel0_n_s(0) = '0' else
171
                      instWord1_s(12 downto 11) when untSel1_n_s(0) = '0' else
172
                      (others => '0');
173
        jmpDstReg  <= instWord0_s(10 downto 0)  when untSel0_n_s(0) = '0' else
174
                      instWord1_s(10 downto 0)  when untSel1_n_s(0) = '0' else
175
                      (others => '0');
176
 
177
end behavior;

powered by: WebSVN 2.1.0

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