当前位置:网站首页>ep240--all
ep240--all
2022-06-09 11:49:00 【ooolmf】

openlight
module openlight(sh,q,clk);
input sh;
input clk;
output q;
reg q;
reg[10:0] counter;
[email protected](posedge clk ) //sh=550us period
begin
if(sh==1'b0)
begin
counter<=11'b0;
q<=1'b0;
end
else
begin
counter<=counter+1'b1; //640ns
if(counter<11'd500)
begin
q<=1'b0;
end
else if(counter<11'd858) //550/0.64=860count
begin
q<=1'b1;
end
else
begin
q<=1'b0;
counter<=11'b0;
end
end
end
endmodule
adclk
module ADCLK(clk,q,en); //en is fai2
input clk;// 50m
input en;
output q;
reg q;
reg[3:0] counter;
[email protected](posedge clk)
begin
if(en==1'b1)
begin
q<=1'b0;
counter<=4'b0;
end
else
begin
if(counter<4'd2)
begin
counter<=counter+1'b1;
q<=1'b1;
end
else
begin
q<=1'b0;
counter<=counter;
end
end
end
endmodule
autoint
module autoint(fai1en,fai1,q);
input fai1;
input fai1en;
output q;
reg q;
reg[11:0] counter;
[email protected](posedge fai1 or negedge fai1en)
begin
if(fai1en==1'b0)
begin
counter<=12'b0;
end
else
begin
counter<=counter+1'b1;
if(counter<12'd2150)
begin
q<=1'b0;
end
else if((counter>12'd2149) && (counter<12'd2350) ) //200*160ns=32us time for stm32
begin
q<=1'b1; // auto clear ,when finsh,q=1,and wait for 2us
end
else
begin
q<=1'b0;
counter<=12'b0;
end
end
end
endmodule
statusccd
module statusccd(clk,sh,fai1,fai1en,light,busy);
input clk; // clk50m
//output[7:0] q; // output led
output sh;
output light;
output fai1;
output fai1en;
output busy;
reg busy;
reg light;
reg sh;
reg fai1;
reg fai1en;
//reg[7:0] q;
reg[15:0] counter;
reg[3:0] status;
[email protected](posedge clk) //20ns
begin
if(counter<16'd27501) //max period about 550 us
begin
counter<=counter+1'b1;
end
else // loop
begin
counter<=16'd0;
end
//*******************************************
if((counter>16'd1) && (counter<16'd7))// 120ns for reset all singal
begin
status<=4'b0001;
end
else if((counter>16'd6) && (counter<16'd17)) // 100 ns for fai1 before SH
begin
status<=4'b0010;
end
else if((counter>16'd16) && (counter<16'd85)) // 1300 ns for SH is high 66*20=1320ns
begin
status<=4'b0011;
end
else if((counter>16'd84) && (counter<16'd107)) // 520 ns for fai1 goes to low before SH
begin
status<=4'b0100;
end
else if((counter>16'd106) && (counter<16'd17307)) // 344us ns for SH is low to shift data to OS
begin // 216us for led light
status<=4'b0101;
end
else if((counter>16'd17306) && (counter<16'd28105)) // 216us for low ,waiting for next loop
begin
status<=4'b0110; //ide time
end
else
begin
status<=4'b0000;
end
end
//--------------------------------------------------------------------------------------------
[email protected](posedge clk)
begin
case(status[3:0])
4'b0000:begin
sh<=1'b0;
fai1<=1'b0;
fai1en<=1'b0;
light<=1'b0;// turn off light
busy<=1'b0;
end
4'b0001:begin
sh<=1'b0;
fai1<=1'b0;
fai1en<=1'b0;
//light<=1'b0;// turn off light
//busy<=1'b0;
end
4'b0010:begin
fai1<=1'b1;
fai1en<=1'b1;
end
4'b0011:begin
sh<=1'b1;
fai1<=1'b1;
fai1en<=1'b1;
end
4'b0100:begin
sh<=1'b0;
fai1<=1'b1;
fai1en<=1'b1;
end
4'b0101:begin
light<=1'b1;// turn on light
fai1<=1'b0;
fai1en<=1'b1;
end
4'b0110:begin
sh<=1'b0;
fai1<=1'b0;
fai1en<=1'b1;
busy<=1'b1;
light<=1'b0;// turn off light
end
default:begin
sh<=1'b0;
fai1<=1'b0;
fai1en<=1'b0;
busy<=1'b0;
light<=1'b0;// turn off light
end
endcase
end
endmodule
eom
module eom(clk,d77,ccdlight,meastime);
input clk;//clk50m
input d77;// ad msb d7
input ccdlight; //light time
output meastime;// test time
reg meastime; //reg
reg[15:0] cnt; //count time
[email protected](posedge clk)
begin
if(ccdlight==1'b0)
begin
cnt<=16'b0;
meastime<=1'b0;
end
else if((cnt>10'd270)&&(cnt<16'd16400))
begin
meastime<=1'b1;
end
else
begin
meastime<=1'b0;
cnt<=cnt+1'b1;
end
end
endmodule
RS
module RS(clk,q,en); //en is fai2
input clk;// 50m
input en;
output q;
reg q;
reg[1:0] counter;
[email protected](posedge clk)
begin
if(en==1'b0)
begin
q<=1'b0;
counter<=2'b0;
end
else
begin
counter<=counter+1'b1;
if(counter<2'd1)
begin
q<=1'b0;
end
else if( counter<2'd3)
begin
q<=1'b1;
end
else
begin
q<=1'b0;
end
end
end
endmodule
CP
module CP(clk,q,en); //en is fai2
input clk;// 50m
input en;
output q;
reg q;
reg[1:0] counter;
[email protected](posedge clk)
begin
if(en==1'b0)
begin
q<=1'b0;
counter<=2'b0;
end
else
begin
counter<=counter+1'b1;
if(counter<2'd2)
begin
q<=1'b0;
end
else if(counter<2'd3)
begin
q<=1'b1;
end
else
begin
q<=1'b0;
end
end
end
endmodule
边栏推荐
- 4.<tag-回溯和组合及其剪枝>lt.39.组合总和 + lt.40. 组合总和 II dbc
- Do you dare to deliver your microservices independently?
- [untitled]
- [译]PostgreSQL 怎么通过vacuum 加速事务ID回收的速度
- 1.<tag-回溯和组合及其剪枝>lt.77.组合 +剪枝 dyh
- 期货开户云,开户可靠安全吗??
- Redis data structure and introduction
- 06 | the first step of China Taiwan landing: enterprise strategy decomposition and current situation research (Discovery)
- 【转载】搞懂G1垃圾收集器
- What are the deadlock troubleshooting tools?
猜你喜欢

Google chrome插件 | pagenote 网页标记

10.<tag-二叉树和BST基础>lt.700. 二叉搜索树中的搜索 + lt.98. 验证二叉搜索树 + lt.530. 二叉搜索树的最小绝对差(同lt.783)

1.<tag-回溯和组合及其剪枝>lt.77.组合 +剪枝 dyh

BFS练手题目

中国科学院院刊 | 包云岗:加速发展关键核心技术,必须把握技术发展的自身规律

flutter Dio示例
![[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?](/img/19/256cdcf783986d1012ddc75c8b2c31.png)
[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?

JMeter installation tutorial

JUC-实现Future

Tag backtracking - brush questions to prepare knowledge -1 Backtracking template, + lt.46 Full Permutation
随机推荐
lombok -异常 non-static variable org cannot be referenced from a static context
Are there any financial products with guaranteed principal and interest in 2022? I want to invest and manage money, but I'm afraid of losing money
09 | the fourth step: the construction and delivery of the middle office
SIGIR 2022 | CMI: micro video recommendation combining comparative learning and multi interest mining
Will investment and wealth management products lose the principal?
Excel | App_ Error in workbookactive cannot set the installed property of class addin
08 | middle stage landing step 3: middle stage planning and design
5. bracket generation
leetcode 1332. Remove Palindromic Subsequences(删掉回文子串)
PMP项目管理知识体系
9.<tag-回溯和同层内去重的组合问题>lt.491. 递增子序列
Anonymous inner classes and local variables
BFS练手题目
Leetcode camera minimum problem
10.<tag-二叉树和BST基础>lt.700. 二叉搜索树中的搜索 + lt.98. 验证二叉搜索树 + lt.530. 二叉搜索树的最小绝对差(同lt.783)
Using radial get entity object attribute record
4. < tag backtracking, combination and pruning > lt.39 Combined sum + lt.40 Combined sum II DBC
[reprint] what is the "brain crack" of distributed systems?
You have to understand the underlying MySQL isolation level
01 | context: why is Zhongtai so popular?