-
Notifications
You must be signed in to change notification settings - Fork 0
/
mult4.c
55 lines (45 loc) · 1.23 KB
/
mult4.c
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
#include <stdio.h>
#include "genpat.h"
#define step 400000LL
#define delay 400000LL
char intToStr(inteiro)
int inteiro; {
charstr;
str = (char) mbkalloc(32sizeof(char));
sprintf(str, "%d", inteiro);
return (str);
}
int main() {
int i;
int j;
int k;
int time = 0;
int cout = 0;
DEF_GENPAT("mult4_genpat");
DECLAR("a", ":2", "X", IN, "3 downto 0", "");
DECLAR("b", ":2", "X", IN, "3 downto 0", "");
DECLAR("product", ":2", "X", OUT, "7 downto 0", "");
DECLAR("cout", ":2", "B", OUT, "", "");
DECLAR("vdd", ":2", "B", IN, "", "");
DECLAR("vss", ":2", "B", IN, "", "");
LABEL("multiplicacao");
AFFECT("0", "vdd", "0b1");
AFFECT("0", "vss", "0b0");
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
k = i*j;
AFFECT(intToStr(time), "a", intToStr(i));
AFFECT(intToStr(time), "b", intToStr(j));
time += delay;
AFFECT(intToStr(time), "product", intToStr(k&0xf));
if (k < 9) {
AFFECT(intToStr(time), "cout", "0");
} else {
AFFECT(intToStr(time), "cout", "1");
time += step;
}
}
}
SAV_GENPAT();
return 0;
}