数字电路设计讲座new.docVIP

  • 4
  • 0
  • 约7.53千字
  • 约 12页
  • 2016-10-18 发布于江西
  • 举报
数字电路设计讲座new.doc

数字电路设计讲座 必须掌握的技能 如何运用Verilog HDL语言进行电路设计 怎样实现层次化/结构化设计 怎样编写测试激励(test_bench) 怎样调试电路代码和进行电路仿真(Debbusy、Modelsim) (一)verilog语言简介(通过几个实例来说明) 1,帧头检测电路 module frame_head_detect (clk, reset, cout, cin); input clk, reset, cin; output cout; reg [7:0] temp; always @ (posedge clk or posedge reset) if (reset) temp = 8b0; else temp = {temp[7:0], cin}; assign cout = (temp==8; endmodule 说明:1,电路模块以module开始,以endmodule结束。 2,电路模块由名称、端口信号、端口信号说明、程序体等组成。 3,程序体由中间信号、语句等组成。 4,语句主要有always和assign语句。边沿触发和电平触发。 5,信号有wire和reg(register)之分。它们可以互换,没有本质区别。 6,改写temp = {temp[7:0], cin}; 7,改写assign cout = (temp==8; 2,查找表电路 module rom_data8 (addr, data, parity); input [2:0] addr; output [3:0] data; output parity; reg [4:0] mem [0:7]; wire [4:0] data_temp; assign data_temp = mem[addr]; assign data = data_temp[4:1]; assign parity = data_temp[0]; initial $readmemh(D:/rom_cof.hex, mem); endmodule 问题:在这个模块中,data_temp定义为wire,所以用assign语句赋值,如何改成always语句的赋值方式? 3,随机数产生器发送和接收电路 //*********************************************************************** //file: prbs15_tx.v // functions: Complete prbs15 transmit function. //author: Yao Yafeng //version 1.0 2010-09-12 //************************************************************************ module prbs15_tx( //input reset, clk2m, phaseinv, //output prbsdata ); Input reset; Input clk2m; Input phaseinv; //测试码反相使能,1表示发送码流反相 Output prbsdata; //产生15位的M序列 Reg [14:0] shift_buf; always @ (posedge clk2m or posedge reset) if(reset) shift_buf =15b100100100000000; //设定初始值 else begin shift_buf[0] =shift_buf[13]^shift_buf[14]; //15级M序列编码规则 shift_buf[1] = shift_buf[0]; shift_buf[2] = shift_buf[1]; shift_buf[3] = shift_buf[2]; shift_buf[4] = shift_buf[3]; shift_buf[5] = shift_buf[4]; shift_buf[6] = shift_buf[5]; shift_buf[7] = shift_buf[6]; shift_buf[8] = shift_buf[7]; shift_buf[9] =

文档评论(0)

1亿VIP精品文档

相关文档