已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
module first_counter (clock , / Clock input of the designreset , / active high, synchronous Reset inputenable , / Active high enable signal for countercounter_out / 4 bit vector output of the counter); / End of port list/-Input Ports-input clock ;input reset ;input enable ;/-Output Ports-output 3:0 counter_out ;/-Input ports Data Type-/ By rule all the input ports should be wires wire clock ;wire reset ;wire enable ;/-Output Ports Data Type-/ Output port can be a storage element (reg) or a wirereg 3:0 counter_out ;/-Code Starts Here-/ Since this counter is a positive edge trigged one,/ We trigger the below block with respect to positive/ edge of the clock.always (posedge clock)begin : COUNTER / Block Name/ At every rising edge of clock we check if reset is active/ If active, we load the counter output with 4b0000if (reset = 1b1) begincounter_out = #1 4b0000;end/ If enable is active, then we increment the counterelse if (enable = 1b1) begincounter_out = #1 counter_out + 1;endend / End of Block COUNTERendmodule / End of Module counterTestbench of counter4include first_counter.v 2module first_counter_tb();3/ Declare inputs as regs and outputs as wires4reg clock, reset, enable;5wire 3:0 counter_out;67/ Initialize all variables8initial begin 9$display ( timet clk reset enable counter ); 10$monitor ( %gt %b % %b %b , 11$time, clock, reset, enable, counter_out); 12clock = 1; / initial value of clock13reset = 0; / initial value of reset14enable = 0; / initial value of enable15r#5eset = 1; / Assert the reset16#10 reset = 0; / De-assert the reset17#5 enable = 1; / Assert enable18#100 enable = 0; / De-assert enable19#10 $finish; / Terminate simulation20end2122/ Clock generator23always begin24#5 clock = clock; / Toggle clock every 5 ticks25end2627/ Connect DUT to test bench28first_counter U_counter (29clock,30reset,31enable,32counter_out33);3435endmodule1module arbiter ( 2clock, 3reset, 4req_0, 5req_1, 6gnt_0, 7gnt_1 8); 910input clock, reset, req_0, req_1; 11output gnt_0, gnt_1; 1213reg gnt_0, gnt_1; 1415always (posedge clock or posedge reset) 16if (reset) begin 17gnt_0 = 0; 18gnt_1 = 0; 19end else if (req_0) begin 20gnt_0 = 1; 21gnt_1 = 0; 22end else if (req_1) begin 23gnt_0 = 0; 24gnt_1 = 1; 25end 2627endmodule 29module arbiter_tb; 3031reg clock, reset, req0,req1; 32wire gnt0,gnt1; 3334initial begin 35$monitor ( req0=%b,req1=%b,gnt0=%b,gnt1=%b , req0,req1,gnt0,gnt1); 36clock = 0; 37reset = 0; 38req0 = 0; 39req1 = 0; 40#5 reset = 1; 41#15 reset = 0; 42#10 req0 = 1; 43#10 req0 = 0; 44#10 req1 = 1; 45#10 req1 = 0; 46#10 req0,req1 = 2b11; 47#10 req0,req1 = 2b00; 48#10 $finish; 49end 5051always begin 52#5 clock = clock; 53end
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 16财经商贸大类2027广西专升本财经商贸大类全真模拟-第二套(能力提升·中)(含详解与质量评价)
- 20 狼(教学设计)-2026-2027学年统编版语文七年级上册
- 20XX教师节短信祝福语教师节发给老师的祝福短信大全
- 江苏省扬州市2027届高三下学期联考数学试题含解析
- 安徽省重点高中联考2026-2027学年高一上学期期中考试政治试卷
- 钢桩施工检验批质量验收记录
- 2026年野生动物栖息地修复员(技师)职业技能等级认定考前冲刺试题
- 2026年土壤采样分析员(初级)职业技能等级认定模拟试题
- 2026年道床清筛机操作员(高级)职业技能等级认定历年真题
- 八年级地理上学期 主题学习 增强国家海洋权益意识 教学设计
- 2026河北石家庄市中晟华章企业管理有限公司公开招聘35人笔试备考题库及答案解析
- 河南省洛阳市2026-2027学年高一上学期11月期中考试化学试卷
- 湖北武汉华师一附中2027届高三上学期11月期中考试数学试卷
- 安徽省建设工程工程量清单计价规程(2026版)
- 住宿场所旅客突发疾病应急方案
- (2026年)个人述职述廉述德报告
- 管理人员竞聘考试题库及答案
- 老旧小区改造外墙保温施工组织设计
- 供水公司泵站运行管理制度
- 2026年高考英语口语北京卷考试真题
- 2025~2026学年江苏省如皋市高二上学期期末考试生物试卷
评论
0/150
提交评论