1、
西 安 邮 电 大 学
(电子工程学院)
VerilogHDL试验汇报
试验名称: 约翰逊计数器
专业名称: 集成电路与集成系统
班 级: 电路1501
学生姓名: 张璐
学号(8位): 05156033
试验日期:
一、 功能描述
二、 设计方案
2、
三、验证方案
四、 设计代码
(一)约翰逊计数器
module count(reset,clk,out);
input reset,clk;
output out;
reg [7:0] out;
reg [23:0]c;
reg b;
always @(posedge clk)
begin
if(reset)
c<=0;
else
begin
c<=c+1’b1;
b=c[23];
end
end
3、
always @(posedge b)
begin
if(reset)
out<=8'b0;
else
begin
out[0]<=~out[7];
out[7:1]<=out[6:0];
end
end
endmodule
//鼓励文献
module sti;
reg clk,reset;
wire [7:0] out;
count test(reset,clk,out);
initial
clk<=8'b0;
4、
always #10 clk<=~clk;
initial
begin
reset<=1;
#50 reset<=0;
end
Endmodule
(二)串并变换电路
功能模块代码:
module counter_mod_8(clock,reset,Q); input clock; //posedge effective input reset; // negedge effective output [2:0] Q;
reg [2:0] Q;
always
5、@(posedge clock or negedge reset) begin if(~reset)
Q <= 3'd0; else
Q <= Q + 1;
end
endmodule
串转并模块:
module ser_to_par_8bit(ser_in,clk,rst,out); input ser_in,clk,rst;
output [7:0] out;
wire [7:0] out;
reg [7:0] par_out;
wire [2:0] count;
counter_mod_8 f1(.clock(clk),.rese
6、t(rst),.Q(count));
always@(posedge clk or negedge rst) begin if(~rst)
par_out <= 8'b0000_0000; else begin
par_out <= {par_out[6:0],ser_in};
end
end
assign out = (count == 7)? par_out : 8'b0000_0000; endmodule
测试模块代码:
module test_ser_par; reg [7:0] data; wire data_in; reg clock,
7、 reset;
wire [7:0] out;
initial begin clock = 1'b0; reset = 1'b0; #3 reset = 1'b1;
data = 8'b1001_1101; #300 $stop;
end
always
#5clock = ~clock; always@(posedge clock)
data ={data[6:0],data[7]}; assign data_in = data[7];
ser_to_par_8bit a(.ser_in(data_in),.clk(clock),.rst(reset),.out(out));
initial
$monitor($time,"reset= %b,data= %b,data_in= %b,out= %b",reset,data,data_in,out); endmodule
五、 仿真成果分析
(一)约翰逊计数器
(二)串并变换电路
六、试验心得