-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlabeltable.v
More file actions
35 lines (31 loc) · 845 Bytes
/
labeltable.v
File metadata and controls
35 lines (31 loc) · 845 Bytes
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
`timescale 1ns / 1ps
module LabelTable(clk, lbid, lbidw, typ, typw, base, basew, count, countw, we);
parameter LBIDWidth = 8;
input clk, we;
input [LBIDWidth-1:0] lbid, lbidw;
output reg [5:0] typ;
input [5:0] typw;
output reg [15:0] base;
input [15:0] basew;
output reg [15:0] count;
input [15:0] countw;
//
wire [LBIDWidth-1:0] lbidrw;
reg [5:0] typefile[2**LBIDWidth-1:0]; // 左が要素の幅、右が添字範囲
reg [15:0] basefile[2*LBIDWidth-1:0];
reg [15:0] countfile[2*LBIDWidth-1:0];
assign lbidrw = (we == 1) ? lbidw : lbid;
always @ (posedge clk)
begin
if(we == 1) begin
typefile[lbidrw] <= typw;
basefile[lbidrw] <= basew;
countfile[lbidrw] <= countw;
end
else begin
typ <= typefile[lbidrw];
base <= basefile[lbidrw];
count <= countfile[lbidrw];
end
end
endmodule