HDB3码编码器及解码器verilog代码编程及实现教案分析.pptVIP

  • 10
  • 0
  • 约5.6千字
  • 约 29页
  • 2016-06-10 发布于湖北
  • 举报

HDB3码编码器及解码器verilog代码编程及实现教案分析.ppt

顶层模块 module yima(clk,BP,BN,out3); input clk,BP,BN; output out3; wire a,b; trans u1(.clk(clk),.BP(BP),.BN(BN),.P(P),.N(N)); findv u2(.clk(clk),.P1(P),.N1(N),.out1(out1),.out2(out2)); chvb u3(.clk(clk),.in(out1),.out(a)); chuvb u4(.clk(clk),.in(out2),.out(b)); jia u5(.clk(clk),.in1(a),.in2(b),.out0(out3)); endmodule 通信原理 基带信号的选择: AMI码 HDB3码 HDB3码保持了AMI码的优点,克服了AMI码在遇到连“0”长时难以提取定时信息的困难,因而获得广泛应用。 HDB3码为3阶高密度双极性码,其编码规则为: 1将消息代码转换为AMI码; 2检查AMI码中连“0”的情况,出现4个或4个以上连“0”时,将第4个“0”变为与前一个非“0”符号同极性的符号,用“V”标识(+V和-V); 3、 检查相邻V符号之间非“0”符号是否为偶数,如果为偶数,则将当前V符号前一个非“0”符号后的第一个“0”变为“B”,”B”的极性与前一个非”0“符号相反,并使“V”后的非“0”符号从“V”开始再交替变化。 编码器实现: 在实际电路设计时,先在纯粹的数字电路下完成插“V”的操作,再完成插“B”的操作;然后再将单极性变成双极性。这样可以在数字电路中实现,且降低寄存器需求。 因为“V”、“B”是认为标识的符号,所以在具体电路中,需做以下替换:0-00,1-01,V-11, B-10。 设计步骤: 插“V”的实现: 1、设置连“0”计数器,复位为0; 2、对输入信号进行判断,如果为1则计数器复位,且输出“01”; 3、如果为“0”,则对“0”进行计数,如果计数值不为4,则输出“00”; 4、如果计数值为“4”,则计数器复位,同时输出为“11”。 module add_v(data_in,clk,data_out); input data_in; input clk; output [1:0] data_out; reg [1:0] data_out; reg counter; always @(posedge clk) if(data_in==1b1) begin counter=0; data_out=2b01; end else begin counter=counter+1; if(counter==3) begin data_out=2b11;counter=0; end else begin data_out=2b00; end end endmodule RTL图 插“B”的实现: 1、 设置对“01”的计数器counter为0,设置对“11”的计数器firstV为0; 2、 对输入进行判断,如果为“01”,则counter加1,仍然输出“01”; 3、 如果输入为“00”,输出为“00”,计数器不变; 4、 如果输入为“11”,firstV加1,此时如果counter为奇数,则输出仍为“11”; 5、 如果counter为偶数,则将counter复位,且将此处前第4个数变成“10”。 关键要设置四位的移位寄存器 module add_b(add_in,addb_out,clk); input clk; input [1:0] add_in; output [1:0] addb_out; reg firstv; reg counter; reg [1:0] d [3:0]; always @(posedge clk) begin d[3]=d[2]; d[2]=d[1]; d[1]=d[0]; d[0]=add_in; end always @(posedge clk) begin if(d[0]==2b11) begin counter=0;firstv=0; end else if(d[0]==2b01) begin counter=counter+1;firstv=1; end else begin firstv=1; end end assign addb_out=(counter==0)(firstv==1)(d[0]==2b11)

文档评论(0)

1亿VIP精品文档

相关文档