📄 rofactor.v
字号:
/*
* filename: rofactor.v
*
* version: 2007-04-21
*
* funciton: 在rof_start出现的下一个时钟,依次输出旋转因子,共
* 输出256*3个
*
*/
module rofactor
(
rst,
clk8x,
rof_start,
angle
// ,state,
// cnt256,
// inc1, inc2, inc3
);
input rst, clk8x, rof_start;
output [7:0] angle;
//output [1:0] state;
//output [7:0] cnt256;
//output [5:0] inc1, inc2, inc3;
reg [1:0] state;
reg [7:0] cnt256;
wire [5:0] inc1, inc2, inc3;
reg [7:0] angle;
always @ (posedge clk8x)
begin
if (rst)
state <= 2'b0;
else if (rof_start)
state <= 2'b01;
else if (cnt256 == 255)
state <= state + 1'b1;
if (rst)
cnt256 <= 8'b0;
else if (state!=0)
cnt256 <= cnt256 + 1'b1;
end
assign inc1 = cnt256[7:2];
assign inc2 = {cnt256[5:2], 2'b0};
assign inc3 = {cnt256[3:2], 4'b0};
always @ (posedge clk8x)
begin
if (rst || cnt256[1:0]==3)
angle <= 8'b0;
else if (state == 1)
angle <= angle + inc1;
else if (state == 2)
angle <= angle + inc2;
else if (state == 3)
angle <= angle + inc3;
else
angle <= 8'b0;
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -