update sdcard_dummy to get/put style interface
[shakti-peripherals.git] / src / peripherals / sdmmc / sdcard_dummy.bsv
1 /*
2 Copyright (c) 2013, IIT Madras All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of IIT Madras nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 --------------------------------------------------------------------
29
30 Author: Neel Gala
31 Email id: neelgala@gmail.com
32 Details:
33
34 -------------------------------------------------------------------
35 */
36
37 package sdcard_dummy;
38 `define SDBUSWIDTH 4
39 `include "instance_defines.bsv"
40 import ClockDiv::*;
41 import ConcatReg::*;
42 import Semi_FIFOF::*;
43 import BUtils ::*;
44 import AXI4_Lite_Types::*;
45
46 interface Ifc_sdcard_dummy;
47 interface AXI4_Lite_Slave_IFC#(`ADDR, `DATA, `USERSPACE) slave;
48 interface Get#(Bit#(1)) cmd;
49 interface Get#(Bit#(1)) clk;
50 interface Get#(Bit#(`SDBUSWIDTH)) out;
51 interface Get#(Bit#(`SDBUSWIDTH)) out_en;
52 interface Put#(Bit#(`SDBUSWIDTH)) in;
53 endinterface
54
55 (*synthesize*)
56 module mksdcard_dummy(Ifc_sdcard_dummy);
57 AXI4_Lite_Slave_Xactor_IFC#(`ADDR,`DATA, `USERSPACE)
58 s_xactor<-mkAXI4_Lite_Slave_Xactor();
59
60 Reg#(Bit#(1)) rg_cmd <- mkReg(0);
61 Reg#(Bit#(1)) rg_clk <- mkReg(0);
62 Reg#(Bit#(`SDBUSWIDTH)) rg_out <- mkReg(0);
63 Reg#(Bit#(`SDBUSWIDTH)) rg_outen <- mkReg(0);
64 Reg#(Bit#(`SDBUSWIDTH)) rg_in <- mkReg(0);
65
66 interface cmd = interface Get
67 method ActionValue#(Bit#(1)) get;
68 return rg_cmd;
69 endmethod
70 endinterface;
71
72 interface clk = interface Get
73 method ActionValue#(Bit#(1)) get;
74 return rg_clk;
75 endmethod
76 endinterface;
77
78 interface out_en = interface Get
79 method ActionValue#(Bit#(`SDBUSWIDTH)) get;
80 return rg_out_en;
81 endmethod
82 endinterface;
83
84 interface out = interface Get
85 method ActionValue#(Bit#(`SDBUSWIDTH)) get;
86 return rg_out;
87 endmethod
88 endinterface;
89
90 interface in = interface Put
91 method Action put(Bit#(`SDBUSWIDTH) in);
92 rg_in <= in;
93 endmethod
94 endinterface;
95
96 interface slave=s_xactor.axi_side;
97
98 endmodule
99
100 endpackage