please help me code a working testbench with comments
This is a HDL code for the state machine below, please help me code a working testbench with comments for better understanding for this structural module. The diagrams provided are the state diagrams and logic circuit diagrams for this circuit/module. I will rate 5 star for this pls tq
module dsd_assignment_structural_s ( input clk, x, clr, //setting input clock, x and clear/reset output [2:0] Q, Qbar, //setting output Q, Qbar and Z output z);
wire j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, dclk; //wire connecting the circuit
Clk_div_s #(.div_value(29999999)) ip5( .clk(clk), .divided_clk(dclk)); //run clock division command
Dflipflop A0 (j9, dclk, clr, Q[2], Qbar[2]); Dflipflop A1 (j10, dclk, clr, Q[1], Qbar[1]); Dflipflop A2 (~x, dclk, clr, Q[0], Qbar[0]); //Use the D Flip Flop command to link the inputs and //wires and G0 (j0, Q[2], Qbar[1]); and G1 (j1, Q[2], Qbar[1], ~x); and G2 (j2, Q[2], Q[0], x); and G3 (j3, Qbar[2], Q[1], Qbar[0], x); and G4 (j4, Qbar[2], Q[1], Q[0], ~x); //AND the variables according to transition eqn & circuit diag.
and G5 (j5, Q[1], Qbar[0], ~x); and G6 (j6, Q[1], Q[0], x); and G7 (j7, Qbar[1], Qbar[0], x); and G8 (j8, Qbar[1], Q[0], ~x); //AND the variables together according to transition eqn & circuit //diagram or G9 (j9, j0, j1, j2, j3, j4); or G10 (j10, j5, j6, j7, j8); //OR the variables together according to transition eqn & circuit //diagram
endmodule
module Dflipflop(input D, clk, reset, output reg Q, Qp); //coding D Flip Flop to be used above
always @(posedge clk or negedge reset) begin //operate when clock is 1 or reset is 0 if (~reset) begin //if reset = 0 Q<=0; //force Q=0 Qp<=1; end //force Q=1
else begin //if reset = 1 Q<=D; //set Q = D Qp<=~D; end //set Q = D* end endmodule
|
![X=1
Z=1
X=0
Z=0
A
000
E
001
X=0
Z=1
X=1
Z=0
X=1
Z=0
X=0
Z=0
X=0
Z=0
B
010
F
011
X=1
Z=0
X=1
Z=0
↑
X=0
Z=0
с
100
X=0 X=1
Z=0
Z=0
Figure 1
G
101
X=1
Z=0
个
X=0
Z=0
D
Ⓡ
110
X=0
Z=1
H
111
X=1
Z=1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F83b03dd8-9c4e-4cbb-afac-50fcd26752ac%2F08ab3c3b-f43d-4393-9189-0472580b4bae%2Fo098jtw_processed.png&w=3840&q=75)
![D
S2
$1
S2
SO
X'
X
SO'
$2
$1
SO
X"
$1
SO'
X'
$1
$1'
TTTT
SO'
$1'
,SO'
U6
AND2
Us Us
AND3
AND3
U9
AND4
U10
AND4
U11
AND3
U12
AND3.
U13
AND3
U14
AND3
....2 ..... ........
U3
OR5
S2SI'+S2SO'X'+S
2S0X+S2'S1S0'X
+S2'S1S0X':
U4
15
AA
1kHz
OR4
Sis0'X'+S1S0X+S1'SO'X+S1'SOX'
*SET
ELK
........
D_FF
SO
SET
RESET
SET
REAKT
D_FF
S2
.D_FF
$1
:Z
AND2
S2](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F83b03dd8-9c4e-4cbb-afac-50fcd26752ac%2F08ab3c3b-f43d-4393-9189-0472580b4bae%2F9gpkub_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)