URL
https://opencores.org/ocsvn/zet86/zet86/trunk
[/] [zet86/] [trunk/] [sim/] [memory.v] - Diff between revs 27 and 35
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 27 |
Rev 35 |
Line 1... |
Line 1... |
`timescale 1ns/10ps
|
`timescale 1ns/10ps
|
|
|
module memory (
|
module memory (
|
input clk,
|
// Wishbone slave interface
|
input [19:0] addr,
|
input wb_clk_i,
|
input [15:0] wr_data,
|
input wb_rst_i,
|
output [15:0] rd_data,
|
input [15:0] wb_dat_i,
|
input we,
|
output [15:0] wb_dat_o,
|
input byte_m
|
input [19:1] wb_adr_i,
|
|
input wb_we_i,
|
|
input [ 1:0] wb_sel_i,
|
|
input wb_stb_i,
|
|
input wb_cyc_i,
|
|
output wb_ack_o
|
);
|
);
|
|
|
// Registers and nets
|
// Registers and nets
|
wire [19:0] addr1;
|
reg [15:0] ram[2**19-1:0];
|
|
|
reg [7:0] ram[2**20-1:0];
|
wire we;
|
|
wire [7:0] bhw, blw;
|
|
|
// Assignments
|
// Assignments
|
assign rd_data = byte_m ? { {8{ram[addr][7]}}, ram[addr]}
|
assign wb_dat_o = ram[wb_adr_i];
|
: {ram[addr1], ram[addr]};
|
assign wb_ack_o = wb_stb_i;
|
assign addr1 = addr + 20'd1;
|
assign we = wb_we_i & wb_stb_i & wb_cyc_i;
|
|
|
|
assign bhw = wb_sel_i[1] ? wb_dat_i[15:8]
|
|
: ram[wb_adr_i][15:8];
|
|
assign blw = wb_sel_i[0] ? wb_dat_i[7:0]
|
|
: ram[wb_adr_i][7:0];
|
|
|
// Behaviour
|
// Behaviour
|
always @(posedge clk)
|
always @(posedge wb_clk_i)
|
if (we) if (byte_m) ram[addr] <= wr_data[7:0];
|
if (we) ram[wb_adr_i] <= { bhw, blw };
|
else { ram[addr1], ram[addr] } <= wr_data;
|
|
|
|
initial $readmemh("/home/zeus/zet/sim/data.rtlrom", ram, 20'hf0000);
|
initial $readmemh("/home/zeus/zet/sim/data.rtlrom",
|
|
ram, 19'h78000);
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.