2019-01-09 14:28:29 +03:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// reset_set.sv
|
|
|
|
// Konstantin Pavlov, pavlovconst@gmail.com
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// INFO --------------------------------------------------------------------------------
|
2019-12-13 13:19:49 +03:00
|
|
|
// Synchronous SR trigger variant
|
|
|
|
// No metastable state. SET signal dominates here
|
2019-01-09 14:28:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* --- INSTANTIATION TEMPLATE BEGIN ---
|
|
|
|
|
|
|
|
reset_set RS1 (
|
|
|
|
.clk( clk ),
|
|
|
|
.nrst( 1'b1 ),
|
|
|
|
.s( ),
|
|
|
|
.r( ),
|
|
|
|
.q( ),
|
|
|
|
.nq( )
|
|
|
|
);
|
|
|
|
|
|
|
|
--- INSTANTIATION TEMPLATE END ---*/
|
|
|
|
|
|
|
|
|
|
|
|
module reset_set(
|
2019-01-09 15:12:55 +03:00
|
|
|
input clk,
|
|
|
|
input nrst,
|
|
|
|
input s,
|
|
|
|
input r,
|
|
|
|
output logic q = 0, // aka "present state"
|
|
|
|
output nq
|
2019-01-09 14:28:29 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
always_ff @(posedge clk) begin
|
2019-12-13 13:19:49 +03:00
|
|
|
if( ~nrst ) begin
|
2019-01-09 14:28:29 +03:00
|
|
|
q = 0;
|
|
|
|
end else begin
|
2019-12-13 13:19:49 +03:00
|
|
|
if( r ) q = 1'b0;
|
|
|
|
if( s ) q = 1'b1;
|
2019-01-09 14:28:29 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assign nq = ~q;
|
|
|
|
|
|
|
|
endmodule
|