`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
// IBM 650 Reconstruction in Verilog (i650)
|
// IBM 650 Reconstruction in Verilog (i650)
|
//
|
//
|
// This file is part of the IBM 650 Reconstruction in Verilog (i650) project
|
// This file is part of the IBM 650 Reconstruction in Verilog (i650) project
|
// http:////www.opencores.org/project,i650
|
// http:////www.opencores.org/project,i650
|
//
|
//
|
// Description: General storage.
|
// Description: General storage.
|
//
|
//
|
// Additional Comments: Drum storage is implemented as an array of 24000 5-bit
|
// Additional Comments: Drum storage is implemented as an array of 24000 5-bit
|
// digits. An array address is formed by decoding the static portion of the
|
// digits. An array address is formed by decoding the static portion of the
|
// bi-quinary address into an origin (a multiple of 600), then adding the
|
// bi-quinary address into an origin (a multiple of 600), then adding the
|
// dynamic portion of the address (range 0..599).
|
// dynamic portion of the address (range 0..599).
|
//
|
//
|
// Copyright (c) 2015 Robert Abeles
|
// Copyright (c) 2015 Robert Abeles
|
//
|
//
|
// This source file is free software; you can redistribute it
|
// This source file is free software; you can redistribute it
|
// and/or modify it under the terms of the GNU Lesser General
|
// and/or modify it under the terms of the GNU Lesser General
|
// Public License as published by the Free Software Foundation;
|
// Public License as published by the Free Software Foundation;
|
// either version 2.1 of the License, or (at your option) any
|
// either version 2.1 of the License, or (at your option) any
|
// later version.
|
// later version.
|
//
|
//
|
// This source is distributed in the hope that it will be
|
// This source is distributed in the hope that it will be
|
// useful, but WITHOUT ANY WARRANTY; without even the implied
|
// useful, but WITHOUT ANY WARRANTY; without even the implied
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
// PURPOSE. See the GNU Lesser General Public License for more
|
// PURPOSE. See the GNU Lesser General Public License for more
|
// details.
|
// details.
|
//
|
//
|
// You should have received a copy of the GNU Lesser General
|
// You should have received a copy of the GNU Lesser General
|
// Public License along with this source; if not, download it
|
// Public License along with this source; if not, download it
|
// from http://www.opencores.org/lgpl.shtml
|
// from http://www.opencores.org/lgpl.shtml
|
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
`include "defines.v"
|
`include "defines.v"
|
|
|
module gen_store (
|
module gen_store (
|
input rst,
|
input rst,
|
input ap, dp,
|
input ap, dp,
|
input write_gate,
|
input write_gate,
|
input [0:6] addr_th, addr_h, addr_t,
|
input [0:6] addr_th, addr_h, addr_t,
|
input [0:9] dynamic_addr,
|
input [0:9] dynamic_addr,
|
input [0:4] gs_in,
|
input [0:4] gs_in,
|
input [0:14] console_ram_addr,
|
input [0:14] console_ram_addr,
|
input console_read_gs, console_write_gs,
|
input console_read_gs, console_write_gs,
|
output reg[0:4] gs_out,
|
output reg[0:4] gs_out,
|
output double_write, no_write
|
output double_write, no_write
|
);
|
);
|
|
|
reg [0:4] gs_mem [0:32767]; // Rounded size up from 24000 to next 2^n.
|
reg [0:4] gs_mem [0:32767]; // Rounded size up from 24000 to next 2^n.
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// Calculate the early (next digit) and on-time RAM addresses. Console read
|
// Calculate the early (next digit) and on-time RAM addresses. Console read
|
// and write are implementation extensions.
|
// and write are implementation extensions.
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
wire [0:14] band_addr, gs_addr, gs_addr_early;
|
wire [0:14] band_addr, gs_addr, gs_addr_early;
|
ram_band_addr rba(addr_th, addr_h, addr_t, band_addr);
|
ram_band_addr rba(addr_th, addr_h, addr_t, band_addr);
|
wire console_acc = console_read_gs | console_write_gs;
|
wire console_acc = console_read_gs | console_write_gs;
|
assign gs_addr = console_acc? console_ram_addr : (band_addr + dynamic_addr);
|
assign gs_addr = console_acc? console_ram_addr : (band_addr + dynamic_addr);
|
// The % operator fixes a spurious warning from XST synthesis due to use of a
|
// The % operator fixes a spurious warning from XST synthesis due to use of a
|
// 32-bit mux for ? operator. Uses no gates.
|
// 32-bit mux for ? operator. Uses no gates.
|
assign gs_addr_early = (console_acc? console_ram_addr
|
assign gs_addr_early = (console_acc? console_ram_addr
|
: (band_addr + ((dynamic_addr + 1) % 600))) % 32768;
|
: (band_addr + ((dynamic_addr + 1) % 600))) % 32768;
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// These 650 write errors are not possible for this implementation.
|
// These 650 write errors are not possible for this implementation.
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
assign double_write = 0;
|
assign double_write = 0;
|
assign no_write = 0;
|
assign no_write = 0;
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// A : Read from RAM at on-time address.
|
// A : Read from RAM at on-time address.
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
always @(posedge ap) begin
|
always @(posedge ap)
|
if (rst) begin
|
if (rst) begin
|
gs_out <= `biq_blank;
|
gs_out <= `biq_blank;
|
end else begin
|
end else begin
|
gs_out <= gs_mem[gs_addr];
|
gs_out <= gs_mem[gs_addr];
|
end
|
|
end;
|
end;
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// D : Write to RAM at early address.
|
// D : Write to RAM at early address.
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
always @(posedge dp) begin
|
always @(posedge dp)
|
if (write_gate)
|
if (write_gate)
|
gs_mem[gs_addr_early] <= gs_in;
|
gs_mem[gs_addr_early] <= gs_in;
|
end;
|
|
|
|
endmodule
|
endmodule
|
|
|