add peripherals
[shakti-peripherals.git] / src / peripherals / sdram / tb_top.bsv
1 /*
2 Copyright (c) 2013, IIT Madras
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 * 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.
9 * 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.
10
11 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.
12 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
13 */
14 package tb_top;
15
16 import Semi_FIFOF :: *;
17 import AXI4_Types :: *;
18 import AXI4_Fabric :: *;
19 import sdr_top :: *;
20 import tb_bsv_wrapper :: *;
21 import Connectable :: *;
22 `include "defined_parameters.bsv"
23
24
25 typedef 1 Num_Masters;
26 typedef 1 Num_Slaves;
27
28 function Tuple2 #(Bool, Bit#(TLog#(Num_Slaves))) fn_addr_to_slave_num (Bit #(`PADDR) addr);
29 return tuple2(True, 0);
30 endfunction
31
32 (*synthesize*)
33 module mkTb_top(Empty);
34
35
36 AXI4_Fabric_IFC #(Num_Masters, Num_Slaves, `PADDR, `Reg_width,`USERSPACE)
37 fabric_m <- mkAXI4_Fabric(fn_addr_to_slave_num);
38 AXI4_Fabric_IFC #(Num_Masters, Num_Slaves, `PADDR, `Reg_width,`USERSPACE)
39 fabric_c <- mkAXI4_Fabric(fn_addr_to_slave_num);
40
41 Ifc_sdr_slave sdr_cntrl <- mksdr_axi4_slave;
42
43 Ifc_tb_bsv_wrapper tb_wrapper <- mktb_bsv_wrapper;
44
45 mkConnection (tb_wrapper.axi4_sdram, fabric_m.v_from_masters [0]);
46 mkConnection(fabric_m.v_to_slaves[0], sdr_cntrl.axi4_slave_sdram);
47 mkConnection (tb_wrapper.axi4_cntrl_reg, fabric_c.v_from_masters [0]);
48 mkConnection(fabric_c.v_to_slaves[0], sdr_cntrl.axi4_slave_cntrl_reg);
49 mkConnection(tb_wrapper.dq_0, sdr_cntrl.sdr_dq0);
50 mkConnection(tb_wrapper.dq_1, sdr_cntrl.sdr_dq1);
51
52
53 rule rl_iAddr_connection;
54 let in = sdr_cntrl.ifc_sdram_out.osdr_addr();
55 tb_wrapper.ifc_tb_sdram_in.iAddr(truncate(in));
56 endrule
57
58 rule rl_iBa_connection;
59 let in = sdr_cntrl.ifc_sdram_out.osdr_ba();
60 tb_wrapper.ifc_tb_sdram_in.iBa(in);
61 endrule
62
63 rule rl_iCke_connection;
64 let in = sdr_cntrl.ifc_sdram_out.osdr_cke();
65 tb_wrapper.ifc_tb_sdram_in.iCke(pack(in));
66 endrule
67
68 rule rl_iClk_connection;
69 let in = sdr_cntrl.ifc_sdram_out.osdr_clk();
70 tb_wrapper.ifc_tb_sdram_in.iClk(in);
71 endrule
72
73 rule rl_iCs_n_connection;
74 let in = sdr_cntrl.ifc_sdram_out.osdr_cs_n();
75 tb_wrapper.ifc_tb_sdram_in.iCs_n(pack(in));
76 endrule
77
78 rule rl_iRas_n_connection;
79 let in = sdr_cntrl.ifc_sdram_out.osdr_ras_n();
80 tb_wrapper.ifc_tb_sdram_in.iRas_n(pack(in));
81 endrule
82
83 rule rl_iCas_n_connection;
84 let in = sdr_cntrl.ifc_sdram_out.osdr_cas_n();
85 tb_wrapper.ifc_tb_sdram_in.iCas_n(pack(in));
86 endrule
87
88 rule rl_iWe_n_connection;
89 let in = sdr_cntrl.ifc_sdram_out.osdr_we_n();
90 tb_wrapper.ifc_tb_sdram_in.iWe_n(pack(in));
91 endrule
92
93 rule rl_iDqm_connection;
94 let in = sdr_cntrl.ifc_sdram_out.osdr_dqm();
95 tb_wrapper.ifc_tb_sdram_in.iDqm(extend(in));
96 endrule
97
98 endmodule
99 endpackage