summaryrefslogtreecommitdiffstats
path: root/cpu8/cpu_code_reg/cpu_code_reg.hpp
blob: c48a2560e640c51862681fac08ddde38f44f3726 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef __SYSC_CPU_CODE_REG_HPP
#define __SYSC_CPU_CODE_REG_HPP

#include "systemc.h"
#include "../cpu_and/cpu_and.hpp"
#include "../cpu_not/cpu_not.hpp"
#include "../cpu_srlatch/cpu_srlatch.hpp"

SC_MODULE (cpu_code_reg) 
{
	//Inputs
	sc_port<sc_signal_in_if<bool>,0> in_d;
	sc_port<sc_signal_in_if<bool>,0> in_e;
	//Outputs
	sc_port<sc_signal_out_if<bool>,0> out_q;
	//Internal variables
	bool bit=false;

	void do_code_reg()
	{
		//if enabled
		if (in_e[0]->read())
		{
			//set data
			bit = in_d[0]->read();
		}
		//no delay
		out_q[0]->write(bit);
	}

	SC_CTOR(cpu_code_reg)
	{	
		SC_METHOD(do_code_reg);
		sensitive << in_d << in_e;
	}

};

#endif