Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module RS_gates (
  2.     input clk, R, S,
  3.     output Q
  4.     );
  5.    
  6.     (* KEEP = "TRUE" *) wire R_g, S_g, Qa, Qb;
  7.    
  8.     and (R_g, R, clk);
  9.     and (S_g, S, clk);
  10.     nor (Qa, R_g, Qb);
  11.     nor (Qb, S_g, Qa);
  12.    
  13.     assign Q = Qa;
  14. endmodule
  15.  
  16. //module Zadanie3 (
  17. //  input [2:0] SW,
  18. //  output [0:0] LEDR
  19. //);
  20. //
  21. //  RS_gates ex (SW[2], SW[1], SW[0], LEDR[0]);
  22. //
  23. //endmodule
  24.  
  25.  
  26. module RS_boolean (
  27.     input Clk, R, S,
  28.     output Q
  29.     );
  30.    
  31.     (* KEEP = "TRUE" *) wire R_g, S_g, Qa, Qb;
  32.    
  33.     assign R_g = R & Clk;
  34.     assign S_g = S & Clk;
  35.     assign Qa = ~(R_g | Qb);
  36.     assign Qb = ~(S_g | Qa);
  37.    
  38.     assign Q = Qa;
  39. endmodule
  40.  
  41. //module Zadanie3 (
  42. //  input [2:0] SW,
  43. //  output [0:0] LEDR
  44. //);
  45. //
  46. //  RS_boolean ex (SW[2], SW[1], SW[0], LEDR[0]);
  47. //
  48. //endmodule
  49.  
  50. module D_latch (
  51.     input Clk, D,
  52.     output Q
  53. );
  54.    
  55.     (* KEEP = "TRUE" *) wire R_g, S_g, Qa, Qb;
  56.    
  57.     nand (S_g, D, Clk);
  58.     nand (R_g, ~D, Clk);
  59.     nand (Qa, S_g, Qb);
  60.     nand (Qb, R_g, Qa);
  61.    
  62.     assign Q = Qa;
  63.    
  64. endmodule
  65.  
  66. module master_slave_D (
  67.     input D, clk,
  68.     output Q
  69. );
  70.  
  71.     wire Qm;
  72.    
  73.     D_latch master (~clk, D, Qm);
  74.     D_latch slave (clk, Qm, Q);
  75.  
  76. endmodule
  77.  
  78. //module Zadanie3 (
  79. //  input [1:0] SW,
  80. //  output [0:0] LEDR
  81. //);
  82. //
  83. //  master_slave_D ex (SW[1], SW[0], LEDR[0]);
  84. //
  85. //endmodule
  86.  
  87. module latch_FDDP_FDDN (
  88.     input D, clk,
  89.     output Q
  90. );
  91.  
  92.     wire Qa, Qb, Qc;
  93.    
  94.     D_latch ex0 (clk, D, Qa);
  95.     D_latch ex1 (~clk, D, Qb);
  96.     D_latch ex2 (~clk, D, Qc);
  97.  
  98. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement