2014-12-14 17:18:53 -05:00
|
|
|
/*
|
|
|
|
########################################################################
|
|
|
|
EPIPHANY eMesh Arbiter
|
|
|
|
########################################################################
|
|
|
|
|
2015-05-01 17:58:16 -04:00
|
|
|
This block takes three FIFO inputs (write, read request, read response)
|
|
|
|
and the DMA channel, arbitrates between the active channels, and forwards
|
|
|
|
the result to the transmit output pins.
|
2014-12-14 17:18:53 -05:00
|
|
|
|
2015-05-01 17:58:16 -04:00
|
|
|
Arbitration Priority:
|
|
|
|
1) host writes (highest)
|
2015-04-11 00:04:18 -04:00
|
|
|
2) read requests from host
|
2016-01-10 11:51:49 -05:00
|
|
|
3) read responses (lowest)
|
2015-04-11 00:04:18 -04:00
|
|
|
|
2014-12-14 17:18:53 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
module etx_arbiter (/*AUTOARG*/
|
|
|
|
// Outputs
|
2015-11-25 21:56:56 -05:00
|
|
|
txwr_wait, txrd_wait, txrr_wait, etx_access, etx_rr, etx_packet,
|
2014-12-14 17:18:53 -05:00
|
|
|
// Inputs
|
2015-11-06 16:51:57 -05:00
|
|
|
clk, nreset, txwr_access, txwr_packet, txrd_access, txrd_packet,
|
2015-08-07 09:05:11 -04:00
|
|
|
txrr_access, txrr_packet, etx_rd_wait, etx_wr_wait, etx_cfg_wait,
|
|
|
|
ctrlmode_bypass, ctrlmode
|
2014-12-14 17:18:53 -05:00
|
|
|
);
|
|
|
|
|
2015-04-23 17:57:24 -04:00
|
|
|
parameter PW = 104;
|
2015-04-23 23:16:03 -04:00
|
|
|
parameter ID = 0;
|
2015-04-23 17:57:24 -04:00
|
|
|
|
2015-05-01 17:58:16 -04:00
|
|
|
//tx clock and reset
|
|
|
|
input clk;
|
2015-11-06 16:51:57 -05:00
|
|
|
input nreset;
|
2015-04-23 17:57:24 -04:00
|
|
|
|
2015-04-13 23:35:21 -04:00
|
|
|
//Write Request (from slave)
|
2015-05-10 23:38:08 -04:00
|
|
|
input txwr_access;
|
|
|
|
input [PW-1:0] txwr_packet;
|
|
|
|
output txwr_wait;
|
2014-12-14 17:18:53 -05:00
|
|
|
|
2015-04-13 23:35:21 -04:00
|
|
|
//Read Request (from slave)
|
2015-05-10 23:38:08 -04:00
|
|
|
input txrd_access;
|
|
|
|
input [PW-1:0] txrd_packet;
|
|
|
|
output txrd_wait;
|
2014-12-14 17:18:53 -05:00
|
|
|
|
2015-04-13 23:35:21 -04:00
|
|
|
//Read Response (from master)
|
2015-05-10 23:38:08 -04:00
|
|
|
input txrr_access;
|
|
|
|
input [PW-1:0] txrr_packet;
|
|
|
|
output txrr_wait;
|
2014-12-14 17:18:53 -05:00
|
|
|
|
2015-05-03 23:25:19 -04:00
|
|
|
//Wait signal inputs
|
|
|
|
input etx_rd_wait;
|
|
|
|
input etx_wr_wait;
|
|
|
|
input etx_cfg_wait;
|
|
|
|
|
2015-05-01 17:58:16 -04:00
|
|
|
//ctrlmode for rd/wr transactions
|
|
|
|
input ctrlmode_bypass;
|
|
|
|
input [3:0] ctrlmode;
|
|
|
|
|
|
|
|
//Transaction for IO protocol
|
2015-04-23 17:57:24 -04:00
|
|
|
output etx_access;
|
2015-05-01 17:58:16 -04:00
|
|
|
output etx_rr; //bypass translation on read response
|
2015-11-25 21:56:56 -05:00
|
|
|
output [PW-1:0] etx_packet;
|
2015-05-01 17:58:16 -04:00
|
|
|
|
2014-12-14 22:24:16 -05:00
|
|
|
//regs
|
2015-04-23 17:57:24 -04:00
|
|
|
reg etx_access;
|
|
|
|
reg [PW-1:0] etx_packet;
|
2015-05-01 17:58:16 -04:00
|
|
|
reg etx_rr; //bypass translation on read response
|
2015-04-24 17:39:05 -04:00
|
|
|
|
2015-05-03 23:25:19 -04:00
|
|
|
//wires
|
2015-04-23 17:57:24 -04:00
|
|
|
wire [3:0] txrd_ctrlmode;
|
|
|
|
wire [3:0] txwr_ctrlmode;
|
2015-05-03 23:25:19 -04:00
|
|
|
wire access_in;
|
|
|
|
wire [PW-1:0] etx_packet_mux;
|
|
|
|
wire txrr_grant;
|
|
|
|
wire txrd_grant;
|
2015-12-04 03:36:42 -05:00
|
|
|
wire txwr_grant;
|
2015-11-10 22:29:30 -05:00
|
|
|
wire [PW-1:0] txrd_splice_packet;
|
|
|
|
wire [PW-1:0] txwr_splice_packet;
|
2015-05-03 23:25:19 -04:00
|
|
|
wire [PW-1:0] etx_mux;
|
2015-05-04 17:13:51 -04:00
|
|
|
|
2016-01-10 11:51:49 -05:00
|
|
|
//#########################################################################
|
2015-11-10 22:29:30 -05:00
|
|
|
//# Insert special control mode in packet (UGLY)
|
2016-01-10 11:51:49 -05:00
|
|
|
//#########################################################################
|
2015-05-01 17:58:16 -04:00
|
|
|
assign txrd_ctrlmode[3:0] = ctrlmode_bypass ? ctrlmode[3:0] :
|
2015-11-02 20:51:35 -05:00
|
|
|
txrd_packet[6:3];
|
|
|
|
|
|
|
|
assign txwr_ctrlmode[3:0] = ctrlmode_bypass ? ctrlmode[3:0] :
|
|
|
|
txwr_packet[6:3];
|
2015-04-23 17:57:24 -04:00
|
|
|
|
2015-11-10 22:29:30 -05:00
|
|
|
assign txrd_splice_packet[PW-1:0] = {txrd_packet[PW-1:8],
|
|
|
|
1'b0,
|
|
|
|
txrd_ctrlmode[3:0],
|
|
|
|
txrd_packet[2:0]};
|
2015-05-03 23:25:19 -04:00
|
|
|
|
2015-11-10 22:29:30 -05:00
|
|
|
assign txwr_splice_packet[PW-1:0] = {txwr_packet[PW-1:8],
|
|
|
|
1'b0,
|
|
|
|
txwr_ctrlmode[3:0],
|
|
|
|
txwr_packet[2:0]};
|
2015-05-03 23:25:19 -04:00
|
|
|
|
2016-01-10 11:51:49 -05:00
|
|
|
//########################################################################
|
2015-05-03 23:25:19 -04:00
|
|
|
//# Arbiter
|
2016-01-10 11:51:49 -05:00
|
|
|
//########################################################################
|
2015-05-03 23:25:19 -04:00
|
|
|
|
2016-01-10 11:51:49 -05:00
|
|
|
oh_arbiter #(.N(3)) arbiter (.grants({txrr_grant,
|
|
|
|
txrd_grant,
|
|
|
|
txwr_grant //highest priority
|
|
|
|
}),
|
|
|
|
.requests({txrr_access,
|
|
|
|
txrd_access,
|
|
|
|
txwr_access
|
|
|
|
})
|
|
|
|
);
|
2015-05-03 23:25:19 -04:00
|
|
|
//Priority Mux
|
2015-11-10 22:29:30 -05:00
|
|
|
assign etx_mux[PW-1:0] =({(PW){txwr_grant}} & txwr_splice_packet[PW-1:0]) |
|
|
|
|
({(PW){txrd_grant}} & txrd_splice_packet[PW-1:0]) |
|
2015-08-07 09:05:11 -04:00
|
|
|
({(PW){txrr_grant}} & txrr_packet[PW-1:0]);
|
2015-05-03 23:25:19 -04:00
|
|
|
|
2015-11-25 21:56:56 -05:00
|
|
|
|
2015-05-03 23:25:19 -04:00
|
|
|
//######################################################################
|
|
|
|
//Pushback (stall) Signals
|
|
|
|
//######################################################################
|
|
|
|
|
|
|
|
//Write waits on pin wr wait or cfg_wait
|
2015-11-15 01:35:04 -05:00
|
|
|
assign txwr_wait = etx_wr_wait |
|
|
|
|
etx_rd_wait |
|
2015-08-07 09:05:11 -04:00
|
|
|
etx_cfg_wait;
|
2015-05-03 23:25:19 -04:00
|
|
|
|
|
|
|
//Read response
|
2015-11-15 01:35:04 -05:00
|
|
|
assign txrr_wait = etx_wr_wait |
|
|
|
|
etx_rd_wait |
|
2015-11-04 20:02:45 -05:00
|
|
|
etx_cfg_wait |
|
2015-12-04 03:36:42 -05:00
|
|
|
txwr_access;
|
|
|
|
|
|
|
|
//Host read request (self throttling, one read at a time)
|
|
|
|
assign txrd_wait = etx_rd_wait |
|
|
|
|
etx_wr_wait |
|
|
|
|
etx_cfg_wait |
|
|
|
|
txrr_access |
|
|
|
|
txwr_access;
|
|
|
|
|
2015-05-04 17:13:51 -04:00
|
|
|
//#####################################################################
|
2015-05-03 23:25:19 -04:00
|
|
|
//# Pipeline stage (arbiter+mux takes time..)
|
2015-05-04 17:13:51 -04:00
|
|
|
//#####################################################################
|
2015-05-10 23:38:08 -04:00
|
|
|
assign access_in = (txwr_grant & ~txwr_wait) |
|
|
|
|
(txrd_grant & ~txrd_wait) |
|
2015-08-07 09:05:11 -04:00
|
|
|
(txrr_grant & ~txrr_wait);
|
2015-05-03 23:25:19 -04:00
|
|
|
|
2015-11-25 21:56:56 -05:00
|
|
|
|
2015-08-14 15:37:37 -04:00
|
|
|
//access
|
|
|
|
always @ (posedge clk)
|
2015-11-06 16:51:57 -05:00
|
|
|
if (!nreset)
|
2015-08-14 15:37:37 -04:00
|
|
|
begin
|
2015-10-08 10:34:59 -04:00
|
|
|
etx_access <= 1'b0;
|
2015-08-14 15:37:37 -04:00
|
|
|
etx_rr <= 1'b0;
|
|
|
|
end
|
2015-11-15 01:35:04 -05:00
|
|
|
else if (~(etx_wr_wait | etx_rd_wait))
|
2015-08-14 15:37:37 -04:00
|
|
|
begin
|
2015-11-25 21:56:56 -05:00
|
|
|
etx_access <= access_in ;
|
|
|
|
etx_rr <= txrr_grant & ~txrr_wait;
|
2015-08-14 15:37:37 -04:00
|
|
|
end
|
2015-11-15 01:35:04 -05:00
|
|
|
|
2015-08-14 15:37:37 -04:00
|
|
|
//packet
|
2015-05-01 17:58:16 -04:00
|
|
|
always @ (posedge clk)
|
2015-11-15 01:35:04 -05:00
|
|
|
if (access_in & ~(etx_wr_wait | etx_rd_wait))
|
2015-08-14 15:37:37 -04:00
|
|
|
etx_packet[PW-1:0] <= etx_mux[PW-1:0];
|
2015-05-04 17:13:51 -04:00
|
|
|
|
2015-04-13 23:35:21 -04:00
|
|
|
endmodule // etx_arbiter
|
2015-05-03 23:25:19 -04:00
|
|
|
// Local Variables:
|
2015-11-02 20:51:35 -05:00
|
|
|
// verilog-library-directories:("." "../../emesh/hdl")
|
2015-05-03 23:25:19 -04:00
|
|
|
// End:
|
|
|
|
|
|
|
|
|