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

Subversion Repositories Aquarius

[/] [Aquarius/] [trunk/] [verilog/] [register.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 thorn_aitc
//======================================================
2
// Aquarius Project
3
//    SuperH-2 ISA Compatible RISC CPU
4
//------------------------------------------------------
5
// Module      : General Registers in Data Path Unit
6
//------------------------------------------------------
7
// File        : register.v
8
// Library     : none
9
// Description : General Registers in Data Path.
10
// Simulator   : Icarus Verilog (Cygwin)
11
// Synthesizer : Xilinx XST (Windows XP)
12
// Author      : Thorn Aitch
13
//------------------------------------------------------
14
// Revision Number : 1
15
// Date of Change  : 22nd February 2003
16
// Creator         : Thorn Aitch
17
// Description     : Initial Design                               
18
//------------------------------------------------------
19
// Revision Number : 2
20
// Date of Change  : 30th April 2003
21
// Modifier        : Thorn Aitch
22
// Description     : Release Version 1.0
23
//======================================================
24
// Copyright (C) 2002-2003, Thorn Aitch
25
//
26
// Designs can be altered while keeping list of
27
// modifications "the same as in GNU" No money can
28
// be earned by selling the designs themselves, but
29
// anyone can get money by selling the implementation
30
// of the design, such as ICs based on some cores, 
31
// boards based on some schematics or Layouts, and
32
// even GUI interfaces to text mode drivers.
33
// "The same as GPL SW" Any update to the design
34
// should be documented and returned to the design. 
35
// Any derivative work based on the IP should be free
36
// under OpenIP License. Derivative work means any
37
// update, change or improvement on the design. 
38
// Any work based on the design can be either made
39
// free under OpenIP license or protected by any other
40
// license. Work based on the design means any work uses
41
// the OpenIP Licensed core as a building black without
42
// changing anything on it with any other blocks to
43
// produce larger design.  There is NO WARRANTY on the
44
// functionality or performance of the design on the
45
// real hardware implementation.
46
// On the other hand, the SuperH-2 ISA (Instruction Set
47
// Architecture) executed by Aquarius is rigidly
48
// the property of Renesas Corp. Then you have all 
49
// responsibility to judge if there are not any 
50
// infringements to Renesas's rights regarding your 
51
// Aquarius adoption into your design. 
52
// By adopting Aquarius, the user assumes all 
53
// responsibility for its use.
54
// This project may cause any damages around you, for 
55
// example, loss of properties, data, money, profits,
56
// life, or business etc. By adopting this source, 
57
// the user assumes all responsibility for its use.
58
//======================================================
59
 
60
`include "timescale.v"
61
`include "defines.v"
62
 
63
//*************************************************
64
// Module Definition
65
//*************************************************
66
module register(
67
    // system signal
68
    CLK, SLOT,
69
    // general register strobe and the number
70
    WRREG_Z,  WRREG_W,
71
    REGNUM_X, REGNUM_Y, REGNUM_Z, REGNUM_W,
72
    // input & outout
73
    REG_X, REG_Y, REG_0, ZBUS, WBUS
74
    );
75
 
76
//-------------------
77
// Module I/O Signals
78
//-------------------
79
    input  CLK;            // clock
80
    input  SLOT;           // cpu pipe slot
81
 
82
    input  WRREG_Z;        // write Rn from Z-bus
83
    input  WRREG_W;        // write Rn from W-bus
84
 
85
    input [3:0] REGNUM_X;  // register number to read to X-bus
86
    input [3:0] REGNUM_Y;  // register number to read to Y-bus
87
    input [3:0] REGNUM_Z;  // register number to write from Z-bus
88
    input [3:0] REGNUM_W;  // register number to write from W-bus
89
 
90
    output [31:0] REG_X;   // register output to X-BUS
91
    output [31:0] REG_Y;   // register output to Y-BUS
92
    output [31:0] REG_0;   // R0 value
93
    input  [31:0] ZBUS;    // Z-BUS
94
    input  [31:0] WBUS;    // W-BUS
95
 
96
//-----------------
97
// Internal Signals
98
//-----------------
99
    reg  [31:0] REG[0:15]; // General Register
100
    wire [31:0] REG_X;     // register out toward X
101
    wire [31:0] REG_Y;     // register out toward Y
102
    wire [31:0] REG_0;     // R0 value
103
 
104
//-----------------
105
// General Register
106
//-----------------
107
    always @(posedge CLK)
108
    begin
109
        if (SLOT)
110
        begin
111
            //if (WRREG_Z & WRREG_W)     //WBUS has the higher priority than ZBUS.
112
            //    REG[REGNUM_W] <= WBUS;
113
            // WRREG_W  WRREG_Z REGNUM_W==REGNUM_Z : Operation
114
            // 0        0       *                  : No operation
115
            // 1        0       *                  : REG[REGNUM_W] <= WBUS;
116
            // 0        1       *                  : REG[REGNUM_Z] <= ZBUS;
117
            // 1        1       0                  : REG[REGNUM_W] <= WBUS; REG[REGNUM_Z] <= ZBUS;
118
            // 1        1       1                  : REG[REGNUM_Z] <= ZBUS;
119
                 if ( (WRREG_W) & ~(WRREG_Z))
120
                     REG[REGNUM_W] <= WBUS;
121
            else if (~(WRREG_W) &  (WRREG_Z))
122
                    REG[REGNUM_Z] <= ZBUS;
123
            else if ( (WRREG_W) &  (WRREG_Z) & ~(REGNUM_W==REGNUM_Z))
124
                begin
125
                    REG[REGNUM_W] <= WBUS;
126
                    REG[REGNUM_Z] <= ZBUS;
127
                end
128
            else if ( (WRREG_W) &  (WRREG_Z) &  (REGNUM_W==REGNUM_Z))
129
                    REG[REGNUM_Z] <= ZBUS;
130
        end
131
    end
132
 
133
    assign REG_X[31:0] = REG[REGNUM_X];
134
    assign REG_Y[31:0] = REG[REGNUM_Y];
135
    assign REG_0[31:0] = REG[4'h0];
136
 
137
//======================================================
138
  endmodule
139
//======================================================

powered by: WebSVN 2.1.0

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