?? manchester.txt
字號:
“Manchester碼(雙相碼)編碼器。
一、 硬件描述語言代碼清單
總模塊:
module Manchester_shuchu(clk,clr,in_dat,out_dat_tong,out_dat_fan);
input clk,clr,in_dat;
output out_dat_tong,out_dat_fan;
wire clk_fan;
fpj u0(.clk(clk),
.clk_fan(clk_fan),
);
Manchester_bian u1(.in_dat(in_dat),
.clk_tong(clk),
.clk_fan(clk_fan),
.out_dat_tong(out_dat_tong),
.out_dat_fan(out_dat_fan),
.clr(clr));
endmodule
fpj模塊:
module fpj(clk,clk_fan);
output clk_fan;
input clk;
wire clk2_fan;
assign clk_fan=~clk;
endmodule
Manchester_bian模塊:
module Manchester_bian(in_dat,clk_tong,clk_fan,out_dat_tong,out_dat_fan,clr);
input in_dat,clk_tong,clk_fan,clr;
output out_dat_tong,out_dat_fan;
wire out_dat_tong,out_dat_fan;
wire out_dat_tong_1,out_dat_fan_1;
wire out_dat_tong_0,out_dat_fan_0;
assign out_dat_tong_1=(state1[1:0]==2'b01)?(clk_tong && con):1'b0;
assign out_dat_tong_0=(state1[1:0]==2'b10)?(clk_fan && con):1'b0;
assign out_dat_tong=(out_dat_tong_1) ||( out_dat_tong_0);
assign out_dat_fan_1=(state2[1:0]==2'b01)?(clk_tong && con):1'b0;
assign out_dat_fan_0=(state2[1:0]==2'b10)?(clk_fan && con):1'b0;
assign out_dat_fan=(out_dat_fan_1) || (out_dat_fan_0);
reg [1:0] state1;
reg [1:0] state2;
reg [1:0] dat_reg;
reg con;
always @(posedge clk_tong )
begin
con=1'b0;
if(~clr)
begin
state1[1:0]=2'b01;
state2[1:0]=2'b01;
con=1'b0;
end
else
begin
dat_reg[1:0]=dat_reg[1:0]>>1;
dat_reg[1]=in_dat;
if(dat_reg[1])
begin
state1[1:0]=2'b01;
con=1'b1;
if(state2[1:0]==2'b01)
begin
state2[1:0]=2'b10;
end
else
begin
state2[1:0]=2'b01;
end
end
else
begin
state1[1:0]=2'b10;
con=1'b1;
if(state2[1:0]==2'b01)
begin
state2[1:0]=2'b01;
end
else if(state2[1:0]==2'b10)
begin
state2[1:0]=2'b10;
end
end
end
end
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -