-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMACTB.v
81 lines (66 loc) · 1.6 KB
/
MACTB.v
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
//////////////////////////////////////////////////////////////////////////////////
// Company: SIU Education
// Engineer: Michael Tjemmes
//
// Create Date: 11/19/2021
// Design Name: Piplined Version
// Module Name: MACTB
// Project Name: Final Project
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module MACTB;
reg clk;
reg [0:127] data_a [0:39];
reg [0:127] data_b [0:39];
reg [0:127] a, b;
reg [0:7] count;
reg rst;
wire clk2;
wire [0:19] p;
integer outfile;
parameter half_cycle = 10;
initial
begin
$readmemh("weights_hex.txt", data_a);
$readmemh("digits_hex.txt", data_b);
outfile = $fopen("simout.txt", "w");
clk =0;
count = 0;
rst =0;
end
//Clock Generations
always
begin
clk=1;
#half_cycle;
clk=0;
#half_cycle;
end
assign #2 clk2 = clk; // delayed clk
MAC uut(a,b,clk2,rst,p);
//MAC2 uut(a,b,p);
always @(posedge clk)
begin
$fdisplay(outfile, "%d: a=%h, b=%h, p=%h", count, a, b, p);
end
always @(posedge clk2)
begin
a=data_a[count];
b=data_b[count];
count= count+1;
if (count==43)
begin
$fclose(outfile);
$finish;
end
end
endmodule