中级会员
- 积分
- 407
- 金钱
- 407
- 注册时间
- 2015-8-21
- 在线时间
- 92 小时
|
1金钱
module TOP(
wr_clk, //66.667MHz
rd_clk,
dout
);
//clk
input wr_clk;
input rd_clk;
output[7:0] dout;
wire [ 7:0] din_wire;
wire [10:0] wr_data_count;
wire wr_en;
wire rd_en;
wire full;
wire empty;
assign wr_en = (rd_en==0 && din<=11 ) ? 1 : 0;
assign rd_en = (empty==0) ? 1 : 0;
reg[7:0] din = 0;
always @(posedge wr_clk)
begin
if(wr_en)
din <= din + 1;
end
assign din_wire = din;
uart_ffdc_tx uart_ffdc_tx_inst(
.wr_clk (wr_clk),
.rd_clk (rd_clk),
.din (din_wire),
.wr_en (wr_en),
.rd_en (rd_en),
.dout (dout),
.full (full),
.empty (empty),
.wr_data_count (wr_data_count)
);
endmodule
module test_fifo;
reg wr_clk;
reg rd_clk;
wire [7:0] dout;
TOP uut (
.wr_clk(wr_clk),
.rd_clk(rd_clk),
.dout(dout)
);
parameter clk_period = 1000/132.0;
parameter osc_period = 1000/14.7456;
initial begin
wr_clk = 0;
forever
#(clk_period/2) wr_clk = ~wr_clk;
end
initial begin
rd_clk = 0;
forever
#(osc_period/2) rd_clk = ~rd_clk;
end
endmodule
|
|