// Dean Brock -- April, 1997 // // This is a Example 1 of a combintorial circuit // // Here is the combinational circuit that was used to drive // the J-K flipflops in the implementation of the nabs machine. // // See http://www.cs.unca.edu/~brock/classes/Spring97/274/sequen.html // for more information about the sequential machine that contains // this combinational circuit. // Here the combinational circuit is specified as a dataflow model // in which output are specified in a C-like syntax. module comboCircuit(z, jA, kA, jB, kB, x, y, A, B) ; output z, jA, kA, jB, kB ; input x, y, A, B ; assign z = x&y&A&B ; assign jA = ~x&y&~A&B | x&~y ; assign jB = ~x&y | x&~y&A ; assign kA = x&y&A&B ; assign kB = ~x&y&~A&B | x&y&A&B ; endmodule // This is the module stimulus module simulate ; reg inX, inY, inA, inB ; wire outZ, outJA, outKA, outJB, outKB ; // Here as an instantiation of the combinational circuit. comboCircuit C(outZ, outJA, outKA, outJB, outKB, inX, inY, inA, inB) ; // This is testing funcion. // It is setting new inputs to the circuit at time // units 3, 8, 13, 18, .... // The #3 and #5 statements are time delays initial begin #3 ; {inX, inY, inA, inB } = 4'b0000 ; #5 ; {inX, inY, inA, inB } = 4'b0001; #5 ; {inX, inY, inA, inB } = 4'b0010; #5 ; {inX, inY, inA, inB } = 4'b0011; #5 ; {inX, inY, inA, inB } = 4'b0100; #5 ; {inX, inY, inA, inB } = 4'b0101; #5 ; {inX, inY, inA, inB } = 4'b0110; #5 ; {inX, inY, inA, inB } = 4'b0111; #5 ; {inX, inY, inA, inB } = 4'b1000; #5 ; {inX, inY, inA, inB } = 4'b1001; #5 ; {inX, inY, inA, inB } = 4'b1010; #5 ; {inX, inY, inA, inB } = 4'b1011; #5 ; {inX, inY, inA, inB } = 4'b1100; #5 ; {inX, inY, inA, inB } = 4'b1101; #5 ; {inX, inY, inA, inB } = 4'b1110; #5 ; {inX, inY, inA, inB } = 4'b1111; #5 ; $finish ; end // This loop is the output generation side of the testing unit. // At time units 5, 10, 15, .... it prints the input and output // values of the function. initial begin $display("") ; $display("Example 01") ; $display("") ; forever begin #5 ; $display("(%b,%b,%b,%b) -> %b,%b,%b,%b,%b", inX, inY, inA, inB, outZ, outJA, outKA, outJB, outKB) ; end end endmodule