伪随机码 不过仿真出问题了。。。。
module m_gen (clk,res,y);
input clk,res;
outputy;
reg[3:0] d;
assign y=d[0];
always@(posedge clk or negedge res) begin
if(~res)
d<=4'b1111;
else
d[2:0]<=d[3:1];
d[3]<=d[3]+d[0];
end
endmodule
`timescale 1ns/1ps
module m_gen_tb;
regclk,res;
wirey;
m_gen dut (.clk(clk),.res(res),.y(y));
initial begin
clk<=0;
res<=0;
#10 res<=1;
#600 $stop;
end
always #5 clk<=~clk;
endmodule
module m_gen (clk,res,y);
input clk,res;
outputy;
reg[3:0] d;
assign y=d[0];
always@(posedge clk or negedge res) begin
if(~res)
d<=4'b1111;
else
d[2:0]<=d[3:1];
d[3]<=d[3]+d[0];
end
endmodule
`timescale 1ns/1ps
module m_gen_tb;
regclk,res;
wirey;
m_gen dut (.clk(clk),.res(res),.y(y));
initial begin
clk<=0;
res<=0;
#10 res<=1;
#600 $stop;
end
always #5 clk<=~clk;
endmodule
状态机三角波(加强)发生器的源代码
module tri_gen_2(
clk,
rst,
d_out
);
input clk;
input rst;
output d_out;
reg[8:0] d_out;
reg[7:0] con;
reg[1:0] state;//主状态机寄存器;
always@(posedge clk or negedge rst)
if(~rst) begin
state<=0;d_out<=0;con<=0;
end
else begin
case(state)
0: begin d_out<=d_out+1;
if(d_out==299) begin
state<=1;
end
end
1: begin
if(con==300) begin
state<=2;
con<=0;
end
else begin
con<=con+1;
end
end
2: begin d_out<=d_out-1;
if(d_out==1) begin
state<=0;
end
end
endcase
end
endmodule
module tri_gen_2(
clk,
rst,
d_out
);
input clk;
input rst;
output d_out;
reg[8:0] d_out;
reg[7:0] con;
reg[1:0] state;//主状态机寄存器;
always@(posedge clk or negedge rst)
if(~rst) begin
state<=0;d_out<=0;con<=0;
end
else begin
case(state)
0: begin d_out<=d_out+1;
if(d_out==299) begin
state<=1;
end
end
1: begin
if(con==300) begin
state<=2;
con<=0;
end
else begin
con<=con+1;
end
end
2: begin d_out<=d_out-1;
if(d_out==1) begin
state<=0;
end
end
endcase
end
endmodule
《比较汉语政和拉丁语reg-ere(to rule, guide)》
一.汉语政
(1)词源:从攴(pū)从正,攴者,敲击也。
政,正也。——东汉 许慎 《说文解字》
(2)本义:to rule by force
二.拉丁语reg-ere[完成被动分词为:(rēc-t)-us]
(1)词源:最终来自原始印欧语*h₃reǵ-(to move in a straight line→to direct in a straight line→to rule, guide)
(2)含义:to rule, guide
(3)后代:
A.意大利语règg-ere
B.西班牙语reg-ir
C.葡萄牙语reg-er
D.法语rég-ir
e.英语reg-&(rec-t)-
一.汉语政
(1)词源:从攴(pū)从正,攴者,敲击也。
政,正也。——东汉 许慎 《说文解字》
(2)本义:to rule by force
二.拉丁语reg-ere[完成被动分词为:(rēc-t)-us]
(1)词源:最终来自原始印欧语*h₃reǵ-(to move in a straight line→to direct in a straight line→to rule, guide)
(2)含义:to rule, guide
(3)后代:
A.意大利语règg-ere
B.西班牙语reg-ir
C.葡萄牙语reg-er
D.法语rég-ir
e.英语reg-&(rec-t)-
✋热门推荐