Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. module numarator(output reg [3:0]num_out, input clk, input nrst,input en);
  2.  
  3. always @(posedge clk) begin
  4. if(rst == 0) num_out=0;
  5. else if(en==1) num_out<=num_out+1;
  6. end
  7.  
  8. endmodule
  9.  
  10.  
  11.  
  12. module mux(output [7:0]out, input sel, input [7:0]in0, input [7:0]in1);
  13. always @*() begin
  14. if(sel==0) out<=in0;
  15. else out<=in1;
  16. end
  17. endmodule
  18.  
  19.  
  20. module alu(output [7:0] result, input [2:0]op, input [7:0]opleft, input [7:0] opright);
  21. always @(*) begin
  22. case(op)
  23. 000: result<=opright;
  24. 001: result<=opright+opleft;
  25. 010: result<=opright^opleft;
  26. 011: result<=opright&opleft;
  27. endcase
  28. end
  29. endmodule
  30.  
  31. module RF(output [7:0] ldata, output [7:0]rdata, input clk, input [3:0]laddr, input [3:0]raddr, input[3:0]destaddr, input we,input [7:0]wdata);
  32. reg [7:0] mem[0:7];
  33. assign ldata=mem[laddr];
  34. assign rdata=mem[raddr];
  35. always @(posedge clk) begin
  36. if(we==1)
  37. mem[destaddr]<=wdata;
  38.  
  39. end
  40.  
  41. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement