-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller_tb.v
More file actions
64 lines (40 loc) · 1.27 KB
/
Copy pathcontroller_tb.v
File metadata and controls
64 lines (40 loc) · 1.27 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
`timescale 1ns / 1ps
module controller_tb;
parameter T_dot = 1000;//ns
parameter PERIOD = 20;//clk from generator
parameter K = T_dot/PERIOD;
reg i_clk, i_rst;
wire o_clk1, o_clk2;
wire o_cst;
wire [15:0] o_adrT;
wire [7:0] data_t;
wire [23:0] o_ycd;
wire o_ENW, o_ENR, o_out;
wire [23:0] o_xdc;
wire o_csr;
wire [15:0] o_adrR;
wire [7:0] data_r;
reg [7:0] rom[4095:0];
controller ctrl_inst(.in_clk(i_clk), .rst(i_rst), .DT(data_t), .cst(o_cst), .adrT(o_adrT), .DR(data_r), .csr(o_csr), .adrR(o_adrR), .ENW(o_ENW), .clk1(o_clk1), .clk2(o_clk2), .ENR(o_ENR));
input_ROM rom_inst(.clk(o_clk2), .cs(o_cst), .adr(o_adrT), .data(data_t));
cd cd_inst(.clk(o_clk2), .x(data_t), .y(o_ycd));
IOD iod_inst(.clk1(o_clk1), .clk2(o_clk2), .rst(i_rst), .DW(o_ycd), .ENW(o_ENW), .DR(o_xdc), .ENR(o_ENR), .in(o_out), .out(o_out));
dc dc_inst(.clk(o_clk2), .x(o_xdc), .y(data_r));
output_ROM rom_out_inst(.clk(o_clk2), .cs(o_csr), .adr(o_adrR), .data(data_r));
initial begin
forever #(PERIOD) if(o_csr) begin
rom[o_adrR] = data_r;
end
end
initial begin
i_clk = 0;
forever #(PERIOD/2) i_clk = ~i_clk;
end
initial begin
i_rst = 1'b0;
@(negedge i_clk) i_rst = 1'b1;
repeat (50) @(negedge o_clk2);
$writememh("outh.txt", rom);
$finish;
end
endmodule