-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopcode.h
More file actions
91 lines (78 loc) · 2.21 KB
/
opcode.h
File metadata and controls
91 lines (78 loc) · 2.21 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _OPCODE_H_
#define _OPCODE_H_
#include <stdint.h>
#include <stdio.h>
#define START_CODE 0x1eadc0de
/* rom tick is 40ns: so 1us = 1000ns / 40ns = 25 ticks */
#define TICKS_PER_US (1000 / 40)
typedef union rom_op_cmd_s {
struct {
uint32_t cmd : 8;
uint32_t num : 24;
} b;
uint32_t w;
} rom_op_cmd_t;
typedef struct rom_op_wr_s {
rom_op_cmd_t cmd;
uint32_t addr;
} rom_op_wr_t;
typedef struct rom_op_waiteq_s {
rom_op_cmd_t cmd;
uint32_t addr;
uint32_t data;
uint32_t mask;
} rom_op_waiteq_t;
typedef struct rom_op_waitne_s {
rom_op_cmd_t cmd;
uint32_t addr;
uint32_t data;
uint32_t mask;
} rom_op_waitne_t;
typedef struct rom_op_jmp_s {
rom_op_cmd_t cmd;
uint32_t addr;
uint32_t data;
uint32_t mask;
} rom_op_jmp_t;
typedef struct rom_op_delay_s {
rom_op_cmd_t cmd;
} rom_op_delay_t;
typedef struct rom_op_rmw_s {
rom_op_cmd_t cmd;
uint32_t addr;
uint32_t data;
uint32_t mask;
} rom_op_rmw_t;
typedef struct rom_op_cp_s {
rom_op_cmd_t cmd;
uint32_t src;
uint32_t dst;
} rom_op_cp_t;
typedef struct rom_op_quit_s {
rom_op_cmd_t cmd;
} rom_op_quit_t;
void start_code(FILE *fp);
void quit_code(FILE *fp);
void wr_code(FILE *fp, uint32_t addr, uint32_t length, uint32_t *data);
void wr_single(FILE *fp, uint32_t addr, uint32_t value);
void waiteq_code(FILE *fp, uint32_t addr, uint32_t mask, uint32_t target,
uint32_t delay);
void waitne_code(FILE *fp, uint32_t addr, uint32_t mask, uint32_t target,
uint32_t delay);
void delay_code(FILE *fp, uint32_t delay);
void rmw_code(FILE *fp, uint32_t addr, uint32_t mask, uint32_t value);
void clrbit_code(FILE *fp, uint32_t addr, uint32_t value);
void setbit_code(FILE *fp, uint32_t addr, uint32_t value);
void add_code(FILE *fp, uint32_t addr, uint32_t value);
void cp_code(FILE *fp, uint32_t src, uint32_t dst, uint32_t size_dw);
void declare_label(FILE *fp, char *name);
void jeq_code(FILE *fp, uint32_t addr, uint32_t mask, uint32_t target,
char *label_name);
void jne_code(FILE *fp, uint32_t addr, uint32_t mask, uint32_t target,
char *label_name);
void jmp_code(FILE *fp, char *label_name);
void print_labels(void);
void link_labels(FILE *fp);
void print_rom_patch(FILE *fp);
void parse_opcode(FILE *fp);
#endif /* end of "ifndef _OPCODE_H_" */