/* Copyright 2011 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef MATRIX_H #define MATRIX_H #include #include #if (MATRIX_COLS <= 8) typedef uint8_t matrix_row_t; #elif (MATRIX_COLS <= 16) typedef uint16_t matrix_row_t; #elif (MATRIX_COLS <= 32) typedef uint32_t matrix_row_t; #else #error "MATRIX_COLS: invalid value" #endif #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<
blob: d8dac68e37958ae79ab381a34512ec948286020c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module RAM_BLOCK_SDP(
	input PORT_R_CLK,
	input [9:0] PORT_R_ADDR,
	output reg [15:0] PORT_R_RD_DATA,
	input PORT_W_CLK,
	input PORT_W_WR_EN,
	input [9:0] PORT_W_ADDR,
	input [15:0] PORT_W_WR_DATA
);

parameter INIT = 0;
parameter PORT_R_WIDTH = 1;
parameter PORT_W_WIDTH = 1;
parameter PORT_R_CLK_POL = 0;
parameter PORT_W_CLK_POL = 0;

reg [2**10-1:0] mem = INIT;

always @(negedge (PORT_R_CLK ^ PORT_R_CLK_POL))
	PORT_R_RD_DATA <= mem[PORT_R_ADDR+:PORT_R_WIDTH];

always @(negedge (PORT_W_CLK ^ PORT_W_CLK_POL))
	if (PORT_W_WR_EN)
		mem[PORT_W_ADDR+:PORT_W_WIDTH] <= PORT_W_WR_DATA;

endmodule