From 1e35436b10d6c700a8f8160a5b8ae4ac7723e42b Mon Sep 17 00:00:00 2001 From: Andreas Olofsson Date: Wed, 20 Jan 2016 17:14:55 -0500 Subject: [PATCH] Adding generic mesh packet mux --- emesh/hdl/emesh_mux.v | 79 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 emesh/hdl/emesh_mux.v diff --git a/emesh/hdl/emesh_mux.v b/emesh/hdl/emesh_mux.v new file mode 100644 index 0000000..c2e5eed --- /dev/null +++ b/emesh/hdl/emesh_mux.v @@ -0,0 +1,79 @@ +module emesh_mux (/*AUTOARG*/ + // Outputs + wait_out, access_out, packet_out, + // Inputs + access_in, packet_in, wait_in + ); + + //##################################################################### + //# PARAMETERS + //##################################################################### + parameter AW = 32; + parameter PW = 2 * AW + 40; + parameter N = 99; + parameter CFG = "STATIC"; //Arbitration configuration + //"STATIC" fixed priority + //"DYNAMIC" round robin priority + + //##################################################################### + //# INTERFACE + //##################################################################### + + //Incoming transaction + input [N-1:0] access_in; + input [N*PW-1:0] packet_in; + output [N-1:0] wait_out; + + //Outgoing transaction + output access_out; + output [PW-1:0] packet_out; + input wait_in; + + //##################################################################### + //# BODY + //##################################################################### + + //local variables + wire [N-1:0] grants; + reg [PW-1:0] packet_out; + integer i; + + //arbiter + generate + if(CFG=="STATIC") + begin + oh_arbiter #(.N(N)) + arbiter(// Outputs + .grants (grants[N-1:0]), + // Inputs + .requests (access_in[N-1:0]) + ); + end + else if (CFG=="DYNAMIC") + begin + initial + $display("ROUND ROBIN ARBITER NOT IMPLEMENTED\n"); + end + endgenerate + + //access signal + assign access_out = |(access_in[N-1:0]); + + //raise wait signals + assign wait_out[N-1:0] = access_in[N-1:0] & (~grants[N-1:0] | {(N){wait_in}}); + + //parametrized mux + always @* + begin + packet_out[PW-1:0] = 'b0; + for(i=0;i