这一章,我们要讲 effect_module 和 flashing_module 组织起来,然后命名为“done”
代码如下:
1.module done
2.(
3. CLK, RSTn,
4. Start_Sig, Done_Sig,
5. Q,
6. Right_Done, Left_Done, //用于观察
7. Right_Start, Left_Start //用于观察
8.);
9.
10. input CLK;
11. input RSTn;
12. input Start_Sig;
13. output Done_Sig;
14. output Left_Done;
15. output Right_Done;
16. output Right_Start;
17. output Left_Start;
18. output [7:0]Q;
19.
20. /*******************************/
21.
22. wire Right_Start_Sig;
23. wire Left_Start_Sig;
24. wire Right_Done_Sig;
25. wire Left_Done_Sig;
26.
27. effect_module U3
28. (
29. .CLK( CLK ),
30. .RSTn( RSTn ),
31. .Start_Sig( Start_Sig ), // in from top
32. .Done_Sig( Done_Sig ), // out to top
33. .Right_Start_Sig( Right_Start_Sig ), // out to U2
34. .Left_Start_Sig( Left_Start_Sig ), // out to U2
35. .Right_Done_Sig( Right_Done_Sig ), // in from U2
36. .Left_Done_Sig( Left_Done_Sig ) // in from U2
37. );
38.
39. /*************************************/
40.
41. flashing_module U4
42. (
43. .CLK( CLK ),
44. .RSTn( RSTn ),
45. .Right_Start_Sig( Right_Start_Sig ), // in from U1
46. .Left_Start_Sig( Left_Start_Sig ), // in from U1
47. .Right_Done_Sig( Right_Done_Sig ), // out to U1
48. .Left_Done_Sig( Left_Done_Sig ), // out to U1
49. .Q( Q ) // out to top
50. );
51.
52. /*************************************/
53.
54. //用于观察
55. assign Left_Done = Left_Done_Sig;
56. assign Right_Done = Right_Done_Sig;
57. assign Right_Start = Right_Start_Sig;
58. assign Left_Start = Left_Start_Sig;
59.
60.endmodule
这是第二层的组织了,到这里基本上我们已经完成如下图的效果
1. `timescale 1 ns/ 1 ns
2. module done_vlg_tst();
3. reg CLK;
4. reg RSTn;
5. reg Start_Sig;
6.
7. wire Done_Sig;
8. wire [7:0] Q;
9. wire Left_Done;
10.wire Right_Done;
11.wire Right_Start;
12.wire Left_Start;
13.done i1
14.(
15. .CLK(CLK),
16. .Done_Sig(Done_Sig),
17. .Q(Q),
18. .RSTn(RSTn),
19. .Start_Sig(Start_Sig),
20. .Left_Done( Left_Done ),
21. .Right_Done( Right_Done ),
22. .Right_Start( Right_Start ),
23. .Left_Start( Left_Start )
24.);
25.
26.initial
27.begin RSTn = 0; #20; RSTn = 1; end
28.
29.initial
30.begin CLK = 1; forever #20 CLK = ~CLK; end
31.
32.initial
33.begin Start_Sig = 1; end
34.
35.endmodule
下面是仿真的载图:
文章评论(0条评论)
登录后参与讨论