From 7f355be0ee91943f804e6d295565cb9fa3f6caf7 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 22 Jul 2018 08:53:43 +0100 Subject: [PATCH] add mux.bsv --- src/peripherals/mux/mux.bsv | 97 +++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/peripherals/mux/mux.bsv diff --git a/src/peripherals/mux/mux.bsv b/src/peripherals/mux/mux.bsv new file mode 100644 index 0000000..cb67458 --- /dev/null +++ b/src/peripherals/mux/mux.bsv @@ -0,0 +1,97 @@ +/* +Copyright (c) 2013, IIT Madras +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of IIT Madras nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +*/ +package mux; + /*==== Package imports ==== */ + import TriState ::*; + import Vector ::*; + import BUtils::*; + import ConfigReg ::*; + /*============================ */ + /*===== Project Imports ===== */ + import Semi_FIFOF :: *; + import AXI4_Lite_Types :: *; + /*============================ */ + `include "instance_defines.bsv" + + interface MUX_config#(numeric type ionum); + (*always_ready,always_enabled*) + method Vector#(ionum,Bit#(2)) mux; + endinterface + + interface MUX#(numeric type ionum); + interface MUX_config#(ionum) mux_config; + interface AXI4_Lite_Slave_IFC#(`ADDR,`DATA,`USERSPACE) axi_slave; + endinterface + +// (*synthesize*) + module mkmux(MUX#(ionum_)); + Vector#(ionum_,ConfigReg#(Bit#(2))) muxer_reg <-replicateM(mkConfigReg(0)); + + AXI4_Lite_Slave_Xactor_IFC #(`ADDR, `DATA, `USERSPACE) s_xactor <- mkAXI4_Lite_Slave_Xactor; + let ionum=valueOf(ionum_); + rule rl_wr_respond; + // Get the wr request + //aw is write address, w is write data + let aw <- pop_o (s_xactor.o_wr_addr); + let w <- pop_o (s_xactor.o_wr_data); + let b = AXI4_Lite_Wr_Resp {bresp: AXI4_LITE_OKAY, buser: aw.awuser}; + if(aw.awaddr[5:0]=='h0) + for(Integer i=0;i=16) + for(Integer i=0;i=16)begin + for(Integer i=0;i