新手上路
- 积分
- 48
- 金钱
- 48
- 注册时间
- 2019-10-30
- 在线时间
- 14 小时
|
1金钱
请大家指点一下,先上代码
//确定row_cnt //row_cnt
always @(posedge clk) begin
if(project_done_flag) begin
if(ypos == row_border_hgh + 1'b1)
row_cnt <= row_cnt == num_row - 1'b1 ? 'd0 : row_cnt + 1'b1;
end
else
row_cnt <= 12'd0;
end
//行区域
always @(*) begin
row_area[row_cnt] = ypos >= row_border_low && ypos <= row_border_hgh;
end
//检测行变化
always @(posedge clk) begin
if(project_done_flag) begin
row_cnt_t <= row_cnt; //row_cnt=0,第1时钟先 进入 if(row_cnt_t != row_cnt),
row_d1 <= row_d0 ; //第2时钟row_d0取反;row_d1 <= row_d0 ;row_cnt_t <= row_cnt;
if(row_cnt_t != row_cnt) //
row_d0 <= ~row_d0;
end
else begin
row_d0 <= 1'b1;
row_d1 <= 1'b1;
row_cnt_t <= 4'hf;
end
end
assign row_chg = row_d0 ^ row_d1;
//获取数字的行边界
always @(posedge clk) begin
if(row_chg)
row_border_addr <= (row_cnt << 1'b1) + 1'b1; //根据row_chg来改变row_border_addr[0]值
else
row_border_addr <= row_cnt << 1'b1;
end
always @(posedge clk) begin
if(row_border_addr[0])
row_border_hgh <= row_border_data; //上边界
else
row_border_low <= row_border_data; //下边界 //row_border_data对应相应的row_border_addr
end
always @(posedge clk) begin //信号的多拍处理?
row_chg_d0 <= row_chg;
row_chg_d1 <= row_chg_d0;
row_chg_d2 <= row_chg_d1;
row_chg_d3 <= row_chg_d2;
end
//检测列变化
always @(posedge clk) begin
if(project_done_flag) begin //根据col_cnt使col_d0产生变化,即导致col_chg变化
col_cnt_t <= col_cnt;
col_d1 <= col_d0;
if(col_cnt_t != col_cnt)
col_d0 <= ~col_d0;
end
else begin
col_d0 <= 1'b1;
col_d1 <= 1'b1;
col_cnt_t <= 4'hf;
end
end
我理解的行边界获取过程如下:row_cnt由(ypos == row_border_hgh + 1'b1)改变,导致进入检测行变化模块,使row_chg置1,进入获取行边界模块,得到 row_border_hgh。
可是一开始的row_cnt不就是由(ypos == row_border_hgh + 1'b1)得到的么,所以应该是由row_cnt得到 row_border_high,还是反过来呢
|
最佳答案
查看完整内容[请看2#楼]
行地址为0的时候是下边界,为1是上边界,当记到下边界时,行计数器开始增加以便读取下一排待测数字的行边界
|