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

Subversion Repositories nanoblaze

[/] [nanoblaze/] [trunk/] [Circuit/] [instructionDecoder.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 fcorthay
--##############################################################################
2
--
3
--  InstructionDecoder
4
--      Instriction decoder
5
--
6
--      Provides different parts of the instruction word to differnent blocks.
7
--
8
--------------------------------------------------------------------------------
9
--
10
--  Versions / Authors
11
--      1.0 Francois Corthay    first implementation
12
--
13
--  Provided under GNU LGPL licence: <http://www.gnu.org/copyleft/lesser.html>
14
--
15
--  by the electronics group of "HES-SO//Valais Wallis", in Switzerland:
16
--  <http://www.hevs.ch/en/rad-instituts/institut-systemes-industriels/>.
17
--
18
--------------------------------------------------------------------------------
19
--
20
--  Hierarchy
21
--      Used by "nanoblaze/nanoProcessor".
22
--
23
--##############################################################################
24
 
25
LIBRARY ieee;
26
  USE ieee.std_logic_1164.all;
27
  USE ieee.numeric_std.all;
28
 
29
ENTITY instructionDecoder IS
30
  GENERIC(
31
    registerBitNb        : positive := 8;
32
    registerAddressBitNb : positive := 4;
33
    aluCodeBitNb         : positive := 5;
34
    instructionBitNb     : positive := 18;
35
    programCounterBitNb  : positive := 10;
36
    opCodeBitNb          : positive := 5;
37
    branchCondBitNb      : positive := 3;
38
    intCodeBitNb         : positive := 5;
39
    spadAddressBitNb     : natural  := 4;
40
    portAddressBitNb     : positive := 8
41
  );
42
  PORT(
43
    instruction    : IN  std_ulogic_vector(instructionBitNb-1 DOWNTO 0);
44
    aluCode        : OUT std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
45
    addrA          : OUT unsigned(registerAddressBitNb-1 DOWNTO 0);
46
    addrB          : OUT unsigned(registerAddressBitNb-1 DOWNTO 0);
47
    instrData      : OUT signed(registerBitNb-1 DOWNTO 0);
48
    instrAddress   : OUT unsigned(programCounterBitNb-1 DOWNTO 0);
49
    opCode         : OUT std_ulogic_vector(opCodeBitNb-1 DOWNTO 0);
50
    twoRegInstr    : OUT std_ulogic;
51
    branchCond     : OUT std_ulogic_vector(branchCondBitNb-1 DOWNTO 0);
52
    intCode        : OUT std_ulogic_vector(intCodeBitNb-1 DOWNTO 0);
53
    portIndexedSel : OUT std_ulogic;
54
    portAddress    : OUT unsigned(portAddressBitNb-1 DOWNTO 0);
55
    spadIndexedSel : OUT std_ulogic;
56
    spadAddress    : OUT unsigned(spadAddressBitNb-1 DOWNTO 0)
57
  );
58
END instructionDecoder ;
59
 
60
--==============================================================================
61
 
62
ARCHITECTURE RTL OF instructionDecoder IS
63
 
64
  constant opCodeIndexH         : integer := instruction'high;
65
  constant opCodeIndexL         : integer := opCodeIndexH - opCodeBitNb + 1;
66
 
67
  constant twoRegInstrIndex     : integer := opCodeIndexL - 1;
68
  constant ioAddrIndexed        : integer := twoRegInstrIndex;
69
 
70
  constant addrAIndexH          : integer := twoRegInstrIndex - 1;
71
  constant addrAIndexL          : integer := addrAIndexH - registerAddressBitNb + 1;
72
 
73
  constant immediateDataIndexH  : integer := registerBitNb-1;
74
  constant immediateDataIndexL  : integer := 0;
75
  constant addrBIndexH          : integer := addrAIndexL - 1;
76
  constant addrBIndexL          : integer := addrBIndexH - registerAddressBitNb + 1;
77
 
78
  constant aluCodeIndexH        : integer := opCodeIndexH;
79
  constant aluCodeIndexL        : integer := aluCodeIndexH - aluCodeBitNb + 1;
80
 
81
  constant portAddressH         : integer := registerBitNb-1;
82
  constant portAddressL         : integer := portAddressH-portAddressBitNb+1;
83
  constant spadAddressH         : integer := registerBitNb-1;
84
  constant spadAddressL         : integer := spadAddressH-spadAddressBitNb+1;
85
 
86
  constant branchCondH          : integer := opCodeIndexL-1;
87
  constant branchCondL          : integer := branchCondH-branchCondBitNb+1;
88
 
89
BEGIN
90
  ------------------------------------------------------------------------------
91
                                                                  -- ALU control
92
  aluCode <=
93
    instruction(aluCodeIndexH downto aluCodeIndexL)
94
      when instruction(aluCodeIndexH) = '0' else
95
    '1' & instruction(aluCodeBitNb-2 downto 0);
96
  opCode <= instruction(opCodeIndexH downto opCodeIndexL);
97
  twoRegInstr <= instruction(twoRegInstrIndex);
98
  addrA <= unsigned(instruction(addrAIndexH downto addrAIndexL));
99
  addrB <= unsigned(instruction(addrBIndexH downto addrBIndexL));
100
  instrData <= signed(instruction(immediateDataIndexH downto immediateDataIndexL));
101
 
102
  ------------------------------------------------------------------------------
103
                                                                  -- I/O control
104
  portIndexedSel <= instruction(ioAddrIndexed);
105
  portAddress <= unsigned(instruction(portAddressH downto portAddressL));
106
 
107
  ------------------------------------------------------------------------------
108
                                                           -- scratchpad control
109
  spadIndexedSel <= instruction(ioAddrIndexed);
110
  spadAddress <= unsigned(instruction(spadAddressH downto spadAddressL));
111
 
112
  ------------------------------------------------------------------------------
113
                                                               -- branch control
114
  branchCond <= instruction(branchCondH downto branchCondL);
115
  instrAddress <= unsigned(instruction(instrAddress'range));
116
 
117
END ARCHITECTURE RTL;

powered by: WebSVN 2.1.0

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