⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 system C源码 一种替代verilog的语言
💻
📖 第 1 页 / 共 3 页
字号:
1.3 ArbiterTo the bus more than one master can be connected. Each master isindependent of the others, so each master can issue a bus request atany time. When at a given cycle one or more requests are made for thebus, these requests are collected and passed to an arbiter. Out ofthis collection the most suitable request is selected; the otherrequests are kept in the request state. The arbiter is connected tothe bus by a dedicated interface, and is called with one or morerequests in the collection:simple_bus_request *arbitrate(const simple_bus_request_vec &Q);The arbiter selects the most appropriate request according thefollowing rules: 1. If the current request is a locked burst request, then it is always    selected.2. If the last request had its lock flag set and is again   'requested', this request is selected from the collection Q and   returned, otherwise:3. the request with the highest priority (i.e. lowest number) is   selected from the collection Q and returned.The arbiter checks whether all the priorities of the requests areunique. If that is not the case, the arbiter will produce an errormessage and abort execution.The arbiter is called whenever the last master request is fullyprocessed by the bus, and when there are one or more new requests madeby the set of masters.NOTE: The highest priority is specified by the lowest numerical valueof the unique_priority parameter. 1.4 TimingA bus transfer is initiated by a master request. Each master issensitive to the rising clock edge where it can call a bus interfacefunction.1.4.1 Blocking RequestAt the rising clock edge, masters can issue a bus request. The businterface function registers the request in a request form. The statusof the request becomes SIMPLE_BUS_REQUEST. (The interface function doesnot terminate but waits until the status of the bus is eitherSIMPLE_BUS_OK or SIMPLE_BUS_ERROR, and this status is returned at thefirst rising clock edge after the request is fully completed.)At the next falling clock edge after the request is issued, the bushandles the requests. Since now there is one (or more) request made,the arbiter is called to determine the most suitable request. Thestatus of this request is set to SIMPLE_BUS_WAIT. This request is thenexecuted.For each data transfer to be made, ranging from start_address tostart_address + length - 1, the current address is obtained and thecorresponding slave is selected.  If there is no slave to be found,the status of the request is set to SIMPLE_BUS_ERROR.The master request is transformed into single slave requests, and oneby one these requests are made to the slave. When the status of theslave is SIMPLE_BUS_OK after the call is made, then the transfer of asingle data element has succeeded, the current address of the masterrequest is incremented. If the current address is beyond the lastto-be-addressed data element, the status of the request is set toSIMPLE_BUS_OK and the event is notified, for which the bus interfacefunction that issued the request is waiting.If there are more data elements to be sent to the slave interface, thestatus of the request remains SIMPLE_BUS_WAIT. At the next fallingclock edge the bus process continues with the data transfer to theslave until all data elements are done.If a slave encounters an error, the status of the request is set toSIMPLE_BUS_ERROR and the event is notified, for which thebus interface function that issued the request is waiting.The bus interface function does not actually wait until the status ofthe call becomes SIMPLE_BUS_OK or SIMPLE_BUS_ERROR, but waits for anevent coming from the bus process indicating that the transfer iscompleted. This event comes at the falling clock edge. An additionalwait for the next rising clock edge must be issued in orderto synchronize:simple_bus_status burst_read(...) {  // register request  ...  wait(request->transfer_done);  wait(clock->posedge_event());  return get_status(priority);}1.4.2 Non-Blocking RequestA non-blocking master request is done at a rising clock edge. Therequest is registered by the bus by filling in the request form andthe status of the request is set to SIMPLE_BUS_REQUEST. Thenon-blocking function returns. The status of the request changes assoon as the bus handles the request, and that happens at a fallingclock edge.Now the master must check for the status of the request until thestatus is either SIMPLE_BUS_OK or SIMPLE_BUS_ERROR. Only the busprocess can change the status of the request once the request ismade. And that happens only at a falling clock edge. The sameprocedure is now followed for transferring one single data elementthrough the bus as is described for the blocking interface requestfunctions.1.4.3 Direct RequestA direct interface request from a master does not follow the busprotocol, but is handled instantaneously. Once the request is issuedby a master, it is directly transformed into the corresponding directslave interface function call. The only action performed by the bus isthe selection of the slave according to the address argument of thedirect interface function call.At the slave this direct request is also processed immediately withouthonoring the wait states of the slave. The function will return andits return value is either true if the given address could be readand/or written, or is false if that is not the case.The return value of the direct request of the bus interface functioncall is the same as for the slave side of the interface, only when theaddress parameter could not be mapped to a slave, it will also returnfalse.1.5 Interfaces Usedclass simple_bus_direct_if    : virtual public sc_interface    {...};class simple_bus_non_blocking_if    : virtual public sc_interface    {...};class simple_bus_blocking_if    : virtual public sc_interface    {...};class simple_bus_arbiter_if    : virtual public sc_interface    {...};class simple_bus_slave_if    : public simple_bus_direct_if   {...};1.5.1 BusThe bus is a hierarchical channel, providing the three differentbus interfaces, and containing a clock port, an arbiter port and a(multi-)port for connecting one or more slaves. class simple_bus   : public simple_bus_direct_if   , public simple_bus_non_blocking_if   , public_simple_bus_blocking_if   , public sc_module   {      sc_clk_in clock;      sc_port<simple_bus_slave_if, 0> slave_port;      sc_port<simple_bus_arbiter_if> arbiter_port;      ...   };The implementation of the main process of the bus is a method process,using dynamic sensitivity for 'communicating' with the bus interfacefunctions. The communication towards the slave interface does not usedynamic sensitivity.1.5.2 ArbiterThe arbiter is a hierarchical channel that provides thesimple_bus_arbiter_if interface.class simple_bus_arbiter   : public simple_bus_arbiter_if   , public sc_module   {...};2. The TestbenchThe testbench consists of an instantiation of the simple_bus with anarbiter, three masters and two slaves. Both slaves model a randomaccess memory where the first memory does not have a wait state whilethe second memory has (some). The testbench contains three masterswhere each master issues only requests of a particular interface, likeonly issuing blocking interface function calls, only non-blockinginterface function calls or only direct interface function calls.2.1 SlavesTwo kinds of memories are to be modeled: one without wait states andone with a configurable number of wait states. 2.1.1 Fast Memory SlavesThe fast memory slave has no wait states and no clock port. It reactsimmediately to the bus request and sets the status accordingly. class simple_bus_fast_mem   : public simple_bus_slave_if   , public sc_module   {   public:      // no ports      // constructor      simple_bus_fast_mem(sc_module_name name,                          unsigned int start_address,                          unsigned int end_address)       ...      // interface methods      ...   };The start_address points to the first byte of the first word in the memory of this slave and is a word aligned address, i.e. it has to be a multiple of 4. The end_address points to the last byte of the last word in the memory area of this slave, i.e. to address (start_address + storage_size_in_words * 4 - 1).2.1.2 Slow Memory SlavesThe slow memory slave has a configurable number of wait states(constructor argument), and contains a clock port. Once a request ismade, the status is set to SIMPLE_BUS_WAIT, and a counter is set. Eachrising clock edge this counter is decremented and checked, and if itbecomes zero, the status is set to SIMPLE_BUS_OK. This status ispicked up by the bus at the next falling clock edge.class simple_bus_slow_mem   : public simple_bus_slave_if   , public sc_module   {   public:      sc_clk_in clock;      // constructor      simple_bus_slow_mem(sc_module_name name,                          unsigned int start_address,                          unsigned int end_address,                           unsigned int nr_wait_states)      ...      // interface methods      ...   };The start_address points to the first byte of the first word in the memory of this slave and is a word aligned address, i.e. it has to be a multiple of 4. The end_address points to the last byte of the last word in the memory area of this slave, i.e. to address (start_address + storage_size_in_words * 4 - 1).2.2 MastersFor the testbench three masters are defined, each using one businterface: blocking, non-blocking or direct. The main_action of eachmaster is a thread process.2.2.1 Non-Blocking MastersSC_MODULE(simple_bus_master_non_blocking)   {     // ports     sc_clk_in clock;     sc_port<simple_bus_non_blocking_if> bus_port;     // constructor     simple_bus_master_non_blocking(sc_module_name name,                                    unsigned int unique_priority,                                    ...)     ...   };In this example the non-blocking master reads data from a memory location, performs an arithmetic operation on this data and writes it back to memory. This happens in a loop so that the memory locations are at least changed each loop iteration.2.2.2 Blocking MastersSC_MODULE(simple_bus_master_blocking)   {     // ports     sc_clk_in clock;     sc_port<simple_bus_blocking_if> bus_port;     // constructor     simple_bus_master_blocking(sc_module_name name,                                 unsigned int unique_priority,                                ...)     ...   };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -