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

Subversion Repositories nanoblaze

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

Go to most recent revision | 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
 
59
END instructionDecoder ;
60
 
61
--==============================================================================
62
 
63
ARCHITECTURE RTL OF instructionDecoder IS
64
 
65
  constant opCodeIndexH         : integer := instruction'high;
66
  constant opCodeIndexL         : integer := opCodeIndexH - opCodeBitNb + 1;
67
 
68
  constant twoRegInstrIndex     : integer := opCodeIndexL - 1;
69
  constant ioAddrIndexed        : integer := twoRegInstrIndex;
70
 
71
  constant addrAIndexH          : integer := twoRegInstrIndex - 1;
72
  constant addrAIndexL          : integer := addrAIndexH - registerAddressBitNb + 1;
73
 
74
  constant immediateDataIndexH  : integer := registerBitNb-1;
75
  constant immediateDataIndexL  : integer := 0;
76
  constant addrBIndexH          : integer := addrAIndexL - 1;
77
  constant addrBIndexL          : integer := addrBIndexH - registerAddressBitNb + 1;
78
 
79
  constant aluCodeIndexH        : integer := opCodeIndexH;
80
  constant aluCodeIndexL        : integer := aluCodeIndexH - aluCodeBitNb + 1;
81
 
82
  constant portAddressH         : integer := registerBitNb-1;
83
  constant portAddressL         : integer := portAddressH-portAddressBitNb+1;
84
  constant spadAddressH         : integer := registerBitNb-1;
85
  constant spadAddressL         : integer := spadAddressH-spadAddressBitNb+1;
86
 
87
  constant branchCondH          : integer := opCodeIndexL-1;
88
  constant branchCondL          : integer := branchCondH-branchCondBitNb+1;
89
 
90
BEGIN
91
  ------------------------------------------------------------------------------
92
                                                                  -- ALU control
93
  aluCode <=
94
    instruction(aluCodeIndexH downto aluCodeIndexL)
95
      when instruction(aluCodeIndexH) = '0' else
96
    '1' & instruction(aluCodeBitNb-2 downto 0);
97
  opCode <= instruction(opCodeIndexH downto opCodeIndexL);
98
  twoRegInstr <= instruction(twoRegInstrIndex);
99
  addrA <= unsigned(instruction(addrAIndexH downto addrAIndexL));
100
  addrB <= unsigned(instruction(addrBIndexH downto addrBIndexL));
101
  instrData <= signed(instruction(immediateDataIndexH downto immediateDataIndexL));
102
 
103
  ------------------------------------------------------------------------------
104
                                                                  -- I/O control
105
  portIndexedSel <= instruction(ioAddrIndexed);
106
  portAddress <= unsigned(instruction(portAddressH downto portAddressL));
107
 
108
  ------------------------------------------------------------------------------
109
                                                           -- scratchpad control
110
  spadIndexedSel <= instruction(ioAddrIndexed);
111
  spadAddress <= unsigned(instruction(spadAddressH downto spadAddressL));
112
 
113
  ------------------------------------------------------------------------------
114
                                                               -- branch control
115
  branchCond <= instruction(branchCondH downto branchCondL);
116
  instrAddress <= unsigned(instruction(instrAddress'range));
117
 
118
END ARCHITECTURE RTL;

powered by: WebSVN 2.1.0

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