📄 regs.v
字号:
`define DEBUG_SHOWREADS
`define DEBUG_SHOWWRITES
module regs (clk, reset, we, re, bank, location, din, dout);
input clk;
input reset;
input we;
input re;
input [1:0] bank; // Bank 0,1,2,3
input [4:0] location; // Location
input [7:0] din; // Data Input
output [7:0] dout; // Data Output
reg [6:0] final_address;
// Instatiate memory model.
dram dram (
.clk (clk),
.address (final_address),
.we (we),
.din (din),
.dout (dout)
);
// remapped address
always @(bank or location) begin
casex ({bank, location})
7'b00_01XXX: final_address = {4'b0000, location[2:0]};
7'b01_01XXX: final_address = {4'b0000, location[2:0]};
7'b10_01XXX: final_address = {4'b0000, location[2:0]};
7'b11_01XXX: final_address = {4'b0000, location[2:0]};
// Bank #0
7'b00_10XXX: final_address = {4'b0001, location[2:0]};
7'b00_11XXX: final_address = {4'b0010, location[2:0]};
// Bank #1
7'b01_10XXX: final_address = {4'b0011, location[2:0]};
7'b01_11XXX: final_address = {4'b0100, location[2:0]};
// Bank #2
7'b10_10XXX: final_address = {4'b0101, location[2:0]};
7'b10_11XXX: final_address = {4'b0110, location[2:0]};
// Bank #3
7'b11_10XXX: final_address = {4'b0111, location[2:0]};
7'b11_11XXX: final_address = {4'b1000, location[2:0]};
default: final_address = {4'b0000, location[2:0]};
endcase
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -