verilog习题
答案:1 悬赏:80 手机版
解决时间 2021-04-14 18:08
- 提问者网友:酱爆肉
- 2021-04-14 04:47
verilog习题
最佳答案
- 五星知识达人网友:十鸦
- 2021-04-14 05:09
代码如下,供参考。状态转换图可以根据代码画出。
//=========================================
always@(posedge clk or negedge clr)
if (clr)
ab <= 2'b00;
if (st == st10010)
ab <= 2'b10;
else
ab <= 2'b01;
always@(posedge clk or negedge clr)
if (clr)
st <= 3'b0;
else
st <= next_st;
//
always@(*)
case(st)///定义6个状态st
st0 :if (di) next_st = st1; else next_st = st0;
st1 :if (di) next_st = st1; else next_st = st10;
st10 :if (di) next_st = st1; else next_st = st100;
st100 :if (di) next_st = st1001; else next_st = st0;
st1001 :if (di) next_st = st1; else next_st = st10010;
st10010 :if (di) next_st = st1; else next_st = st100; ////如果允许序列重叠
st10010 :next_st = st0;//如果不允许序列重叠
default :next_st = st0;
endcase
//=========================================
always@(posedge clk or negedge clr)
if (clr)
ab <= 2'b00;
if (st == st10010)
ab <= 2'b10;
else
ab <= 2'b01;
always@(posedge clk or negedge clr)
if (clr)
st <= 3'b0;
else
st <= next_st;
//
always@(*)
case(st)///定义6个状态st
st0 :if (di) next_st = st1; else next_st = st0;
st1 :if (di) next_st = st1; else next_st = st10;
st10 :if (di) next_st = st1; else next_st = st100;
st100 :if (di) next_st = st1001; else next_st = st0;
st1001 :if (di) next_st = st1; else next_st = st10010;
st10010 :if (di) next_st = st1; else next_st = st100; ////如果允许序列重叠
st10010 :next_st = st0;//如果不允许序列重叠
default :next_st = st0;
endcase
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯