Line 2... |
Line 2... |
//
|
//
|
// This file is part of the M32632 project
|
// This file is part of the M32632 project
|
// http://opencores.org/project,m32632
|
// http://opencores.org/project,m32632
|
//
|
//
|
// Filename: REGISTERS.v
|
// Filename: REGISTERS.v
|
// Version: 1.0
|
// Version: 2.0
|
// Date: 30 May 2015
|
// History: 1.0 first release of 30 Mai 2015
|
|
// Date: 14 August 2016
|
//
|
//
|
// Copyright (C) 2015 Udo Moeller
|
// Copyright (C) 2016 Udo Moeller
|
//
|
//
|
// This source file may be used and distributed without
|
// This source file may be used and distributed without
|
// restriction provided that this copyright statement is not
|
// restriction provided that this copyright statement is not
|
// removed from the file and that any derivative work contains
|
// removed from the file and that any derivative work contains
|
// the original copyright notice and the associated disclaimer.
|
// the original copyright notice and the associated disclaimer.
|
Line 273... |
Line 274... |
input [1:0] WMASKE;
|
input [1:0] WMASKE;
|
|
|
output [31:0] DOUT;
|
output [31:0] DOUT;
|
output reg SELI;
|
output reg SELI;
|
|
|
reg [2:0] MX;
|
reg [2:0] mx;
|
|
|
wire [3:0] BE;
|
wire [2:0] be;
|
wire eq_rw;
|
wire eq_rw;
|
|
|
// +++++++++++++++++++ Memories ++++++++++++++++++++
|
// +++++++++++++++++++ Memories ++++++++++++++++++++
|
|
|
reg [7:0] REGFILE_D [0:63];
|
reg [15:0] REGFILE_C [0:63]; // Byte 3 and 2 , Verilog allows no "Byte Write" in wider memories !!!
|
reg [7:0] REGFILE_C [0:63];
|
reg [7:0] REGFILE_B [0:63]; // Byte 1
|
reg [7:0] REGFILE_B [0:63];
|
reg [7:0] REGFILE_A [0:63]; // Byte 0
|
reg [7:0] REGFILE_A [0:63];
|
|
reg [31:0] RF;
|
reg [31:0] RF;
|
|
|
assign BE = {WMASKE[1],WMASKE[1],(WMASKE[1] | WMASKE[0]),1'b1};
|
assign be = {WMASKE[1],(WMASKE[1] | WMASKE[0]),1'b1};
|
|
|
assign eq_rw = ENWR & (RADR[5:0] == WADR);
|
assign eq_rw = ENWR & (RADR[5:0] == WADR);
|
|
|
always @(posedge BCLK) if (RADR[7]) MX[2:0] <= BE[2:0] & {{3{eq_rw}}};
|
always @(posedge BCLK) if (RADR[7]) mx[2:0] <= be[2:0] & {{3{eq_rw}}};
|
|
|
always @(posedge BCLK) if (RADR[7]) SELI <= RADR[6];
|
always @(posedge BCLK) if (RADR[7]) SELI <= RADR[6];
|
|
|
assign DOUT[31:16] = MX[2] ? BYDIN[31:16] : RF[31:16];
|
assign DOUT[31:16] = mx[2] ? BYDIN[31:16] : RF[31:16];
|
assign DOUT[15:8] = MX[1] ? BYDIN[15:8] : RF[15:8];
|
assign DOUT[15:8] = mx[1] ? BYDIN[15:8] : RF[15:8];
|
assign DOUT[7:0] = MX[0] ? BYDIN[7:0] : RF[7:0];
|
assign DOUT[7:0] = mx[0] ? BYDIN[7:0] : RF[7:0];
|
|
|
// ++++++++++++++++ Register File 64 * 32 Bits ++++++++++++
|
// ++++++++++++++++ Register File 64 * 32 Bits ++++++++++++
|
|
|
always @(posedge BCLK)
|
always @(posedge BCLK)
|
if (RADR[7])
|
if (RADR[7])
|
begin
|
begin
|
RF[31:24] <= REGFILE_D[RADR[5:0]];
|
RF[31:16] <= REGFILE_C[RADR[5:0]];
|
RF[23:16] <= REGFILE_C[RADR[5:0]];
|
|
RF[15:8] <= REGFILE_B[RADR[5:0]];
|
RF[15:8] <= REGFILE_B[RADR[5:0]];
|
RF[7:0] <= REGFILE_A[RADR[5:0]];
|
RF[7:0] <= REGFILE_A[RADR[5:0]];
|
end
|
end
|
|
|
always @(posedge BCLK)
|
always @(posedge BCLK)
|
if (DOWR)
|
if (DOWR)
|
begin
|
begin
|
if (BE[3]) REGFILE_D[WADR] <= DIN[31:24];
|
if (be[2]) REGFILE_C[WADR] <= DIN[31:16];
|
if (BE[2]) REGFILE_C[WADR] <= DIN[23:16];
|
if (be[1]) REGFILE_B[WADR] <= DIN[15:8];
|
if (BE[1]) REGFILE_B[WADR] <= DIN[15:8];
|
if (be[0]) REGFILE_A[WADR] <= DIN[7:0];
|
if (BE[0]) REGFILE_A[WADR] <= DIN[7:0];
|
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|