-
Notifications
You must be signed in to change notification settings - Fork 8
/
inst.sv
63 lines (58 loc) · 1.64 KB
/
inst.sv
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
module inst (
input logic [NBITS_TOP-1:0] address,
input logic clock,
output logic [31:0] q);
int data[1<<(NBITS_TOP-2)];
initial begin
int fd, addr, ins;
fd = $fopen("inst.objdump","r");
if(fd)
for(addr=0; addr<(1<<(NBITS_TOP-2)); addr++) begin
$fscanf(fd,"%h",ins);
if($feof(fd)) data[addr] = 0; else begin
ins = {ins[7:0],ins[15:8],ins[23:16],ins[31:24]}; // correct endianess
$fdisplay(32'h8000_0002,"%h",ins);
data[addr] = ins;
end
end
else begin
fd = $fopen("inst.101","r");
if(fd) begin
byte c, has_ins;
has_ins=0;
do begin
c = $fgetc(fd);
case(c)
";": begin
do c = $fgetc(fd);
while(c!=10);
if(has_ins) begin
$fdisplay(32'h8000_0002,"%h",ins);
data[addr] = ins;
addr++;
ins = 0;
has_ins=0;
end
end
"0": begin
ins = ins<<1;
has_ins++;
end
"1": begin
ins = ins<<1 | 1;
has_ins++;
end
10: if(has_ins) begin
$display("%h",ins);
data[addr] = ins;
addr++;
ins = 0;
has_ins=0;
end
endcase
end while(!$feof(fd));
end
end
end
always @(posedge clock) q <= data[address[NBITS_TOP-1:2]];
endmodule