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

Subversion Repositories nanoblaze

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 fcorthay
--##############################################################################
2
--
3
--  aluAndRegs
4
--      ALU and registers
5
--
6
--      This describes the processor ALU, together with the register file.
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 aluAndRegs IS
30
  GENERIC(
31
    registerBitNb          : positive := 8;
32
    registerAddressBitNb   : positive := 4;
33
    aluCodeBitNb           : positive := 5;
34
    portAddressBitNb       : positive := 8;
35
    scratchpadAddressBitNb : natural  := 4
36
  );
37
  PORT(
38
    reset           : IN  std_ulogic;
39
    clock           : IN  std_ulogic;
40
    aluCode         : IN  std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
41
    addrA           : IN  unsigned(registerAddressBitNb-1 DOWNTO 0);
42
    addrB           : IN  unsigned(registerAddressBitNb-1 DOWNTO 0);
43
    instrData       : IN  signed(registerBitNb-1 DOWNTO 0);
44
    registerFileSel : IN  std_ulogic;
45
    instrDataSel    : IN  std_ulogic;
46
    portInSel       : IN  std_ulogic;
47
    scratchpadSel   : IN  std_ulogic;
48
    regWrite        : IN  std_ulogic;
49
    cIn             : IN  std_ulogic;
50
    cOut            : OUT std_ulogic;
51
    zero            : OUT std_ulogic;
52
    portAddr        : OUT unsigned(portAddressBitNb-1 DOWNTO 0);
53
    portOut         : OUT signed(registerBitNb-1 DOWNTO 0);
54
    portIn          : IN  signed(registerBitNb-1 DOWNTO 0);
55
    scratchpadAddr  : OUT unsigned(scratchpadAddressBitNb-1 DOWNTO 0);
56
    spadOut         : OUT signed(registerBitNb-1 DOWNTO 0);
57
    spadIn          : IN  signed(registerBitNb-1 DOWNTO 0)
58
  );
59
END aluAndRegs ;
60
 
61
--==============================================================================
62
 
63
ARCHITECTURE struct OF aluAndRegs IS
64
 
65
  SIGNAL aluOut         : signed(registerBitNb-1 DOWNTO 0);
66
  SIGNAL opA            : signed(registerBitNb-1 DOWNTO 0);
67
  SIGNAL opB            : signed(registerBitNb-1 DOWNTO 0);
68
  SIGNAL registerFileIn : signed(registerBitNb-1 DOWNTO 0);
69
 
70
 
71
  COMPONENT alu
72
    GENERIC (
73
      aluCodeBitNb : positive := 5;
74
      dataBitNb    : positive := 8
75
    );
76
    PORT (
77
      aluCode : IN  std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
78
      opA     : IN  signed(dataBitNb-1 DOWNTO 0);
79
      opB     : IN  signed(dataBitNb-1 DOWNTO 0);
80
      cIn     : IN  std_ulogic;
81
      aluOut  : OUT signed(dataBitNb-1 DOWNTO 0);
82
      cOut    : OUT std_ulogic;
83
      zero    : OUT std_ulogic
84
    );
85
  END COMPONENT;
86
 
87
  COMPONENT aluBOpSelector
88
    GENERIC (
89
      registerBitNb : positive := 8
90
    );
91
    PORT (
92
      instrData       : IN  signed(registerBitNb-1 DOWNTO 0);
93
      instrDataSel    : IN  std_ulogic;
94
      portIn          : IN  signed(registerBitNb-1 DOWNTO 0);
95
      portInSel       : IN  std_ulogic;
96
      registerFileIn  : IN  signed(registerBitNb-1 DOWNTO 0);
97
      registerFileSel : IN  std_ulogic;
98
      scratchpadSel   : IN  std_ulogic;
99
      spadIn          : IN  signed(registerBitNb-1 DOWNTO 0);
100
      opB             : OUT signed (registerBitNb-1 DOWNTO 0)
101
    );
102
  END COMPONENT;
103
 
104
  COMPONENT registerFile
105
    GENERIC (
106
      registerAddressBitNb : positive := 4;
107
      dataBitNb            : positive := 8
108
    );
109
    PORT (
110
      clock       : IN  std_ulogic;
111
      reset       : IN  std_ulogic;
112
      addrA       : IN  unsigned(registerAddressBitNb-1 DOWNTO 0);
113
      addrB       : IN  unsigned(registerAddressBitNb-1 DOWNTO 0);
114
      regWrite    : IN  std_ulogic;
115
      registersIn : IN  signed(dataBitNb-1 DOWNTO 0);
116
      opA         : OUT signed(dataBitNb-1 DOWNTO 0);
117
      opB         : OUT signed(dataBitNb-1 DOWNTO 0)
118
    );
119
  END COMPONENT;
120
 
121
BEGIN
122
  I_ALU : alu
123
    GENERIC MAP (
124
      aluCodeBitNb => aluCodeBitNb,
125
      dataBitNb    => registerBitNb
126
    )
127
    PORT MAP (
128
      aluCode => aluCode,
129
      opA     => opA,
130
      opB     => opB,
131
      cIn     => cIn,
132
      aluOut  => aluOut,
133
      cOut    => cOut,
134
      zero    => zero
135
    );
136
 
137
  I_bSel : aluBOpSelector
138
    GENERIC MAP (
139
      registerBitNb => registerBitNb
140
    )
141
    PORT MAP (
142
      instrData       => instrData,
143
      instrDataSel    => instrDataSel,
144
      portIn          => portIn,
145
      portInSel       => portInSel,
146
      registerFileIn  => registerFileIn,
147
      registerFileSel => registerFileSel,
148
      scratchpadSel   => scratchpadSel,
149
      spadIn          => spadIn,
150
      opB             => opB
151
    );
152
 
153
  I_regs : registerFile
154
    GENERIC MAP (
155
      registerAddressBitNb => registerAddressBitNb,
156
      dataBitNb            => registerBitNb
157
    )
158
    PORT MAP (
159
      clock       => clock,
160
      reset       => reset,
161
      addrA       => addrA,
162
      addrB       => addrB,
163
      regWrite    => regWrite,
164
      registersIn => aluOut,
165
      opA         => opA,
166
      opB         => registerFileIn
167
    );
168
 
169
  portAddr <= resize(unsigned(registerFileIn), portAddressBitNb);
170
  portOut <= opA;
171
  scratchpadAddr <= resize(unsigned(registerFileIn), scratchpadAddressBitNb);
172
  spadOut <= opA;
173
 
174
END ARCHITECTURE struct;

powered by: WebSVN 2.1.0

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