mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-17 20:02:53 +08:00
Splitting register file (rx,tx,base)
The goal is to have 100% independence in RX and TX pipes
This commit is contained in:
parent
0d10fbd26f
commit
1e1644138e
142
elink/hdl/ecfg_if.v
Normal file
142
elink/hdl/ecfg_if.v
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
########################################################################
|
||||
ELINK CONFIGURATION INTERFACE
|
||||
########################################################################
|
||||
|
||||
*/
|
||||
|
||||
module ecfg_if (/*AUTOARG*/
|
||||
// Outputs
|
||||
rxrr_access, rxrr_packet, mi_clk, mi_en, mi_we, mi_addr, mi_din,
|
||||
// Inputs
|
||||
txwr_clk, txwr_access, txwr_packet, txrd_access, txrd_packet,
|
||||
rxrr_clk, mi_ba_cfg_dout, mi_rx_cfg_dout, mi_rx_edma_dout,
|
||||
mi_rx_emmu_dout, mi_rx_mailbox_dout, mi_tx_cfg_dout,
|
||||
mi_tx_emmu_dout
|
||||
);
|
||||
|
||||
parameter [11:0] ELINKID = 12'h810;
|
||||
parameter DW = 32;
|
||||
parameter AW = 32;
|
||||
parameter PW = 104;
|
||||
|
||||
/******************************/
|
||||
/*Host Write Interface */
|
||||
/******************************/
|
||||
input txwr_clk; //write clock used as mi_clk
|
||||
input txwr_access;
|
||||
input [PW-1:0] txwr_packet;
|
||||
|
||||
/******************************/
|
||||
/*Host Write Interface */
|
||||
/******************************/
|
||||
input txrd_access;
|
||||
input [PW-1:0] txrd_packet;
|
||||
|
||||
/******************************/
|
||||
/*Host Write Interface */
|
||||
/******************************/
|
||||
input rxrr_clk;
|
||||
output rxrr_access;
|
||||
output [PW-1:0] rxrr_packet;
|
||||
|
||||
/******************************/
|
||||
/*Register Interface */
|
||||
/******************************/
|
||||
output mi_clk;
|
||||
output mi_en;
|
||||
output mi_we;
|
||||
output [19:0] mi_addr;
|
||||
output [31:0] mi_din;
|
||||
|
||||
/******************************/
|
||||
/*Readback Data */
|
||||
/******************************/
|
||||
|
||||
//base
|
||||
input [31:0] mi_ba_cfg_dout;
|
||||
//rx
|
||||
input [DW-1:0] mi_rx_cfg_dout;
|
||||
input [DW-1:0] mi_rx_edma_dout;
|
||||
input [DW-1:0] mi_rx_emmu_dout;
|
||||
input [DW-1:0] mi_rx_mailbox_dout;
|
||||
//tx
|
||||
input [DW-1:0] mi_tx_cfg_dout;
|
||||
input [DW-1:0] mi_tx_emmu_dout;
|
||||
|
||||
//wires
|
||||
|
||||
wire [DW-1:0] txwr_data;
|
||||
wire [AW-1:0] txwr_dstaddr;
|
||||
wire [AW-1:0] txwr_srcaddr;
|
||||
wire [AW-1:0] txrd_dstaddr;
|
||||
wire [AW-1:0] txrd_srcaddr;
|
||||
|
||||
|
||||
|
||||
wire mi_wr;
|
||||
wire mi_rd;
|
||||
|
||||
|
||||
//splicing packets
|
||||
packet2emesh p2e_wr(.access_out (),
|
||||
.write_out (),
|
||||
.datamode_out (),
|
||||
.ctrlmode_out (),
|
||||
.dstaddr_out (txwr_dstaddr[AW-1:0]),
|
||||
.data_out (txwr_data[DW-1:0]),
|
||||
.srcaddr_out (),
|
||||
.packet_in (txwr_packet[PW-1:0])
|
||||
);
|
||||
|
||||
packet2emesh p2e_rd(.access_out (),
|
||||
.write_out (),
|
||||
.datamode_out (),
|
||||
.ctrlmode_out (),
|
||||
.dstaddr_out (txrd_dstaddr[AW-1:0]),
|
||||
.data_out (),
|
||||
.srcaddr_out (txrd_srcaddr[AW-1:0]),
|
||||
.packet_in (txrd_packet[PW-1:0])
|
||||
);
|
||||
|
||||
|
||||
//pass through clock
|
||||
//TODO: gate?
|
||||
assign mi_clk = txwr_clk;
|
||||
|
||||
//Register file access (from slave)
|
||||
assign mi_wr = txwr_access & (txwr_dstaddr[31:20]==ELINKID);
|
||||
assign mi_rd = txrd_access & (txrd_dstaddr[31:20]==ELINKID);
|
||||
|
||||
//Only 32 bit writes supported
|
||||
assign mi_we = mi_wr;
|
||||
assign mi_en = mi_wr | mi_rd;
|
||||
|
||||
//Read/write address
|
||||
assign mi_addr[19:0] = mi_we ? txwr_dstaddr[19:0] :
|
||||
txrd_dstaddr[19:0];
|
||||
|
||||
//Data
|
||||
assign mi_din[31:0] = txwr_data[31:0];
|
||||
|
||||
//TODO: Do readback later....
|
||||
endmodule // ecfg_base
|
||||
// Local Variables:
|
||||
// verilog-library-directories:("." "../../common/hdl")
|
||||
// End:
|
||||
|
||||
|
||||
/*
|
||||
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/>.
|
||||
*/
|
130
elink/hdl/ecfg_rx.v
Normal file
130
elink/hdl/ecfg_rx.v
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
########################################################################
|
||||
ELINK CONFIGURATION REGISTER FILE
|
||||
########################################################################
|
||||
|
||||
*/
|
||||
|
||||
module ecfg_rx (/*AUTOARG*/
|
||||
// Outputs
|
||||
mi_dout, ecfg_rx_enable, ecfg_rx_mmu_enable,
|
||||
// Inputs
|
||||
reset, mi_clk, mi_en, mi_we, mi_addr, mi_din, ecfg_rx_datain,
|
||||
ecfg_rx_debug
|
||||
);
|
||||
|
||||
/******************************/
|
||||
/*Compile Time Parameters */
|
||||
/******************************/
|
||||
parameter RFAW = 5; // 32 registers for now
|
||||
|
||||
/******************************/
|
||||
/*HARDWARE RESET (EXTERNAL) */
|
||||
/******************************/
|
||||
input reset; // ecfg registers reset only by "hard reset"
|
||||
|
||||
/*****************************/
|
||||
/*SIMPLE MEMORY INTERFACE */
|
||||
/*****************************/
|
||||
input mi_clk;
|
||||
input mi_en;
|
||||
input mi_we; // single we, must write 32 bit words
|
||||
input [19:0] mi_addr; // complete physical address (no shifting!)
|
||||
input [31:0] mi_din;
|
||||
output [31:0] mi_dout;
|
||||
|
||||
/*****************************/
|
||||
/*CONFIG SIGNALS */
|
||||
/*****************************/
|
||||
//rx
|
||||
output ecfg_rx_enable; // enable signal for rx
|
||||
output ecfg_rx_mmu_enable; // enables MMU on rx path
|
||||
input [8:0] ecfg_rx_datain; // frame and data inputs
|
||||
input [15:0] ecfg_rx_debug; // erx debug signals
|
||||
|
||||
/*------------------------CODE BODY---------------------------------------*/
|
||||
|
||||
//registers
|
||||
reg [4:0] ecfg_rx_reg;
|
||||
reg [8:0] ecfg_datain_reg;
|
||||
reg [8:0] ecfg_datain_sync;
|
||||
reg [2:0] ecfg_rx_debug_reg;
|
||||
reg [31:0] mi_dout;
|
||||
|
||||
//wires
|
||||
wire ecfg_read;
|
||||
wire ecfg_write;
|
||||
wire ecfg_rx_write;
|
||||
|
||||
/*****************************/
|
||||
/*ADDRESS DECODE LOGIC */
|
||||
/*****************************/
|
||||
|
||||
//read/write decode
|
||||
assign ecfg_write = mi_en & mi_we;
|
||||
assign ecfg_read = mi_en & ~mi_we;
|
||||
|
||||
//Config write enables
|
||||
assign ecfg_rx_write = ecfg_write & (mi_addr[RFAW+1:2]==`ELRX);
|
||||
|
||||
|
||||
//###########################
|
||||
//# RXCFG
|
||||
//###########################
|
||||
always @ (posedge mi_clk)
|
||||
if(reset)
|
||||
ecfg_rx_reg[4:0] <= 5'b0;
|
||||
else if (ecfg_rx_write)
|
||||
ecfg_rx_reg[4:0] <= mi_din[4:0];
|
||||
|
||||
assign ecfg_rx_enable = ecfg_rx_reg[0];
|
||||
assign ecfg_rx_mmu_enable = ecfg_rx_reg[1];
|
||||
|
||||
//###########################
|
||||
//# DATAIN (synchronized)
|
||||
//###########################
|
||||
always @ (posedge mi_clk)
|
||||
begin
|
||||
ecfg_datain_sync[8:0] <= ecfg_rx_datain[8:0];
|
||||
ecfg_datain_reg[8:0] <= ecfg_datain_sync[8:0];
|
||||
end
|
||||
|
||||
//###########################1
|
||||
//# DEBUG
|
||||
//###########################
|
||||
|
||||
always @ (posedge mi_clk)
|
||||
if(reset)
|
||||
ecfg_rx_debug_reg[2:0] <= 'd0;
|
||||
else
|
||||
ecfg_rx_debug_reg[2:0] <=ecfg_rx_debug_reg[2:0] | ecfg_rx_debug[2:0];
|
||||
|
||||
//###############################
|
||||
//# DATA READBACK MUX
|
||||
//###############################
|
||||
|
||||
//Pipelineing readback
|
||||
always @ (posedge mi_clk)
|
||||
if(ecfg_read)
|
||||
case(mi_addr[RFAW+1:2])
|
||||
`ELRX: mi_dout[31:0] <= {27'b0, ecfg_rx_reg[4:0]};
|
||||
`ELDATAIN: mi_dout[31:0] <= {23'b0, ecfg_datain_reg[8:0]};
|
||||
default: mi_dout[31:0] <= 32'd0;
|
||||
endcase
|
||||
|
||||
endmodule // ecfg
|
||||
|
||||
/*
|
||||
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/>.
|
||||
*/
|
144
elink/hdl/ecfg_tx.v
Normal file
144
elink/hdl/ecfg_tx.v
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
########################################################################
|
||||
ELINK CONFIGURATION REGISTER FILE
|
||||
########################################################################
|
||||
|
||||
*/
|
||||
|
||||
module ecfg_tx (/*AUTOARG*/
|
||||
// Outputs
|
||||
mi_dout, ecfg_tx_enable, ecfg_tx_mmu_enable, ecfg_tx_gpio_enable,
|
||||
ecfg_tx_ctrlmode, ecfg_tx_ctrlmode_bp, ecfg_dataout,
|
||||
// Inputs
|
||||
reset, mi_clk, mi_en, mi_we, mi_addr, mi_din, ecfg_tx_debug
|
||||
);
|
||||
|
||||
/******************************/
|
||||
/*Compile Time Parameters */
|
||||
/******************************/
|
||||
parameter RFAW = 5; // 32 registers for now
|
||||
parameter DEFAULT_COREID = 12'h808; // reset value for ecfg_coreid
|
||||
parameter DEFAULT_VERSION = 16'h0000; // reset value for version
|
||||
parameter DEFAULT_CLKDIV = 4'd7;
|
||||
|
||||
/******************************/
|
||||
/*HARDWARE RESET (EXTERNAL) */
|
||||
/******************************/
|
||||
input reset; // ecfg registers reset only by "hard reset"
|
||||
/*****************************/
|
||||
/*SIMPLE MEMORY INTERFACE */
|
||||
/*****************************/
|
||||
input mi_clk;
|
||||
input mi_en;
|
||||
input mi_we; // single we, must write 32 bit words
|
||||
input [19:0] mi_addr; // complete physical address (no shifting!)
|
||||
input [31:0] mi_din;
|
||||
output [31:0] mi_dout;
|
||||
|
||||
/*****************************/
|
||||
/*ELINK CONTROL SIGNALS */
|
||||
/*****************************/
|
||||
//tx
|
||||
output ecfg_tx_enable; // enable signal for TX
|
||||
output ecfg_tx_mmu_enable; // enables MMU on transmit path
|
||||
output ecfg_tx_gpio_enable; // forces TX output pins to constants
|
||||
output [3:0] ecfg_tx_ctrlmode; // value for emesh ctrlmode tag
|
||||
output ecfg_tx_ctrlmode_bp; // bypass value for emesh ctrlmode tag
|
||||
output [8:0] ecfg_dataout; // data for elink outputs
|
||||
input [15:0] ecfg_tx_debug; // etx debug signals
|
||||
|
||||
/*------------------------CODE BODY---------------------------------------*/
|
||||
|
||||
//registers
|
||||
|
||||
reg [8:0] ecfg_tx_reg;
|
||||
reg [8:0] ecfg_dataout_reg;
|
||||
reg [2:0] ecfg_tx_debug_reg;
|
||||
reg [31:0] mi_dout;
|
||||
|
||||
//wires
|
||||
wire ecfg_read;
|
||||
wire ecfg_write;
|
||||
wire ecfg_tx_write;
|
||||
wire ecfg_dataout_write;
|
||||
|
||||
/*****************************/
|
||||
/*ADDRESS DECODE LOGIC */
|
||||
/*****************************/
|
||||
|
||||
//read/write decode
|
||||
assign ecfg_write = mi_en & mi_we;
|
||||
assign ecfg_read = mi_en & ~mi_we;
|
||||
|
||||
//Config write enables
|
||||
assign ecfg_tx_write = ecfg_write & (mi_addr[RFAW+1:2]==`ELTX);
|
||||
assign ecfg_dataout_write = ecfg_write & (mi_addr[RFAW+1:2]==`ELDATAOUT);
|
||||
|
||||
//###########################
|
||||
//# TX
|
||||
//###########################
|
||||
always @ (posedge mi_clk)
|
||||
if(reset)
|
||||
ecfg_tx_reg[8:0] <= 9'b0;
|
||||
else if (ecfg_tx_write)
|
||||
ecfg_tx_reg[8:0] <= mi_din[8:0];
|
||||
|
||||
assign ecfg_tx_enable = ecfg_tx_reg[0];
|
||||
assign ecfg_tx_mmu_enable = ecfg_tx_reg[1];
|
||||
assign ecfg_tx_gpio_enable = (ecfg_tx_reg[3:2]==2'b01);
|
||||
assign ecfg_tx_tp_enable = (ecfg_tx_reg[3:2]==2'b10);//test clock pattern
|
||||
assign ecfg_tx_ctrlmode[3:0] = ecfg_tx_reg[7:4];
|
||||
assign ecfg_tx_ctrlmode_bp = ecfg_tx_reg[8];
|
||||
|
||||
//###########################
|
||||
//# DATAOUT
|
||||
//###########################
|
||||
always @ (posedge mi_clk)
|
||||
if(reset)
|
||||
ecfg_dataout_reg[8:0] <= 'd0;
|
||||
else if (ecfg_dataout_write)
|
||||
ecfg_dataout_reg[8:0] <= mi_din[8:0];
|
||||
|
||||
assign ecfg_dataout[8:0] = ecfg_dataout_reg[8:0];
|
||||
|
||||
//###########################1
|
||||
//# DEBUG
|
||||
//###########################
|
||||
|
||||
always @ (posedge mi_clk)
|
||||
if(reset)
|
||||
ecfg_tx_debug_reg[2:0] <= 'd0;
|
||||
else
|
||||
ecfg_tx_debug_reg[2:0] <=ecfg_tx_debug_reg[2:0] | ecfg_tx_debug[2:0];
|
||||
|
||||
//###############################
|
||||
//# DATA READBACK MUX
|
||||
//###############################
|
||||
|
||||
//Pipelineing readback
|
||||
always @ (posedge mi_clk)
|
||||
if(ecfg_read)
|
||||
case(mi_addr[RFAW+1:2])
|
||||
`ELTX: mi_dout[31:0] <= {23'b0, ecfg_tx_reg[8:0]};
|
||||
`ELDATAOUT: mi_dout[31:0] <= {23'b0, ecfg_dataout_reg[8:0]};
|
||||
`ELDEBUG: mi_dout[31:0] <= {16'b0,ecfg_tx_debug[15:3],ecfg_tx_debug_reg[2:0]};
|
||||
default: mi_dout[31:0] <= 32'd0;
|
||||
endcase
|
||||
|
||||
endmodule // ecfg_tx
|
||||
|
||||
|
||||
/*
|
||||
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/>.
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user