2015-06-30 13:32:05 +02:00
|
|
|
`include "elink_regmap.v"
|
|
|
|
|
2014-12-14 17:18:53 -05:00
|
|
|
module etx_protocol (/*AUTOARG*/
|
|
|
|
// Outputs
|
2015-05-13 23:28:06 -04:00
|
|
|
etx_rd_wait, etx_wr_wait, tx_packet, tx_access, tx_burst,
|
2014-12-14 17:18:53 -05:00
|
|
|
// Inputs
|
2015-11-06 16:51:57 -05:00
|
|
|
nreset, clk, etx_access, etx_packet, tx_enable, gpio_data,
|
2015-11-15 01:35:46 -05:00
|
|
|
gpio_enable, tx_rd_wait, tx_wr_wait
|
2014-12-14 17:18:53 -05:00
|
|
|
);
|
|
|
|
|
2015-04-23 17:56:15 -04:00
|
|
|
parameter PW = 104;
|
|
|
|
parameter AW = 32;
|
|
|
|
parameter DW = 32;
|
2015-05-01 17:47:24 -04:00
|
|
|
parameter ID = 12'h000;
|
2014-12-14 17:18:53 -05:00
|
|
|
|
2015-05-01 17:47:24 -04:00
|
|
|
//Clock/reset
|
2015-11-06 16:51:57 -05:00
|
|
|
input nreset;
|
2015-05-01 17:47:24 -04:00
|
|
|
input clk;
|
|
|
|
|
|
|
|
//System side
|
2015-04-23 17:56:15 -04:00
|
|
|
input etx_access;
|
|
|
|
input [PW-1:0] etx_packet;
|
2015-05-01 17:47:24 -04:00
|
|
|
|
|
|
|
//Pushback signals
|
2015-04-23 17:56:15 -04:00
|
|
|
output etx_rd_wait;
|
|
|
|
output etx_wr_wait;
|
2015-04-23 18:57:55 -04:00
|
|
|
|
2015-05-01 17:47:24 -04:00
|
|
|
//Enble transmit
|
2015-05-10 23:35:04 -04:00
|
|
|
input tx_enable; //transmit enable
|
|
|
|
input [8:0] gpio_data; //TODO
|
|
|
|
input gpio_enable; //TODO
|
2015-04-08 13:20:25 -04:00
|
|
|
|
2015-05-01 17:47:24 -04:00
|
|
|
//Interface to IO
|
2015-05-13 23:28:06 -04:00
|
|
|
output [PW-1:0] tx_packet;
|
|
|
|
output tx_access;
|
|
|
|
output tx_burst;
|
|
|
|
input tx_rd_wait; // The wait signals are passed through
|
|
|
|
input tx_wr_wait; // to the emesh interfaces
|
2015-04-23 17:56:15 -04:00
|
|
|
|
2015-05-01 17:47:24 -04:00
|
|
|
//###################################################################
|
2014-12-14 17:18:53 -05:00
|
|
|
//# Local regs & wires
|
2015-05-01 17:47:24 -04:00
|
|
|
//###################################################################
|
2015-05-13 23:28:06 -04:00
|
|
|
reg tx_access;
|
|
|
|
reg [PW-1:0] tx_packet;
|
2015-11-13 16:31:59 -05:00
|
|
|
reg tx_io_wait;
|
2015-11-15 12:26:54 -05:00
|
|
|
reg tx_burst;
|
2015-04-23 17:56:15 -04:00
|
|
|
wire etx_write;
|
|
|
|
wire [1:0] etx_datamode;
|
|
|
|
wire [3:0] etx_ctrlmode;
|
|
|
|
wire [AW-1:0] etx_dstaddr;
|
|
|
|
wire [DW-1:0] etx_data;
|
2015-05-14 22:31:42 -04:00
|
|
|
wire last_write;
|
|
|
|
wire [1:0] last_datamode;
|
|
|
|
wire [3:0] last_ctrlmode;
|
|
|
|
wire [AW-1:0] last_dstaddr;
|
|
|
|
wire burst_match;
|
|
|
|
wire burst_type_match;
|
|
|
|
wire [31:0] burst_addr;
|
2015-05-18 15:38:30 -04:00
|
|
|
wire burst_addr_match;
|
2015-11-11 22:33:54 -05:00
|
|
|
wire burst_in;
|
2015-11-15 01:35:46 -05:00
|
|
|
|
|
|
|
//##############################################################
|
|
|
|
//# Packet Pipeline
|
|
|
|
//##############################################################
|
2015-11-02 16:10:05 -05:00
|
|
|
packet2emesh p2m0 (
|
2015-05-14 22:31:42 -04:00
|
|
|
.write_out (etx_write),
|
|
|
|
.datamode_out (etx_datamode[1:0]),
|
|
|
|
.ctrlmode_out (etx_ctrlmode[3:0]),
|
|
|
|
.dstaddr_out (etx_dstaddr[31:0]),
|
|
|
|
.data_out (),
|
|
|
|
.srcaddr_out (),
|
|
|
|
.packet_in (etx_packet[PW-1:0]));//input
|
2015-05-04 10:41:14 -04:00
|
|
|
|
2015-11-15 01:35:46 -05:00
|
|
|
//Creates a one cycle wait whenever there is no burst
|
2015-11-08 23:28:39 -05:00
|
|
|
always @ (posedge clk or negedge nreset)
|
|
|
|
if(!nreset)
|
2015-11-16 00:42:34 -05:00
|
|
|
tx_io_wait <= 1'b0;
|
|
|
|
else if (tx_rd_wait | tx_wr_wait)
|
|
|
|
tx_io_wait <= 1'b0;
|
2015-11-13 16:31:59 -05:00
|
|
|
else
|
2015-11-16 00:42:34 -05:00
|
|
|
tx_io_wait <= (~tx_io_wait & etx_access & ~tx_burst_in);
|
|
|
|
|
2015-11-11 22:33:54 -05:00
|
|
|
//Hold transaction while waiting
|
2015-11-15 01:35:46 -05:00
|
|
|
//This transaction should be flushed out on wait????
|
2015-05-17 23:00:53 -04:00
|
|
|
always @ (posedge clk)
|
2015-11-06 16:51:57 -05:00
|
|
|
if(!nreset)
|
2015-05-13 23:28:06 -04:00
|
|
|
begin
|
|
|
|
tx_packet[PW-1:0] <= 'b0;
|
2015-11-16 00:42:34 -05:00
|
|
|
tx_access <= 1'b0;
|
2015-11-13 16:31:59 -05:00
|
|
|
end
|
|
|
|
else if(~(etx_wr_wait | etx_rd_wait))
|
|
|
|
begin
|
|
|
|
tx_packet[PW-1:0] <= etx_packet[PW-1:0];
|
2015-11-15 01:35:46 -05:00
|
|
|
tx_access <= tx_enable & etx_access;
|
2015-05-13 23:28:06 -04:00
|
|
|
end
|
2015-11-15 01:35:46 -05:00
|
|
|
|
2015-11-16 00:42:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-11 22:33:54 -05:00
|
|
|
//#############################
|
|
|
|
//# Burst Detection
|
|
|
|
//#############################
|
2015-05-14 22:31:42 -04:00
|
|
|
|
2015-11-02 16:10:05 -05:00
|
|
|
packet2emesh p2m1 (
|
2015-05-14 22:31:42 -04:00
|
|
|
.write_out (last_write),
|
2015-11-13 16:31:59 -05:00
|
|
|
.datamode_out (last_datamode[1:0]),
|
2015-05-14 22:31:42 -04:00
|
|
|
.ctrlmode_out (last_ctrlmode[3:0]),
|
|
|
|
.dstaddr_out (last_dstaddr[31:0]),
|
|
|
|
.data_out (),
|
|
|
|
.srcaddr_out (),
|
|
|
|
.packet_in (tx_packet[PW-1:0]));//input
|
|
|
|
|
2015-11-09 21:57:25 -05:00
|
|
|
assign burst_addr[31:0] = (last_dstaddr[31:0] + 32'h8);
|
2015-05-18 15:38:30 -04:00
|
|
|
|
|
|
|
assign burst_addr_match = (burst_addr[31:0] == etx_dstaddr[31:0]);
|
2015-05-14 22:31:42 -04:00
|
|
|
|
2015-08-14 17:13:52 -04:00
|
|
|
assign burst_type_match = {last_ctrlmode[3:0],last_datamode[1:0],last_write}
|
|
|
|
==
|
2015-05-14 22:31:42 -04:00
|
|
|
{etx_ctrlmode[3:0],etx_datamode[1:0], etx_write};
|
2015-05-18 15:38:30 -04:00
|
|
|
|
2015-11-16 00:42:34 -05:00
|
|
|
assign tx_burst_in = tx_access & //avoid garbage
|
2015-11-15 01:35:46 -05:00
|
|
|
~tx_wr_wait_reg & //clear on wait
|
|
|
|
etx_write & //write
|
|
|
|
(etx_datamode[1:0]==2'b11) & //double only
|
|
|
|
burst_type_match & //same types
|
2015-11-13 16:31:59 -05:00
|
|
|
burst_addr_match; //inc by 8
|
2015-11-15 01:35:46 -05:00
|
|
|
|
|
|
|
|
2015-11-16 00:42:34 -05:00
|
|
|
reg tx_wr_wait_reg;
|
|
|
|
reg tx_rd_wait_reg;
|
|
|
|
reg tx_io_wait_reg;
|
|
|
|
//sample to align up witth tx_access
|
2015-11-15 01:35:46 -05:00
|
|
|
always @ (posedge clk)
|
2015-11-16 00:42:34 -05:00
|
|
|
begin
|
|
|
|
tx_burst <= tx_burst_in;
|
|
|
|
tx_wr_wait_reg <= tx_wr_wait;
|
|
|
|
tx_rd_wait_reg <= tx_rd_wait;
|
|
|
|
tx_io_wait_reg <= tx_io_wait;
|
|
|
|
end
|
|
|
|
|
2015-11-15 01:35:46 -05:00
|
|
|
|
2015-11-16 00:42:34 -05:00
|
|
|
assign special_sample = tx_io_wait_reg &
|
|
|
|
(tx_wr_wait | tx_rd_wait) &
|
|
|
|
~(tx_wr_wait_reg | tx_rd_wait_reg)
|
|
|
|
;
|
|
|
|
//#############################
|
|
|
|
//# Wait propagation circuit
|
|
|
|
//#############################
|
|
|
|
assign etx_wr_wait = (tx_wr_wait | tx_io_wait) & ~special_sample;
|
|
|
|
assign etx_rd_wait = (tx_rd_wait | tx_io_wait) & ~special_sample;
|
|
|
|
|
2015-04-13 23:35:21 -04:00
|
|
|
endmodule // etx_protocol
|
2015-04-23 17:56:15 -04:00
|
|
|
// Local Variables:
|
|
|
|
// verilog-library-directories:("." "../../common/hdl")
|
|
|
|
// End:
|
2014-12-14 17:18:53 -05:00
|
|
|
|