ParaNut SystemC Model
A SystemC Model of the ParaNut architecture
intc.h
Go to the documentation of this file.
1 /*************************************************************************
2 
3  This file is part of the ParaNut project.
4 
5  Copyright (C) 2019 Alexander Bahle <alexander.bahle@hs-augsburg.de>
6  Hochschule Augsburg, University of Applied Sciences
7 
8  Description:
9  This is a SystemC model of a simple Interrupt Controller for the
10  ParaNut.
11 
12  Redistribution and use in source and binary forms, with or without modification,
13  are permitted provided that the following conditions are met:
14 
15  1. Redistributions of source code must retain the above copyright notice, this
16  list of conditions and the following disclaimer.
17 
18  2. Redistributions in binary form must reproduce the above copyright notice,
19  this list of conditions and the following disclaimer in the documentation and/or
20  other materials provided with the distribution.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  *************************************************************************/
34 #ifndef _INTCONTROL_
35 #define _INTCONTROL_
36 
37 #include "base.h"
38 #include "paranut-config.h"
39 
40 #include <systemc.h>
41 
42 // **************** INTC States *************
43 typedef enum {
48 
49 
50 // **************** MIntC *************
51 class MIntC : ::sc_core::sc_module {
52 public:
53  // Ports ...
54  sc_in<bool> clk, reset;
55 
56  // to CePU
57  // Interrupt request: CePU executes the interrupt handler
58  sc_out<bool> ir_request;
59  // Interrupt ID: Interrupt information, gets saved in mcause CSR
60  sc_out<sc_uint<5> > ir_id;
61  // to csr mip register MTIP bit
62  sc_out<bool> mip_mtip_out;
63  // to csr mip register MEIP bit
64  sc_out<bool> mip_meip_out;
65 
66  // from CePU
67  // Interrupt acknowledge: Set on jump to the interrupt handler
68  sc_in<bool> ir_ack;
69  // Interrupt enbale: Main enable for the interrupt controller
70  sc_in<bool> ir_enable;
71 
72  // from mtimer
73  sc_in<bool> mtimer_int;
74 
75  // from external interrupts:
76  sc_in<sc_uint<CFG_NUT_EX_INT> > ex_int;
77 
78  // Constructor...
79  SC_HAS_PROCESS (MIntC);
80  MIntC (sc_module_name name)
81  : sc_module (name) {
82  SC_METHOD (OutputMethod);
83  sensitive << state << id_reg << mtip_reg << meip_reg;
84  SC_METHOD (TransitionMethod);
85  sensitive << clk.pos ();
86  }
87 
88  // Functions...
89  void Trace (sc_trace_file * tf, int levels = 1);
90 
91  // Processes...
92  void OutputMethod ();
93  void TransitionMethod ();
94 
95 protected:
96  // Registers ...
97  sc_signal<sc_uint<2> > state;
98  sc_signal<sc_uint<5> > id_reg;
99  sc_signal<bool> mtip_reg;
100  sc_signal<bool> meip_reg;
101  sc_signal<sc_uint<CFG_NUT_EX_INT> > irq_reg;
102 };
103 
104 
105 #endif
Helpers, Makros and performance measuring Classes used in most ParaNut files.
Definition: intc.h:51
sc_out< bool > ir_request
Definition: intc.h:58
sc_in< bool > clk
Definition: intc.h:54
sc_in< bool > reset
Definition: intc.h:54
sc_signal< sc_uint< 2 > > state
Definition: intc.h:97
void TransitionMethod()
Definition: intc.cpp:74
void OutputMethod()
Definition: intc.cpp:62
void Trace(sc_trace_file *tf, int levels=1)
Definition: intc.cpp:40
sc_in< bool > ir_ack
Definition: intc.h:68
sc_signal< bool > mtip_reg
Definition: intc.h:99
sc_signal< sc_uint< 5 > > id_reg
Definition: intc.h:98
sc_out< bool > mip_mtip_out
Definition: intc.h:62
sc_signal< sc_uint< CFG_NUT_EX_INT > > irq_reg
Definition: intc.h:101
sc_in< bool > mtimer_int
Definition: intc.h:73
sc_out< bool > mip_meip_out
Definition: intc.h:64
sc_out< sc_uint< 5 > > ir_id
Definition: intc.h:60
sc_signal< bool > meip_reg
Definition: intc.h:100
sc_in< bool > ir_enable
Definition: intc.h:70
MIntC(sc_module_name name)
Definition: intc.h:80
sc_in< sc_uint< CFG_NUT_EX_INT > > ex_int
Definition: intc.h:76
EIntStates
Definition: intc.h:43
@ IntHandled
Definition: intc.h:46
@ IntPending
Definition: intc.h:45
@ IntIdle
Definition: intc.h:44
Configuration Makros used in most ParaNut files.
sc_trace_file * tf
Definition: tlb_tb.cpp:94