1 | /* -*- c++ -*- |
---|
2 | * |
---|
3 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
4 | * |
---|
5 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
6 | * |
---|
7 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
8 | * under the terms of the GNU Lesser General Public License as published |
---|
9 | * by the Free Software Foundation; version 2.1 of the License. |
---|
10 | * |
---|
11 | * SoCLib is distributed in the hope that it will be useful, but |
---|
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | * Lesser General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU Lesser General Public |
---|
17 | * License along with SoCLib; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
19 | * 02110-1301 USA |
---|
20 | * |
---|
21 | * SOCLIB_LGPL_HEADER_END |
---|
22 | * |
---|
23 | * Copyright (c) UPMC, Lip6, Asim |
---|
24 | * Nicolas Pouillon <nipo@ssji.net>, 2007 |
---|
25 | * Eric Guthmuller <eric.guthmuller@polytechnique.edu> |
---|
26 | * |
---|
27 | * Maintainers: nipo eric.guthmuller@polytechnique.edu |
---|
28 | */ |
---|
29 | #ifndef SOCLIB_VCI_BLOCK_DEVICE_TSAR_H |
---|
30 | #define SOCLIB_VCI_BLOCK_DEVICE_TSAR_H |
---|
31 | |
---|
32 | #include <stdint.h> |
---|
33 | #include <systemc> |
---|
34 | #include "vci_target_fsm.h" |
---|
35 | #include "vci_initiator_fsm.h" |
---|
36 | #include "caba_base_module.h" |
---|
37 | #include "mapping_table.h" |
---|
38 | |
---|
39 | namespace soclib { |
---|
40 | namespace caba { |
---|
41 | |
---|
42 | using namespace sc_core; |
---|
43 | |
---|
44 | template<typename vci_param> |
---|
45 | class VciBlockDeviceTsar |
---|
46 | : public caba::BaseModule |
---|
47 | { |
---|
48 | private: |
---|
49 | soclib::caba::VciTargetFsm<vci_param, true> m_vci_target_fsm; |
---|
50 | soclib::caba::VciInitiatorFsm<vci_param> m_vci_init_fsm; |
---|
51 | typedef typename soclib::caba::VciInitiatorReq<vci_param> req_t; |
---|
52 | |
---|
53 | bool on_write(int seg, typename vci_param::addr_t addr, typename vci_param::data_t data, int be); |
---|
54 | bool on_read(int seg, typename vci_param::addr_t addr, typename vci_param::data_t &data); |
---|
55 | void read_done( req_t *req ); |
---|
56 | void write_finish( req_t *req ); |
---|
57 | void open_finish( req_t *req ); |
---|
58 | void next_req(); |
---|
59 | void transition(); |
---|
60 | void genMoore(); |
---|
61 | |
---|
62 | const uint32_t m_block_size; |
---|
63 | const uint32_t m_burst_size; // Maximum size of the burst |
---|
64 | |
---|
65 | int m_fd; |
---|
66 | int m_op; |
---|
67 | uint32_t m_buffer; |
---|
68 | uint32_t m_count; |
---|
69 | uint64_t m_device_size; |
---|
70 | uint32_t m_lba; |
---|
71 | int m_status; |
---|
72 | uint32_t m_chunck_offset; |
---|
73 | uint32_t m_transfer_size; |
---|
74 | bool m_irq_enabled; |
---|
75 | bool r_irq; |
---|
76 | |
---|
77 | int m_current_op; |
---|
78 | |
---|
79 | uint8_t *m_data; |
---|
80 | |
---|
81 | inline void ended(int status); |
---|
82 | |
---|
83 | protected: |
---|
84 | SC_HAS_PROCESS(VciBlockDeviceTsar); |
---|
85 | |
---|
86 | public: |
---|
87 | sc_in<bool> p_clk; |
---|
88 | sc_in<bool> p_resetn; |
---|
89 | soclib::caba::VciTarget<vci_param> p_vci_target; |
---|
90 | soclib::caba::VciInitiator<vci_param> p_vci_initiator; |
---|
91 | sc_out<bool> p_irq; |
---|
92 | |
---|
93 | VciBlockDeviceTsar( |
---|
94 | sc_module_name name, |
---|
95 | const soclib::common::MappingTable &mt, |
---|
96 | const soclib::common::IntTab &srcid, |
---|
97 | const soclib::common::IntTab &tgtid, |
---|
98 | const std::string &filename, |
---|
99 | const uint32_t block_size = 512, |
---|
100 | const uint32_t burst_size = 64); |
---|
101 | }; |
---|
102 | |
---|
103 | }} |
---|
104 | |
---|
105 | #endif /* SOCLIB_VCI_BLOCK_DEVICE_TSAR_H */ |
---|
106 | |
---|
107 | // Local Variables: |
---|
108 | // tab-width: 4 |
---|
109 | // c-basic-offset: 4 |
---|
110 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
111 | // indent-tabs-mode: nil |
---|
112 | // End: |
---|
113 | |
---|
114 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
115 | |
---|