如何实现乒乓操作Word文档格式.docx

上传人:b****3 文档编号:15506794 上传时间:2022-11-03 格式:DOCX 页数:7 大小:130.08KB
下载 相关 举报
如何实现乒乓操作Word文档格式.docx_第1页
第1页 / 共7页
如何实现乒乓操作Word文档格式.docx_第2页
第2页 / 共7页
如何实现乒乓操作Word文档格式.docx_第3页
第3页 / 共7页
如何实现乒乓操作Word文档格式.docx_第4页
第4页 / 共7页
如何实现乒乓操作Word文档格式.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

如何实现乒乓操作Word文档格式.docx

《如何实现乒乓操作Word文档格式.docx》由会员分享,可在线阅读,更多相关《如何实现乒乓操作Word文档格式.docx(7页珍藏版)》请在冰豆网上搜索。

如何实现乒乓操作Word文档格式.docx

rst_n,

data_in,//输入数据

data_out//输出数据

);

inputclk;

inputrst_n;

input[7:

0]data_in;

output[7:

0]data_out;

reg[7:

0]buffer1[255:

0];

//缓存区1

0]buffer2[255:

0];

//缓存区2

regwr_flag;

//写标志,wr_flag=0,写buffer1,wr_flag=1,写buffer2

regrd_flag;

//读标志,rd_flag=0,读buffer2,wr_flag=1,读buffer1

regstate;

//状态机,0:

写1读2,1:

写2读1,状态转移和输出分开编码

reg[7:

0]cnt;

parameterstate0=1'

b0;

parameterstate1=1'

b1;

always@(posedgeclkornegedgerst_n)//状态转移

begin

if(rst_n==1'

b0)cnt<

=0;

elsecnt<

=cnt+1;

end

always@(posedgeclkornegedgerst_n)//状态转移

begin

if(rst_n==1'

b0)state<

=1'

else

begin

case(state)

state0:

if(cnt==8'

hff)state<

state1:

default:

state<

endcase

end

end

always@(state)//状态输出

case(state)

state0:

begin

wr_flag=1'

//写1

rd_flag=1'

//读2

end

state1:

wr_flag=1'

//写2

rd_flag=1'

//读1

end

default:

endcase

end

always@(posedgeclk)

begin

case(wr_flag)

1'

b0:

buffer1[cnt]<

=data_in;

//wr_flag=0,写buffer1

b1:

buffer2[cnt]<

//wr_flag=1,写buffer2

default:

buffer1[cnt]<

=8'

buffer2[cnt]<

end

endcase

end

always@(posedgeclkornegedgerst_n)

begin

if(rst_n==1'

b0)data_out<

else

begin

case(rd_flag)

1'

b0:

data_out<

=buffer2[cnt];

//rd_flag=0,读buffer2

b1:

=buffer1[cnt];

//rd_flag=1,读buffer1

default:

b0;

endcase

end

end

endmodule

TB代码如下:

`timescale100ns/10ns

modulepingpang_tb_v;

//Inputs

regclk;

regrst_n;

reg[7:

0]data_in;

//Outputs

wire[7:

//InstantiatetheUnitUnderTest(UUT)

pingpanguut(

.clk(clk),

.rst_n(rst_n),

.data_in(data_in),

.data_out(data_out)

);

initial

begin

//InitializeInputs

clk=0;

rst_n=0;

data_in=0;

#100;

rst_n=1;

always#10clk=~clk;

always@(posedgeclkornegedgerst_n)

if(rst_n==1'

b0)data_in<

elsedata_in<

=data_in+1'

end

仿真波形如图:

当state进行状态切换后,数据读写存储区域发生了变化,实现乒乓的操作。

通过“输入数据选择单元”和“输出数据选择单元’’按节拍的切换,将经过缓冲的数据流没有停顿地送到“数据流运算处理模块”进行运算处理。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 财务管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1