-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.h
67 lines (49 loc) · 2.01 KB
/
pipeline.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/******************************************************************************
* pipe.h
*
* Code for implementing pipelined processor simulators
******************************************************************************/
#ifndef PIPE_H
#define PIPE_H
/******************************************************************************
* #includes
******************************************************************************/
#include <stdio.h>
/******************************************************************************
* typedefs
******************************************************************************/
/* Different control operations for pipeline register */
/* LOAD: Copy next state to current */
/* STALL: Keep current state unchanged */
/* BUBBLE: Set current state to nop */
/* ERROR: Occurs when both stall & load signals set */
typedef enum { P_LOAD, P_STALL, P_BUBBLE, P_ERROR } p_stat_t;
typedef struct {
/* Current and next register state */
void *current;
void *next;
/* Contents of register when bubble occurs */
void *bubble_val;
/* Number of state bytes */
int count;
/* How should state be updated next time? */
p_stat_t op;
} pipe_ele, *pipe_ptr;
/******************************************************************************
* function declarations
******************************************************************************/
/* Create new pipe with count bytes of state */
/* bubble_val indicates state corresponding to pipeline bubble */
pipe_ptr new_pipe(int count, void *bubble_val);
/* Update all pipes */
void update_pipes();
/* Set all pipes to bubble values */
void clear_pipes();
/* Utility code */
/* Print hex/oct/binary format with leading zeros */
/* bpd denotes bits per digit Should be in range 1-4,
bpw denotes bits per word.*/
void wprint(uword_t x, int bpd, int bpw, FILE *fp);
void wstring(uword_t x, int bpd, int bpw, char *s);
/******************************************************************************/
#endif /* PIPE_H */