ParaNut SystemC Model
A SystemC Model of the ParaNut architecture
ifu.h
Go to the documentation of this file.
1 /*************************************************************************
2 
3  This file is part of the ParaNut project.
4 
5  Copyright (C) 2010-2022 Alexander Bahle <alexander.bahle@hs-augsburg.de>
6  Gundolf Kiefer <gundolf.kiefer@hs-augsburg.de>
7  Christian H. Meyer <christian.meyer@hs-augsburg.de>
8  Hochschule Augsburg, University of Applied Sciences
9 
10  Description:
11  This is a SystemC model of the instruction fetch unit (IFU) of the
12  ParaNut. The IFU interfaces with the MEMU and the EXU and is capable
13  of instruction prefetching.
14 
15  Redistribution and use in source and binary forms, with or without modification,
16  are permitted provided that the following conditions are met:
17 
18  1. Redistributions of source code must retain the above copyright notice, this
19  list of conditions and the following disclaimer.
20 
21  2. Redistributions in binary form must reproduce the above copyright notice,
22  this list of conditions and the following disclaimer in the documentation and/or
23  other materials provided with the distribution.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
29  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36  *************************************************************************/
37 
38 
39 #ifndef _IFU_
40 #define _IFU_
41 
42 #include "base.h"
43 #include "paranut-config.h"
44 
45 #include <systemc.h>
46 
47 
48 class MIfu : ::sc_core::sc_module {
49 public:
50  // Ports ...
51  sc_in<bool> clk, reset;
52 
53  // to MEMU (read port)...
54  sc_out<bool> rp_rd;
55  sc_in<bool> rp_ack;
56  sc_out<bool> rp_paging;
57  sc_out<sc_uint<32> > rp_adr;
58  sc_in<sc_uint<32> > rp_data;
59  sc_out<bool> rp_direct;
60  sc_in<bool> rp_ac_x;
61  sc_in<bool> rp_ac_u;
62 
63  // to EXU ...
64  sc_in<bool> next, jump, flush, paging;
65  // (next, jump) = (1, 1) lets the (current + 1)'th instruction be the jump target.
66  // Logically, 'jump' is performed before 'next'. Hence, jump instructions may either sequentially first
67  // assert 'jump' and then 'next' or both signals in the same cycle.
68  sc_in<sc_uint<32> > jump_adr;
69  sc_out<sc_uint<32> > ir, pc, npc; // registered outputs
70  sc_out<bool> ir_valid, npc_valid;
71  sc_in<bool> icache_enable;
72  sc_out<bool> ac_x;
73  sc_out<bool> ac_u;
74 
75  // Constructor...
76  SC_HAS_PROCESS (MIfu);
77  MIfu (sc_module_name name)
78  : sc_module (name) {
79  SC_METHOD (OutputMethod);
80  sensitive << insn_top << adr_top << next << sig_rp_read << paging;
81  for (int n = 0; n < CFG_IFU_IBUF_SIZE; n++)
82  sensitive << insn_buf[n] << adr_buf[n] << ac_x_buf[n] << ac_u_buf[n];
83  SC_METHOD (TransitionMethod);
84  sensitive << clk.pos ();
85  }
86 
87  // Functions...
88  void Trace (sc_trace_file * tf, int levels = 1);
89 
90  // Processes...
91  void OutputMethod ();
92  void TransitionMethod ();
93 
94 protected:
95  // Registers ...
96  sc_signal<TWord> insn_buf[CFG_IFU_IBUF_SIZE];
97  sc_signal<TWord> adr_buf[CFG_IFU_IBUF_SIZE];
98  sc_signal<sc_uint<CFG_IFU_IBUF_SIZE_LD + 1> > insn_top, // 'insn_top': first buffer place with not-yet-known contents (insn)
99  adr_top; // 'adr_top': first buffer place with not-yet-known address
100  sc_signal<bool> ac_x_buf[CFG_IFU_IBUF_SIZE];
101  sc_signal<bool> ac_u_buf[CFG_IFU_IBUF_SIZE];
102 
103  sc_signal<bool> last_rp_ack;
104  sc_signal<bool> rd_ack_dirty, sig_rp_read;
105  sc_signal<TWord> sig_rp_adr;
106 };
107 
108 
109 #endif
Helpers, Makros and performance measuring Classes used in most ParaNut files.
Definition: ifu.h:48
void Trace(sc_trace_file *tf, int levels=1)
Definition: ifu.cpp:38
sc_out< sc_uint< 32 > > ir
Definition: ifu.h:69
sc_signal< TWord > insn_buf[CFG_IFU_IBUF_SIZE]
Definition: ifu.h:96
sc_out< bool > npc_valid
Definition: ifu.h:70
sc_in< bool > next
Definition: ifu.h:64
void OutputMethod()
Definition: ifu.cpp:85
sc_signal< sc_uint< CFG_IFU_IBUF_SIZE_LD+1 > > adr_top
Definition: ifu.h:99
sc_out< bool > rp_paging
Definition: ifu.h:56
sc_in< sc_uint< 32 > > jump_adr
Definition: ifu.h:68
sc_in< bool > reset
Definition: ifu.h:51
sc_out< bool > rp_direct
Definition: ifu.h:59
sc_out< sc_uint< 32 > > pc
Definition: ifu.h:69
sc_out< bool > ir_valid
Definition: ifu.h:70
sc_in< bool > jump
Definition: ifu.h:64
sc_signal< bool > rd_ack_dirty
Definition: ifu.h:104
sc_in< bool > rp_ack
Definition: ifu.h:55
sc_out< sc_uint< 32 > > npc
Definition: ifu.h:69
sc_signal< bool > ac_u_buf[CFG_IFU_IBUF_SIZE]
Definition: ifu.h:101
sc_signal< bool > ac_x_buf[CFG_IFU_IBUF_SIZE]
Definition: ifu.h:100
MIfu(sc_module_name name)
Definition: ifu.h:77
sc_in< bool > flush
Definition: ifu.h:64
sc_in< bool > rp_ac_x
Definition: ifu.h:60
sc_in< bool > clk
Definition: ifu.h:51
sc_in< sc_uint< 32 > > rp_data
Definition: ifu.h:58
sc_in< bool > icache_enable
Definition: ifu.h:71
sc_signal< sc_uint< CFG_IFU_IBUF_SIZE_LD+1 > > insn_top
Definition: ifu.h:98
sc_out< bool > ac_x
Definition: ifu.h:72
sc_signal< TWord > sig_rp_adr
Definition: ifu.h:105
sc_out< bool > ac_u
Definition: ifu.h:73
sc_signal< bool > last_rp_ack
Definition: ifu.h:103
sc_signal< TWord > adr_buf[CFG_IFU_IBUF_SIZE]
Definition: ifu.h:97
void TransitionMethod()
Definition: ifu.cpp:102
sc_out< sc_uint< 32 > > rp_adr
Definition: ifu.h:57
sc_out< bool > rp_rd
Definition: ifu.h:54
sc_in< bool > rp_ac_u
Definition: ifu.h:61
sc_signal< bool > sig_rp_read
Definition: ifu.h:104
sc_in< bool > paging
Definition: ifu.h:64
#define CFG_IFU_IBUF_SIZE
Instruction buffer size (derived).
Definition: paranut-config.h:275
Configuration Makros used in most ParaNut files.
sc_trace_file * tf
Definition: tlb_tb.cpp:94