2015-04-23 17:50:45 -04:00
|
|
|
/*
|
|
|
|
########################################################################
|
|
|
|
ELINK CONFIGURATION REGISTER FILE
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
*/
|
2015-06-30 13:32:05 +02:00
|
|
|
`include "elink_regmap.v"
|
2015-04-23 17:50:45 -04:00
|
|
|
|
2015-05-05 14:56:35 -04:00
|
|
|
module erx_cfg (/*AUTOARG*/
|
2015-04-23 17:50:45 -04:00
|
|
|
// Outputs
|
2015-04-24 17:38:01 -04:00
|
|
|
mi_dout, rx_enable, mmu_enable, remap_mode, remap_base,
|
2015-04-27 13:00:00 -04:00
|
|
|
remap_pattern, remap_sel, timer_cfg,
|
2015-04-23 17:50:45 -04:00
|
|
|
// Inputs
|
2015-05-01 17:58:16 -04:00
|
|
|
reset, clk, mi_en, mi_we, mi_addr, mi_din, gpio_datain, rx_status
|
2015-04-23 17:50:45 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/*Compile Time Parameters */
|
|
|
|
/******************************/
|
2015-05-01 17:58:16 -04:00
|
|
|
parameter RFAW = 6; // 32 registers for now
|
2015-04-23 23:11:58 -04:00
|
|
|
parameter GROUP = 4'h0;
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/*HARDWARE RESET (EXTERNAL) */
|
|
|
|
/******************************/
|
|
|
|
input reset; // ecfg registers reset only by "hard reset"
|
2015-04-29 11:55:01 -04:00
|
|
|
input clk;
|
2015-04-23 17:50:45 -04:00
|
|
|
/*****************************/
|
|
|
|
/*SIMPLE MEMORY INTERFACE */
|
|
|
|
/*****************************/
|
|
|
|
input mi_en;
|
|
|
|
input mi_we; // single we, must write 32 bit words
|
2015-05-01 17:58:16 -04:00
|
|
|
input [14:0] mi_addr; // complete physical address (no shifting!)
|
2015-04-23 17:50:45 -04:00
|
|
|
input [31:0] mi_din;
|
|
|
|
output [31:0] mi_dout;
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/*CONFIG SIGNALS */
|
|
|
|
/*****************************/
|
|
|
|
//rx
|
2015-05-01 17:58:16 -04:00
|
|
|
output rx_enable; // enable signal for rx
|
|
|
|
output mmu_enable; // enables MMU on rx path (static)
|
|
|
|
input [8:0] gpio_datain; // frame and data inputs (static)
|
|
|
|
input [15:0] rx_status; // etx status signals
|
|
|
|
output [1:0] remap_mode; // remap mode (static)
|
|
|
|
output [31:0] remap_base; // base for dynamic remap (static)
|
|
|
|
output [11:0] remap_pattern; // patter for static remap (static)
|
|
|
|
output [11:0] remap_sel; // selects for static remap (static)
|
|
|
|
output [1:0] timer_cfg; // timeout config (00=off) (static)
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
/*------------------------CODE BODY---------------------------------------*/
|
|
|
|
|
|
|
|
//registers
|
2015-04-24 17:38:01 -04:00
|
|
|
reg [31:0] ecfg_rx_reg;
|
2015-05-04 10:49:17 -04:00
|
|
|
reg [31:0] ecfg_offset_reg;
|
2015-05-01 17:58:16 -04:00
|
|
|
reg [8:0] ecfg_gpio_reg;
|
|
|
|
reg [2:0] ecfg_rx_status_reg;
|
2015-04-23 17:50:45 -04:00
|
|
|
reg [31:0] mi_dout;
|
|
|
|
|
|
|
|
//wires
|
|
|
|
wire ecfg_read;
|
|
|
|
wire ecfg_write;
|
|
|
|
wire ecfg_rx_write;
|
2015-04-24 17:38:01 -04:00
|
|
|
wire ecfg_base_write;
|
|
|
|
wire ecfg_remap_write;
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/*ADDRESS DECODE LOGIC */
|
|
|
|
/*****************************/
|
|
|
|
|
|
|
|
//read/write decode
|
2015-04-29 11:55:01 -04:00
|
|
|
assign ecfg_write = mi_en & mi_we;
|
|
|
|
assign ecfg_read = mi_en & ~mi_we;
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
//Config write enables
|
2015-05-01 17:58:16 -04:00
|
|
|
assign ecfg_rx_write = ecfg_write & (mi_addr[RFAW+1:2]==`ERX_CFG);
|
|
|
|
assign ecfg_base_write = ecfg_write & (mi_addr[RFAW+1:2]==`ERX_OFFSET);
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
//###########################
|
|
|
|
//# RXCFG
|
|
|
|
//###########################
|
2015-05-17 23:00:53 -04:00
|
|
|
always @ (posedge clk)
|
2015-04-23 17:50:45 -04:00
|
|
|
if(reset)
|
2015-04-24 17:38:01 -04:00
|
|
|
ecfg_rx_reg[31:0] <= 'b0;
|
2015-04-23 17:50:45 -04:00
|
|
|
else if (ecfg_rx_write)
|
2015-04-24 17:38:01 -04:00
|
|
|
ecfg_rx_reg[31:0] <= mi_din[31:0];
|
2015-04-23 17:50:45 -04:00
|
|
|
|
2015-04-28 00:45:16 -04:00
|
|
|
assign rx_enable = 1'b1;//is there any good reason turn RX off?
|
2015-04-24 17:38:01 -04:00
|
|
|
assign mmu_enable = ecfg_rx_reg[1];
|
|
|
|
assign remap_mode[1:0] = ecfg_rx_reg[3:2];
|
|
|
|
assign remap_sel[11:0] = ecfg_rx_reg[15:4];
|
|
|
|
assign remap_pattern[11:0] = ecfg_rx_reg[27:16];
|
2015-04-27 13:00:00 -04:00
|
|
|
assign timer_cfg[1:0] = ecfg_rx_reg[29:28];
|
|
|
|
|
2015-04-23 17:50:45 -04:00
|
|
|
//###########################
|
2015-05-01 17:58:16 -04:00
|
|
|
//# DATAIN
|
2015-04-23 17:50:45 -04:00
|
|
|
//###########################
|
2015-04-29 11:55:01 -04:00
|
|
|
always @ (posedge clk)
|
2015-05-01 17:58:16 -04:00
|
|
|
ecfg_gpio_reg[8:0] <= gpio_datain[8:0];
|
|
|
|
|
2015-04-23 17:50:45 -04:00
|
|
|
//###########################1
|
|
|
|
//# DEBUG
|
2015-05-01 17:58:16 -04:00
|
|
|
//###########################
|
2015-05-17 23:00:53 -04:00
|
|
|
always @ (posedge clk)
|
2015-04-23 17:50:45 -04:00
|
|
|
if(reset)
|
2015-05-04 17:13:51 -04:00
|
|
|
ecfg_rx_status_reg[2:0] <= 'b0;
|
2015-04-23 17:50:45 -04:00
|
|
|
else
|
2015-05-04 17:13:51 -04:00
|
|
|
ecfg_rx_status_reg[2:0] <= ecfg_rx_status_reg[2:0] | rx_status[2:0];
|
2015-04-24 17:38:01 -04:00
|
|
|
|
|
|
|
//###########################1
|
|
|
|
//# DYNAMIC REMAP BASE
|
|
|
|
//###########################
|
2015-05-04 17:13:51 -04:00
|
|
|
always @ (posedge clk)
|
|
|
|
if (ecfg_base_write)
|
|
|
|
ecfg_offset_reg[31:0] <= mi_din[31:0];
|
2015-04-24 17:38:01 -04:00
|
|
|
|
2015-05-04 10:49:17 -04:00
|
|
|
assign remap_base[31:0] = ecfg_offset_reg[31:0];
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
//###############################
|
|
|
|
//# DATA READBACK MUX
|
|
|
|
//###############################
|
|
|
|
|
|
|
|
//Pipelineing readback
|
2015-04-29 11:55:01 -04:00
|
|
|
always @ (posedge clk)
|
2015-04-23 17:50:45 -04:00
|
|
|
if(ecfg_read)
|
|
|
|
case(mi_addr[RFAW+1:2])
|
2015-05-01 17:58:16 -04:00
|
|
|
`ERX_CFG: mi_dout[31:0] <= {ecfg_rx_reg[31:0]};
|
|
|
|
`ERX_GPIO: mi_dout[31:0] <= {23'b0, ecfg_gpio_reg[8:0]};
|
|
|
|
`ERX_STATUS: mi_dout[31:0] <= {16'b0, rx_status[15:3],ecfg_rx_status_reg[2:0]};
|
2015-05-04 10:49:17 -04:00
|
|
|
`ERX_OFFSET: mi_dout[31:0] <= {ecfg_offset_reg[31:0]};
|
2015-05-01 17:58:16 -04:00
|
|
|
default: mi_dout[31:0] <= 32'd0;
|
2015-05-04 10:49:17 -04:00
|
|
|
endcase // case (mi_addr[RFAW+1:2])
|
|
|
|
else
|
|
|
|
mi_dout[31:0] <= 32'd0;
|
|
|
|
|
2015-04-29 11:55:01 -04:00
|
|
|
endmodule // ecfg_rx
|
2015-04-23 17:50:45 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Adapteva, Inc.
|
|
|
|
Contributed by Andreas Olofsson <andreas@adapteva.com>
|
|
|
|
|
|
|
|
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 3 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 (see the file
|
|
|
|
COPYING). If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|